@aztec/cli-wallet 0.0.1-commit.d431d1c → 0.0.1-commit.db765a8

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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Q,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;IAID,mBAAmB,CAAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
@@ -48,7 +48,7 @@ export class CLIWallet extends BaseWallet {
48
48
  }
49
49
  async proveCancellationTx(from, txNonce, increasedFee) {
50
50
  const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
51
- return await this.pxe.proveTx(cancellationTxRequest);
51
+ return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
52
52
  }
53
53
  async getAccountFromAddress(address) {
54
54
  let account;
@@ -147,10 +147,22 @@ export class CLIWallet extends BaseWallet {
147
147
  };
148
148
  }
149
149
  async simulateTx(executionPayload, opts) {
150
- let simulationResults;
151
- 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
+ }
152
165
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
153
- const chainInfo = await this.getChainInfo();
154
166
  const executionOptions = {
155
167
  txNonce: Fr.random(),
156
168
  cancellable: this.cancellableTransactions,
@@ -160,31 +172,23 @@ export class CLIWallet extends BaseWallet {
160
172
  feeExecutionPayload,
161
173
  executionPayload
162
174
  ]) : executionPayload;
163
- // Kernelless simulations using the multicall entrypoints are not currently supported,
164
- // since we only override proper account contracts.
165
- // TODO: allow disabling kernels even when no overrides are necessary
166
- if (opts.from.equals(AztecAddress.ZERO)) {
167
- const fromAccount = await this.getAccountFromAddress(opts.from);
168
- const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
169
- simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
170
- } else {
171
- const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
172
- const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
173
- const contractOverrides = {
174
- [opts.from.toString()]: {
175
- instance,
176
- 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
+ }
177
188
  }
178
- };
179
- simulationResults = await this.pxe.simulateTx(txRequest, true, true, true, {
180
- contracts: contractOverrides
181
- });
182
- }
183
- if (opts.fee?.estimateGas) {
184
- const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
185
- printGasEstimates(feeOptions, limits, this.userLog);
186
- }
187
- return simulationResults;
189
+ },
190
+ scopes
191
+ });
188
192
  }
189
193
  // Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
190
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.d431d1c",
3
+ "version": "0.0.1-commit.db765a8",
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.d431d1c",
71
- "@aztec/aztec.js": "0.0.1-commit.d431d1c",
72
- "@aztec/bb.js": "0.0.1-commit.d431d1c",
73
- "@aztec/cli": "0.0.1-commit.d431d1c",
74
- "@aztec/entrypoints": "0.0.1-commit.d431d1c",
75
- "@aztec/ethereum": "0.0.1-commit.d431d1c",
76
- "@aztec/foundation": "0.0.1-commit.d431d1c",
77
- "@aztec/kv-store": "0.0.1-commit.d431d1c",
78
- "@aztec/noir-contracts.js": "0.0.1-commit.d431d1c",
79
- "@aztec/noir-noirc_abi": "0.0.1-commit.d431d1c",
80
- "@aztec/pxe": "0.0.1-commit.d431d1c",
81
- "@aztec/stdlib": "0.0.1-commit.d431d1c",
82
- "@aztec/wallet-sdk": "0.0.1-commit.d431d1c",
70
+ "@aztec/accounts": "0.0.1-commit.db765a8",
71
+ "@aztec/aztec.js": "0.0.1-commit.db765a8",
72
+ "@aztec/bb.js": "0.0.1-commit.db765a8",
73
+ "@aztec/cli": "0.0.1-commit.db765a8",
74
+ "@aztec/entrypoints": "0.0.1-commit.db765a8",
75
+ "@aztec/ethereum": "0.0.1-commit.db765a8",
76
+ "@aztec/foundation": "0.0.1-commit.db765a8",
77
+ "@aztec/kv-store": "0.0.1-commit.db765a8",
78
+ "@aztec/noir-contracts.js": "0.0.1-commit.db765a8",
79
+ "@aztec/noir-noirc_abi": "0.0.1-commit.db765a8",
80
+ "@aztec/pxe": "0.0.1-commit.db765a8",
81
+ "@aztec/stdlib": "0.0.1-commit.db765a8",
82
+ "@aztec/wallet-sdk": "0.0.1-commit.db765a8",
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
  }
@@ -1,8 +1,10 @@
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 type { LogFn, Logger } from '@aztec/foundation/log';
7
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
6
8
 
7
9
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
8
10
  import type { CLIFeeArgs } from '../utils/options/fees.js';
@@ -45,8 +47,8 @@ export async function deployAccount(
45
47
  log(`Init hash: ${initializationHash.toString()}`);
46
48
  }
47
49
 
48
- let tx;
49
- let txReceipt;
50
+ let txHash: TxHash | undefined;
51
+ let txReceipt: TxReceipt | undefined;
50
52
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
51
53
 
52
54
  const delegatedDeployment = deployer && !account.address.equals(deployer);
@@ -61,10 +63,13 @@ export async function deployAccount(
61
63
  };
62
64
 
63
65
  const deployMethod = await account.getDeployMethod();
64
- const { estimatedGas, stats } = await deployMethod.simulate({
66
+ const sim = await deployMethod.simulate({
65
67
  ...deployAccountOpts,
66
68
  fee: { ...deployAccountOpts.fee, estimateGas: true },
67
69
  });
70
+ // estimateGas: true guarantees these fields are present
71
+ const estimatedGas = sim.estimatedGas!;
72
+ const stats = sim.stats!;
68
73
 
69
74
  if (feeOpts.estimateOnly) {
70
75
  if (json) {
@@ -80,7 +85,14 @@ export async function deployAccount(
80
85
  };
81
86
  }
82
87
  } else {
83
- tx = deployMethod.send({
88
+ if (verbose) {
89
+ printProfileResult(stats, log);
90
+ }
91
+
92
+ if (!json) {
93
+ log(`\nWaiting for account contract deployment...`);
94
+ }
95
+ const sendOpts = {
84
96
  ...deployAccountOpts,
85
97
  fee: deployAccountOpts.fee
86
98
  ? {
@@ -88,31 +100,30 @@ export async function deployAccount(
88
100
  gasSettings: estimatedGas,
89
101
  }
90
102
  : undefined,
91
- });
92
- if (verbose) {
93
- printProfileResult(stats, log);
94
- }
95
-
96
- const txHash = await tx.getTxHash();
97
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
98
- out.txHash = txHash;
103
+ };
99
104
  if (wait) {
100
- if (!json) {
101
- log(`\nWaiting for account contract deployment...`);
102
- }
103
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
105
+ const { receipt } = await deployMethod.send({
106
+ ...sendOpts,
107
+ wait: { timeout: DEFAULT_TX_TIMEOUT_S, returnReceipt: true },
108
+ });
109
+ txReceipt = receipt;
110
+ txHash = receipt.txHash;
104
111
  out.txReceipt = {
105
112
  status: txReceipt.status,
106
113
  transactionFee: txReceipt.transactionFee,
107
114
  };
115
+ } else {
116
+ ({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
108
117
  }
118
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
119
+ out.txHash = txHash;
109
120
  }
110
121
 
111
122
  if (json) {
112
123
  log(prettyPrintJSON(out));
113
124
  } else {
114
- if (tx) {
115
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
125
+ if (txHash) {
126
+ log(`Deploy tx hash: ${txHash.toString()}`);
116
127
  }
117
128
  if (txReceipt) {
118
129
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
package/src/cmds/index.ts CHANGED
@@ -63,7 +63,7 @@ export function injectCommands(
63
63
  const createAccountCommand = program
64
64
  .command('create-account')
65
65
  .description(
66
- 'Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).',
66
+ 'Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr account which uses an immutable key for authentication.',
67
67
  )
68
68
  .summary('Creates an aztec account that can be used for sending transactions.')
69
69
  .addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db))