@aztec/cli-wallet 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6

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 (51) 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 +44 -14
  7. package/dest/cmds/create_account.d.ts +1 -1
  8. package/dest/cmds/create_account.d.ts.map +1 -1
  9. package/dest/cmds/create_account.js +31 -17
  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 +1 -1
  13. package/dest/cmds/deploy.d.ts.map +1 -1
  14. package/dest/cmds/deploy.js +50 -24
  15. package/dest/cmds/deploy_account.d.ts +1 -1
  16. package/dest/cmds/deploy_account.d.ts.map +1 -1
  17. package/dest/cmds/deploy_account.js +31 -17
  18. package/dest/cmds/index.js +1 -1
  19. package/dest/cmds/send.d.ts +2 -2
  20. package/dest/cmds/send.d.ts.map +1 -1
  21. package/dest/cmds/send.js +32 -17
  22. package/dest/cmds/simulate.d.ts +1 -1
  23. package/dest/cmds/simulate.d.ts.map +1 -1
  24. package/dest/cmds/simulate.js +3 -3
  25. package/dest/storage/wallet_db.d.ts +1 -1
  26. package/dest/storage/wallet_db.d.ts.map +1 -1
  27. package/dest/storage/wallet_db.js +46 -31
  28. package/dest/utils/options/fees.d.ts +1 -1
  29. package/dest/utils/options/fees.d.ts.map +1 -1
  30. package/dest/utils/options/fees.js +2 -0
  31. package/dest/utils/options/options.d.ts +2 -2
  32. package/dest/utils/options/options.d.ts.map +1 -1
  33. package/dest/utils/profiling.d.ts +1 -1
  34. package/dest/utils/profiling.d.ts.map +1 -1
  35. package/dest/utils/profiling.js +9 -1
  36. package/dest/utils/wallet.d.ts +9 -3
  37. package/dest/utils/wallet.d.ts.map +1 -1
  38. package/dest/utils/wallet.js +61 -35
  39. package/package.json +15 -15
  40. package/src/cmds/authorize_action.ts +1 -1
  41. package/src/cmds/check_tx.ts +48 -18
  42. package/src/cmds/create_account.ts +29 -18
  43. package/src/cmds/deploy.ts +45 -23
  44. package/src/cmds/deploy_account.ts +29 -18
  45. package/src/cmds/index.ts +1 -1
  46. package/src/cmds/send.ts +26 -11
  47. package/src/cmds/simulate.ts +4 -7
  48. package/src/storage/wallet_db.ts +49 -36
  49. package/src/utils/options/fees.ts +6 -0
  50. package/src/utils/profiling.ts +15 -1
  51. package/src/utils/wallet.ts +73 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli-wallet",
3
- "version": "0.0.1-commit.6d3c34e",
3
+ "version": "0.0.1-commit.7035c9bd6",
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.6d3c34e",
71
- "@aztec/aztec.js": "0.0.1-commit.6d3c34e",
72
- "@aztec/bb.js": "0.0.1-commit.6d3c34e",
73
- "@aztec/cli": "0.0.1-commit.6d3c34e",
74
- "@aztec/entrypoints": "0.0.1-commit.6d3c34e",
75
- "@aztec/ethereum": "0.0.1-commit.6d3c34e",
76
- "@aztec/foundation": "0.0.1-commit.6d3c34e",
77
- "@aztec/kv-store": "0.0.1-commit.6d3c34e",
78
- "@aztec/noir-contracts.js": "0.0.1-commit.6d3c34e",
79
- "@aztec/noir-noirc_abi": "0.0.1-commit.6d3c34e",
80
- "@aztec/pxe": "0.0.1-commit.6d3c34e",
81
- "@aztec/stdlib": "0.0.1-commit.6d3c34e",
82
- "@aztec/wallet-sdk": "0.0.1-commit.6d3c34e",
70
+ "@aztec/accounts": "0.0.1-commit.7035c9bd6",
71
+ "@aztec/aztec.js": "0.0.1-commit.7035c9bd6",
72
+ "@aztec/bb.js": "0.0.1-commit.7035c9bd6",
73
+ "@aztec/cli": "0.0.1-commit.7035c9bd6",
74
+ "@aztec/entrypoints": "0.0.1-commit.7035c9bd6",
75
+ "@aztec/ethereum": "0.0.1-commit.7035c9bd6",
76
+ "@aztec/foundation": "0.0.1-commit.7035c9bd6",
77
+ "@aztec/kv-store": "0.0.1-commit.7035c9bd6",
78
+ "@aztec/noir-contracts.js": "0.0.1-commit.7035c9bd6",
79
+ "@aztec/noir-noirc_abi": "0.0.1-commit.7035c9bd6",
80
+ "@aztec/pxe": "0.0.1-commit.7035c9bd6",
81
+ "@aztec/stdlib": "0.0.1-commit.7035c9bd6",
82
+ "@aztec/wallet-sdk": "0.0.1-commit.7035c9bd6",
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
 
@@ -5,7 +5,11 @@ 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
  }
@@ -85,7 +92,7 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
85
92
  for (const nullifier of effects.nullifiers) {
86
93
  const deployed = deployNullifiers[nullifier.toString()];
87
94
  const note = deployed
88
- ? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
95
+ ? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: 'ALL_SCOPES' }))[0]
89
96
  : undefined;
90
97
  const initialized = initNullifiers[nullifier.toString()];
91
98
  const registered = classNullifiers[nullifier.toString()];
@@ -141,22 +148,49 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
141
148
 
142
149
  async function getKnownNullifiers(wallet: CLIWallet, artifactMap: ArtifactMap) {
143
150
  const knownContracts = await wallet.getContracts();
144
- const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
145
- const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
151
+
152
+ const [contractResults, classResults] = await Promise.all([
153
+ Promise.all(knownContracts.map(contract => getContractNullifiers(wallet, contract))),
154
+ Promise.all(Object.values(artifactMap).map(artifact => getClassNullifier(artifact))),
155
+ ]);
156
+
146
157
  const initNullifiers: Record<string, AztecAddress> = {};
147
158
  const deployNullifiers: Record<string, AztecAddress> = {};
148
159
  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;
160
+
161
+ for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults) {
162
+ deployNullifiers[deployNullifier.toString()] = contract;
163
+ if (privateInitNullifier) {
164
+ initNullifiers[privateInitNullifier.toString()] = contract;
165
+ }
166
+ initNullifiers[publicInitNullifier.toString()] = contract;
152
167
  }
153
- for (const artifact of Object.values(artifactMap)) {
154
- classNullifiers[(await siloNullifier(classRegistryAddress, artifact.classId)).toString()] =
155
- `${artifact.name}Class<${artifact.classId}>`;
168
+ for (const { nullifier, label } of classResults) {
169
+ classNullifiers[nullifier.toString()] = label;
156
170
  }
171
+
157
172
  return { initNullifiers, deployNullifiers, classNullifiers };
158
173
  }
159
174
 
175
+ async function getContractNullifiers(wallet: CLIWallet, contract: AztecAddress) {
176
+ const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
177
+ const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
178
+
179
+ const metadata = await wallet.getContractMetadata(contract);
180
+ const privateInitNullifier = metadata.instance
181
+ ? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash)
182
+ : undefined;
183
+ const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
184
+
185
+ return { contract, deployNullifier, privateInitNullifier, publicInitNullifier };
186
+ }
187
+
188
+ async function getClassNullifier(artifact: ContractArtifactWithClassId) {
189
+ const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
190
+ const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
191
+ return { nullifier, label: `${artifact.name}Class<${artifact.classId}>` };
192
+ }
193
+
160
194
  type ArtifactMap = Record<string, ContractArtifactWithClassId>;
161
195
  type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
162
196
 
@@ -164,15 +198,11 @@ async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
164
198
  const knownContractAddresses = await wallet.getContracts();
165
199
  const knownContracts = (
166
200
  await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
167
- ).map(contractMetadata => contractMetadata.contractInstance);
201
+ ).map(contractMetadata => contractMetadata.instance);
168
202
  const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
169
203
  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
- );
204
+ await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
205
+ ).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
176
206
  const map: Record<string, ContractArtifactWithClassId> = {};
177
207
  for (const instance of knownContracts) {
178
208
  if (instance) {
@@ -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))
package/src/cmds/send.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import { AuthWitness } from '@aztec/aztec.js/authorization';
3
- import { Contract, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
3
+ import { Contract, NO_WAIT, type SendInteractionOptions } from '@aztec/aztec.js/contracts';
4
4
  import type { AztecNode } from '@aztec/aztec.js/node';
5
5
  import { prepTx } from '@aztec/cli/utils';
6
6
  import type { LogFn } from '@aztec/foundation/log';
@@ -37,40 +37,55 @@ export async function send(
37
37
  authWitnesses,
38
38
  };
39
39
 
40
- const { estimatedGas, stats } = await call.simulate({
40
+ const sim = await call.simulate({
41
41
  ...sendOptions,
42
42
  fee: { ...sendOptions.fee, estimateGas: true },
43
43
  });
44
+ // estimateGas: true guarantees these fields are present
45
+ const estimatedGas = sim.estimatedGas!;
46
+ const stats = sim.stats!;
44
47
 
45
48
  if (feeOpts.estimateOnly) {
46
49
  return;
47
50
  }
48
51
 
49
- const tx = call.send({ ...sendOptions, fee: { ...sendOptions.fee, gasSettings: estimatedGas } });
50
52
  if (verbose) {
51
53
  printProfileResult(stats!, log);
52
54
  }
53
55
 
54
- const txHash = await tx.getTxHash();
55
- log(`\nTransaction hash: ${txHash.toString()}`);
56
56
  if (wait) {
57
57
  try {
58
- await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
58
+ const { receipt } = await call.send({
59
+ ...sendOptions,
60
+ fee: { ...sendOptions.fee, gasSettings: estimatedGas },
61
+ wait: { timeout: DEFAULT_TX_TIMEOUT_S },
62
+ });
59
63
 
64
+ const txHash = receipt.txHash;
65
+ log(`\nTransaction hash: ${txHash.toString()}`);
60
66
  log('Transaction has been mined');
61
-
62
- const receipt = await tx.getReceipt();
63
67
  log(` Tx fee: ${receipt.transactionFee}`);
64
68
  log(` Status: ${receipt.status}`);
65
69
  log(` Block number: ${receipt.blockNumber}`);
66
70
  log(` Block hash: ${receipt.blockHash?.toString()}`);
71
+
72
+ return {
73
+ txHash,
74
+ };
67
75
  } catch (err: any) {
68
76
  log(`Transaction failed\n ${err.message}`);
77
+ throw err;
69
78
  }
70
79
  } else {
80
+ const { txHash } = await call.send({
81
+ ...sendOptions,
82
+ fee: { ...sendOptions.fee, gasSettings: estimatedGas },
83
+ wait: NO_WAIT,
84
+ });
85
+ log(`\nTransaction hash: ${txHash.toString()}`);
71
86
  log('Transaction pending. Check status with check-tx');
87
+ return {
88
+ txHash,
89
+ };
72
90
  }
73
- return {
74
- txHash,
75
- };
76
91
  }
@@ -38,17 +38,14 @@ export async function simulate(
38
38
  });
39
39
  if (verbose) {
40
40
  await printAuthorizations(
41
- simulationResult.offchainEffects!,
41
+ simulationResult.offchainEffects,
42
42
  async (address: AztecAddress) => {
43
43
  const metadata = await wallet.getContractMetadata(address);
44
- if (!metadata.contractInstance) {
44
+ if (!metadata.instance) {
45
45
  return undefined;
46
46
  }
47
- const classMetadata = await wallet.getContractClassMetadata(
48
- metadata.contractInstance.currentContractClassId,
49
- true,
50
- );
51
- return classMetadata.artifact;
47
+ const artifact = await wallet.getContractArtifact(metadata.instance.currentContractClassId);
48
+ return artifact;
52
49
  },
53
50
  log,
54
51
  );