@aztec/cli-wallet 0.0.1-commit.3469e52 → 0.0.1-commit.350e0a4d

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 (59) hide show
  1. package/dest/bin/index.js +1 -1
  2. package/dest/cmds/authorize_action.d.ts +2 -2
  3. package/dest/cmds/authorize_action.d.ts.map +1 -1
  4. package/dest/cmds/authorize_action.js +4 -2
  5. package/dest/cmds/check_tx.d.ts +1 -1
  6. package/dest/cmds/check_tx.d.ts.map +1 -1
  7. package/dest/cmds/check_tx.js +54 -22
  8. package/dest/cmds/create_account.d.ts +4 -3
  9. package/dest/cmds/create_account.d.ts.map +1 -1
  10. package/dest/cmds/create_account.js +46 -30
  11. package/dest/cmds/deploy.d.ts +5 -4
  12. package/dest/cmds/deploy.d.ts.map +1 -1
  13. package/dest/cmds/deploy.js +65 -36
  14. package/dest/cmds/deploy_account.d.ts +4 -3
  15. package/dest/cmds/deploy_account.d.ts.map +1 -1
  16. package/dest/cmds/deploy_account.js +38 -24
  17. package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
  18. package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
  19. package/dest/cmds/get_fee_juice_balance.js +27 -0
  20. package/dest/cmds/import_test_accounts.d.ts +1 -1
  21. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  22. package/dest/cmds/import_test_accounts.js +1 -1
  23. package/dest/cmds/index.d.ts +1 -1
  24. package/dest/cmds/index.d.ts.map +1 -1
  25. package/dest/cmds/index.js +31 -15
  26. package/dest/cmds/send.d.ts +4 -3
  27. package/dest/cmds/send.d.ts.map +1 -1
  28. package/dest/cmds/send.js +33 -20
  29. package/dest/cmds/simulate.d.ts +1 -1
  30. package/dest/cmds/simulate.d.ts.map +1 -1
  31. package/dest/cmds/simulate.js +2 -1
  32. package/dest/storage/wallet_db.d.ts +7 -2
  33. package/dest/storage/wallet_db.d.ts.map +1 -1
  34. package/dest/storage/wallet_db.js +60 -31
  35. package/dest/utils/constants.d.ts +2 -2
  36. package/dest/utils/constants.d.ts.map +1 -1
  37. package/dest/utils/constants.js +1 -0
  38. package/dest/utils/options/fees.d.ts +3 -2
  39. package/dest/utils/options/fees.d.ts.map +1 -1
  40. package/dest/utils/options/fees.js +36 -10
  41. package/dest/utils/wallet.d.ts +24 -6
  42. package/dest/utils/wallet.d.ts.map +1 -1
  43. package/dest/utils/wallet.js +135 -60
  44. package/package.json +16 -15
  45. package/src/bin/index.ts +1 -1
  46. package/src/cmds/authorize_action.ts +1 -1
  47. package/src/cmds/check_tx.ts +61 -25
  48. package/src/cmds/create_account.ts +48 -26
  49. package/src/cmds/deploy.ts +64 -37
  50. package/src/cmds/deploy_account.ts +39 -20
  51. package/src/cmds/get_fee_juice_balance.ts +37 -0
  52. package/src/cmds/import_test_accounts.ts +5 -1
  53. package/src/cmds/index.ts +60 -6
  54. package/src/cmds/send.ts +33 -13
  55. package/src/cmds/simulate.ts +3 -2
  56. package/src/storage/wallet_db.ts +63 -36
  57. package/src/utils/constants.ts +7 -1
  58. package/src/utils/options/fees.ts +42 -10
  59. package/src/utils/wallet.ts +148 -76
@@ -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,19 @@ 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;
69
- if (!registerOnly) {
72
+ let txHash: TxHash | undefined;
73
+ let txReceipt: TxReceipt | undefined;
74
+ // Initializerless accounts have no deployment tx — creating one only registers it locally — so there is
75
+ // nothing to deploy on-chain.
76
+ if (!registerOnly && accountType !== 'schnorr_initializerless') {
70
77
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
71
78
 
72
79
  const delegatedDeployment = deployer && !account.address.equals(deployer);
73
- const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
80
+ const from = delegatedDeployment ? deployer : NO_FROM;
74
81
 
75
82
  const deployAccountOpts: DeployAccountOptions = {
76
83
  skipClassPublication: !registerClass,
@@ -80,11 +87,15 @@ export async function createAccount(
80
87
  fee: { paymentMethod, gasSettings },
81
88
  };
82
89
 
90
+ const localStart = performance.now();
83
91
  const deployMethod = await account.getDeployMethod();
84
- const { estimatedGas, stats } = await deployMethod.simulate({
92
+ const sim = await deployMethod.simulate({
85
93
  ...deployAccountOpts,
86
- fee: { ...deployAccountOpts.fee, estimateGas: true },
94
+ includeMetadata: true,
87
95
  });
96
+ // includeMetadata: true guarantees these fields are present
97
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
98
+ const stats = sim.stats!;
88
99
 
89
100
  if (feeOpts.estimateOnly) {
90
101
  if (json) {
@@ -100,7 +111,14 @@ export async function createAccount(
100
111
  };
101
112
  }
102
113
  } else {
103
- tx = deployMethod.send({
114
+ if (verbose) {
115
+ printProfileResult(stats, log);
116
+ }
117
+
118
+ if (!json) {
119
+ log(`\nWaiting for account contract deployment...`);
120
+ }
121
+ const sendOpts = {
104
122
  ...deployAccountOpts,
105
123
  fee: deployAccountOpts.fee
106
124
  ? {
@@ -108,37 +126,41 @@ export async function createAccount(
108
126
  gasSettings: estimatedGas,
109
127
  }
110
128
  : undefined,
111
- });
112
- if (verbose) {
113
- printProfileResult(stats, log);
114
- }
129
+ };
130
+
131
+ ({ txHash } = await deployMethod.send({ ...sendOpts, wait: NO_WAIT }));
132
+ const localTimeMs = performance.now() - localStart;
115
133
 
116
- const txHash = await tx.getTxHash();
117
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
118
- out.txHash = txHash;
119
134
  if (wait) {
120
- if (!json) {
121
- log(`\nWaiting for account contract deployment...`);
122
- }
123
- txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
135
+ const nodeStart = performance.now();
136
+ txReceipt = await waitForTx(aztecNode, txHash, { timeout: DEFAULT_TX_TIMEOUT_S, waitForStatus });
137
+ const nodeTimeMs = performance.now() - nodeStart;
138
+
124
139
  out.txReceipt = {
125
140
  status: txReceipt.status,
126
141
  transactionFee: txReceipt.transactionFee,
127
142
  };
143
+
144
+ if (!json) {
145
+ log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
146
+ log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
147
+ }
128
148
  }
149
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
150
+ out.txHash = txHash;
129
151
  }
130
152
  }
131
153
 
132
154
  if (json) {
133
155
  log(prettyPrintJSON(out));
134
156
  } else {
135
- if (tx) {
136
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
157
+ if (txHash) {
158
+ log(`Deploy tx hash: ${txHash.toString()}`);
137
159
  }
138
160
  if (txReceipt) {
139
161
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
140
162
  }
141
163
  }
142
164
 
143
- return { alias, address, secretKey, salt };
165
+ return { alias, address, secretKey, salt: instanceSalt };
144
166
  }
@@ -1,12 +1,15 @@
1
- import { AztecAddress } from '@aztec/aztec.js/addresses';
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
+ import type { 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,10 +31,12 @@ 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,
34
38
  log: LogFn,
39
+ universal?: boolean,
35
40
  ) {
36
41
  const out: Record<string, any> = {};
37
42
  salt ??= Fr.random();
@@ -41,12 +46,7 @@ export async function deploy(
41
46
 
42
47
  // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
43
48
 
44
- const contractDeployer = new ContractDeployer(
45
- contractArtifact,
46
- wallet,
47
- publicKeys ?? PublicKeys.default(),
48
- initializer,
49
- );
49
+ const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
50
50
 
51
51
  let args = [];
52
52
  if (rawArgs.length > 0) {
@@ -58,22 +58,28 @@ export async function deploy(
58
58
  debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
59
59
  }
60
60
 
61
- const deploy = contractDeployer.deploy(...args);
61
+ const deployInteraction = contractDeployer.deploy(args, {
62
+ salt,
63
+ publicKeys: publicKeys ?? PublicKeys.default(),
64
+ ...(universal ? { universalDeploy: true as const } : {}),
65
+ });
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,
66
- contractAddressSalt: salt,
67
- universalDeploy: !deployer,
69
+ from: deployer ?? NO_FROM,
68
70
  skipClassPublication,
69
71
  skipInitialization,
70
72
  skipInstancePublication,
71
73
  };
72
74
 
73
- const { estimatedGas, stats } = await deploy.simulate({
75
+ const localStart = performance.now();
76
+ const sim = await deployInteraction.simulate({
74
77
  ...deployOpts,
75
- fee: { ...deployOpts.fee, estimateGas: true },
78
+ includeMetadata: true,
76
79
  });
80
+ // includeMetadata: true guarantees these fields are present
81
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
82
+ const stats = sim.stats!;
77
83
 
78
84
  if (feeOpts.estimateOnly) {
79
85
  if (json) {
@@ -89,42 +95,63 @@ export async function deploy(
89
95
  };
90
96
  }
91
97
  } else {
92
- const tx = deploy.send(deployOpts);
93
98
  if (verbose) {
94
99
  printProfileResult(stats, log);
95
100
  }
96
101
 
97
- const txHash = await tx.getTxHash();
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;
98
108
  debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
99
109
  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
- }
110
+
117
111
  if (wait) {
118
- const deployed = await tx.wait({ timeout });
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
+ }
135
+ } else {
119
136
  if (!json) {
120
- log(`Transaction fee: ${deployed.transactionFee?.toString()}`);
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()}`);
121
143
  } else {
122
- out.contract.transactionFee = deployed.transactionFee?.toString();
144
+ out.contract = {
145
+ address: address.toString(),
146
+ partialAddress: partialAddress.toString(),
147
+ initializationHash: instance.initializationHash.toString(),
148
+ salt: salt.toString(),
149
+ };
123
150
  }
124
151
  }
125
152
  }
126
153
  if (json) {
127
154
  log(prettyPrintJSON(out));
128
155
  }
129
- return deploy.address;
156
+ return await deployInteraction.getAddress();
130
157
  }
@@ -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
- fee: { ...deployAccountOpts.fee, estimateGas: true },
71
+ includeMetadata: true,
67
72
  });
73
+ // includeMetadata: true guarantees these fields are present
74
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
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
+ }
@@ -16,7 +16,11 @@ export async function importTestAccounts(wallet: CLIWallet, db: WalletDB, json:
16
16
  const secret = testAccounts[i].secret;
17
17
  const salt = new Fr(account.salt);
18
18
  const address = account.address;
19
- await db.storeAccount(address, { type: 'schnorr', secretKey: secret, salt, alias, publicKey: undefined }, log);
19
+ await db.storeAccount(
20
+ address,
21
+ { type: 'schnorr_initializerless', secretKey: secret, salt, alias, publicKey: undefined },
22
+ log,
23
+ );
20
24
 
21
25
  if (json) {
22
26
  out[alias] = {