Skip to content

Commit

Permalink
chore: support v1 accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Jan 19, 2024
1 parent 8980503 commit c002a04
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/react/react-app/src/dojo/DojoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const DojoProvider = ({
);

const masterAccount = useMemo(
() => new Account(rpcProvider, masterAddress, masterPrivateKey),
() => new Account(rpcProvider, masterAddress, masterPrivateKey, "1"),
[rpcProvider, masterAddress, masterPrivateKey]
);

Expand Down
3 changes: 2 additions & 1 deletion examples/react/react-phaser-example/src/dojo/createBurner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const createBurner = async ({ ...config }: Config) => {
masterAccount: new Account(
rpcProvider,
config.masterAddress,
config.masterPrivateKey
config.masterPrivateKey,
"1"
),
accountClassHash: config.accountClassHash,
rpcProvider,
Expand Down
18 changes: 10 additions & 8 deletions packages/core/src/provider/DojoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,16 @@ export class DojoProvider extends Provider {
const nonce = await account?.getNonce();

return await account?.execute(
{
contractAddress: getContractByName(
this.manifest,
contract_name
),
entrypoint: call,
calldata: calldata,
},
[
{
contractAddress: getContractByName(
this.manifest,
contract_name
),
entrypoint: call,
calldata: calldata,
},
],
undefined,
{
maxFee: 0, // TODO: Update this value as needed.
Expand Down
22 changes: 15 additions & 7 deletions packages/create-burner/src/manager/burnerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { prefundAccount } from "./prefundAccount";
* const masterAccount = new Account(
* rpcProvider,
* import.meta.env.VITE_PUBLIC_MASTER_ADDRESS!,
* import.meta.env.VITE_PUBLIC_MASTER_PRIVATE_KEY!
* import.meta.env.VITE_PUBLIC_MASTER_PRIVATE_KEY!,
* "1"
* );
*
* const burnerManager = new BurnerManager({
Expand Down Expand Up @@ -90,7 +91,8 @@ export class BurnerManager {
this.account = new Account(
this.provider,
address,
storage[address].privateKey
storage[address].privateKey,
"1"
);
return;
}
Expand Down Expand Up @@ -146,7 +148,8 @@ export class BurnerManager {
this.account = new Account(
this.provider,
address,
storage[address].privateKey
storage[address].privateKey,
"1"
);
}

Expand All @@ -156,7 +159,12 @@ export class BurnerManager {
throw new Error("burner not found");
}

return new Account(this.provider, address, storage[address].privateKey);
return new Account(
this.provider,
address,
storage[address].privateKey,
"1"
);
}

clear(): void {
Expand All @@ -170,7 +178,8 @@ export class BurnerManager {
return new Account(
this.provider,
address,
storage[address].privateKey
storage[address].privateKey,
"1"
);
}
}
Expand All @@ -192,7 +201,6 @@ export class BurnerManager {
if (!this.masterAccount) {
throw new Error("wallet account not found");
}

try {
await prefundAccount(address, this.masterAccount);
} catch (e) {
Expand All @@ -206,7 +214,7 @@ export class BurnerManager {
};

// deploy burner
const burner = new Account(this.provider, address, privateKey);
const burner = new Account(this.provider, address, privateKey, "1");

const nonce = await this.account?.getNonce();

Expand Down
3 changes: 1 addition & 2 deletions packages/create-burner/src/manager/prefundAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ export const prefundAccount = async (

// Retrieve the nonce for the account to avoid transaction collisions
const nonce = await account.getNonce();

// Initiate the transaction
const { transaction_hash } = await account.execute(
transferOptions,
[transferOptions],
undefined,
{
nonce,
Expand Down

0 comments on commit c002a04

Please sign in to comment.