@aztec/cli-wallet 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e

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.
Files changed (57) hide show
  1. package/dest/cmds/authorize_action.d.ts +2 -2
  2. package/dest/cmds/authorize_action.d.ts.map +1 -1
  3. package/dest/cmds/authorize_action.js +4 -2
  4. package/dest/cmds/check_tx.d.ts +1 -1
  5. package/dest/cmds/check_tx.d.ts.map +1 -1
  6. package/dest/cmds/check_tx.js +45 -14
  7. package/dest/cmds/create_account.d.ts +4 -3
  8. package/dest/cmds/create_account.d.ts.map +1 -1
  9. package/dest/cmds/create_account.js +42 -25
  10. package/dest/cmds/create_authwit.d.ts +2 -2
  11. package/dest/cmds/create_authwit.d.ts.map +1 -1
  12. package/dest/cmds/deploy.d.ts +4 -3
  13. package/dest/cmds/deploy.d.ts.map +1 -1
  14. package/dest/cmds/deploy.js +56 -29
  15. package/dest/cmds/deploy_account.d.ts +4 -3
  16. package/dest/cmds/deploy_account.d.ts.map +1 -1
  17. package/dest/cmds/deploy_account.js +37 -20
  18. package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
  19. package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
  20. package/dest/cmds/get_fee_juice_balance.js +27 -0
  21. package/dest/cmds/index.d.ts +1 -1
  22. package/dest/cmds/index.d.ts.map +1 -1
  23. package/dest/cmds/index.js +30 -14
  24. package/dest/cmds/send.d.ts +5 -4
  25. package/dest/cmds/send.d.ts.map +1 -1
  26. package/dest/cmds/send.js +32 -16
  27. package/dest/cmds/simulate.d.ts +1 -1
  28. package/dest/cmds/simulate.d.ts.map +1 -1
  29. package/dest/cmds/simulate.js +3 -3
  30. package/dest/storage/wallet_db.d.ts +6 -1
  31. package/dest/storage/wallet_db.d.ts.map +1 -1
  32. package/dest/storage/wallet_db.js +60 -31
  33. package/dest/utils/options/fees.d.ts +3 -2
  34. package/dest/utils/options/fees.d.ts.map +1 -1
  35. package/dest/utils/options/fees.js +32 -9
  36. package/dest/utils/options/options.d.ts +2 -2
  37. package/dest/utils/options/options.d.ts.map +1 -1
  38. package/dest/utils/profiling.d.ts +1 -1
  39. package/dest/utils/profiling.d.ts.map +1 -1
  40. package/dest/utils/profiling.js +9 -1
  41. package/dest/utils/wallet.d.ts +12 -5
  42. package/dest/utils/wallet.d.ts.map +1 -1
  43. package/dest/utils/wallet.js +87 -47
  44. package/package.json +15 -15
  45. package/src/cmds/authorize_action.ts +1 -1
  46. package/src/cmds/check_tx.ts +50 -19
  47. package/src/cmds/create_account.ts +44 -24
  48. package/src/cmds/deploy.ts +55 -27
  49. package/src/cmds/deploy_account.ts +38 -19
  50. package/src/cmds/get_fee_juice_balance.ts +37 -0
  51. package/src/cmds/index.ts +57 -4
  52. package/src/cmds/send.ts +32 -12
  53. package/src/cmds/simulate.ts +4 -7
  54. package/src/storage/wallet_db.ts +63 -36
  55. package/src/utils/options/fees.ts +39 -9
  56. package/src/utils/profiling.ts +15 -1
  57. package/src/utils/wallet.ts +99 -63
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli-wallet",
3
- "version": "0.0.1-commit.1142ef1",
3
+ "version": "0.0.1-commit.11bf3dd6e",
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.1142ef1",
71
- "@aztec/aztec.js": "0.0.1-commit.1142ef1",
72
- "@aztec/bb.js": "0.0.1-commit.1142ef1",
73
- "@aztec/cli": "0.0.1-commit.1142ef1",
74
- "@aztec/entrypoints": "0.0.1-commit.1142ef1",
75
- "@aztec/ethereum": "0.0.1-commit.1142ef1",
76
- "@aztec/foundation": "0.0.1-commit.1142ef1",
77
- "@aztec/kv-store": "0.0.1-commit.1142ef1",
78
- "@aztec/noir-contracts.js": "0.0.1-commit.1142ef1",
79
- "@aztec/noir-noirc_abi": "0.0.1-commit.1142ef1",
80
- "@aztec/pxe": "0.0.1-commit.1142ef1",
81
- "@aztec/stdlib": "0.0.1-commit.1142ef1",
82
- "@aztec/wallet-sdk": "0.0.1-commit.1142ef1",
70
+ "@aztec/accounts": "0.0.1-commit.11bf3dd6e",
71
+ "@aztec/aztec.js": "0.0.1-commit.11bf3dd6e",
72
+ "@aztec/bb.js": "0.0.1-commit.11bf3dd6e",
73
+ "@aztec/cli": "0.0.1-commit.11bf3dd6e",
74
+ "@aztec/entrypoints": "0.0.1-commit.11bf3dd6e",
75
+ "@aztec/ethereum": "0.0.1-commit.11bf3dd6e",
76
+ "@aztec/foundation": "0.0.1-commit.11bf3dd6e",
77
+ "@aztec/kv-store": "0.0.1-commit.11bf3dd6e",
78
+ "@aztec/noir-contracts.js": "0.0.1-commit.11bf3dd6e",
79
+ "@aztec/noir-noirc_abi": "0.0.1-commit.11bf3dd6e",
80
+ "@aztec/pxe": "0.0.1-commit.11bf3dd6e",
81
+ "@aztec/stdlib": "0.0.1-commit.11bf3dd6e",
82
+ "@aztec/wallet-sdk": "0.0.1-commit.11bf3dd6e",
83
83
  "commander": "^12.1.0",
84
84
  "inquirer": "^10.1.8",
85
85
  "source-map-support": "^0.5.21",
@@ -90,7 +90,7 @@
90
90
  "@types/jest": "^30.0.0",
91
91
  "@types/node": "^22.15.17",
92
92
  "@types/source-map-support": "^0.5.10",
93
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
93
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
94
94
  "jest": "^30.0.0",
95
95
  "jest-mock-extended": "^4.0.0",
96
96
  "ts-jest": "^29.4.0",
@@ -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
 
@@ -1,11 +1,15 @@
1
1
  import type { ContractArtifact } from '@aztec/aztec.js/abi';
2
- import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
3
3
  import { Fr } from '@aztec/aztec.js/fields';
4
4
  import type { AztecNode } from '@aztec/aztec.js/node';
5
5
  import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
6
6
  import type { TxHash } from '@aztec/aztec.js/tx';
7
7
  import type { LogFn } from '@aztec/foundation/log';
8
- import { siloNullifier } from '@aztec/stdlib/hash';
8
+ import {
9
+ computeSiloedPrivateInitializationNullifier,
10
+ computeSiloedPublicInitializationNullifier,
11
+ siloNullifier,
12
+ } from '@aztec/stdlib/hash';
9
13
  import { NoteDao } from '@aztec/stdlib/note';
10
14
 
11
15
  import type { CLIWallet } from '../utils/wallet.js';
@@ -32,7 +36,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
32
36
  const [receipt, effectsInBlock] = await Promise.all([aztecNode.getTxReceipt(txHash), aztecNode.getTxEffect(txHash)]);
33
37
  // Base tx data
34
38
  log(`Tx ${txHash.toString()}`);
35
- log(` Status: ${receipt.status} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`);
39
+ log(` Status: ${receipt.status}`);
40
+ if (receipt.executionResult) {
41
+ log(` Execution result: ${receipt.executionResult}`);
42
+ }
36
43
  if (receipt.error) {
37
44
  log(` Error: ${receipt.error}`);
38
45
  }
@@ -80,12 +87,13 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
80
87
  // Nullifiers
81
88
  const nullifierCount = effects.nullifiers.length;
82
89
  const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
90
+ const accounts = (await wallet.getAccounts()).map(a => a.item);
83
91
  if (nullifierCount > 0) {
84
92
  log(' Nullifiers:');
85
93
  for (const nullifier of effects.nullifiers) {
86
94
  const deployed = deployNullifiers[nullifier.toString()];
87
95
  const note = deployed
88
- ? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
96
+ ? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: accounts }))[0]
89
97
  : undefined;
90
98
  const initialized = initNullifiers[nullifier.toString()];
91
99
  const registered = classNullifiers[nullifier.toString()];
@@ -141,22 +149,49 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
141
149
 
142
150
  async function getKnownNullifiers(wallet: CLIWallet, artifactMap: ArtifactMap) {
143
151
  const knownContracts = await wallet.getContracts();
144
- const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
145
- const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
152
+
153
+ const [contractResults, classResults] = await Promise.all([
154
+ Promise.all(knownContracts.map(contract => getContractNullifiers(wallet, contract))),
155
+ Promise.all(Object.values(artifactMap).map(artifact => getClassNullifier(artifact))),
156
+ ]);
157
+
146
158
  const initNullifiers: Record<string, AztecAddress> = {};
147
159
  const deployNullifiers: Record<string, AztecAddress> = {};
148
160
  const classNullifiers: Record<string, string> = {};
149
- for (const contract of knownContracts) {
150
- initNullifiers[(await siloNullifier(contract, contract.toField())).toString()] = contract;
151
- deployNullifiers[(await siloNullifier(deployerAddress, contract.toField())).toString()] = contract;
161
+
162
+ for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults) {
163
+ deployNullifiers[deployNullifier.toString()] = contract;
164
+ if (privateInitNullifier) {
165
+ initNullifiers[privateInitNullifier.toString()] = contract;
166
+ }
167
+ initNullifiers[publicInitNullifier.toString()] = contract;
152
168
  }
153
- for (const artifact of Object.values(artifactMap)) {
154
- classNullifiers[(await siloNullifier(classRegistryAddress, artifact.classId)).toString()] =
155
- `${artifact.name}Class<${artifact.classId}>`;
169
+ for (const { nullifier, label } of classResults) {
170
+ classNullifiers[nullifier.toString()] = label;
156
171
  }
172
+
157
173
  return { initNullifiers, deployNullifiers, classNullifiers };
158
174
  }
159
175
 
176
+ async function getContractNullifiers(wallet: CLIWallet, contract: AztecAddress) {
177
+ const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
178
+ const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
179
+
180
+ const metadata = await wallet.getContractMetadata(contract);
181
+ const privateInitNullifier = metadata.instance
182
+ ? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash)
183
+ : undefined;
184
+ const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
185
+
186
+ return { contract, deployNullifier, privateInitNullifier, publicInitNullifier };
187
+ }
188
+
189
+ async function getClassNullifier(artifact: ContractArtifactWithClassId) {
190
+ const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
191
+ const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
192
+ return { nullifier, label: `${artifact.name}Class<${artifact.classId}>` };
193
+ }
194
+
160
195
  type ArtifactMap = Record<string, ContractArtifactWithClassId>;
161
196
  type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
162
197
 
@@ -164,15 +199,11 @@ async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
164
199
  const knownContractAddresses = await wallet.getContracts();
165
200
  const knownContracts = (
166
201
  await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
167
- ).map(contractMetadata => contractMetadata.contractInstance);
202
+ ).map(contractMetadata => contractMetadata.instance);
168
203
  const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
169
204
  const knownArtifacts = (
170
- await Promise.all(classIds.map(classId => (classId ? wallet.getContractClassMetadata(classId) : undefined)))
171
- ).map(contractClassMetadata =>
172
- contractClassMetadata
173
- ? { ...contractClassMetadata.artifact, classId: contractClassMetadata.contractClass?.id }
174
- : undefined,
175
- );
205
+ await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
206
+ ).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
176
207
  const map: Record<string, ContractArtifactWithClassId> = {};
177
208
  for (const instance of knownContracts) {
178
209
  if (instance) {
@@ -1,9 +1,12 @@
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
1
2
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
4
+ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
3
5
  import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
4
6
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
7
  import { Fr } from '@aztec/foundation/curves/bn254';
6
8
  import type { LogFn, Logger } from '@aztec/foundation/log';
9
+ import { type TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
7
10
 
8
11
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
9
12
  import type { AccountType } from '../utils/constants.js';
@@ -16,6 +19,7 @@ export async function createAccount(
16
19
  aztecNode: AztecNode,
17
20
  accountType: AccountType,
18
21
  secretKey: Fr | undefined,
22
+ salt: Fr | undefined,
19
23
  publicKey: string | undefined,
20
24
  alias: string | undefined,
21
25
  deployer: AztecAddress | undefined,
@@ -25,6 +29,7 @@ export async function createAccount(
25
29
  registerClass: boolean,
26
30
  wait: boolean,
27
31
  feeOpts: CLIFeeArgs,
32
+ waitForStatus: TxStatus,
28
33
  json: boolean,
29
34
  verbose: boolean,
30
35
  debugLogger: Logger,
@@ -36,10 +41,10 @@ export async function createAccount(
36
41
  undefined /* address, we don't have it yet */,
37
42
  secretKey,
38
43
  accountType,
39
- Fr.ZERO,
44
+ salt,
40
45
  publicKey,
41
46
  );
42
- const { salt } = account.getInstance();
47
+ const instanceSalt = account.getInstance().salt;
43
48
  const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
44
49
 
45
50
  const out: Record<string, any> = {};
@@ -50,7 +55,7 @@ export async function createAccount(
50
55
  out.secretKey = secretKey;
51
56
  }
52
57
  out.partialAddress = partialAddress;
53
- out.salt = salt;
58
+ out.salt = instanceSalt;
54
59
  out.initHash = account.getInstance().initializationHash;
55
60
  } else {
56
61
  log(`\nNew account:\n`);
@@ -60,17 +65,17 @@ export async function createAccount(
60
65
  log(`Secret key: ${secretKey.toString()}`);
61
66
  }
62
67
  log(`Partial address: ${partialAddress.toString()}`);
63
- log(`Salt: ${salt.toString()}`);
68
+ log(`Salt: ${instanceSalt.toString()}`);
64
69
  log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
65
70
  }
66
71
 
67
- let tx;
68
- let txReceipt;
72
+ let txHash: TxHash | undefined;
73
+ let txReceipt: TxReceipt | undefined;
69
74
  if (!registerOnly) {
70
75
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
71
76
 
72
77
  const delegatedDeployment = deployer && !account.address.equals(deployer);
73
- const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
78
+ const from = delegatedDeployment ? deployer : NO_FROM;
74
79
 
75
80
  const deployAccountOpts: DeployAccountOptions = {
76
81
  skipClassPublication: !registerClass,
@@ -80,11 +85,15 @@ export async function createAccount(
80
85
  fee: { paymentMethod, gasSettings },
81
86
  };
82
87
 
88
+ const localStart = performance.now();
83
89
  const deployMethod = await account.getDeployMethod();
84
- const { estimatedGas, stats } = await deployMethod.simulate({
90
+ const sim = await deployMethod.simulate({
85
91
  ...deployAccountOpts,
86
92
  fee: { ...deployAccountOpts.fee, estimateGas: true },
87
93
  });
94
+ // estimateGas: true guarantees these fields are present
95
+ const estimatedGas = sim.estimatedGas!;
96
+ const stats = sim.stats!;
88
97
 
89
98
  if (feeOpts.estimateOnly) {
90
99
  if (json) {
@@ -100,7 +109,14 @@ export async function createAccount(
100
109
  };
101
110
  }
102
111
  } else {
103
- tx = deployMethod.send({
112
+ if (verbose) {
113
+ printProfileResult(stats, log);
114
+ }
115
+
116
+ if (!json) {
117
+ log(`\nWaiting for account contract deployment...`);
118
+ }
119
+ const sendOpts = {
104
120
  ...deployAccountOpts,
105
121
  fee: deployAccountOpts.fee
106
122
  ? {
@@ -108,37 +124,41 @@ export async function createAccount(
108
124
  gasSettings: estimatedGas,
109
125
  }
110
126
  : undefined,
111
- });
112
- if (verbose) {
113
- printProfileResult(stats, log);
114
- }
127
+ };
128
+
129
+ ({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
130
+ const localTimeMs = performance.now() - localStart;
115
131
 
116
- const txHash = await tx.getTxHash();
117
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
118
- out.txHash = txHash;
119
132
  if (wait) {
120
- if (!json) {
121
- log(`\nWaiting for account contract deployment...`);
122
- }
123
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
133
+ const nodeStart = performance.now();
134
+ txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
135
+ const nodeTimeMs = performance.now() - nodeStart;
136
+
124
137
  out.txReceipt = {
125
138
  status: txReceipt.status,
126
139
  transactionFee: txReceipt.transactionFee,
127
140
  };
141
+
142
+ if (!json) {
143
+ log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
144
+ log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
145
+ }
128
146
  }
147
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
148
+ out.txHash = txHash;
129
149
  }
130
150
  }
131
151
 
132
152
  if (json) {
133
153
  log(prettyPrintJSON(out));
134
154
  } else {
135
- if (tx) {
136
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
155
+ if (txHash) {
156
+ log(`Deploy tx hash: ${txHash.toString()}`);
137
157
  }
138
158
  if (txReceipt) {
139
159
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
140
160
  }
141
161
  }
142
162
 
143
- return { alias, address, secretKey, salt };
163
+ return { alias, address, secretKey, salt: instanceSalt };
144
164
  }
@@ -1,12 +1,15 @@
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
1
2
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
3
  import type { DeployOptions } from '@aztec/aztec.js/contracts';
4
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
3
5
  import { ContractDeployer } from '@aztec/aztec.js/deployment';
4
6
  import { Fr } from '@aztec/aztec.js/fields';
5
- import type { AztecNode } from '@aztec/aztec.js/node';
7
+ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
6
8
  import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec/cli/utils';
7
9
  import type { LogFn, Logger } from '@aztec/foundation/log';
8
10
  import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
9
11
  import { PublicKeys } from '@aztec/stdlib/keys';
12
+ import type { TxStatus } from '@aztec/stdlib/tx';
10
13
 
11
14
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
12
15
  import { CLIFeeArgs } from '../utils/options/fees.js';
@@ -28,6 +31,7 @@ export async function deploy(
28
31
  skipInitialization: boolean | undefined,
29
32
  wait: boolean,
30
33
  feeOpts: CLIFeeArgs,
34
+ waitForStatus: TxStatus,
31
35
  verbose: boolean,
32
36
  timeout: number = DEFAULT_TX_TIMEOUT_S,
33
37
  debugLogger: Logger,
@@ -58,11 +62,11 @@ export async function deploy(
58
62
  debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
59
63
  }
60
64
 
61
- const deploy = contractDeployer.deploy(...args);
65
+ const deployInteraction = contractDeployer.deploy(...args);
62
66
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
63
67
  const deployOpts: DeployOptions = {
64
68
  fee: { gasSettings, paymentMethod },
65
- from: deployer ?? AztecAddress.ZERO,
69
+ from: deployer ?? NO_FROM,
66
70
  contractAddressSalt: salt,
67
71
  universalDeploy: !deployer,
68
72
  skipClassPublication,
@@ -70,10 +74,14 @@ export async function deploy(
70
74
  skipInstancePublication,
71
75
  };
72
76
 
73
- const { estimatedGas, stats } = await deploy.simulate({
77
+ const localStart = performance.now();
78
+ const sim = await deployInteraction.simulate({
74
79
  ...deployOpts,
75
80
  fee: { ...deployOpts.fee, estimateGas: true },
76
81
  });
82
+ // estimateGas: true guarantees these fields are present
83
+ const estimatedGas = sim.estimatedGas!;
84
+ const stats = sim.stats!;
77
85
 
78
86
  if (feeOpts.estimateOnly) {
79
87
  if (json) {
@@ -89,42 +97,62 @@ export async function deploy(
89
97
  };
90
98
  }
91
99
  } else {
92
- const tx = deploy.send(deployOpts);
93
100
  if (verbose) {
94
101
  printProfileResult(stats, log);
95
102
  }
96
103
 
97
- const txHash = await tx.getTxHash();
104
+ const { address, partialAddress } = deployInteraction;
105
+ const instance = await deployInteraction.getInstance();
106
+
107
+ const { txHash } = await deployInteraction.send({ ...deployOpts, wait: NO_WAIT });
108
+ const localTimeMs = performance.now() - localStart;
98
109
  debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
99
110
  out.hash = txHash;
100
- const { address, partialAddress } = deploy;
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
- }
111
+
117
112
  if (wait) {
118
- const deployed = await tx.wait({ timeout });
113
+ const nodeStart = performance.now();
114
+ const receipt = await waitForTx(node, txHash, { timeout, waitForStatus });
115
+ const nodeTimeMs = performance.now() - nodeStart;
116
+
117
+ if (!json) {
118
+ log(`Contract deployed at ${address?.toString()}`);
119
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
120
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
121
+ log(`Deployment tx hash: ${txHash.toString()}`);
122
+ log(`Deployment salt: ${salt.toString()}`);
123
+ log(`Deployer: ${instance.deployer.toString()}`);
124
+ log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
125
+ log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
126
+ log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
127
+ } else {
128
+ out.contract = {
129
+ address: address?.toString(),
130
+ partialAddress: (await partialAddress)?.toString(),
131
+ initializationHash: instance.initializationHash.toString(),
132
+ salt: salt.toString(),
133
+ transactionFee: receipt.transactionFee?.toString(),
134
+ };
135
+ }
136
+ } else {
119
137
  if (!json) {
120
- log(`Transaction fee: ${deployed.transactionFee?.toString()}`);
138
+ log(`Contract deployed at ${address?.toString()}`);
139
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
140
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
141
+ log(`Deployment tx hash: ${txHash.toString()}`);
142
+ log(`Deployment salt: ${salt.toString()}`);
143
+ log(`Deployer: ${instance.deployer.toString()}`);
121
144
  } else {
122
- out.contract.transactionFee = deployed.transactionFee?.toString();
145
+ out.contract = {
146
+ address: address?.toString(),
147
+ partialAddress: (await partialAddress)?.toString(),
148
+ initializationHash: instance.initializationHash.toString(),
149
+ salt: salt.toString(),
150
+ };
123
151
  }
124
152
  }
125
153
  }
126
154
  if (json) {
127
155
  log(prettyPrintJSON(out));
128
156
  }
129
- return deploy.address;
157
+ return deployInteraction.address;
130
158
  }
@@ -1,8 +1,11 @@
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
1
2
  import { AztecAddress } from '@aztec/aztec.js/addresses';
2
- import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
4
+ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
3
5
  import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
4
6
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
7
  import type { LogFn, Logger } from '@aztec/foundation/log';
8
+ import type { TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
6
9
 
7
10
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
8
11
  import type { CLIFeeArgs } from '../utils/options/fees.js';
@@ -19,6 +22,7 @@ export async function deployAccount(
19
22
  publicDeploy: boolean,
20
23
  skipInitialization: boolean,
21
24
  feeOpts: CLIFeeArgs,
25
+ waitForStatus: TxStatus,
22
26
  json: boolean,
23
27
  verbose: boolean,
24
28
  debugLogger: Logger,
@@ -45,12 +49,12 @@ export async function deployAccount(
45
49
  log(`Init hash: ${initializationHash.toString()}`);
46
50
  }
47
51
 
48
- let tx;
49
- let txReceipt;
52
+ let txHash: TxHash | undefined;
53
+ let txReceipt: TxReceipt | undefined;
50
54
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
51
55
 
52
56
  const delegatedDeployment = deployer && !account.address.equals(deployer);
53
- const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
57
+ const from = delegatedDeployment ? deployer : NO_FROM;
54
58
 
55
59
  const deployAccountOpts: DeployAccountOptions = {
56
60
  skipClassPublication: !registerClass,
@@ -60,11 +64,15 @@ export async function deployAccount(
60
64
  fee: { paymentMethod, gasSettings },
61
65
  };
62
66
 
67
+ const localStart = performance.now();
63
68
  const deployMethod = await account.getDeployMethod();
64
- const { estimatedGas, stats } = await deployMethod.simulate({
69
+ const sim = await deployMethod.simulate({
65
70
  ...deployAccountOpts,
66
71
  fee: { ...deployAccountOpts.fee, estimateGas: true },
67
72
  });
73
+ // estimateGas: true guarantees these fields are present
74
+ const estimatedGas = sim.estimatedGas!;
75
+ const stats = sim.stats!;
68
76
 
69
77
  if (feeOpts.estimateOnly) {
70
78
  if (json) {
@@ -80,7 +88,14 @@ export async function deployAccount(
80
88
  };
81
89
  }
82
90
  } else {
83
- tx = deployMethod.send({
91
+ if (verbose) {
92
+ printProfileResult(stats, log);
93
+ }
94
+
95
+ if (!json) {
96
+ log(`\nWaiting for account contract deployment...`);
97
+ }
98
+ const sendOpts = {
84
99
  ...deployAccountOpts,
85
100
  fee: deployAccountOpts.fee
86
101
  ? {
@@ -88,31 +103,35 @@ export async function deployAccount(
88
103
  gasSettings: estimatedGas,
89
104
  }
90
105
  : undefined,
91
- });
92
- if (verbose) {
93
- printProfileResult(stats, log);
94
- }
106
+ };
107
+
108
+ ({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
109
+ const localTimeMs = performance.now() - localStart;
95
110
 
96
- const txHash = await tx.getTxHash();
97
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
98
- out.txHash = txHash;
99
111
  if (wait) {
100
- if (!json) {
101
- log(`\nWaiting for account contract deployment...`);
102
- }
103
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
112
+ const nodeStart = performance.now();
113
+ txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
114
+ const nodeTimeMs = performance.now() - nodeStart;
115
+
104
116
  out.txReceipt = {
105
117
  status: txReceipt.status,
106
118
  transactionFee: txReceipt.transactionFee,
107
119
  };
120
+
121
+ if (!json) {
122
+ log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
123
+ log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
124
+ }
108
125
  }
126
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
127
+ out.txHash = txHash;
109
128
  }
110
129
 
111
130
  if (json) {
112
131
  log(prettyPrintJSON(out));
113
132
  } else {
114
- if (tx) {
115
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
133
+ if (txHash) {
134
+ log(`Deploy tx hash: ${txHash.toString()}`);
116
135
  }
117
136
  if (txReceipt) {
118
137
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -0,0 +1,37 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
4
+ import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
+ import type { LogFn } from '@aztec/foundation/log';
6
+
7
+ const FEE_JUICE_DECIMALS = 18;
8
+ const FEE_JUICE_UNIT = 10n ** BigInt(FEE_JUICE_DECIMALS);
9
+
10
+ /** Formats a raw FeeJuice balance (18 decimals) for human-readable display. */
11
+ function formatFeeJuice(raw: bigint, exact: boolean): string {
12
+ const whole = raw / FEE_JUICE_UNIT;
13
+ const fractional = raw % FEE_JUICE_UNIT;
14
+ const fracStr = fractional.toString().padStart(FEE_JUICE_DECIMALS, '0');
15
+ if (exact) {
16
+ return `${whole}.${fracStr} FJ`;
17
+ }
18
+ if (fractional === 0n) {
19
+ return `${whole} FJ`;
20
+ }
21
+ return `${whole}.${fracStr.replace(/0+$/, '')} FJ`;
22
+ }
23
+
24
+ export async function getFeeJuiceBalanceCmd(
25
+ node: AztecNode,
26
+ address: AztecAddress,
27
+ json: boolean,
28
+ exact: boolean,
29
+ log: LogFn,
30
+ ) {
31
+ const balance = await getFeeJuiceBalance(address, node);
32
+ if (json) {
33
+ log(prettyPrintJSON({ address: address.toString(), balance: balance.toString() }));
34
+ } else {
35
+ log(`Fee Juice balance for ${address.toString()}: ${formatFeeJuice(balance, exact)}`);
36
+ }
37
+ }