@aztec/cli-wallet 0.0.1-commit.f295ac2 → 0.0.1-commit.f504929

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ export const Aliases = [
9
9
  'authwits'
10
10
  ];
11
11
  export class WalletDB {
12
+ #store;
12
13
  #accounts;
13
14
  #aliases;
14
15
  #bridgedFeeJuice;
@@ -21,6 +22,7 @@ export class WalletDB {
21
22
  return WalletDB.instance;
22
23
  }
23
24
  async init(store) {
25
+ this.#store = store;
24
26
  this.#accounts = store.openMap('accounts');
25
27
  this.#aliases = store.openMap('aliases');
26
28
  this.#bridgedFeeJuice = store.openMap('bridgedFeeJuice');
@@ -33,13 +35,15 @@ export class WalletDB {
33
35
  ]));
34
36
  }
35
37
  async pushBridgedFeeJuice(recipient, secret, amount, leafIndex, log) {
36
- let stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
37
- stackPointer++;
38
- await this.#bridgedFeeJuice.set(`${recipient.toString()}:${stackPointer}`, Buffer.from(`${amount.toString()}:${secret.toString()}:${leafIndex.toString()}`));
39
- await this.#bridgedFeeJuice.set(`${recipient.toString()}:stackPointer`, Buffer.from([
40
- stackPointer
41
- ]));
42
- log(`Pushed ${amount} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
38
+ await this.#store.transactionAsync(async ()=>{
39
+ let stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
40
+ stackPointer++;
41
+ await this.#bridgedFeeJuice.set(`${recipient.toString()}:${stackPointer}`, Buffer.from(`${amount.toString()}:${secret.toString()}:${leafIndex.toString()}`));
42
+ await this.#bridgedFeeJuice.set(`${recipient.toString()}:stackPointer`, Buffer.from([
43
+ stackPointer
44
+ ]));
45
+ log(`Pushed ${amount} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
46
+ });
43
47
  }
44
48
  async popBridgedFeeJuice(recipient, log) {
45
49
  let stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
@@ -59,17 +63,22 @@ export class WalletDB {
59
63
  };
60
64
  }
61
65
  async storeAccount(address, { type, secretKey, salt, alias, publicKey }, log) {
62
- if (alias) {
63
- await this.#aliases.set(`accounts:${alias}`, Buffer.from(address.toString()));
64
- }
65
- await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
66
- await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
67
- await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
66
+ let publicSigningKey;
68
67
  if (type === 'ecdsasecp256r1ssh' && publicKey) {
69
- const publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
70
- await this.storeAccountMetadata(address, 'publicSigningKey', publicSigningKey);
68
+ publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
71
69
  }
72
- await this.#aliases.set('accounts:last', Buffer.from(address.toString()));
70
+ await this.#store.transactionAsync(async ()=>{
71
+ if (alias) {
72
+ await this.#aliases.set(`accounts:${alias}`, Buffer.from(address.toString()));
73
+ }
74
+ await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
75
+ await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
76
+ await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
77
+ if (publicSigningKey) {
78
+ await this.#accounts.set(`${address.toString()}:publicSigningKey`, publicSigningKey);
79
+ }
80
+ await this.#aliases.set('accounts:last', Buffer.from(address.toString()));
81
+ });
73
82
  log(`Account stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
74
83
  await this.refreshAliasCache();
75
84
  }
@@ -79,29 +88,35 @@ export class WalletDB {
79
88
  await this.refreshAliasCache();
80
89
  }
81
90
  async storeContract(address, artifactPath, log, alias) {
82
- if (alias) {
83
- await this.#aliases.set(`contracts:${alias}`, Buffer.from(address.toString()));
84
- await this.#aliases.set(`artifacts:${alias}`, Buffer.from(artifactPath));
85
- }
86
- await this.#aliases.set(`contracts:last`, Buffer.from(address.toString()));
87
- await this.#aliases.set(`artifacts:last`, Buffer.from(artifactPath));
88
- await this.#aliases.set(`artifacts:${address.toString()}`, Buffer.from(artifactPath));
91
+ await this.#store.transactionAsync(async ()=>{
92
+ if (alias) {
93
+ await this.#aliases.set(`contracts:${alias}`, Buffer.from(address.toString()));
94
+ await this.#aliases.set(`artifacts:${alias}`, Buffer.from(artifactPath));
95
+ }
96
+ await this.#aliases.set(`contracts:last`, Buffer.from(address.toString()));
97
+ await this.#aliases.set(`artifacts:last`, Buffer.from(artifactPath));
98
+ await this.#aliases.set(`artifacts:${address.toString()}`, Buffer.from(artifactPath));
99
+ });
89
100
  log(`Contract stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
90
101
  await this.refreshAliasCache();
91
102
  }
92
103
  async storeAuthwitness(authWit, log, alias) {
93
- if (alias) {
94
- await this.#aliases.set(`authwits:${alias}`, Buffer.from(authWit.toString()));
95
- }
96
- await this.#aliases.set(`authwits:last`, Buffer.from(authWit.toString()));
104
+ await this.#store.transactionAsync(async ()=>{
105
+ if (alias) {
106
+ await this.#aliases.set(`authwits:${alias}`, Buffer.from(authWit.toString()));
107
+ }
108
+ await this.#aliases.set(`authwits:last`, Buffer.from(authWit.toString()));
109
+ });
97
110
  log(`Authorization witness stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
98
111
  await this.refreshAliasCache();
99
112
  }
100
113
  async storeTx({ txHash }, log, alias) {
101
- if (alias) {
102
- await this.#aliases.set(`transactions:${alias}`, Buffer.from(txHash.toString()));
103
- }
104
- await this.#aliases.set(`transactions:last`, Buffer.from(txHash.toString()));
114
+ await this.#store.transactionAsync(async ()=>{
115
+ if (alias) {
116
+ await this.#aliases.set(`transactions:${alias}`, Buffer.from(txHash.toString()));
117
+ }
118
+ await this.#aliases.set(`transactions:last`, Buffer.from(txHash.toString()));
119
+ });
105
120
  log(`Transaction hash stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
106
121
  await this.refreshAliasCache();
107
122
  }
@@ -4,14 +4,14 @@ import type { AztecNode } from '@aztec/aztec.js/node';
4
4
  import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
5
5
  import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import type { LogFn } from '@aztec/foundation/log';
7
+ import type { AccessScopes, NotesFilter } from '@aztec/pxe/client/lazy';
7
8
  import type { PXEConfig } from '@aztec/pxe/config';
8
9
  import type { PXE } from '@aztec/pxe/server';
9
10
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
10
11
  import { NoteDao } from '@aztec/stdlib/note';
11
- import type { NotesFilter } from '@aztec/stdlib/note';
12
12
  import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
13
13
  import { ExecutionPayload } from '@aztec/stdlib/tx';
14
- import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
14
+ import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
15
15
  import type { WalletDB } from '../storage/wallet_db.js';
16
16
  import type { AccountType } from './constants.js';
17
17
  export declare class CLIWallet extends BaseWallet {
@@ -28,8 +28,13 @@ export declare class CLIWallet extends BaseWallet {
28
28
  createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
29
29
  private getFakeAccountDataFor;
30
30
  simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
31
+ /**
32
+ * Uses a stub account for kernelless simulation, bypassing real account authorization.
33
+ * Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
34
+ */
35
+ protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, scopes: AccessScopes, skipTxValidation?: boolean, skipFeeEnforcement?: boolean): Promise<TxSimulationResult>;
31
36
  getContracts(): Promise<AztecAddress[]>;
32
37
  getNotes(filter: NotesFilter): Promise<NoteDao[]>;
33
38
  getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
34
39
  }
35
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBMkMsTUFBTSx5QkFBeUIsQ0FBQztBQUNoRyxPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFHM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFNUYsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRTdDLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUzRCxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDN0MsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDdEQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLGtCQUFrQixFQUFFLE1BQU0sa0JBQWt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EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;IAID,mBAAmB,CAAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
@@ -38,22 +38,22 @@ export class CLIWallet extends BaseWallet {
38
38
  const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
39
39
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
40
40
  const fromAccount = await this.getAccountFromAddress(from);
41
+ const chainInfo = await this.getChainInfo();
41
42
  const executionOptions = {
42
43
  txNonce,
43
44
  cancellable: this.cancellableTransactions,
44
45
  feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
45
46
  };
46
- return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, executionOptions);
47
+ return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
47
48
  }
48
49
  async proveCancellationTx(from, txNonce, increasedFee) {
49
50
  const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
50
- return await this.pxe.proveTx(cancellationTxRequest);
51
+ return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
51
52
  }
52
53
  async getAccountFromAddress(address) {
53
54
  let account;
54
55
  if (address.equals(AztecAddress.ZERO)) {
55
- const chainInfo = await this.getChainInfo();
56
- account = new SignerlessAccount(chainInfo);
56
+ account = new SignerlessAccount();
57
57
  } else if (this.accountCache.has(address.toString())) {
58
58
  return this.accountCache.get(address.toString());
59
59
  } else {
@@ -118,15 +118,25 @@ export class CLIWallet extends BaseWallet {
118
118
  }
119
119
  return account;
120
120
  }
121
- async getFakeAccountDataFor(address) {
122
- const chainInfo = await this.getChainInfo();
121
+ /**
122
+ * Creates a stub account that impersonates the given address, allowing kernelless simulations
123
+ * to bypass the account's authorization mechanisms via contract overrides.
124
+ * @param address - The address of the account to impersonate
125
+ * @returns The stub account, contract instance, and artifact for simulation
126
+ */ async getFakeAccountDataFor(address) {
123
127
  const originalAccount = await this.getAccountFromAddress(address);
128
+ // Account contracts can only be overridden if they have an associated address
129
+ // Overwriting SignerlessAccount is not supported, and does not really make sense
130
+ // since it has no authorization mechanism.
131
+ if (originalAccount instanceof SignerlessAccount) {
132
+ throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
133
+ }
124
134
  const originalAddress = originalAccount.getCompleteAddress();
125
135
  const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
126
136
  if (!contractInstance) {
127
137
  throw new Error(`No contract instance found for address: ${originalAddress.address}`);
128
138
  }
129
- const stubAccount = createStubAccount(originalAddress, chainInfo);
139
+ const stubAccount = createStubAccount(originalAddress);
130
140
  const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
131
141
  salt: Fr.random()
132
142
  });
@@ -137,8 +147,21 @@ export class CLIWallet extends BaseWallet {
137
147
  };
138
148
  }
139
149
  async simulateTx(executionPayload, opts) {
140
- let simulationResults;
141
- const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
150
+ const simulationResults = await super.simulateTx(executionPayload, opts);
151
+ if (opts.fee?.estimateGas) {
152
+ const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
153
+ const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
154
+ printGasEstimates(feeOptions, limits, this.userLog);
155
+ }
156
+ return simulationResults;
157
+ }
158
+ /**
159
+ * Uses a stub account for kernelless simulation, bypassing real account authorization.
160
+ * Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
161
+ */ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
162
+ if (from.equals(AztecAddress.ZERO)) {
163
+ return super.simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement);
164
+ }
142
165
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
143
166
  const executionOptions = {
144
167
  txNonce: Fr.random(),
@@ -149,31 +172,23 @@ export class CLIWallet extends BaseWallet {
149
172
  feeExecutionPayload,
150
173
  executionPayload
151
174
  ]) : executionPayload;
152
- // Kernelless simulations using the multicall entrypoints are not currently supported,
153
- // since we only override proper account contracts.
154
- // TODO: allow disabling kernels even when no overrides are necessary
155
- if (opts.from.equals(AztecAddress.ZERO)) {
156
- const fromAccount = await this.getAccountFromAddress(opts.from);
157
- const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
158
- simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
159
- } else {
160
- const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
161
- const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
162
- const contractOverrides = {
163
- [opts.from.toString()]: {
164
- instance,
165
- artifact
175
+ const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
176
+ const chainInfo = await this.getChainInfo();
177
+ const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
178
+ return this.pxe.simulateTx(txRequest, {
179
+ simulatePublic: true,
180
+ skipFeeEnforcement: true,
181
+ skipTxValidation: true,
182
+ overrides: {
183
+ contracts: {
184
+ [from.toString()]: {
185
+ instance,
186
+ artifact
187
+ }
166
188
  }
167
- };
168
- simulationResults = await this.pxe.simulateTx(txRequest, true, true, true, {
169
- contracts: contractOverrides
170
- });
171
- }
172
- if (opts.fee?.estimateGas) {
173
- const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
174
- printGasEstimates(feeOptions, limits, this.userLog);
175
- }
176
- return simulationResults;
189
+ },
190
+ scopes
191
+ });
177
192
  }
178
193
  // Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
179
194
  // this is just a CLI wallet.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli-wallet",
3
- "version": "0.0.1-commit.f295ac2",
3
+ "version": "0.0.1-commit.f504929",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/cmds/index.js",
@@ -67,19 +67,19 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/accounts": "0.0.1-commit.f295ac2",
71
- "@aztec/aztec.js": "0.0.1-commit.f295ac2",
72
- "@aztec/bb.js": "0.0.1-commit.f295ac2",
73
- "@aztec/cli": "0.0.1-commit.f295ac2",
74
- "@aztec/entrypoints": "0.0.1-commit.f295ac2",
75
- "@aztec/ethereum": "0.0.1-commit.f295ac2",
76
- "@aztec/foundation": "0.0.1-commit.f295ac2",
77
- "@aztec/kv-store": "0.0.1-commit.f295ac2",
78
- "@aztec/noir-contracts.js": "0.0.1-commit.f295ac2",
79
- "@aztec/noir-noirc_abi": "0.0.1-commit.f295ac2",
80
- "@aztec/pxe": "0.0.1-commit.f295ac2",
81
- "@aztec/stdlib": "0.0.1-commit.f295ac2",
82
- "@aztec/wallet-sdk": "0.0.1-commit.f295ac2",
70
+ "@aztec/accounts": "0.0.1-commit.f504929",
71
+ "@aztec/aztec.js": "0.0.1-commit.f504929",
72
+ "@aztec/bb.js": "0.0.1-commit.f504929",
73
+ "@aztec/cli": "0.0.1-commit.f504929",
74
+ "@aztec/entrypoints": "0.0.1-commit.f504929",
75
+ "@aztec/ethereum": "0.0.1-commit.f504929",
76
+ "@aztec/foundation": "0.0.1-commit.f504929",
77
+ "@aztec/kv-store": "0.0.1-commit.f504929",
78
+ "@aztec/noir-contracts.js": "0.0.1-commit.f504929",
79
+ "@aztec/noir-noirc_abi": "0.0.1-commit.f504929",
80
+ "@aztec/pxe": "0.0.1-commit.f504929",
81
+ "@aztec/stdlib": "0.0.1-commit.f504929",
82
+ "@aztec/wallet-sdk": "0.0.1-commit.f504929",
83
83
  "commander": "^12.1.0",
84
84
  "inquirer": "^10.1.8",
85
85
  "source-map-support": "^0.5.21",
@@ -39,7 +39,7 @@ export async function authorizeAction(
39
39
  { caller, action },
40
40
  true,
41
41
  );
42
- const witness = await setAuthwitnessInteraction.send().wait({ timeout: DEFAULT_TX_TIMEOUT_S });
42
+ const witness = await setAuthwitnessInteraction.send({ wait: { timeout: DEFAULT_TX_TIMEOUT_S } });
43
43
 
44
44
  log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
45
45
 
@@ -32,7 +32,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
32
32
  const [receipt, effectsInBlock] = await Promise.all([aztecNode.getTxReceipt(txHash), aztecNode.getTxEffect(txHash)]);
33
33
  // Base tx data
34
34
  log(`Tx ${txHash.toString()}`);
35
- log(` Status: ${receipt.status} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`);
35
+ log(` Status: ${receipt.status}`);
36
+ if (receipt.executionResult) {
37
+ log(` Execution result: ${receipt.executionResult}`);
38
+ }
36
39
  if (receipt.error) {
37
40
  log(` Error: ${receipt.error}`);
38
41
  }
@@ -85,7 +88,7 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
85
88
  for (const nullifier of effects.nullifiers) {
86
89
  const deployed = deployNullifiers[nullifier.toString()];
87
90
  const note = deployed
88
- ? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
91
+ ? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: 'ALL_SCOPES' }))[0]
89
92
  : undefined;
90
93
  const initialized = initNullifiers[nullifier.toString()];
91
94
  const registered = classNullifiers[nullifier.toString()];
@@ -1,9 +1,11 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
2
3
  import type { AztecNode } from '@aztec/aztec.js/node';
3
4
  import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
4
5
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
6
  import { Fr } from '@aztec/foundation/curves/bn254';
6
7
  import type { LogFn, Logger } from '@aztec/foundation/log';
8
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
7
9
 
8
10
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
9
11
  import type { AccountType } from '../utils/constants.js';
@@ -64,8 +66,8 @@ export async function createAccount(
64
66
  log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
65
67
  }
66
68
 
67
- let tx;
68
- let txReceipt;
69
+ let txHash: TxHash | undefined;
70
+ let txReceipt: TxReceipt | undefined;
69
71
  if (!registerOnly) {
70
72
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
71
73
 
@@ -81,10 +83,13 @@ export async function createAccount(
81
83
  };
82
84
 
83
85
  const deployMethod = await account.getDeployMethod();
84
- const { estimatedGas, stats } = await deployMethod.simulate({
86
+ const sim = await deployMethod.simulate({
85
87
  ...deployAccountOpts,
86
88
  fee: { ...deployAccountOpts.fee, estimateGas: true },
87
89
  });
90
+ // estimateGas: true guarantees these fields are present
91
+ const estimatedGas = sim.estimatedGas!;
92
+ const stats = sim.stats!;
88
93
 
89
94
  if (feeOpts.estimateOnly) {
90
95
  if (json) {
@@ -100,7 +105,14 @@ export async function createAccount(
100
105
  };
101
106
  }
102
107
  } else {
103
- tx = deployMethod.send({
108
+ if (verbose) {
109
+ printProfileResult(stats, log);
110
+ }
111
+
112
+ if (!json) {
113
+ log(`\nWaiting for account contract deployment...`);
114
+ }
115
+ const sendOpts = {
104
116
  ...deployAccountOpts,
105
117
  fee: deployAccountOpts.fee
106
118
  ? {
@@ -108,32 +120,31 @@ export async function createAccount(
108
120
  gasSettings: estimatedGas,
109
121
  }
110
122
  : undefined,
111
- });
112
- if (verbose) {
113
- printProfileResult(stats, log);
114
- }
115
-
116
- const txHash = await tx.getTxHash();
117
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
118
- out.txHash = txHash;
123
+ };
119
124
  if (wait) {
120
- if (!json) {
121
- log(`\nWaiting for account contract deployment...`);
122
- }
123
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
125
+ const { receipt } = await deployMethod.send({
126
+ ...sendOpts,
127
+ wait: { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true },
128
+ });
129
+ txReceipt = receipt;
130
+ txHash = receipt.txHash;
124
131
  out.txReceipt = {
125
132
  status: txReceipt.status,
126
133
  transactionFee: txReceipt.transactionFee,
127
134
  };
135
+ } else {
136
+ ({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
128
137
  }
138
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
139
+ out.txHash = txHash;
129
140
  }
130
141
  }
131
142
 
132
143
  if (json) {
133
144
  log(prettyPrintJSON(out));
134
145
  } else {
135
- if (tx) {
136
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
146
+ if (txHash) {
147
+ log(`Deploy tx hash: ${txHash.toString()}`);
137
148
  }
138
149
  if (txReceipt) {
139
150
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -1,5 +1,6 @@
1
1
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import type { DeployOptions } from '@aztec/aztec.js/contracts';
3
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
4
  import { ContractDeployer } from '@aztec/aztec.js/deployment';
4
5
  import { Fr } from '@aztec/aztec.js/fields';
5
6
  import type { AztecNode } from '@aztec/aztec.js/node';
@@ -70,10 +71,13 @@ export async function deploy(
70
71
  skipInstancePublication,
71
72
  };
72
73
 
73
- const { estimatedGas, stats } = await deploy.simulate({
74
+ const sim = await deploy.simulate({
74
75
  ...deployOpts,
75
76
  fee: { ...deployOpts.fee, estimateGas: true },
76
77
  });
78
+ // estimateGas: true guarantees these fields are present
79
+ const estimatedGas = sim.estimatedGas!;
80
+ const stats = sim.stats!;
77
81
 
78
82
  if (feeOpts.estimateOnly) {
79
83
  if (json) {
@@ -89,37 +93,55 @@ export async function deploy(
89
93
  };
90
94
  }
91
95
  } else {
92
- const tx = deploy.send(deployOpts);
93
96
  if (verbose) {
94
97
  printProfileResult(stats, log);
95
98
  }
96
99
 
97
- const txHash = await tx.getTxHash();
98
- debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
99
- out.hash = txHash;
100
100
  const { address, partialAddress } = deploy;
101
101
  const instance = await deploy.getInstance();
102
- if (!json) {
103
- log(`Contract deployed at ${address?.toString()}`);
104
- log(`Contract partial address ${(await partialAddress)?.toString()}`);
105
- log(`Contract init hash ${instance.initializationHash.toString()}`);
106
- log(`Deployment tx hash: ${txHash.toString()}`);
107
- log(`Deployment salt: ${salt.toString()}`);
108
- log(`Deployer: ${instance.deployer.toString()}`);
109
- } else {
110
- out.contract = {
111
- address: address?.toString(),
112
- partialAddress: (await partialAddress)?.toString(),
113
- initializationHash: instance.initializationHash.toString(),
114
- salt: salt.toString(),
115
- };
116
- }
102
+
117
103
  if (wait) {
118
- const deployed = await tx.wait({ timeout });
104
+ const { receipt } = await deploy.send({ ...deployOpts, wait: { timeout, returnReceipt: true } });
105
+ const txHash = receipt.txHash;
106
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
107
+ out.hash = txHash;
108
+
109
+ if (!json) {
110
+ log(`Contract deployed at ${address?.toString()}`);
111
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
112
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
113
+ log(`Deployment tx hash: ${txHash.toString()}`);
114
+ log(`Deployment salt: ${salt.toString()}`);
115
+ log(`Deployer: ${instance.deployer.toString()}`);
116
+ log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
117
+ } else {
118
+ out.contract = {
119
+ address: address?.toString(),
120
+ partialAddress: (await partialAddress)?.toString(),
121
+ initializationHash: instance.initializationHash.toString(),
122
+ salt: salt.toString(),
123
+ transactionFee: receipt.transactionFee?.toString(),
124
+ };
125
+ }
126
+ } else {
127
+ const { txHash } = await deploy.send({ ...deployOpts, wait: NO_WAIT });
128
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
129
+ out.hash = txHash;
130
+
119
131
  if (!json) {
120
- log(`Transaction fee: ${deployed.transactionFee?.toString()}`);
132
+ log(`Contract deployed at ${address?.toString()}`);
133
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
134
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
135
+ log(`Deployment tx hash: ${txHash.toString()}`);
136
+ log(`Deployment salt: ${salt.toString()}`);
137
+ log(`Deployer: ${instance.deployer.toString()}`);
121
138
  } else {
122
- out.contract.transactionFee = deployed.transactionFee?.toString();
139
+ out.contract = {
140
+ address: address?.toString(),
141
+ partialAddress: (await partialAddress)?.toString(),
142
+ initializationHash: instance.initializationHash.toString(),
143
+ salt: salt.toString(),
144
+ };
123
145
  }
124
146
  }
125
147
  }