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

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 (105) hide show
  1. package/README.md +30 -0
  2. package/dest/bin/index.js +48 -26
  3. package/dest/cmds/authorize_action.d.ts +3 -2
  4. package/dest/cmds/authorize_action.d.ts.map +1 -1
  5. package/dest/cmds/authorize_action.js +8 -4
  6. package/dest/cmds/bridge_fee_juice.d.ts +2 -2
  7. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
  8. package/dest/cmds/bridge_fee_juice.js +8 -7
  9. package/dest/cmds/check_tx.d.ts +4 -2
  10. package/dest/cmds/check_tx.d.ts.map +1 -1
  11. package/dest/cmds/check_tx.js +145 -6
  12. package/dest/cmds/create_account.d.ts +6 -5
  13. package/dest/cmds/create_account.d.ts.map +1 -1
  14. package/dest/cmds/create_account.js +46 -27
  15. package/dest/cmds/create_authwit.d.ts +3 -2
  16. package/dest/cmds/create_authwit.d.ts.map +1 -1
  17. package/dest/cmds/create_authwit.js +5 -5
  18. package/dest/cmds/deploy.d.ts +6 -3
  19. package/dest/cmds/deploy.d.ts.map +1 -1
  20. package/dest/cmds/deploy.js +71 -54
  21. package/dest/cmds/deploy_account.d.ts +5 -7
  22. package/dest/cmds/deploy_account.d.ts.map +1 -1
  23. package/dest/cmds/deploy_account.js +46 -29
  24. package/dest/cmds/import_test_accounts.d.ts +2 -2
  25. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  26. package/dest/cmds/import_test_accounts.js +6 -9
  27. package/dest/cmds/index.d.ts +2 -2
  28. package/dest/cmds/index.d.ts.map +1 -1
  29. package/dest/cmds/index.js +83 -115
  30. package/dest/cmds/profile.d.ts +8 -0
  31. package/dest/cmds/profile.d.ts.map +1 -0
  32. package/dest/cmds/profile.js +28 -0
  33. package/dest/cmds/register_contract.d.ts +6 -2
  34. package/dest/cmds/register_contract.d.ts.map +1 -1
  35. package/dest/cmds/register_contract.js +20 -7
  36. package/dest/cmds/register_sender.d.ts +3 -2
  37. package/dest/cmds/register_sender.d.ts.map +1 -1
  38. package/dest/cmds/send.d.ts +7 -8
  39. package/dest/cmds/send.d.ts.map +1 -1
  40. package/dest/cmds/send.js +31 -20
  41. package/dest/cmds/simulate.d.ts +6 -2
  42. package/dest/cmds/simulate.d.ts.map +1 -1
  43. package/dest/cmds/simulate.js +25 -19
  44. package/dest/storage/wallet_db.d.ts +4 -16
  45. package/dest/storage/wallet_db.d.ts.map +1 -1
  46. package/dest/storage/wallet_db.js +2 -23
  47. package/dest/utils/authorizations.d.ts +6 -0
  48. package/dest/utils/authorizations.d.ts.map +1 -0
  49. package/dest/utils/authorizations.js +28 -0
  50. package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
  51. package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
  52. package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
  53. package/dest/utils/ecdsa.d.ts +0 -2
  54. package/dest/utils/ecdsa.d.ts.map +1 -1
  55. package/dest/utils/options/fees.d.ts +20 -27
  56. package/dest/utils/options/fees.d.ts.map +1 -1
  57. package/dest/utils/options/fees.js +85 -144
  58. package/dest/utils/options/options.d.ts +8 -4
  59. package/dest/utils/options/options.d.ts.map +1 -1
  60. package/dest/utils/options/options.js +26 -14
  61. package/dest/utils/profiling.d.ts +5 -0
  62. package/dest/utils/profiling.d.ts.map +1 -0
  63. package/dest/utils/profiling.js +60 -0
  64. package/dest/utils/wallet.d.ts +35 -0
  65. package/dest/utils/wallet.d.ts.map +1 -0
  66. package/dest/utils/wallet.js +193 -0
  67. package/package.json +24 -20
  68. package/src/bin/index.ts +56 -32
  69. package/src/cmds/authorize_action.ts +15 -4
  70. package/src/cmds/bridge_fee_juice.ts +14 -11
  71. package/src/cmds/check_tx.ts +182 -5
  72. package/src/cmds/create_account.ts +55 -32
  73. package/src/cmds/create_authwit.ts +8 -4
  74. package/src/cmds/deploy.ts +79 -62
  75. package/src/cmds/deploy_account.ts +57 -28
  76. package/src/cmds/import_test_accounts.ts +7 -11
  77. package/src/cmds/index.ts +256 -220
  78. package/src/cmds/profile.ts +48 -0
  79. package/src/cmds/register_contract.ts +28 -5
  80. package/src/cmds/register_sender.ts +3 -2
  81. package/src/cmds/send.ts +31 -17
  82. package/src/cmds/simulate.ts +39 -23
  83. package/src/storage/wallet_db.ts +3 -31
  84. package/src/utils/authorizations.ts +51 -0
  85. package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
  86. package/src/utils/options/fees.ts +134 -206
  87. package/src/utils/options/options.ts +41 -19
  88. package/src/utils/profiling.ts +158 -0
  89. package/src/utils/wallet.ts +264 -0
  90. package/dest/cmds/add_authwit.d.ts +0 -4
  91. package/dest/cmds/add_authwit.d.ts.map +0 -1
  92. package/dest/cmds/add_authwit.js +0 -4
  93. package/dest/cmds/cancel_tx.d.ts +0 -11
  94. package/dest/cmds/cancel_tx.d.ts.map +0 -1
  95. package/dest/cmds/cancel_tx.js +0 -38
  96. package/dest/utils/accounts.d.ts +0 -11
  97. package/dest/utils/accounts.d.ts.map +0 -1
  98. package/dest/utils/accounts.js +0 -87
  99. package/dest/utils/pxe_wrapper.d.ts +0 -10
  100. package/dest/utils/pxe_wrapper.d.ts.map +0 -1
  101. package/dest/utils/pxe_wrapper.js +0 -21
  102. package/src/cmds/add_authwit.ts +0 -13
  103. package/src/cmds/cancel_tx.ts +0 -62
  104. package/src/utils/accounts.ts +0 -102
  105. package/src/utils/pxe_wrapper.ts +0 -26
@@ -1,22 +1,34 @@
1
- import type { AccountManager, DeployAccountOptions } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
2
4
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
3
5
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
6
 
5
- import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
7
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
8
+ import type { CLIFeeArgs } from '../utils/options/fees.js';
9
+ import { printProfileResult } from '../utils/profiling.js';
10
+ import type { CLIWallet } from '../utils/wallet.js';
6
11
 
7
12
  export async function deployAccount(
8
- account: AccountManager,
13
+ wallet: CLIWallet,
14
+ aztecNode: AztecNode,
15
+ address: AztecAddress,
9
16
  wait: boolean,
10
- feeOpts: IFeeOpts,
17
+ deployer: AztecAddress | undefined,
18
+ registerClass: boolean,
19
+ publicDeploy: boolean,
20
+ skipInitialization: boolean,
21
+ feeOpts: CLIFeeArgs,
11
22
  json: boolean,
23
+ verbose: boolean,
12
24
  debugLogger: Logger,
13
25
  log: LogFn,
14
26
  ) {
15
27
  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();
28
+
29
+ const account = await wallet.createOrRetrieveAccount(address);
30
+ const { partialAddress, publicKeys } = await account.getCompleteAddress();
31
+ const { initializationHash, salt } = account.getInstance();
20
32
 
21
33
  if (json) {
22
34
  out.address = address;
@@ -28,48 +40,67 @@ export async function deployAccount(
28
40
  log(`\nNew account:\n`);
29
41
  log(`Address: ${address.toString()}`);
30
42
  log(`Public key: ${publicKeys.toString()}`);
31
- if (secretKey) {
32
- log(`Secret key: ${secretKey.toString()}`);
33
- }
34
43
  log(`Partial address: ${partialAddress.toString()}`);
35
44
  log(`Salt: ${salt.toString()}`);
36
45
  log(`Init hash: ${initializationHash.toString()}`);
37
- log(`Deployer: ${deployer.toString()}`);
38
46
  }
39
47
 
40
48
  let tx;
41
49
  let txReceipt;
50
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
42
51
 
43
- const deployOpts: DeployAccountOptions = {
44
- ...(await feeOpts.toDeployAccountOpts(wallet)),
45
- skipInitialization: false,
52
+ const delegatedDeployment = deployer && !account.address.equals(deployer);
53
+ const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
54
+
55
+ const deployAccountOpts: DeployAccountOptions = {
56
+ skipClassPublication: !registerClass,
57
+ skipInstancePublication: !publicDeploy,
58
+ skipInitialization,
59
+ from,
60
+ fee: { paymentMethod, gasSettings },
46
61
  };
62
+
63
+ const deployMethod = await account.getDeployMethod();
64
+ const { estimatedGas, stats } = await deployMethod.simulate({
65
+ ...deployAccountOpts,
66
+ fee: { ...deployAccountOpts.fee, estimateGas: true },
67
+ });
68
+
47
69
  if (feeOpts.estimateOnly) {
48
- const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
49
70
  if (json) {
50
71
  out.fee = {
51
72
  gasLimits: {
52
- da: gas.gasLimits.daGas,
53
- l2: gas.gasLimits.l2Gas,
73
+ da: estimatedGas.gasLimits.daGas,
74
+ l2: estimatedGas.gasLimits.l2Gas,
54
75
  },
55
76
  teardownGasLimits: {
56
- da: gas.teardownGasLimits.daGas,
57
- l2: gas.teardownGasLimits,
77
+ da: estimatedGas.teardownGasLimits.daGas,
78
+ l2: estimatedGas.teardownGasLimits,
58
79
  },
59
80
  };
60
- } else {
61
- printGasEstimates(feeOpts, gas, log);
62
81
  }
63
82
  } else {
64
- tx = account.deploy(deployOpts);
83
+ tx = deployMethod.send({
84
+ ...deployAccountOpts,
85
+ fee: deployAccountOpts.fee
86
+ ? {
87
+ ...deployAccountOpts.fee,
88
+ gasSettings: estimatedGas,
89
+ }
90
+ : undefined,
91
+ });
92
+ if (verbose) {
93
+ printProfileResult(stats, log);
94
+ }
95
+
65
96
  const txHash = await tx.getTxHash();
66
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
97
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
67
98
  out.txHash = txHash;
68
99
  if (wait) {
69
100
  if (!json) {
70
101
  log(`\nWaiting for account contract deployment...`);
71
102
  }
72
- txReceipt = await tx.wait();
103
+ txReceipt = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
73
104
  out.txReceipt = {
74
105
  status: txReceipt.status,
75
106
  transactionFee: txReceipt.transactionFee,
@@ -81,12 +112,10 @@ export async function deployAccount(
81
112
  log(prettyPrintJSON(out));
82
113
  } else {
83
114
  if (tx) {
84
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
115
+ log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
85
116
  }
86
117
  if (txReceipt) {
87
118
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
88
119
  }
89
120
  }
90
-
91
- return { address, secretKey, salt };
92
121
  }
@@ -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) {