@aztec-labs/cli-wallet 6.0.0-nightly.20260829

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 (110) hide show
  1. package/README.md +32 -0
  2. package/dest/bin/index.d.ts +3 -0
  3. package/dest/bin/index.d.ts.map +1 -0
  4. package/dest/bin/index.js +96 -0
  5. package/dest/cmds/authorize_action.d.ts +5 -0
  6. package/dest/cmds/authorize_action.d.ts.map +1 -0
  7. package/dest/cmds/authorize_action.js +23 -0
  8. package/dest/cmds/bridge_fee_juice.d.ts +6 -0
  9. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -0
  10. package/dest/cmds/bridge_fee_juice.js +54 -0
  11. package/dest/cmds/check_tx.d.ts +6 -0
  12. package/dest/cmds/check_tx.d.ts.map +1 -0
  13. package/dest/cmds/check_tx.js +181 -0
  14. package/dest/cmds/create_account.d.ts +17 -0
  15. package/dest/cmds/create_account.d.ts.map +1 -0
  16. package/dest/cmds/create_account.js +146 -0
  17. package/dest/cmds/create_authwit.d.ts +5 -0
  18. package/dest/cmds/create_authwit.d.ts.map +1 -0
  19. package/dest/cmds/create_authwit.js +16 -0
  20. package/dest/cmds/deploy.d.ts +10 -0
  21. package/dest/cmds/deploy.d.ts.map +1 -0
  22. package/dest/cmds/deploy.js +129 -0
  23. package/dest/cmds/deploy_account.d.ts +8 -0
  24. package/dest/cmds/deploy_account.d.ts.map +1 -0
  25. package/dest/cmds/deploy_account.js +111 -0
  26. package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
  27. package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
  28. package/dest/cmds/get_fee_juice_balance.js +27 -0
  29. package/dest/cmds/import_test_accounts.d.ts +5 -0
  30. package/dest/cmds/import_test_accounts.d.ts.map +1 -0
  31. package/dest/cmds/import_test_accounts.js +40 -0
  32. package/dest/cmds/index.d.ts +6 -0
  33. package/dest/cmds/index.d.ts.map +1 -0
  34. package/dest/cmds/index.js +208 -0
  35. package/dest/cmds/profile.d.ts +8 -0
  36. package/dest/cmds/profile.d.ts.map +1 -0
  37. package/dest/cmds/profile.js +28 -0
  38. package/dest/cmds/register_contract.d.ts +8 -0
  39. package/dest/cmds/register_contract.d.ts.map +1 -0
  40. package/dest/cmds/register_contract.js +27 -0
  41. package/dest/cmds/register_sender.d.ts +5 -0
  42. package/dest/cmds/register_sender.d.ts.map +1 -0
  43. package/dest/cmds/register_sender.js +4 -0
  44. package/dest/cmds/send.d.ts +11 -0
  45. package/dest/cmds/send.d.ts.map +1 -0
  46. package/dest/cmds/send.js +73 -0
  47. package/dest/cmds/simulate.d.ts +8 -0
  48. package/dest/cmds/simulate.d.ts.map +1 -0
  49. package/dest/cmds/simulate.js +33 -0
  50. package/dest/storage/wallet_db.d.ts +61 -0
  51. package/dest/storage/wallet_db.d.ts.map +1 -0
  52. package/dest/storage/wallet_db.js +231 -0
  53. package/dest/utils/authorizations.d.ts +6 -0
  54. package/dest/utils/authorizations.d.ts.map +1 -0
  55. package/dest/utils/authorizations.js +28 -0
  56. package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
  57. package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
  58. package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
  59. package/dest/utils/constants.d.ts +4 -0
  60. package/dest/utils/constants.d.ts.map +1 -0
  61. package/dest/utils/constants.js +8 -0
  62. package/dest/utils/ecdsa.d.ts +2 -0
  63. package/dest/utils/ecdsa.d.ts.map +1 -0
  64. package/dest/utils/ecdsa.js +13 -0
  65. package/dest/utils/options/fees.d.ts +36 -0
  66. package/dest/utils/options/fees.d.ts.map +1 -0
  67. package/dest/utils/options/fees.js +250 -0
  68. package/dest/utils/options/index.d.ts +3 -0
  69. package/dest/utils/options/index.d.ts.map +1 -0
  70. package/dest/utils/options/index.js +2 -0
  71. package/dest/utils/options/options.d.ts +24 -0
  72. package/dest/utils/options/options.d.ts.map +1 -0
  73. package/dest/utils/options/options.js +134 -0
  74. package/dest/utils/profiling.d.ts +5 -0
  75. package/dest/utils/profiling.d.ts.map +1 -0
  76. package/dest/utils/profiling.js +68 -0
  77. package/dest/utils/wallet.d.ts +64 -0
  78. package/dest/utils/wallet.d.ts.map +1 -0
  79. package/dest/utils/wallet.js +285 -0
  80. package/dest/utils/well_known_contracts.d.ts +8 -0
  81. package/dest/utils/well_known_contracts.d.ts.map +1 -0
  82. package/dest/utils/well_known_contracts.js +38 -0
  83. package/package.json +108 -0
  84. package/src/bin/index.ts +141 -0
  85. package/src/cmds/authorize_action.ts +47 -0
  86. package/src/cmds/bridge_fee_juice.ts +92 -0
  87. package/src/cmds/check_tx.ts +220 -0
  88. package/src/cmds/create_account.ts +176 -0
  89. package/src/cmds/create_authwit.ts +39 -0
  90. package/src/cmds/deploy.ts +157 -0
  91. package/src/cmds/deploy_account.ts +140 -0
  92. package/src/cmds/get_fee_juice_balance.ts +37 -0
  93. package/src/cmds/import_test_accounts.ts +54 -0
  94. package/src/cmds/index.ts +732 -0
  95. package/src/cmds/profile.ts +47 -0
  96. package/src/cmds/register_contract.ts +43 -0
  97. package/src/cmds/register_sender.ts +8 -0
  98. package/src/cmds/send.ts +96 -0
  99. package/src/cmds/simulate.ts +55 -0
  100. package/src/storage/wallet_db.ts +264 -0
  101. package/src/utils/authorizations.ts +50 -0
  102. package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
  103. package/src/utils/constants.ts +10 -0
  104. package/src/utils/ecdsa.ts +15 -0
  105. package/src/utils/options/fees.ts +325 -0
  106. package/src/utils/options/index.ts +2 -0
  107. package/src/utils/options/options.ts +196 -0
  108. package/src/utils/profiling.ts +171 -0
  109. package/src/utils/wallet.ts +377 -0
  110. package/src/utils/well_known_contracts.ts +46 -0
@@ -0,0 +1,157 @@
1
+ import { NO_FROM } from '@aztec-labs/aztec.js/account';
2
+ import type { AztecAddress } from '@aztec-labs/aztec.js/addresses';
3
+ import type { DeployOptions } from '@aztec-labs/aztec.js/contracts';
4
+ import { NO_WAIT } from '@aztec-labs/aztec.js/contracts';
5
+ import { ContractDeployer } from '@aztec-labs/aztec.js/deployment';
6
+ import { Fr } from '@aztec-labs/aztec.js/fields';
7
+ import { type AztecNode, waitForTx } from '@aztec-labs/aztec.js/node';
8
+ import { encodeArgs, getContractArtifact, prettyPrintJSON } from '@aztec-labs/cli/utils';
9
+ import type { LogFn, Logger } from '@aztec-labs/foundation/log';
10
+ import { getAllFunctionAbis, getInitializer } from '@aztec-labs/stdlib/abi';
11
+ import { PublicKeys } from '@aztec-labs/stdlib/keys';
12
+ import type { TxStatus } from '@aztec-labs/stdlib/tx';
13
+
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';
18
+
19
+ export async function deploy(
20
+ wallet: CLIWallet,
21
+ node: AztecNode,
22
+ deployer: AztecAddress,
23
+ artifactPath: string,
24
+ json: boolean,
25
+ publicKeys: PublicKeys | undefined,
26
+ rawArgs: any[],
27
+ salt: Fr | undefined,
28
+ initializer: string | undefined,
29
+ skipInstancePublication: boolean,
30
+ skipClassPublication: boolean,
31
+ skipInitialization: boolean | undefined,
32
+ wait: boolean,
33
+ feeOpts: CLIFeeArgs,
34
+ waitForStatus: TxStatus,
35
+ verbose: boolean,
36
+ timeout: number = DEFAULT_TX_TIMEOUT_S,
37
+ debugLogger: Logger,
38
+ log: LogFn,
39
+ universal?: boolean,
40
+ ) {
41
+ const out: Record<string, any> = {};
42
+ salt ??= Fr.random();
43
+ const contractArtifact = await getContractArtifact(artifactPath, log);
44
+ const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
45
+ const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
46
+
47
+ // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
48
+
49
+ const contractDeployer = new ContractDeployer(contractArtifact, wallet, initializer);
50
+
51
+ let args = [];
52
+ if (rawArgs.length > 0) {
53
+ if (!constructorArtifact) {
54
+ throw new Error(`Cannot process constructor arguments as no constructor was found`);
55
+ }
56
+ debugLogger.debug(`Input arguments: ${rawArgs.map((x: any) => `"${x}"`).join(', ')}`);
57
+ args = encodeArgs(rawArgs, constructorArtifact!.parameters);
58
+ debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
59
+ }
60
+
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,
71
+ skipInitialization,
72
+ skipInstancePublication,
73
+ };
74
+
75
+ const localStart = performance.now();
76
+ const sim = await deployInteraction.simulate({
77
+ ...deployOpts,
78
+ includeMetadata: true,
79
+ });
80
+ // includeMetadata: true guarantees these fields are present
81
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
82
+ const stats = sim.stats!;
83
+
84
+ if (feeOpts.estimateOnly) {
85
+ if (json) {
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
+ };
96
+ }
97
+ } else {
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
+ }
135
+ } else {
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
+ }
151
+ }
152
+ }
153
+ if (json) {
154
+ log(prettyPrintJSON(out));
155
+ }
156
+ return await deployInteraction.getAddress();
157
+ }
@@ -0,0 +1,140 @@
1
+ import { NO_FROM } from '@aztec-labs/aztec.js/account';
2
+ import { AztecAddress } from '@aztec-labs/aztec.js/addresses';
3
+ import { NO_WAIT } from '@aztec-labs/aztec.js/contracts';
4
+ import { type AztecNode, waitForTx } from '@aztec-labs/aztec.js/node';
5
+ import type { DeployAccountOptions } from '@aztec-labs/aztec.js/wallet';
6
+ import { prettyPrintJSON } from '@aztec-labs/cli/cli-utils';
7
+ import type { LogFn, Logger } from '@aztec-labs/foundation/log';
8
+ import type { TxHash, TxReceipt, TxStatus } from '@aztec-labs/stdlib/tx';
9
+
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';
14
+
15
+ export async function deployAccount(
16
+ wallet: CLIWallet,
17
+ aztecNode: AztecNode,
18
+ address: AztecAddress,
19
+ wait: boolean,
20
+ deployer: AztecAddress | undefined,
21
+ registerClass: boolean,
22
+ publicDeploy: boolean,
23
+ skipInitialization: boolean,
24
+ feeOpts: CLIFeeArgs,
25
+ waitForStatus: TxStatus,
26
+ json: boolean,
27
+ verbose: boolean,
28
+ debugLogger: Logger,
29
+ log: LogFn,
30
+ ) {
31
+ const out: Record<string, any> = {};
32
+
33
+ const account = await wallet.retrieveAccount(address);
34
+ const { partialAddress, publicKeys } = await account.getCompleteAddress();
35
+ const { initializationHash, salt } = account.getInstance();
36
+
37
+ if (json) {
38
+ out.address = address;
39
+ out.partialAddress = partialAddress;
40
+ out.salt = salt;
41
+ out.initHash = initializationHash;
42
+ out.deployer = deployer;
43
+ } else {
44
+ log(`\nNew account:\n`);
45
+ log(`Address: ${address.toString()}`);
46
+ log(`Public key: ${publicKeys.toString()}`);
47
+ log(`Partial address: ${partialAddress.toString()}`);
48
+ log(`Salt: ${salt.toString()}`);
49
+ log(`Init hash: ${initializationHash.toString()}`);
50
+ }
51
+
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;
58
+
59
+ const deployAccountOpts: DeployAccountOptions = {
60
+ skipClassPublication: !registerClass,
61
+ skipInstancePublication: !publicDeploy,
62
+ skipInitialization,
63
+ from,
64
+ fee: { paymentMethod, gasSettings },
65
+ };
66
+
67
+ const localStart = performance.now();
68
+ const deployMethod = await account.getDeployMethod();
69
+ const sim = await deployMethod.simulate({
70
+ ...deployAccountOpts,
71
+ includeMetadata: true,
72
+ });
73
+ // includeMetadata: true guarantees these fields are present
74
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
75
+ const stats = sim.stats!;
76
+
77
+ if (feeOpts.estimateOnly) {
78
+ if (json) {
79
+ out.fee = {
80
+ gasLimits: {
81
+ da: estimatedGas.gasLimits.daGas,
82
+ l2: estimatedGas.gasLimits.l2Gas,
83
+ },
84
+ teardownGasLimits: {
85
+ da: estimatedGas.teardownGasLimits.daGas,
86
+ l2: estimatedGas.teardownGasLimits,
87
+ },
88
+ };
89
+ }
90
+ } else {
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
+
111
+ if (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
+
116
+ out.txReceipt = {
117
+ status: txReceipt.status,
118
+ transactionFee: txReceipt.transactionFee,
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
+ }
125
+ }
126
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
127
+ out.txHash = txHash;
128
+ }
129
+
130
+ if (json) {
131
+ log(prettyPrintJSON(out));
132
+ } else {
133
+ if (txHash) {
134
+ log(`Deploy tx hash: ${txHash.toString()}`);
135
+ }
136
+ if (txReceipt) {
137
+ log(`Deploy tx fee: ${txReceipt.transactionFee}`);
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,37 @@
1
+ import type { AztecAddress } from '@aztec-labs/aztec.js/addresses';
2
+ import type { AztecNode } from '@aztec-labs/aztec.js/node';
3
+ import { getFeeJuiceBalance } from '@aztec-labs/aztec.js/utils';
4
+ import { prettyPrintJSON } from '@aztec-labs/cli/cli-utils';
5
+ import type { LogFn } from '@aztec-labs/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
+ }
@@ -0,0 +1,54 @@
1
+ import { getInitialTestAccountsData } from '@aztec-labs/accounts/testing';
2
+ import { Fr } from '@aztec-labs/aztec.js/fields';
3
+ import { prettyPrintJSON } from '@aztec-labs/cli/cli-utils';
4
+ import type { LogFn } from '@aztec-labs/foundation/log';
5
+
6
+ import type { WalletDB } from '../storage/wallet_db.js';
7
+ import type { CLIWallet } from '../utils/wallet.js';
8
+
9
+ export async function importTestAccounts(wallet: CLIWallet, db: WalletDB, json: boolean, log: LogFn) {
10
+ const testAccounts = await getInitialTestAccountsData();
11
+
12
+ const out: Record<string, any> = {};
13
+ await Promise.all(
14
+ testAccounts.map(async (account, i) => {
15
+ const alias = `test${i}`;
16
+ const secret = testAccounts[i].secret;
17
+ const salt = new Fr(account.salt);
18
+ const address = account.address;
19
+ await db.storeAccount(
20
+ address,
21
+ {
22
+ type: 'schnorr_initializerless',
23
+ signingKey: account.signingKey,
24
+ secretKey: secret,
25
+ salt,
26
+ alias,
27
+ publicKey: undefined,
28
+ },
29
+ log,
30
+ );
31
+
32
+ if (json) {
33
+ out[alias] = {
34
+ alias,
35
+ address,
36
+ secret,
37
+ salt,
38
+ };
39
+ } else {
40
+ log(`\nTest account:`);
41
+ log(`Alias: ${alias}`);
42
+ log(`Address: ${address}`);
43
+ log(`Secret key: ${secret}`);
44
+ log(`Salt: ${salt}`);
45
+ }
46
+ }),
47
+ );
48
+
49
+ if (json) {
50
+ log(prettyPrintJSON(out));
51
+ } else {
52
+ log(`\n${testAccounts.length} test accounts imported to wallet db.\n`);
53
+ }
54
+ }