@aztec/cli-wallet 0.0.0-test.1 → 0.0.1-commit.017a351

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 (115) hide show
  1. package/README.md +30 -0
  2. package/dest/bin/index.d.ts +2 -1
  3. package/dest/bin/index.js +58 -26
  4. package/dest/cmds/authorize_action.d.ts +4 -3
  5. package/dest/cmds/authorize_action.d.ts.map +1 -1
  6. package/dest/cmds/authorize_action.js +11 -5
  7. package/dest/cmds/bridge_fee_juice.d.ts +4 -4
  8. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
  9. package/dest/cmds/bridge_fee_juice.js +10 -8
  10. package/dest/cmds/check_tx.d.ts +5 -3
  11. package/dest/cmds/check_tx.d.ts.map +1 -1
  12. package/dest/cmds/check_tx.js +174 -6
  13. package/dest/cmds/create_account.d.ts +10 -7
  14. package/dest/cmds/create_account.d.ts.map +1 -1
  15. package/dest/cmds/create_account.js +74 -38
  16. package/dest/cmds/create_authwit.d.ts +4 -3
  17. package/dest/cmds/create_authwit.d.ts.map +1 -1
  18. package/dest/cmds/create_authwit.js +6 -6
  19. package/dest/cmds/deploy.d.ts +8 -4
  20. package/dest/cmds/deploy.d.ts.map +1 -1
  21. package/dest/cmds/deploy.js +108 -59
  22. package/dest/cmds/deploy_account.d.ts +7 -8
  23. package/dest/cmds/deploy_account.d.ts.map +1 -1
  24. package/dest/cmds/deploy_account.js +70 -36
  25. package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
  26. package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
  27. package/dest/cmds/get_fee_juice_balance.js +27 -0
  28. package/dest/cmds/import_test_accounts.d.ts +3 -3
  29. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  30. package/dest/cmds/import_test_accounts.js +6 -9
  31. package/dest/cmds/index.d.ts +3 -3
  32. package/dest/cmds/index.d.ts.map +1 -1
  33. package/dest/cmds/index.js +99 -115
  34. package/dest/cmds/profile.d.ts +8 -0
  35. package/dest/cmds/profile.d.ts.map +1 -0
  36. package/dest/cmds/profile.js +28 -0
  37. package/dest/cmds/register_contract.d.ts +7 -3
  38. package/dest/cmds/register_contract.d.ts.map +1 -1
  39. package/dest/cmds/register_contract.js +20 -7
  40. package/dest/cmds/register_sender.d.ts +4 -3
  41. package/dest/cmds/register_sender.d.ts.map +1 -1
  42. package/dest/cmds/send.d.ts +9 -9
  43. package/dest/cmds/send.d.ts.map +1 -1
  44. package/dest/cmds/send.js +54 -27
  45. package/dest/cmds/simulate.d.ts +7 -3
  46. package/dest/cmds/simulate.d.ts.map +1 -1
  47. package/dest/cmds/simulate.js +26 -20
  48. package/dest/storage/wallet_db.d.ts +12 -19
  49. package/dest/storage/wallet_db.d.ts.map +1 -1
  50. package/dest/storage/wallet_db.js +63 -55
  51. package/dest/utils/authorizations.d.ts +6 -0
  52. package/dest/utils/authorizations.d.ts.map +1 -0
  53. package/dest/utils/authorizations.js +28 -0
  54. package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
  55. package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
  56. package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
  57. package/dest/utils/constants.d.ts +4 -0
  58. package/dest/utils/constants.d.ts.map +1 -0
  59. package/dest/utils/constants.js +7 -0
  60. package/dest/utils/ecdsa.d.ts +1 -3
  61. package/dest/utils/ecdsa.d.ts.map +1 -1
  62. package/dest/utils/options/fees.d.ts +23 -28
  63. package/dest/utils/options/fees.d.ts.map +1 -1
  64. package/dest/utils/options/fees.js +112 -148
  65. package/dest/utils/options/index.d.ts +1 -1
  66. package/dest/utils/options/options.d.ts +9 -5
  67. package/dest/utils/options/options.d.ts.map +1 -1
  68. package/dest/utils/options/options.js +26 -14
  69. package/dest/utils/profiling.d.ts +5 -0
  70. package/dest/utils/profiling.d.ts.map +1 -0
  71. package/dest/utils/profiling.js +68 -0
  72. package/dest/utils/wallet.d.ts +44 -0
  73. package/dest/utils/wallet.d.ts.map +1 -0
  74. package/dest/utils/wallet.js +263 -0
  75. package/package.json +31 -23
  76. package/src/bin/index.ts +63 -33
  77. package/src/cmds/authorize_action.ts +16 -5
  78. package/src/cmds/bridge_fee_juice.ts +16 -12
  79. package/src/cmds/check_tx.ts +212 -5
  80. package/src/cmds/create_account.ts +89 -45
  81. package/src/cmds/create_authwit.ts +9 -5
  82. package/src/cmds/deploy.ts +115 -71
  83. package/src/cmds/deploy_account.ts +84 -36
  84. package/src/cmds/get_fee_juice_balance.ts +37 -0
  85. package/src/cmds/import_test_accounts.ts +7 -11
  86. package/src/cmds/index.ts +312 -222
  87. package/src/cmds/profile.ts +48 -0
  88. package/src/cmds/register_contract.ts +28 -5
  89. package/src/cmds/register_sender.ts +3 -2
  90. package/src/cmds/send.ts +59 -25
  91. package/src/cmds/simulate.ts +37 -24
  92. package/src/storage/wallet_db.ts +67 -68
  93. package/src/utils/authorizations.ts +51 -0
  94. package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
  95. package/src/utils/constants.ts +4 -0
  96. package/src/utils/options/fees.ts +169 -210
  97. package/src/utils/options/options.ts +41 -19
  98. package/src/utils/profiling.ts +172 -0
  99. package/src/utils/wallet.ts +330 -0
  100. package/dest/cmds/add_authwit.d.ts +0 -4
  101. package/dest/cmds/add_authwit.d.ts.map +0 -1
  102. package/dest/cmds/add_authwit.js +0 -4
  103. package/dest/cmds/cancel_tx.d.ts +0 -11
  104. package/dest/cmds/cancel_tx.d.ts.map +0 -1
  105. package/dest/cmds/cancel_tx.js +0 -38
  106. package/dest/utils/accounts.d.ts +0 -11
  107. package/dest/utils/accounts.d.ts.map +0 -1
  108. package/dest/utils/accounts.js +0 -87
  109. package/dest/utils/pxe_wrapper.d.ts +0 -10
  110. package/dest/utils/pxe_wrapper.d.ts.map +0 -1
  111. package/dest/utils/pxe_wrapper.js +0 -21
  112. package/src/cmds/add_authwit.ts +0 -13
  113. package/src/cmds/cancel_tx.ts +0 -62
  114. package/src/utils/accounts.ts +0 -102
  115. package/src/utils/pxe_wrapper.ts +0 -26
@@ -1,43 +1,52 @@
1
- import { type AccountWalletWithSecretKey, ContractDeployer, type DeployMethod, Fr, type PXE } from '@aztec/aztec.js';
2
- import { GITHUB_TAG_PREFIX, encodeArgs, getContractArtifact } from '@aztec/cli/utils';
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
3
+ import type { DeployOptions } from '@aztec/aztec.js/contracts';
4
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
5
+ import { ContractDeployer } from '@aztec/aztec.js/deployment';
6
+ import { Fr } from '@aztec/aztec.js/fields';
7
+ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
8
+ import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec/cli/utils';
3
9
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
- import { getInitializer } from '@aztec/stdlib/abi';
10
+ import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
5
11
  import { PublicKeys } from '@aztec/stdlib/keys';
12
+ import type { TxStatus } from '@aztec/stdlib/tx';
6
13
 
7
- import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
14
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
15
+ import { CLIFeeArgs } from '../utils/options/fees.js';
16
+ import { printProfileResult } from '../utils/profiling.js';
17
+ import type { CLIWallet } from '../utils/wallet.js';
8
18
 
9
19
  export async function deploy(
10
- client: PXE,
11
- wallet: AccountWalletWithSecretKey,
20
+ wallet: CLIWallet,
21
+ node: AztecNode,
22
+ deployer: AztecAddress,
12
23
  artifactPath: string,
13
24
  json: boolean,
14
25
  publicKeys: PublicKeys | undefined,
15
26
  rawArgs: any[],
16
27
  salt: Fr | undefined,
17
28
  initializer: string | undefined,
18
- skipPublicDeployment: boolean,
19
- skipClassRegistration: boolean,
29
+ skipInstancePublication: boolean,
30
+ skipClassPublication: boolean,
20
31
  skipInitialization: boolean | undefined,
21
- universalDeploy: boolean | undefined,
22
32
  wait: boolean,
23
- feeOpts: IFeeOpts,
33
+ feeOpts: CLIFeeArgs,
34
+ waitForStatus: TxStatus,
35
+ verbose: boolean,
36
+ timeout: number = DEFAULT_TX_TIMEOUT_S,
24
37
  debugLogger: Logger,
25
38
  log: LogFn,
26
- logJson: (output: any) => void,
39
+ universal?: boolean,
27
40
  ) {
41
+ const out: Record<string, any> = {};
28
42
  salt ??= Fr.random();
29
43
  const contractArtifact = await getContractArtifact(artifactPath, log);
30
- const constructorArtifact = getInitializer(contractArtifact, initializer);
44
+ const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
45
+ const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
31
46
 
32
- const nodeInfo = await client.getNodeInfo();
33
- const expectedAztecNrVersion = `${GITHUB_TAG_PREFIX}-v${nodeInfo.nodeVersion}`;
34
- if (contractArtifact.aztecNrVersion && contractArtifact.aztecNrVersion !== expectedAztecNrVersion) {
35
- log(
36
- `\nWarning: Contract was compiled with a different version of Aztec.nr: ${contractArtifact.aztecNrVersion}. Consider updating Aztec.nr to ${expectedAztecNrVersion}\n`,
37
- );
38
- }
47
+ // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
39
48
 
40
- const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);
49
+ const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
41
50
 
42
51
  let args = [];
43
52
  if (rawArgs.length > 0) {
@@ -49,65 +58,100 @@ export async function deploy(
49
58
  debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
50
59
  }
51
60
 
52
- const deploy = deployer.deploy(...args);
53
- const deployOpts: Parameters<DeployMethod['send']>[0] = {
54
- ...(await feeOpts.toSendOpts(wallet)),
55
- contractAddressSalt: salt,
56
- universalDeploy,
57
- skipClassRegistration,
61
+ const deployInteraction = contractDeployer.deploy(args, {
62
+ salt,
63
+ publicKeys: publicKeys ?? PublicKeys.default(),
64
+ ...(universal ? { universalDeploy: true as const } : {}),
65
+ });
66
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, deployer);
67
+ const deployOpts: DeployOptions = {
68
+ fee: { gasSettings, paymentMethod },
69
+ from: deployer ?? NO_FROM,
70
+ skipClassPublication,
58
71
  skipInitialization,
59
- skipPublicDeployment,
72
+ skipInstancePublication,
60
73
  };
61
74
 
62
- if (feeOpts.estimateOnly) {
63
- const gas = await deploy.estimateGas(deployOpts);
64
- printGasEstimates(feeOpts, gas, log);
65
- return;
66
- }
67
-
68
- const tx = deploy.send(deployOpts);
75
+ const localStart = performance.now();
76
+ const sim = await deployInteraction.simulate({
77
+ ...deployOpts,
78
+ fee: { ...deployOpts.fee, estimateGas: true },
79
+ });
80
+ // estimateGas: true guarantees these fields are present
81
+ const estimatedGas = sim.estimatedGas!;
82
+ const stats = sim.stats!;
69
83
 
70
- const txHash = await tx.getTxHash();
71
- debugLogger.debug(`Deploy tx sent with hash ${txHash}`);
72
- if (wait) {
73
- const deployed = await tx.wait();
74
- const { address, partialAddress, instance } = deployed.contract;
84
+ if (feeOpts.estimateOnly) {
75
85
  if (json) {
76
- logJson({
77
- address: address.toString(),
78
- partialAddress: (await partialAddress).toString(),
79
- initializationHash: instance.initializationHash.toString(),
80
- salt: salt.toString(),
81
- transactionFee: deployed.transactionFee?.toString(),
82
- });
83
- } else {
84
- log(`Contract deployed at ${address.toString()}`);
85
- log(`Contract partial address ${(await partialAddress).toString()}`);
86
- log(`Contract init hash ${instance.initializationHash.toString()}`);
87
- log(`Deployment tx hash: ${txHash.toString()}`);
88
- log(`Deployment salt: ${salt.toString()}`);
89
- log(`Deployment fee: ${deployed.transactionFee}`);
86
+ out.fee = {
87
+ gasLimits: {
88
+ da: estimatedGas.gasLimits.daGas,
89
+ l2: estimatedGas.gasLimits.l2Gas,
90
+ },
91
+ teardownGasLimits: {
92
+ da: estimatedGas.teardownGasLimits.daGas,
93
+ l2: estimatedGas.teardownGasLimits,
94
+ },
95
+ };
90
96
  }
91
97
  } else {
92
- const { address, partialAddress } = deploy;
93
- const instance = await deploy.getInstance();
94
- if (json) {
95
- logJson({
96
- address: address?.toString() ?? 'N/A',
97
- partialAddress: (await partialAddress)?.toString() ?? 'N/A',
98
- txHash: txHash.toString(),
99
- initializationHash: instance.initializationHash.toString(),
100
- salt: salt.toString(),
101
- deployer: instance.deployer.toString(),
102
- });
98
+ if (verbose) {
99
+ printProfileResult(stats, log);
100
+ }
101
+
102
+ const instance = await deployInteraction.getInstance();
103
+ const address = instance.address;
104
+ const partialAddress = await deployInteraction.getPartialAddress();
105
+
106
+ const { txHash } = await deployInteraction.send({ ...deployOpts, wait: NO_WAIT });
107
+ const localTimeMs = performance.now() - localStart;
108
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
109
+ out.hash = txHash;
110
+
111
+ if (wait) {
112
+ const nodeStart = performance.now();
113
+ const receipt = await waitForTx(node, txHash, { timeout, waitForStatus });
114
+ const nodeTimeMs = performance.now() - nodeStart;
115
+
116
+ if (!json) {
117
+ log(`Contract deployed at ${address.toString()}`);
118
+ log(`Contract partial address ${partialAddress.toString()}`);
119
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
120
+ log(`Deployment tx hash: ${txHash.toString()}`);
121
+ log(`Deployment salt: ${salt.toString()}`);
122
+ log(`Deployer: ${instance.deployer.toString()}`);
123
+ log(`Transaction fee: ${receipt.transactionFee?.toString()}`);
124
+ log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
125
+ log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
126
+ } else {
127
+ out.contract = {
128
+ address: address.toString(),
129
+ partialAddress: partialAddress.toString(),
130
+ initializationHash: instance.initializationHash.toString(),
131
+ salt: salt.toString(),
132
+ transactionFee: receipt.transactionFee?.toString(),
133
+ };
134
+ }
103
135
  } else {
104
- log(`Contract deployed at ${address?.toString()}`);
105
- log(`Contract partial address ${(await partialAddress)?.toString()}`);
106
- log(`Contract init hash ${instance.initializationHash.toString()}`);
107
- log(`Deployment tx hash: ${txHash.toString()}`);
108
- log(`Deployment salt: ${salt.toString()}`);
109
- log(`Deployer: ${instance.deployer.toString()}`);
136
+ if (!json) {
137
+ log(`Contract deployed at ${address.toString()}`);
138
+ log(`Contract partial address ${partialAddress.toString()}`);
139
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
140
+ log(`Deployment tx hash: ${txHash.toString()}`);
141
+ log(`Deployment salt: ${salt.toString()}`);
142
+ log(`Deployer: ${instance.deployer.toString()}`);
143
+ } else {
144
+ out.contract = {
145
+ address: address.toString(),
146
+ partialAddress: partialAddress.toString(),
147
+ initializationHash: instance.initializationHash.toString(),
148
+ salt: salt.toString(),
149
+ };
150
+ }
110
151
  }
111
152
  }
112
- return deploy.address;
153
+ if (json) {
154
+ log(prettyPrintJSON(out));
155
+ }
156
+ return await deployInteraction.getAddress();
113
157
  }
@@ -1,22 +1,38 @@
1
- import type { AccountManager, DeployAccountOptions } from '@aztec/aztec.js';
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
3
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
4
+ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
5
+ import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
2
6
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
3
7
  import type { LogFn, Logger } from '@aztec/foundation/log';
8
+ import type { TxHash, TxReceipt, TxStatus } from '@aztec/stdlib/tx';
4
9
 
5
- import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
10
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
11
+ import type { CLIFeeArgs } from '../utils/options/fees.js';
12
+ import { printProfileResult } from '../utils/profiling.js';
13
+ import type { CLIWallet } from '../utils/wallet.js';
6
14
 
7
15
  export async function deployAccount(
8
- account: AccountManager,
16
+ wallet: CLIWallet,
17
+ aztecNode: AztecNode,
18
+ address: AztecAddress,
9
19
  wait: boolean,
10
- feeOpts: IFeeOpts,
20
+ deployer: AztecAddress | undefined,
21
+ registerClass: boolean,
22
+ publicDeploy: boolean,
23
+ skipInitialization: boolean,
24
+ feeOpts: CLIFeeArgs,
25
+ waitForStatus: TxStatus,
11
26
  json: boolean,
27
+ verbose: boolean,
12
28
  debugLogger: Logger,
13
29
  log: LogFn,
14
30
  ) {
15
31
  const out: Record<string, any> = {};
16
- const { address, partialAddress, publicKeys } = await account.getCompleteAddress();
17
- const { initializationHash, deployer, salt } = account.getInstance();
18
- const wallet = await account.getWallet();
19
- const secretKey = wallet.getSecretKey();
32
+
33
+ const account = await wallet.createOrRetrieveAccount(address);
34
+ const { partialAddress, publicKeys } = await account.getCompleteAddress();
35
+ const { initializationHash, salt } = account.getInstance();
20
36
 
21
37
  if (json) {
22
38
  out.address = address;
@@ -28,65 +44,97 @@ export async function deployAccount(
28
44
  log(`\nNew account:\n`);
29
45
  log(`Address: ${address.toString()}`);
30
46
  log(`Public key: ${publicKeys.toString()}`);
31
- if (secretKey) {
32
- log(`Secret key: ${secretKey.toString()}`);
33
- }
34
47
  log(`Partial address: ${partialAddress.toString()}`);
35
48
  log(`Salt: ${salt.toString()}`);
36
49
  log(`Init hash: ${initializationHash.toString()}`);
37
- log(`Deployer: ${deployer.toString()}`);
38
50
  }
39
51
 
40
- let tx;
41
- let txReceipt;
52
+ let txHash: TxHash | undefined;
53
+ let txReceipt: TxReceipt | undefined;
54
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
55
+
56
+ const delegatedDeployment = deployer && !account.address.equals(deployer);
57
+ const from = delegatedDeployment ? deployer : NO_FROM;
42
58
 
43
- const deployOpts: DeployAccountOptions = {
44
- ...(await feeOpts.toDeployAccountOpts(wallet)),
45
- skipInitialization: false,
59
+ const deployAccountOpts: DeployAccountOptions = {
60
+ skipClassPublication: !registerClass,
61
+ skipInstancePublication: !publicDeploy,
62
+ skipInitialization,
63
+ from,
64
+ fee: { paymentMethod, gasSettings },
46
65
  };
66
+
67
+ const localStart = performance.now();
68
+ const deployMethod = await account.getDeployMethod();
69
+ const sim = await deployMethod.simulate({
70
+ ...deployAccountOpts,
71
+ fee: { ...deployAccountOpts.fee, estimateGas: true },
72
+ });
73
+ // estimateGas: true guarantees these fields are present
74
+ const estimatedGas = sim.estimatedGas!;
75
+ const stats = sim.stats!;
76
+
47
77
  if (feeOpts.estimateOnly) {
48
- const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
49
78
  if (json) {
50
79
  out.fee = {
51
80
  gasLimits: {
52
- da: gas.gasLimits.daGas,
53
- l2: gas.gasLimits.l2Gas,
81
+ da: estimatedGas.gasLimits.daGas,
82
+ l2: estimatedGas.gasLimits.l2Gas,
54
83
  },
55
84
  teardownGasLimits: {
56
- da: gas.teardownGasLimits.daGas,
57
- l2: gas.teardownGasLimits,
85
+ da: estimatedGas.teardownGasLimits.daGas,
86
+ l2: estimatedGas.teardownGasLimits,
58
87
  },
59
88
  };
60
- } else {
61
- printGasEstimates(feeOpts, gas, log);
62
89
  }
63
90
  } else {
64
- tx = account.deploy(deployOpts);
65
- const txHash = await tx.getTxHash();
66
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
67
- out.txHash = txHash;
91
+ if (verbose) {
92
+ printProfileResult(stats, log);
93
+ }
94
+
95
+ if (!json) {
96
+ log(`\nWaiting for account contract deployment...`);
97
+ }
98
+ const sendOpts = {
99
+ ...deployAccountOpts,
100
+ fee: deployAccountOpts.fee
101
+ ? {
102
+ ...deployAccountOpts.fee,
103
+ gasSettings: estimatedGas,
104
+ }
105
+ : undefined,
106
+ };
107
+
108
+ ({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
109
+ const localTimeMs = performance.now() - localStart;
110
+
68
111
  if (wait) {
69
- if (!json) {
70
- log(`\nWaiting for account contract deployment...`);
71
- }
72
- txReceipt = await tx.wait();
112
+ const nodeStart = performance.now();
113
+ txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
114
+ const nodeTimeMs = performance.now() - nodeStart;
115
+
73
116
  out.txReceipt = {
74
117
  status: txReceipt.status,
75
118
  transactionFee: txReceipt.transactionFee,
76
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
+ }
77
125
  }
126
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
127
+ out.txHash = txHash;
78
128
  }
79
129
 
80
130
  if (json) {
81
131
  log(prettyPrintJSON(out));
82
132
  } else {
83
- if (tx) {
84
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
133
+ if (txHash) {
134
+ log(`Deploy tx hash: ${txHash.toString()}`);
85
135
  }
86
136
  if (txReceipt) {
87
137
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
88
138
  }
89
139
  }
90
-
91
- return { address, secretKey, salt };
92
140
  }
@@ -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
+ }
@@ -1,25 +1,21 @@
1
- import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
- import { getInitialTestAccounts } from '@aztec/accounts/testing';
3
- import { Fr, type PXE } from '@aztec/aztec.js';
1
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import { Fr } from '@aztec/aztec.js/fields';
4
3
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
5
4
  import type { LogFn } from '@aztec/foundation/log';
6
5
 
7
6
  import type { WalletDB } from '../storage/wallet_db.js';
7
+ import type { CLIWallet } from '../utils/wallet.js';
8
8
 
9
- export async function importTestAccounts(client: PXE, db: WalletDB, json: boolean, log: LogFn) {
10
- const testAccounts = await getInitialTestAccounts();
11
- const accounts = await Promise.all(
12
- testAccounts.map(({ secret, signingKey, salt }) => getSchnorrAccount(client, secret, signingKey, salt)),
13
- );
9
+ export async function importTestAccounts(wallet: CLIWallet, db: WalletDB, json: boolean, log: LogFn) {
10
+ const testAccounts = await getInitialTestAccountsData();
14
11
 
15
12
  const out: Record<string, any> = {};
16
13
  await Promise.all(
17
- accounts.map(async (account, i) => {
14
+ testAccounts.map(async (account, i) => {
18
15
  const alias = `test${i}`;
19
16
  const secret = testAccounts[i].secret;
20
17
  const salt = new Fr(account.salt);
21
- const address = account.getAddress();
22
- await account.register();
18
+ const address = account.address;
23
19
  await db.storeAccount(address, { type: 'schnorr', secretKey: secret, salt, alias, publicKey: undefined }, log);
24
20
 
25
21
  if (json) {