@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
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 sandbox 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 --sandbox
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
+
package/dest/bin/index.js CHANGED
@@ -1,18 +1,25 @@
1
- import { Fr, computeSecretHash, fileURLToPath } from '@aztec/aztec.js';
1
+ import { computeSecretHash } from '@aztec/aztec.js/crypto';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
4
+ import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
2
5
  import { LOCALHOST } from '@aztec/cli/cli-utils';
3
6
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
4
7
  import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
8
+ import { getPackageVersion } from '@aztec/stdlib/update-checker';
5
9
  import { Argument, Command, Option } from 'commander';
6
- import { mkdirSync, readFileSync } from 'fs';
10
+ import { mkdirSync } from 'fs';
7
11
  import { homedir } from 'os';
8
12
  import { dirname, join, resolve } from 'path';
13
+ import { fileURLToPath } from 'url';
9
14
  import { injectCommands } from '../cmds/index.js';
10
15
  import { Aliases, WalletDB } from '../storage/wallet_db.js';
16
+ import { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
11
17
  import { createAliasOption } from '../utils/options/index.js';
12
- import { PXEWrapper } from '../utils/pxe_wrapper.js';
18
+ import { CLIWallet } from '../utils/wallet.js';
13
19
  const userLog = createConsoleLogger();
14
20
  const debugLogger = createLogger('wallet');
15
- const { WALLET_DATA_DIRECTORY = join(homedir(), '.aztec/wallet'), PXE_PROVER = 'none' } = process.env;
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
16
23
  function injectInternalCommands(program, log, db) {
17
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)=>{
18
25
  value = db.tryRetrieveAlias(value) || value;
@@ -33,38 +40,53 @@ function injectInternalCommands(program, log, db) {
33
40
  const options = command.optsWithGlobals();
34
41
  const { alias } = options;
35
42
  const value = Fr.random();
36
- const hash = computeSecretHash(value);
43
+ const hash = await computeSecretHash(value);
37
44
  await db.storeAlias('secrets', alias, Buffer.from(value.toString()), log);
38
45
  await db.storeAlias('secrets', `${alias}:hash`, Buffer.from(hash.toString()), log);
39
46
  });
40
47
  return program;
41
48
  }
42
49
  /** CLI wallet main entrypoint */ async function main() {
43
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
44
- const walletVersion = JSON.parse(readFileSync(packageJsonPath).toString()).version;
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).option('-p, --prover <string>', 'wasm|native|none', PXE_PROVER).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)=>{
49
- const { dataDir, remotePxe, nodeUrl, prover } = command.optsWithGlobals();
50
- if (!remotePxe) {
51
- debugLogger.info('Using local PXE service');
52
- const proverEnabled = prover !== 'none';
53
- const bbBinaryPath = prover === 'native' ? resolve(dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/cpp/build/bin/bb') : undefined;
54
- const bbWorkingDirectory = dataDir + '/bb';
55
- mkdirSync(bbWorkingDirectory, {
56
- recursive: true
57
- });
58
- const overridePXEConfig = {
59
- proverEnabled,
60
- bbBinaryPath: prover === 'native' ? bbBinaryPath : undefined,
61
- bbWorkingDirectory: prover === 'native' ? bbWorkingDirectory : undefined
62
- };
63
- await pxeWrapper.init(nodeUrl, join(dataDir, 'pxe'), overridePXEConfig);
64
- }
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([
55
+ 'wasm',
56
+ 'native',
57
+ 'none'
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
+ const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
60
+ const proverEnabled = prover !== 'none';
61
+ const bbBinaryPath = prover === 'native' ? process.env.BB_BINARY_PATH ?? resolve(dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/cpp/build/bin/bb') : undefined;
62
+ const bbWorkingDirectory = dataDir + '/bb';
63
+ mkdirSync(bbWorkingDirectory, {
64
+ recursive: true
65
+ });
66
+ const overridePXEConfig = {
67
+ proverEnabled,
68
+ bbBinaryPath: prover === 'native' ? bbBinaryPath : undefined,
69
+ bbWorkingDirectory: prover === 'native' ? bbWorkingDirectory : undefined,
70
+ dataDirectory: join(dataDir, 'pxe')
71
+ };
72
+ const node = createAztecNodeClient(nodeUrl);
73
+ const wallet = await CLIWallet.create(node, userLog, db, overridePXEConfig);
74
+ walletAndNodeWrapper.setNodeAndWallet(node, wallet);
65
75
  await db.init(await openStoreAt(dataDir));
76
+ let protocolContractsRegistered;
77
+ try {
78
+ protocolContractsRegistered = !!await db.retrieveAlias('contracts:ContractClassRegistry');
79
+ // eslint-disable-next-line no-empty
80
+ } catch {}
81
+ if (!protocolContractsRegistered) {
82
+ userLog('Registering protocol contract aliases...');
83
+ for (const [name, address] of Object.entries(ProtocolContractAddress)){
84
+ await db.storeAlias('contracts', name, Buffer.from(address.toString()), userLog);
85
+ await db.storeAlias('artifacts', address.toString(), Buffer.from(`${name.slice(0, 1).toUpperCase()}${name.slice(1)}`), userLog);
86
+ }
87
+ }
66
88
  });
67
- injectCommands(program, userLog, debugLogger, db, pxeWrapper);
89
+ injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
68
90
  injectInternalCommands(program, userLog, db);
69
91
  await program.parseAsync(process.argv);
70
92
  }
@@ -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, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/aztec.js").FieldsOf<import("@aztec/aztec.js").TxReceipt>>;
4
+ export declare function authorizeAction(wallet: Wallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/foundation/types").FieldsOf<import("@aztec/aztec.js/tx").TxReceipt>>;
4
5
  //# sourceMappingURL=authorize_action.d.ts.map
@@ -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;AAEnD,wBAAsB,eAAe,CACnC,MAAM,EAAE,0BAA0B,EAClC,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,+FA6BX"}
@@ -1,17 +1,21 @@
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
- export async function authorizeAction(wallet, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
4
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
5
+ export async function authorizeAction(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
4
6
  const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
5
7
  if (isPrivate) {
6
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');
7
9
  }
8
10
  const contract = await Contract.at(contractAddress, contractArtifact, wallet);
9
11
  const action = contract.methods[functionName](...functionArgs);
10
- const setAuthwitnessInteraction = await wallet.setPublicAuthWit({
12
+ const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(wallet, from, {
11
13
  caller,
12
14
  action
13
15
  }, true);
14
- const witness = await setAuthwitnessInteraction.send().wait();
16
+ const witness = await setAuthwitnessInteraction.send().wait({
17
+ timeout: DEFAULT_TX_TIMEOUT_S
18
+ });
15
19
  log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
16
20
  return witness;
17
21
  }
@@ -1,6 +1,6 @@
1
- import { type PXE } from '@aztec/aztec.js';
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
2
  import { Fr } from '@aztec/foundation/fields';
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]>;
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
6
  //# sourceMappingURL=bridge_fee_juice.d.ts.map
@@ -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;AAItD,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;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,15 @@
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, createL1Clients } from '@aztec/ethereum';
4
+ import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
4
5
  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) {
6
+ import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
7
+ export async function bridgeL1FeeJuice(amount, recipient, node, l1RpcUrls, chainId, privateKey, mnemonic, mint, json, wait, interval = 60_000, log, debugLogger) {
6
8
  // Prepare L1 client
7
9
  const chain = createEthereumChain(l1RpcUrls, chainId);
8
- const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
9
- const { protocolContractAddresses: { feeJuice: feeJuiceAddress } } = await pxe.getPXEInfo();
10
+ const client = createExtendedL1Client(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
10
11
  // Setup portal manager
11
- const portal = await L1FeeJuicePortalManager.new(pxe, publicClient, walletClient, debugLogger);
12
+ const portal = await L1FeeJuicePortalManager.new(node, client, debugLogger);
12
13
  const { claimAmount, claimSecret, messageHash, messageLeafIndex } = await portal.bridgeTokensPublic(recipient, amount, mint);
13
14
  if (json) {
14
15
  const out = {
@@ -33,7 +34,7 @@ export async function bridgeL1FeeJuice(amount, recipient, pxe, l1RpcUrls, chainI
33
34
  const delayedCheck = (delay)=>{
34
35
  return new Promise((resolve, reject)=>{
35
36
  setTimeout(()=>{
36
- void pxe.getL1ToL2MembershipWitness(feeJuiceAddress, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
37
+ void getNonNullifiedL1ToL2MessageWitness(node, ProtocolContractAddress.FeeJuice, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
37
38
  }, delay);
38
39
  });
39
40
  };
@@ -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
+ 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>;
4
6
  //# sourceMappingURL=check_tx.d.ts.map
@@ -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,150 @@
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} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`);
21
+ if (receipt.error) {
22
+ log(` Error: ${receipt.error}`);
23
+ }
24
+ if (!effectsInBlock) {
25
+ return;
26
+ }
27
+ const effects = effectsInBlock.data;
28
+ const artifactMap = await getKnownArtifacts(wallet);
29
+ log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
30
+ if (receipt.transactionFee) {
31
+ log(` Fee: ${receipt.transactionFee.toString()}`);
32
+ }
33
+ // Public logs
34
+ const publicLogs = effects.publicLogs;
35
+ if (publicLogs.length > 0) {
36
+ log(' Logs:');
37
+ for (const publicLog of publicLogs){
38
+ log(` ${publicLog.toHumanReadable()}`);
39
+ }
40
+ }
41
+ // Public data writes
42
+ const writes = effects.publicDataWrites;
43
+ if (writes.length > 0) {
44
+ log(' Public data writes:');
45
+ for (const write of writes){
46
+ log(` Leaf ${write.leafSlot.toString()} = ${write.value.toString()}`);
47
+ }
48
+ }
49
+ // Created notes
50
+ const notes = effects.noteHashes;
51
+ if (notes.length > 0) {
52
+ log(' Created notes:');
53
+ log(` Total: ${notes.length}`);
54
+ for (const note of notes){
55
+ log(` Note hash: ${note.toShortString()}`);
56
+ }
57
+ }
58
+ // Nullifiers
59
+ const nullifierCount = effects.nullifiers.length;
60
+ const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
61
+ if (nullifierCount > 0) {
62
+ log(' Nullifiers:');
63
+ for (const nullifier of effects.nullifiers){
64
+ const deployed = deployNullifiers[nullifier.toString()];
65
+ const note = deployed ? (await wallet.getNotes({
66
+ siloedNullifier: nullifier,
67
+ contractAddress: deployed
68
+ }))[0] : undefined;
69
+ const initialized = initNullifiers[nullifier.toString()];
70
+ const registered = classNullifiers[nullifier.toString()];
71
+ if (nullifier.toBuffer().equals(txHash.toBuffer())) {
72
+ log(` Transaction hash nullifier ${nullifier.toShortString()}`);
73
+ } else if (note) {
74
+ inspectNote(note, artifactMap, log, `Nullifier ${nullifier.toShortString()} for note`);
75
+ } else if (deployed) {
76
+ log(` Contract ${toFriendlyAddress(deployed, artifactMap)} deployed via nullifier ${nullifier.toShortString()}`);
77
+ } else if (initialized) {
78
+ log(` Contract ${toFriendlyAddress(initialized, artifactMap)} initialized via nullifier ${nullifier.toShortString()}`);
79
+ } else if (registered) {
80
+ log(` Class ${registered} registered via nullifier ${nullifier.toShortString()}`);
81
+ } else {
82
+ log(` Unknown nullifier ${nullifier.toString()}`);
83
+ }
84
+ }
85
+ }
86
+ // L2 to L1 messages
87
+ if (effects.l2ToL1Msgs.length > 0) {
88
+ log(` L2 to L1 messages:`);
89
+ for (const msg of effects.l2ToL1Msgs){
90
+ log(` ${msg.toString()}`);
91
+ }
92
+ }
93
+ }
94
+ function inspectNote(note, artifactMap, log, text = 'Note') {
95
+ const artifact = artifactMap[note.contractAddress.toString()];
96
+ const contract = artifact?.name ?? note.contractAddress.toString();
97
+ log(` ${text} at ${contract}`);
98
+ log(` Recipient: ${toFriendlyAddress(note.recipient, artifactMap)}`);
99
+ for (const field of note.note.items){
100
+ log(` ${field.toString()}`);
101
+ }
102
+ }
103
+ function toFriendlyAddress(address, artifactMap) {
104
+ const artifact = artifactMap[address.toString()];
105
+ if (!artifact) {
106
+ return address.toString();
107
+ }
108
+ return `${artifact.name}<${address.toString()}>`;
109
+ }
110
+ async function getKnownNullifiers(wallet, artifactMap) {
111
+ const knownContracts = await wallet.getContracts();
112
+ const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
113
+ const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
114
+ const initNullifiers = {};
115
+ const deployNullifiers = {};
116
+ const classNullifiers = {};
117
+ for (const contract of knownContracts){
118
+ initNullifiers[(await siloNullifier(contract, contract.toField())).toString()] = contract;
119
+ deployNullifiers[(await siloNullifier(deployerAddress, contract.toField())).toString()] = contract;
120
+ }
121
+ for (const artifact of Object.values(artifactMap)){
122
+ classNullifiers[(await siloNullifier(classRegistryAddress, artifact.classId)).toString()] = `${artifact.name}Class<${artifact.classId}>`;
123
+ }
124
+ return {
125
+ initNullifiers,
126
+ deployNullifiers,
127
+ classNullifiers
128
+ };
129
+ }
130
+ async function getKnownArtifacts(wallet) {
131
+ const knownContractAddresses = await wallet.getContracts();
132
+ const knownContracts = (await Promise.all(knownContractAddresses.map((contractAddress)=>wallet.getContractMetadata(contractAddress)))).map((contractMetadata)=>contractMetadata.contractInstance);
133
+ const classIds = [
134
+ ...new Set(knownContracts.map((contract)=>contract?.currentContractClassId))
135
+ ];
136
+ const knownArtifacts = (await Promise.all(classIds.map((classId)=>classId ? wallet.getContractClassMetadata(classId) : undefined))).map((contractClassMetadata)=>contractClassMetadata ? {
137
+ ...contractClassMetadata.artifact,
138
+ classId: contractClassMetadata.contractClass?.id
139
+ } : undefined);
140
+ const map = {};
141
+ for (const instance of knownContracts){
142
+ if (instance) {
143
+ const artifact = knownArtifacts.find((a)=>a?.classId?.equals(instance.currentContractClassId));
144
+ if (artifact) {
145
+ map[instance.address.toString()] = artifact;
146
+ }
147
+ }
148
+ }
149
+ return map;
150
+ }
@@ -1,11 +1,12 @@
1
- import type { PXE } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
3
  import { Fr } from '@aztec/foundation/fields';
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, debugLogger: Logger, log: LogFn): Promise<{
5
+ import { CLIFeeArgs } from '../utils/options/fees.js';
6
+ import { type AccountType, CLIWallet } from '../utils/wallet.js';
7
+ 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
8
  alias: string | undefined;
8
- address: import("@aztec/aztec.js").AztecAddress;
9
+ address: AztecAddress;
9
10
  secretKey: Fr;
10
11
  salt: Fr;
11
12
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEjE,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;AAE5E,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,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAkGX"}
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;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,KAAK,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,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;;;;;GAiHX"}
@@ -1,11 +1,12 @@
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
1
2
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
2
3
  import { Fr } from '@aztec/foundation/fields';
3
- import { createOrRetrieveAccount } from '../utils/accounts.js';
4
- import { printGasEstimates } from '../utils/options/fees.js';
5
- export async function createAccount(client, accountType, secretKey, publicKey, alias, registerOnly, publicDeploy, skipInitialization, wait, feeOpts, json, debugLogger, log) {
4
+ import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
5
+ import { printProfileResult } from '../utils/profiling.js';
6
+ export async function createAccount(wallet, aztecNode, accountType, secretKey, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, json, verbose, debugLogger, log) {
6
7
  secretKey ??= Fr.random();
7
- 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);
8
- const salt = account.getInstance().salt;
8
+ const account = await wallet.createOrRetrieveAccount(undefined /* address, we don't have it yet */ , secretKey, accountType, Fr.ZERO, publicKey);
9
+ const { salt } = account.getInstance();
9
10
  const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
10
11
  const out = {};
11
12
  if (json) {
@@ -17,7 +18,6 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
17
18
  out.partialAddress = partialAddress;
18
19
  out.salt = salt;
19
20
  out.initHash = account.getInstance().initializationHash;
20
- out.deployer = account.getInstance().deployer;
21
21
  } else {
22
22
  log(`\nNew account:\n`);
23
23
  log(`Address: ${address.toString()}`);
@@ -28,46 +28,65 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
28
28
  log(`Partial address: ${partialAddress.toString()}`);
29
29
  log(`Salt: ${salt.toString()}`);
30
30
  log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
31
- log(`Deployer: ${account.getInstance().deployer.toString()}`);
32
31
  }
33
32
  let tx;
34
33
  let txReceipt;
35
- if (registerOnly) {
36
- await account.register();
37
- } else {
38
- const wallet = await account.getWallet();
39
- const deployOpts = {
40
- skipClassRegistration: !publicDeploy,
41
- skipPublicDeployment: !publicDeploy,
42
- skipInitialization: skipInitialization,
43
- ...await feeOpts.toDeployAccountOpts(wallet)
34
+ if (!registerOnly) {
35
+ const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
36
+ const delegatedDeployment = deployer && !account.address.equals(deployer);
37
+ const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
38
+ const deployAccountOpts = {
39
+ skipClassPublication: !registerClass,
40
+ skipInstancePublication: !publicDeploy,
41
+ skipInitialization,
42
+ from,
43
+ fee: {
44
+ paymentMethod,
45
+ gasSettings
46
+ }
44
47
  };
48
+ const deployMethod = await account.getDeployMethod();
49
+ const { estimatedGas, stats } = await deployMethod.simulate({
50
+ ...deployAccountOpts,
51
+ fee: {
52
+ ...deployAccountOpts.fee,
53
+ estimateGas: true
54
+ }
55
+ });
45
56
  if (feeOpts.estimateOnly) {
46
- const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
47
57
  if (json) {
48
58
  out.fee = {
49
59
  gasLimits: {
50
- da: gas.gasLimits.daGas,
51
- l2: gas.gasLimits.l2Gas
60
+ da: estimatedGas.gasLimits.daGas,
61
+ l2: estimatedGas.gasLimits.l2Gas
52
62
  },
53
63
  teardownGasLimits: {
54
- da: gas.teardownGasLimits.daGas,
55
- l2: gas.teardownGasLimits
64
+ da: estimatedGas.teardownGasLimits.daGas,
65
+ l2: estimatedGas.teardownGasLimits
56
66
  }
57
67
  };
58
- } else {
59
- printGasEstimates(feeOpts, gas, log);
60
68
  }
61
69
  } else {
62
- tx = account.deploy(deployOpts);
70
+ tx = deployMethod.send({
71
+ ...deployAccountOpts,
72
+ fee: deployAccountOpts.fee ? {
73
+ ...deployAccountOpts.fee,
74
+ gasSettings: estimatedGas
75
+ } : undefined
76
+ });
77
+ if (verbose) {
78
+ printProfileResult(stats, log);
79
+ }
63
80
  const txHash = await tx.getTxHash();
64
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
81
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
65
82
  out.txHash = txHash;
66
83
  if (wait) {
67
84
  if (!json) {
68
85
  log(`\nWaiting for account contract deployment...`);
69
86
  }
70
- txReceipt = await tx.wait();
87
+ txReceipt = await tx.wait({
88
+ timeout: DEFAULT_TX_TIMEOUT_S
89
+ });
71
90
  out.txReceipt = {
72
91
  status: txReceipt.status,
73
92
  transactionFee: txReceipt.transactionFee
@@ -79,7 +98,7 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
79
98
  log(prettyPrintJSON(out));
80
99
  } else {
81
100
  if (tx) {
82
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
101
+ log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
83
102
  }
84
103
  if (txReceipt) {
85
104
  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>;
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>;
4
5
  //# sourceMappingURL=create_authwit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/create_authwit.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;AAEnD,wBAAsB,aAAa,CACjC,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,kDAuBX"}
1
+ {"version":3,"file":"create_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/create_authwit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,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,6DAuBX"}
@@ -1,15 +1,15 @@
1
- import { Contract } from '@aztec/aztec.js';
1
+ import { Contract } from '@aztec/aztec.js/contracts';
2
2
  import { prepTx } from '@aztec/cli/utils';
3
- export async function createAuthwit(wallet, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
3
+ export async function createAuthwit(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
4
4
  const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
5
5
  if (!isPrivate) {
6
6
  throw new Error('Cannot create an authwit for a public function. To allow a third party to call a public function, please authorize the action via the authorize-action command');
7
7
  }
8
8
  const contract = await Contract.at(contractAddress, contractArtifact, wallet);
9
- const action = contract.methods[functionName](...functionArgs);
10
- const witness = await wallet.createAuthWit({
9
+ const call = await contract.methods[functionName](...functionArgs).getFunctionCall();
10
+ const witness = await wallet.createAuthWit(from, {
11
11
  caller,
12
- action
12
+ call
13
13
  });
14
14
  log(`Created authorization witness for action ${functionName} on contract ${contractAddress} for caller ${caller}`);
15
15
  return witness;
@@ -1,6 +1,9 @@
1
- import { type AccountWalletWithSecretKey, Fr, type PXE } from '@aztec/aztec.js';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
4
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
5
  import { PublicKeys } from '@aztec/stdlib/keys';
4
- import { type IFeeOpts } from '../utils/options/fees.js';
5
- export declare function deploy(client: PXE, wallet: AccountWalletWithSecretKey, artifactPath: string, json: boolean, publicKeys: PublicKeys | undefined, rawArgs: any[], salt: Fr | undefined, initializer: string | undefined, skipPublicDeployment: boolean, skipClassRegistration: boolean, skipInitialization: boolean | undefined, universalDeploy: boolean | undefined, wait: boolean, feeOpts: IFeeOpts, debugLogger: Logger, log: LogFn, logJson: (output: any) => void): Promise<import("@aztec/aztec.js").AztecAddress | undefined>;
6
+ import { CLIFeeArgs } from '../utils/options/fees.js';
7
+ import type { CLIWallet } from '../utils/wallet.js';
8
+ export declare function deploy(wallet: CLIWallet, node: AztecNode, deployer: AztecAddress, artifactPath: string, json: boolean, publicKeys: PublicKeys | undefined, rawArgs: any[], salt: Fr | undefined, initializer: string | undefined, skipInstancePublication: boolean, skipClassPublication: boolean, skipInitialization: boolean | undefined, wait: boolean, feeOpts: CLIFeeArgs, verbose: boolean, timeout: number | undefined, debugLogger: Logger, log: LogFn): Promise<AztecAddress | undefined>;
6
9
  //# sourceMappingURL=deploy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAuC,EAAE,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAErH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAE5E,wBAAsB,MAAM,CAC1B,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,OAAO,EAAE,GAAG,EAAE,EACd,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,oBAAoB,EAAE,OAAO,EAC7B,qBAAqB,EAAE,OAAO,EAC9B,kBAAkB,EAAE,OAAO,GAAG,SAAS,EACvC,eAAe,EAAE,OAAO,GAAG,SAAS,EACpC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,+DAuF/B"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,MAAM,CAC1B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,OAAO,EAAE,GAAG,EAAE,EACd,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,kBAAkB,EAAE,OAAO,GAAG,SAAS,EACvC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,YAAuB,EACtC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,qCAgGX"}