@aztec/cli-wallet 0.0.1-fake-ceab37513c → 0.0.2-commit.217f559981

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 (106) hide show
  1. package/README.md +30 -0
  2. package/dest/bin/index.d.ts +2 -1
  3. package/dest/bin/index.js +39 -23
  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 +8 -7
  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 +9 -7
  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 +148 -6
  13. package/dest/cmds/create_account.d.ts +8 -6
  14. package/dest/cmds/create_account.d.ts.map +1 -1
  15. package/dest/cmds/create_account.js +56 -62
  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 +7 -4
  20. package/dest/cmds/deploy.d.ts.map +1 -1
  21. package/dest/cmds/deploy.js +84 -50
  22. package/dest/cmds/deploy_account.d.ts +6 -8
  23. package/dest/cmds/deploy_account.d.ts.map +1 -1
  24. package/dest/cmds/deploy_account.js +56 -65
  25. package/dest/cmds/import_test_accounts.d.ts +3 -3
  26. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  27. package/dest/cmds/import_test_accounts.js +6 -9
  28. package/dest/cmds/index.d.ts +3 -3
  29. package/dest/cmds/index.d.ts.map +1 -1
  30. package/dest/cmds/index.js +73 -112
  31. package/dest/cmds/profile.d.ts +7 -4
  32. package/dest/cmds/profile.d.ts.map +1 -1
  33. package/dest/cmds/profile.js +9 -4
  34. package/dest/cmds/register_contract.d.ts +7 -3
  35. package/dest/cmds/register_contract.d.ts.map +1 -1
  36. package/dest/cmds/register_contract.js +5 -6
  37. package/dest/cmds/register_sender.d.ts +4 -3
  38. package/dest/cmds/register_sender.d.ts.map +1 -1
  39. package/dest/cmds/send.d.ts +8 -9
  40. package/dest/cmds/send.d.ts.map +1 -1
  41. package/dest/cmds/send.js +46 -31
  42. package/dest/cmds/simulate.d.ts +7 -4
  43. package/dest/cmds/simulate.d.ts.map +1 -1
  44. package/dest/cmds/simulate.js +12 -7
  45. package/dest/storage/wallet_db.d.ts +6 -16
  46. package/dest/storage/wallet_db.d.ts.map +1 -1
  47. package/dest/storage/wallet_db.js +48 -54
  48. package/dest/utils/authorizations.d.ts +3 -2
  49. package/dest/utils/authorizations.d.ts.map +1 -1
  50. package/dest/utils/authorizations.js +1 -1
  51. package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
  52. package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
  53. package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
  54. package/dest/utils/constants.d.ts +4 -0
  55. package/dest/utils/constants.d.ts.map +1 -0
  56. package/dest/utils/constants.js +7 -0
  57. package/dest/utils/ecdsa.d.ts +1 -1
  58. package/dest/utils/options/fees.d.ts +22 -28
  59. package/dest/utils/options/fees.d.ts.map +1 -1
  60. package/dest/utils/options/fees.js +66 -133
  61. package/dest/utils/options/index.d.ts +1 -1
  62. package/dest/utils/options/options.d.ts +3 -2
  63. package/dest/utils/options/options.d.ts.map +1 -1
  64. package/dest/utils/options/options.js +1 -1
  65. package/dest/utils/profiling.d.ts +1 -1
  66. package/dest/utils/profiling.d.ts.map +1 -1
  67. package/dest/utils/profiling.js +9 -1
  68. package/dest/utils/wallet.d.ts +40 -0
  69. package/dest/utils/wallet.d.ts.map +1 -0
  70. package/dest/utils/wallet.js +208 -0
  71. package/package.json +17 -14
  72. package/src/bin/index.ts +39 -31
  73. package/src/cmds/authorize_action.ts +14 -6
  74. package/src/cmds/bridge_fee_juice.ts +15 -11
  75. package/src/cmds/check_tx.ts +180 -5
  76. package/src/cmds/create_account.ts +63 -66
  77. package/src/cmds/create_authwit.ts +9 -5
  78. package/src/cmds/deploy.ts +82 -61
  79. package/src/cmds/deploy_account.ts +62 -64
  80. package/src/cmds/import_test_accounts.ts +7 -11
  81. package/src/cmds/index.ts +120 -206
  82. package/src/cmds/profile.ts +14 -6
  83. package/src/cmds/register_contract.ts +9 -11
  84. package/src/cmds/register_sender.ts +3 -2
  85. package/src/cmds/send.ts +42 -40
  86. package/src/cmds/simulate.ts +17 -12
  87. package/src/storage/wallet_db.ts +52 -67
  88. package/src/utils/authorizations.ts +3 -1
  89. package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
  90. package/src/utils/constants.ts +4 -0
  91. package/src/utils/options/fees.ts +88 -178
  92. package/src/utils/options/options.ts +3 -2
  93. package/src/utils/profiling.ts +15 -1
  94. package/src/utils/wallet.ts +290 -0
  95. package/dest/cmds/cancel_tx.d.ts +0 -11
  96. package/dest/cmds/cancel_tx.d.ts.map +0 -1
  97. package/dest/cmds/cancel_tx.js +0 -43
  98. package/dest/utils/accounts.d.ts +0 -9
  99. package/dest/utils/accounts.d.ts.map +0 -1
  100. package/dest/utils/accounts.js +0 -61
  101. package/dest/utils/pxe_wrapper.d.ts +0 -12
  102. package/dest/utils/pxe_wrapper.d.ts.map +0 -1
  103. package/dest/utils/pxe_wrapper.js +0 -26
  104. package/src/cmds/cancel_tx.ts +0 -66
  105. package/src/utils/accounts.ts +0 -77
  106. package/src/utils/pxe_wrapper.ts +0 -32
package/README.md CHANGED
@@ -1,2 +1,32 @@
1
1
  # Aztec wallet Documentation
2
2
 
3
+ ### Run tests locally
4
+
5
+ 1) Start a local Ethereum node (Anvil) in one terminal:
6
+
7
+ ```bash
8
+ anvil --host 127.0.0.1 --port 8545
9
+ ```
10
+
11
+ 2) In another terminal, start the Aztec local network from `yarn-project/aztec`:
12
+
13
+ ```bash
14
+ cd yarn-project/aztec
15
+ NODE_NO_WARNINGS=1 ETHEREUM_HOSTS=http://127.0.0.1:8545 node ./dest/bin/index.js start --local-network
16
+ ```
17
+
18
+ 3) Run the wallet tests from `yarn-project/cli-wallet/test`:
19
+
20
+ ```bash
21
+ cd yarn-project/cli-wallet/test
22
+ ./test.sh --filter <partialnameoftest>
23
+ ```
24
+
25
+ Notes:
26
+ - **Filter tests**: Omit `--filter` to run all tests, or pass part of a test filename to run a subset.
27
+ - **Docker mode**: You can run tests using Docker by adding `--docker`:
28
+
29
+ ```bash
30
+ ./test.sh --docker --filter <partialnameoftest>
31
+ ```
32
+
@@ -1,2 +1,3 @@
1
+ #!/usr/bin/env node
1
2
  export {};
2
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
package/dest/bin/index.js CHANGED
@@ -1,19 +1,25 @@
1
- import { Fr, ProtocolContractAddress, computeSecretHash, fileURLToPath } from '@aztec/aztec.js';
1
+ #!/usr/bin/env node
2
+ import { computeSecretHash } from '@aztec/aztec.js/crypto';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
5
+ import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
6
+ import { BackendType, Barretenberg } from '@aztec/bb.js';
2
7
  import { LOCALHOST } from '@aztec/cli/cli-utils';
3
8
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
4
9
  import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
5
10
  import { getPackageVersion } from '@aztec/stdlib/update-checker';
6
11
  import { Argument, Command, Option } from 'commander';
7
- import { mkdirSync } from 'fs';
8
12
  import { homedir } from 'os';
9
- import { dirname, join, resolve } from 'path';
13
+ import { join } from 'path';
10
14
  import { injectCommands } from '../cmds/index.js';
11
15
  import { Aliases, WalletDB } from '../storage/wallet_db.js';
16
+ import { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
12
17
  import { createAliasOption } from '../utils/options/index.js';
13
- import { PXEWrapper } from '../utils/pxe_wrapper.js';
18
+ import { CLIWallet } from '../utils/wallet.js';
14
19
  const userLog = createConsoleLogger();
15
20
  const debugLogger = createLogger('wallet');
16
21
  const { WALLET_DATA_DIRECTORY = join(homedir(), '.aztec/wallet') } = process.env;
22
+ // TODO: This function is only used in 1 place so we could just inline this
17
23
  function injectInternalCommands(program, log, db) {
18
24
  program.command('alias').description('Aliases information for easy reference.').addArgument(new Argument('<type>', 'Type of alias to create').choices(Aliases)).argument('<key>', 'Key to alias.').argument('<value>', 'Value to assign to the alias.').action(async (type, key, value)=>{
19
25
  value = db.tryRetrieveAlias(value) || value;
@@ -43,29 +49,38 @@ function injectInternalCommands(program, log, db) {
43
49
  /** CLI wallet main entrypoint */ async function main() {
44
50
  const walletVersion = getPackageVersion() ?? '0.0.0';
45
51
  const db = WalletDB.getInstance();
46
- const pxeWrapper = new PXEWrapper();
52
+ const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
47
53
  const program = new Command('wallet');
48
- program.description('Aztec wallet').version(walletVersion).option('-d, --data-dir <string>', 'Storage directory for wallet data', WALLET_DATA_DIRECTORY).addOption(new Option('-p, --prover <string>', 'The type of prover the wallet uses (only applies if not using a remote PXE)').choices([
54
+ program.description('Aztec wallet').version(walletVersion).option('-d, --data-dir <string>', 'Storage directory for wallet data', WALLET_DATA_DIRECTORY).addOption(new Option('-p, --prover <string>', 'The type of prover the wallet uses').choices([
49
55
  'wasm',
50
56
  'native',
51
57
  'none'
52
- ]).env('PXE_PROVER').default('native')).addOption(new Option('--remote-pxe', 'Connect to an external PXE RPC server instead of the local one').env('REMOTE_PXE').default(false).conflicts('rpc-url')).addOption(new Option('-n, --node-url <string>', 'URL of the Aztec node to connect to').env('AZTEC_NODE_URL').default(`http://${LOCALHOST}:8080`)).hook('preSubcommand', async (command)=>{
53
- const { dataDir, remotePxe, nodeUrl, prover } = command.optsWithGlobals();
54
- if (!remotePxe) {
55
- debugLogger.info('Using local PXE service');
56
- const proverEnabled = prover !== 'none';
57
- const bbBinaryPath = prover === 'native' ? resolve(dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/cpp/build/bin/bb') : undefined;
58
- const bbWorkingDirectory = dataDir + '/bb';
59
- mkdirSync(bbWorkingDirectory, {
60
- recursive: true
61
- });
62
- const overridePXEConfig = {
63
- proverEnabled,
64
- bbBinaryPath: prover === 'native' ? bbBinaryPath : undefined,
65
- bbWorkingDirectory: prover === 'native' ? bbWorkingDirectory : undefined
66
- };
67
- pxeWrapper.prepare(nodeUrl, join(dataDir, 'pxe'), overridePXEConfig);
58
+ ]).env('PXE_PROVER').default('native')).addOption(new Option('-n, --node-url <string>', 'URL of the Aztec node to connect to').env('AZTEC_NODE_URL').default(`http://${LOCALHOST}:8080`)).hook('preSubcommand', async (command)=>{
59
+ // Skip initialization if user is just requesting help
60
+ if (command.args.includes('--help') || command.args.includes('-h')) {
61
+ return;
68
62
  }
63
+ const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
64
+ const proverEnabled = prover !== 'none';
65
+ switch(prover){
66
+ case 'native':
67
+ await Barretenberg.initSingleton({
68
+ backend: BackendType.NativeUnixSocket
69
+ });
70
+ break;
71
+ case 'wasm':
72
+ await Barretenberg.initSingleton({
73
+ backend: BackendType.Wasm
74
+ });
75
+ break;
76
+ }
77
+ const overridePXEConfig = {
78
+ proverEnabled,
79
+ dataDirectory: join(dataDir, 'pxe')
80
+ };
81
+ const node = createAztecNodeClient(nodeUrl);
82
+ const wallet = await CLIWallet.create(node, userLog, db, overridePXEConfig);
83
+ walletAndNodeWrapper.setNodeAndWallet(node, wallet);
69
84
  await db.init(await openStoreAt(dataDir));
70
85
  let protocolContractsRegistered;
71
86
  try {
@@ -80,9 +95,10 @@ function injectInternalCommands(program, log, db) {
80
95
  }
81
96
  }
82
97
  });
83
- injectCommands(program, userLog, debugLogger, db, pxeWrapper);
98
+ injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
84
99
  injectInternalCommands(program, userLog, db);
85
100
  await program.parseAsync(process.argv);
101
+ await Barretenberg.destroySingleton();
86
102
  }
87
103
  main().catch((err)=>{
88
104
  debugLogger.error(`Error in command execution`);
@@ -1,4 +1,5 @@
1
- import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
3
  import type { LogFn } from '@aztec/foundation/log';
3
- export declare function authorizeAction(wallet: AccountWalletWithSecretKey, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/aztec.js").FieldsOf<import("@aztec/aztec.js").TxReceipt>>;
4
- //# sourceMappingURL=authorize_action.d.ts.map
4
+ export declare function authorizeAction(wallet: Wallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/stdlib/tx").TxReceipt>;
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplX2FjdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYXV0aG9yaXplX2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUc5RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVyRCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUluRCx3QkFBc0IsZUFBZSxDQUNuQyxNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyxpREE2QlgifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE/F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,eAAe,CACnC,MAAM,EAAE,0BAA0B,EAClC,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,oFAwBX"}
1
+ {"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,iDA6BX"}
@@ -1,21 +1,22 @@
1
- import { Contract } from '@aztec/aztec.js';
1
+ import { SetPublicAuthwitContractInteraction } from '@aztec/aztec.js/authorization';
2
+ import { Contract } from '@aztec/aztec.js/contracts';
2
3
  import { prepTx } from '@aztec/cli/utils';
3
- import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
4
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
4
5
  export async function authorizeAction(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
5
6
  const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
6
7
  if (isPrivate) {
7
8
  throw new Error('Cannot authorize private function. To allow a third party to call a private function, please create an authorization witness via the create-authwit command');
8
9
  }
9
- const contract = await Contract.at(contractAddress, contractArtifact, wallet);
10
+ const contract = Contract.at(contractAddress, contractArtifact, wallet);
10
11
  const action = contract.methods[functionName](...functionArgs);
11
- const setAuthwitnessInteraction = await wallet.setPublicAuthWit({
12
+ const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(wallet, from, {
12
13
  caller,
13
14
  action
14
15
  }, true);
15
16
  const witness = await setAuthwitnessInteraction.send({
16
- from
17
- }).wait({
18
- timeout: DEFAULT_TX_TIMEOUT_S
17
+ wait: {
18
+ timeout: DEFAULT_TX_TIMEOUT_S
19
+ }
19
20
  });
20
21
  log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
21
22
  return witness;
@@ -1,6 +1,6 @@
1
- import { type PXE } from '@aztec/aztec.js';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- export declare function bridgeL1FeeJuice(amount: bigint, recipient: AztecAddress, pxe: PXE, l1RpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mint: boolean, json: boolean, wait: boolean, interval: number | undefined, log: LogFn, debugLogger: Logger): Promise<readonly [Fr, bigint]>;
6
- //# sourceMappingURL=bridge_fee_juice.d.ts.map
5
+ export declare function bridgeL1FeeJuice(amount: bigint, recipient: AztecAddress, node: AztecNode, l1RpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mint: boolean, json: boolean, wait: boolean, interval: number | undefined, log: LogFn, debugLogger: Logger): Promise<readonly [Fr, bigint]>;
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJpZGdlX2ZlZV9qdWljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYnJpZGdlX2ZlZV9qdWljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUt0RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzNELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR2hFLHdCQUFzQixnQkFBZ0IsQ0FDcEMsTUFBTSxFQUFFLE1BQU0sRUFDZCxTQUFTLEVBQUUsWUFBWSxFQUN2QixJQUFJLEVBQUUsU0FBUyxFQUNmLFNBQVMsRUFBRSxNQUFNLEVBQUUsRUFDbkIsT0FBTyxFQUFFLE1BQU0sRUFDZixVQUFVLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDOUIsUUFBUSxFQUFFLE1BQU0sRUFDaEIsSUFBSSxFQUFFLE9BQU8sRUFDYixJQUFJLEVBQUUsT0FBTyxFQUNiLElBQUksRUFBRSxPQUFPLEVBQ2IsUUFBUSxvQkFBUyxFQUNqQixHQUFHLEVBQUUsS0FBSyxFQUNWLFdBQVcsRUFBRSxNQUFNLGtDQW1FcEIifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"bridge_fee_juice.d.ts","sourceRoot":"","sources":["../../src/cmds/bridge_fee_juice.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,EACvB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,QAAQ,oBAAS,EACjB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,kCAmEpB"}
1
+ {"version":3,"file":"bridge_fee_juice.d.ts","sourceRoot":"","sources":["../../src/cmds/bridge_fee_juice.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,QAAQ,oBAAS,EACjB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,kCAmEpB"}
@@ -1,14 +1,16 @@
1
- import { L1FeeJuicePortalManager } from '@aztec/aztec.js';
1
+ import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
2
+ import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
2
3
  import { prettyPrintJSON } from '@aztec/cli/utils';
3
- import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
4
- import { Fr } from '@aztec/foundation/fields';
5
- export async function bridgeL1FeeJuice(amount, recipient, pxe, l1RpcUrls, chainId, privateKey, mnemonic, mint, json, wait, interval = 60_000, log, debugLogger) {
4
+ import { createEthereumChain } from '@aztec/ethereum/chain';
5
+ import { createExtendedL1Client } from '@aztec/ethereum/client';
6
+ import { Fr } from '@aztec/foundation/curves/bn254';
7
+ import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
8
+ export async function bridgeL1FeeJuice(amount, recipient, node, l1RpcUrls, chainId, privateKey, mnemonic, mint, json, wait, interval = 60_000, log, debugLogger) {
6
9
  // Prepare L1 client
7
10
  const chain = createEthereumChain(l1RpcUrls, chainId);
8
11
  const client = createExtendedL1Client(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
9
- const { protocolContractAddresses: { feeJuice: feeJuiceAddress } } = await pxe.getPXEInfo();
10
12
  // Setup portal manager
11
- const portal = await L1FeeJuicePortalManager.new(pxe, client, debugLogger);
13
+ const portal = await L1FeeJuicePortalManager.new(node, client, debugLogger);
12
14
  const { claimAmount, claimSecret, messageHash, messageLeafIndex } = await portal.bridgeTokensPublic(recipient, amount, mint);
13
15
  if (json) {
14
16
  const out = {
@@ -33,7 +35,7 @@ export async function bridgeL1FeeJuice(amount, recipient, pxe, l1RpcUrls, chainI
33
35
  const delayedCheck = (delay)=>{
34
36
  return new Promise((resolve, reject)=>{
35
37
  setTimeout(()=>{
36
- void pxe.getL1ToL2MembershipWitness(feeJuiceAddress, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
38
+ void getNonNullifiedL1ToL2MessageWitness(node, ProtocolContractAddress.FeeJuice, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
37
39
  }, delay);
38
40
  });
39
41
  };
@@ -1,4 +1,6 @@
1
- import type { PXE, TxHash } from '@aztec/aztec.js';
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import type { TxHash } from '@aztec/aztec.js/tx';
2
3
  import type { LogFn } from '@aztec/foundation/log';
3
- export declare function checkTx(client: PXE, txHash: TxHash, statusOnly: boolean, log: LogFn): Promise<import("@aztec/aztec.js").TxStatus | undefined>;
4
- //# sourceMappingURL=check_tx.d.ts.map
4
+ import type { CLIWallet } from '../utils/wallet.js';
5
+ export declare function checkTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash, statusOnly: boolean, log: LogFn): Promise<import("@aztec/aztec.js/tx").TxStatus | undefined>;
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2tfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NoZWNrX3R4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRXRELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBSW5ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixPQUFPLENBQzNCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxNQUFNLEVBQ2QsVUFBVSxFQUFFLE9BQU8sRUFDbkIsR0FBRyxFQUFFLEtBQUssOERBUVgifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,2DAOzF"}
1
+ {"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,OAAO,EACnB,GAAG,EAAE,KAAK,8DAQX"}
@@ -1,11 +1,153 @@
1
- import { inspectTx } from '@aztec/cli/inspect';
2
- export async function checkTx(client, txHash, statusOnly, log) {
1
+ import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
2
+ import { siloNullifier } from '@aztec/stdlib/hash';
3
+ export async function checkTx(wallet, aztecNode, txHash, statusOnly, log) {
3
4
  if (statusOnly) {
4
- const receipt = await client.getTxReceipt(txHash);
5
+ const receipt = await aztecNode.getTxReceipt(txHash);
5
6
  return receipt.status;
6
7
  } else {
7
- await inspectTx(client, txHash, log, {
8
- includeBlockInfo: true
9
- });
8
+ await inspectTx(wallet, aztecNode, txHash, log);
10
9
  }
11
10
  }
11
+ // The rest of the code here was copied over here from CLI because in CLI I needed to prune the inspect function of the PXE
12
+ // dependency when dropping PXE JSON RPC Server.
13
+ async function inspectTx(wallet, aztecNode, txHash, log) {
14
+ const [receipt, effectsInBlock] = await Promise.all([
15
+ aztecNode.getTxReceipt(txHash),
16
+ aztecNode.getTxEffect(txHash)
17
+ ]);
18
+ // Base tx data
19
+ log(`Tx ${txHash.toString()}`);
20
+ log(` Status: ${receipt.status}`);
21
+ if (receipt.executionResult) {
22
+ log(` Execution result: ${receipt.executionResult}`);
23
+ }
24
+ if (receipt.error) {
25
+ log(` Error: ${receipt.error}`);
26
+ }
27
+ if (!effectsInBlock) {
28
+ return;
29
+ }
30
+ const effects = effectsInBlock.data;
31
+ const artifactMap = await getKnownArtifacts(wallet);
32
+ log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
33
+ if (receipt.transactionFee) {
34
+ log(` Fee: ${receipt.transactionFee.toString()}`);
35
+ }
36
+ // Public logs
37
+ const publicLogs = effects.publicLogs;
38
+ if (publicLogs.length > 0) {
39
+ log(' Logs:');
40
+ for (const publicLog of publicLogs){
41
+ log(` ${publicLog.toHumanReadable()}`);
42
+ }
43
+ }
44
+ // Public data writes
45
+ const writes = effects.publicDataWrites;
46
+ if (writes.length > 0) {
47
+ log(' Public data writes:');
48
+ for (const write of writes){
49
+ log(` Leaf ${write.leafSlot.toString()} = ${write.value.toString()}`);
50
+ }
51
+ }
52
+ // Created notes
53
+ const notes = effects.noteHashes;
54
+ if (notes.length > 0) {
55
+ log(' Created notes:');
56
+ log(` Total: ${notes.length}`);
57
+ for (const note of notes){
58
+ log(` Note hash: ${note.toShortString()}`);
59
+ }
60
+ }
61
+ // Nullifiers
62
+ const nullifierCount = effects.nullifiers.length;
63
+ const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
64
+ if (nullifierCount > 0) {
65
+ log(' Nullifiers:');
66
+ for (const nullifier of effects.nullifiers){
67
+ const deployed = deployNullifiers[nullifier.toString()];
68
+ const note = deployed ? (await wallet.getNotes({
69
+ siloedNullifier: nullifier,
70
+ contractAddress: deployed,
71
+ scopes: 'ALL_SCOPES'
72
+ }))[0] : undefined;
73
+ const initialized = initNullifiers[nullifier.toString()];
74
+ const registered = classNullifiers[nullifier.toString()];
75
+ if (nullifier.toBuffer().equals(txHash.toBuffer())) {
76
+ log(` Transaction hash nullifier ${nullifier.toShortString()}`);
77
+ } else if (note) {
78
+ inspectNote(note, artifactMap, log, `Nullifier ${nullifier.toShortString()} for note`);
79
+ } else if (deployed) {
80
+ log(` Contract ${toFriendlyAddress(deployed, artifactMap)} deployed via nullifier ${nullifier.toShortString()}`);
81
+ } else if (initialized) {
82
+ log(` Contract ${toFriendlyAddress(initialized, artifactMap)} initialized via nullifier ${nullifier.toShortString()}`);
83
+ } else if (registered) {
84
+ log(` Class ${registered} registered via nullifier ${nullifier.toShortString()}`);
85
+ } else {
86
+ log(` Unknown nullifier ${nullifier.toString()}`);
87
+ }
88
+ }
89
+ }
90
+ // L2 to L1 messages
91
+ if (effects.l2ToL1Msgs.length > 0) {
92
+ log(` L2 to L1 messages:`);
93
+ for (const msg of effects.l2ToL1Msgs){
94
+ log(` ${msg.toString()}`);
95
+ }
96
+ }
97
+ }
98
+ function inspectNote(note, artifactMap, log, text = 'Note') {
99
+ const artifact = artifactMap[note.contractAddress.toString()];
100
+ const contract = artifact?.name ?? note.contractAddress.toString();
101
+ log(` ${text} at ${contract}`);
102
+ for (const field of note.note.items){
103
+ log(` ${field.toString()}`);
104
+ }
105
+ }
106
+ function toFriendlyAddress(address, artifactMap) {
107
+ const artifact = artifactMap[address.toString()];
108
+ if (!artifact) {
109
+ return address.toString();
110
+ }
111
+ return `${artifact.name}<${address.toString()}>`;
112
+ }
113
+ async function getKnownNullifiers(wallet, artifactMap) {
114
+ const knownContracts = await wallet.getContracts();
115
+ const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
116
+ const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
117
+ const initNullifiers = {};
118
+ const deployNullifiers = {};
119
+ const classNullifiers = {};
120
+ for (const contract of knownContracts){
121
+ initNullifiers[(await siloNullifier(contract, contract.toField())).toString()] = contract;
122
+ deployNullifiers[(await siloNullifier(deployerAddress, contract.toField())).toString()] = contract;
123
+ }
124
+ for (const artifact of Object.values(artifactMap)){
125
+ classNullifiers[(await siloNullifier(classRegistryAddress, artifact.classId)).toString()] = `${artifact.name}Class<${artifact.classId}>`;
126
+ }
127
+ return {
128
+ initNullifiers,
129
+ deployNullifiers,
130
+ classNullifiers
131
+ };
132
+ }
133
+ async function getKnownArtifacts(wallet) {
134
+ const knownContractAddresses = await wallet.getContracts();
135
+ const knownContracts = (await Promise.all(knownContractAddresses.map((contractAddress)=>wallet.getContractMetadata(contractAddress)))).map((contractMetadata)=>contractMetadata.instance);
136
+ const classIds = [
137
+ ...new Set(knownContracts.map((contract)=>contract?.currentContractClassId))
138
+ ];
139
+ const knownArtifacts = (await Promise.all(classIds.map((classId)=>classId ? wallet.getContractArtifact(classId) : undefined))).map((artifact, index)=>artifact ? {
140
+ ...artifact,
141
+ classId: classIds[index]
142
+ } : undefined);
143
+ const map = {};
144
+ for (const instance of knownContracts){
145
+ if (instance) {
146
+ const artifact = knownArtifacts.find((a)=>a?.classId?.equals(instance.currentContractClassId));
147
+ if (artifact) {
148
+ map[instance.address.toString()] = artifact;
149
+ }
150
+ }
151
+ }
152
+ return map;
153
+ }
@@ -1,12 +1,14 @@
1
- import { AztecAddress, type PXE } from '@aztec/aztec.js';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
- import { type AccountType } from '../utils/accounts.js';
5
- import { type IFeeOpts } from '../utils/options/fees.js';
6
- export declare function createAccount(client: PXE, accountType: AccountType, secretKey: Fr | undefined, publicKey: string | undefined, alias: string | undefined, registerOnly: boolean, publicDeploy: boolean, skipInitialization: boolean, wait: boolean, feeOpts: IFeeOpts, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
5
+ import type { AccountType } from '../utils/constants.js';
6
+ import { CLIFeeArgs } from '../utils/options/fees.js';
7
+ import { CLIWallet } from '../utils/wallet.js';
8
+ export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType, secretKey: Fr | undefined, publicKey: string | undefined, alias: string | undefined, deployer: AztecAddress | undefined, registerOnly: boolean, skipInitialization: boolean, publicDeploy: boolean, registerClass: boolean, wait: boolean, feeOpts: CLIFeeArgs, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
7
9
  alias: string | undefined;
8
10
  address: AztecAddress;
9
11
  secretKey: Fr;
10
12
  salt: Fr;
11
13
  }>;
12
- //# sourceMappingURL=create_account.d.ts.map
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2FjY291bnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUV6RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUd0RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBSTNELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFL0Msd0JBQXNCLGFBQWEsQ0FDakMsTUFBTSxFQUFFLFNBQVMsRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsV0FBVyxFQUFFLFdBQVcsRUFDeEIsU0FBUyxFQUFFLEVBQUUsR0FBRyxTQUFTLEVBQ3pCLFNBQVMsRUFBRSxNQUFNLEdBQUcsU0FBUyxFQUM3QixLQUFLLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDekIsUUFBUSxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQ2xDLFlBQVksRUFBRSxPQUFPLEVBQ3JCLGtCQUFrQixFQUFFLE9BQU8sRUFDM0IsWUFBWSxFQUFFLE9BQU8sRUFDckIsYUFBYSxFQUFFLE9BQU8sRUFDdEIsSUFBSSxFQUFFLE9BQU8sRUFDYixPQUFPLEVBQUUsVUFBVSxFQUNuQixJQUFJLEVBQUUsT0FBTyxFQUNiLE9BQU8sRUFBRSxPQUFPLEVBQ2hCLFdBQVcsRUFBRSxNQUFNLEVBQ25CLEdBQUcsRUFBRSxLQUFLOzs7OztHQXFIWCJ9
@@ -1 +1 @@
1
- {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6B,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEpF,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,WAAW,EAA2B,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,aAAa,CACjC,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAgIX"}
1
+ {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,YAAY,EAAE,OAAO,EACrB,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAqHX"}
@@ -1,13 +1,12 @@
1
- import { AztecAddress } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { NO_WAIT } from '@aztec/aztec.js/contracts';
2
3
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
3
- import { Fr } from '@aztec/foundation/fields';
4
- import { createOrRetrieveAccount } from '../utils/accounts.js';
5
- import { printGasEstimates } from '../utils/options/fees.js';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
6
6
  import { printProfileResult } from '../utils/profiling.js';
7
- import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
8
- export async function createAccount(client, accountType, secretKey, publicKey, alias, registerOnly, publicDeploy, skipInitialization, wait, feeOpts, json, verbose, debugLogger, log) {
7
+ export async function createAccount(wallet, aztecNode, accountType, secretKey, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, json, verbose, debugLogger, log) {
9
8
  secretKey ??= Fr.random();
10
- const account = await createOrRetrieveAccount(client, undefined /* address, we don't have it yet */ , undefined /* db, as we want to create from scratch */ , secretKey, accountType, Fr.ZERO, publicKey);
9
+ const account = await wallet.createOrRetrieveAccount(undefined /* address, we don't have it yet */ , secretKey, accountType, Fr.ZERO, publicKey);
11
10
  const { salt } = account.getInstance();
12
11
  const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
13
12
  const out = {};
@@ -20,7 +19,6 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
20
19
  out.partialAddress = partialAddress;
21
20
  out.salt = salt;
22
21
  out.initHash = account.getInstance().initializationHash;
23
- out.deployer = account.getInstance().deployer;
24
22
  } else {
25
23
  log(`\nNew account:\n`);
26
24
  log(`Address: ${address.toString()}`);
@@ -31,86 +29,82 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
31
29
  log(`Partial address: ${partialAddress.toString()}`);
32
30
  log(`Salt: ${salt.toString()}`);
33
31
  log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
34
- log(`Deployer: ${account.getInstance().deployer.toString()}`);
35
32
  }
36
- let tx;
33
+ let txHash;
37
34
  let txReceipt;
38
- if (registerOnly) {
39
- await account.register();
40
- } else {
41
- const wallet = await account.getWallet();
42
- const deployOpts = {
43
- skipClassPublication: !publicDeploy,
35
+ if (!registerOnly) {
36
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
37
+ const delegatedDeployment = deployer && !account.address.equals(deployer);
38
+ const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
39
+ const deployAccountOpts = {
40
+ skipClassPublication: !registerClass,
44
41
  skipInstancePublication: !publicDeploy,
45
- skipInitialization: skipInitialization,
46
- ...await feeOpts.toDeployAccountOpts(wallet)
42
+ skipInitialization,
43
+ from,
44
+ fee: {
45
+ paymentMethod,
46
+ gasSettings
47
+ }
47
48
  };
48
- /*
49
- * This is usually handled by accountManager.create(), but we're accessing the lower
50
- * level method to get gas and timings. That means we have to replicate some of the logic here.
51
- * In case we're initializing and/or publishing our own account, we need to hijack the payment method for the fee,
52
- * wrapping it in the one that will make use of the freshly deployed account's
53
- * entrypoint. For reference, see aztec.js/src/account_manager.ts:sendAccountContractSetupTx()
54
- * Also, salt and universalDeploy have to be explicitly provided
55
- */ deployOpts.fee = !deployOpts?.deployWallet && deployOpts?.fee ? {
56
- ...deployOpts.fee,
57
- paymentMethod: await account.getSelfPaymentMethod(deployOpts.fee.paymentMethod)
58
- } : deployOpts?.fee;
59
- const deployMethod = await account.getDeployMethod(deployOpts.deployWallet);
49
+ const deployMethod = await account.getDeployMethod();
50
+ const { estimatedGas, stats } = await deployMethod.simulate({
51
+ ...deployAccountOpts,
52
+ fee: {
53
+ ...deployAccountOpts.fee,
54
+ estimateGas: true
55
+ }
56
+ });
60
57
  if (feeOpts.estimateOnly) {
61
- const gas = await deployMethod.estimateGas({
62
- ...deployOpts,
63
- from: AztecAddress.ZERO,
64
- universalDeploy: true,
65
- contractAddressSalt: salt
66
- });
67
58
  if (json) {
68
59
  out.fee = {
69
60
  gasLimits: {
70
- da: gas.gasLimits.daGas,
71
- l2: gas.gasLimits.l2Gas
61
+ da: estimatedGas.gasLimits.daGas,
62
+ l2: estimatedGas.gasLimits.l2Gas
72
63
  },
73
64
  teardownGasLimits: {
74
- da: gas.teardownGasLimits.daGas,
75
- l2: gas.teardownGasLimits
65
+ da: estimatedGas.teardownGasLimits.daGas,
66
+ l2: estimatedGas.teardownGasLimits
76
67
  }
77
68
  };
78
- } else {
79
- printGasEstimates(feeOpts, gas, log);
80
69
  }
81
70
  } else {
82
- const provenTx = await deployMethod.prove({
83
- ...deployOpts,
84
- from: AztecAddress.ZERO,
85
- universalDeploy: true,
86
- contractAddressSalt: salt
87
- });
88
71
  if (verbose) {
89
- printProfileResult(provenTx.stats, log);
72
+ printProfileResult(stats, log);
90
73
  }
91
- tx = provenTx.send();
92
- const txHash = await tx.getTxHash();
93
- debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
94
- out.txHash = txHash;
95
- if (wait) {
96
- if (!json) {
97
- log(`\nWaiting for account contract deployment...`);
98
- }
99
- txReceipt = await tx.wait({
100
- timeout: DEFAULT_TX_TIMEOUT_S
101
- });
74
+ if (!json) {
75
+ log(`\nWaiting for account contract deployment...`);
76
+ }
77
+ const result = await deployMethod.send({
78
+ ...deployAccountOpts,
79
+ fee: deployAccountOpts.fee ? {
80
+ ...deployAccountOpts.fee,
81
+ gasSettings: estimatedGas
82
+ } : undefined,
83
+ wait: wait ? {
84
+ timeout: DEFAULT_TX_TIMEOUT_S,
85
+ returnReceipt: true
86
+ } : NO_WAIT
87
+ });
88
+ const isReceipt = (data)=>'txHash' in data;
89
+ if (isReceipt(result)) {
90
+ txReceipt = result;
91
+ txHash = result.txHash;
102
92
  out.txReceipt = {
103
93
  status: txReceipt.status,
104
94
  transactionFee: txReceipt.transactionFee
105
95
  };
96
+ } else {
97
+ txHash = result;
106
98
  }
99
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
100
+ out.txHash = txHash;
107
101
  }
108
102
  }
109
103
  if (json) {
110
104
  log(prettyPrintJSON(out));
111
105
  } else {
112
- if (tx) {
113
- log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
106
+ if (txHash) {
107
+ log(`Deploy tx hash: ${txHash.toString()}`);
114
108
  }
115
109
  if (txReceipt) {
116
110
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -1,4 +1,5 @@
1
- import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
- export declare function createAuthwit(wallet: AccountWalletWithSecretKey, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/aztec.js").AuthWitness>;
4
- //# sourceMappingURL=create_authwit.d.ts.map
3
+ import type { CLIWallet } from '../utils/wallet.js';
4
+ export declare function createAuthwit(wallet: CLIWallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/stdlib/auth-witness").AuthWitness>;
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2F1dGh3aXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hdXRod2l0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRzlELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixhQUFhLENBQ2pDLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyw2REF1QlgifQ==