@aztec/cli-wallet 0.0.0-test.0

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 (94) hide show
  1. package/README.md +2 -0
  2. package/dest/bin/index.d.ts +2 -0
  3. package/dest/bin/index.d.ts.map +1 -0
  4. package/dest/bin/index.js +75 -0
  5. package/dest/cmds/add_authwit.d.ts +4 -0
  6. package/dest/cmds/add_authwit.d.ts.map +1 -0
  7. package/dest/cmds/add_authwit.js +4 -0
  8. package/dest/cmds/authorize_action.d.ts +4 -0
  9. package/dest/cmds/authorize_action.d.ts.map +1 -0
  10. package/dest/cmds/authorize_action.js +17 -0
  11. package/dest/cmds/bridge_fee_juice.d.ts +6 -0
  12. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -0
  13. package/dest/cmds/bridge_fee_juice.js +52 -0
  14. package/dest/cmds/cancel_tx.d.ts +11 -0
  15. package/dest/cmds/cancel_tx.d.ts.map +1 -0
  16. package/dest/cmds/cancel_tx.js +38 -0
  17. package/dest/cmds/check_tx.d.ts +4 -0
  18. package/dest/cmds/check_tx.d.ts.map +1 -0
  19. package/dest/cmds/check_tx.js +11 -0
  20. package/dest/cmds/create_account.d.ts +12 -0
  21. package/dest/cmds/create_account.d.ts.map +1 -0
  22. package/dest/cmds/create_account.js +94 -0
  23. package/dest/cmds/create_authwit.d.ts +4 -0
  24. package/dest/cmds/create_authwit.d.ts.map +1 -0
  25. package/dest/cmds/create_authwit.js +16 -0
  26. package/dest/cmds/deploy.d.ts +6 -0
  27. package/dest/cmds/deploy.d.ts.map +1 -0
  28. package/dest/cmds/deploy.js +83 -0
  29. package/dest/cmds/deploy_account.d.ts +9 -0
  30. package/dest/cmds/deploy_account.d.ts.map +1 -0
  31. package/dest/cmds/deploy_account.js +80 -0
  32. package/dest/cmds/import_test_accounts.d.ts +5 -0
  33. package/dest/cmds/import_test_accounts.d.ts.map +1 -0
  34. package/dest/cmds/import_test_accounts.js +42 -0
  35. package/dest/cmds/index.d.ts +6 -0
  36. package/dest/cmds/index.d.ts.map +1 -0
  37. package/dest/cmds/index.js +223 -0
  38. package/dest/cmds/register_contract.d.ts +4 -0
  39. package/dest/cmds/register_contract.d.ts.map +1 -0
  40. package/dest/cmds/register_contract.js +14 -0
  41. package/dest/cmds/register_sender.d.ts +4 -0
  42. package/dest/cmds/register_sender.d.ts.map +1 -0
  43. package/dest/cmds/register_sender.js +4 -0
  44. package/dest/cmds/send.d.ts +11 -0
  45. package/dest/cmds/send.d.ts.map +1 -0
  46. package/dest/cmds/send.js +49 -0
  47. package/dest/cmds/simulate.d.ts +4 -0
  48. package/dest/cmds/simulate.d.ts.map +1 -0
  49. package/dest/cmds/simulate.js +26 -0
  50. package/dest/storage/wallet_db.d.ts +65 -0
  51. package/dest/storage/wallet_db.d.ts.map +1 -0
  52. package/dest/storage/wallet_db.js +209 -0
  53. package/dest/utils/accounts.d.ts +11 -0
  54. package/dest/utils/accounts.d.ts.map +1 -0
  55. package/dest/utils/accounts.js +87 -0
  56. package/dest/utils/ecdsa.d.ts +4 -0
  57. package/dest/utils/ecdsa.d.ts.map +1 -0
  58. package/dest/utils/ecdsa.js +13 -0
  59. package/dest/utils/options/fees.d.ts +41 -0
  60. package/dest/utils/options/fees.d.ts.map +1 -0
  61. package/dest/utils/options/fees.js +283 -0
  62. package/dest/utils/options/index.d.ts +3 -0
  63. package/dest/utils/options/index.d.ts.map +1 -0
  64. package/dest/utils/options/index.js +2 -0
  65. package/dest/utils/options/options.d.ts +20 -0
  66. package/dest/utils/options/options.d.ts.map +1 -0
  67. package/dest/utils/options/options.js +122 -0
  68. package/dest/utils/pxe_wrapper.d.ts +10 -0
  69. package/dest/utils/pxe_wrapper.d.ts.map +1 -0
  70. package/dest/utils/pxe_wrapper.js +21 -0
  71. package/package.json +102 -0
  72. package/src/bin/index.ts +127 -0
  73. package/src/cmds/add_authwit.ts +13 -0
  74. package/src/cmds/authorize_action.ts +36 -0
  75. package/src/cmds/bridge_fee_juice.ts +88 -0
  76. package/src/cmds/cancel_tx.ts +62 -0
  77. package/src/cmds/check_tx.ts +12 -0
  78. package/src/cmds/create_account.ts +120 -0
  79. package/src/cmds/create_authwit.ts +35 -0
  80. package/src/cmds/deploy.ts +113 -0
  81. package/src/cmds/deploy_account.ts +92 -0
  82. package/src/cmds/import_test_accounts.ts +47 -0
  83. package/src/cmds/index.ts +641 -0
  84. package/src/cmds/register_contract.ts +20 -0
  85. package/src/cmds/register_sender.ts +7 -0
  86. package/src/cmds/send.ts +62 -0
  87. package/src/cmds/simulate.ts +42 -0
  88. package/src/storage/wallet_db.ts +243 -0
  89. package/src/utils/accounts.ts +102 -0
  90. package/src/utils/ecdsa.ts +15 -0
  91. package/src/utils/options/fees.ts +365 -0
  92. package/src/utils/options/index.ts +2 -0
  93. package/src/utils/options/options.ts +175 -0
  94. package/src/utils/pxe_wrapper.ts +26 -0
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # Aztec wallet Documentation
2
+
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,75 @@
1
+ import { Fr, computeSecretHash, fileURLToPath } from '@aztec/aztec.js';
2
+ import { LOCALHOST } from '@aztec/cli/cli-utils';
3
+ import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
4
+ import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
5
+ import { Argument, Command, Option } from 'commander';
6
+ import { mkdirSync, readFileSync } from 'fs';
7
+ import { homedir } from 'os';
8
+ import { dirname, join, resolve } from 'path';
9
+ import { injectCommands } from '../cmds/index.js';
10
+ import { Aliases, WalletDB } from '../storage/wallet_db.js';
11
+ import { createAliasOption } from '../utils/options/index.js';
12
+ import { PXEWrapper } from '../utils/pxe_wrapper.js';
13
+ const userLog = createConsoleLogger();
14
+ const debugLogger = createLogger('wallet');
15
+ const { WALLET_DATA_DIRECTORY = join(homedir(), '.aztec/wallet'), PXE_PROVER = 'none' } = process.env;
16
+ function injectInternalCommands(program, log, db) {
17
+ 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
+ value = db.tryRetrieveAlias(value) || value;
19
+ await db.storeAlias(type, key, value, log);
20
+ });
21
+ program.command('get-alias').description('Shows stored aliases').addArgument(new Argument('[alias]', 'Alias to retrieve')).action(async (alias)=>{
22
+ if (alias?.includes(':')) {
23
+ const value = await db.retrieveAlias(alias);
24
+ log(value);
25
+ } else {
26
+ const aliases = await db.listAliases(alias);
27
+ for (const { key, value } of aliases){
28
+ log(`${key} -> ${value}`);
29
+ }
30
+ }
31
+ });
32
+ program.command('create-secret').description('Creates an aliased secret to use in other commands').addOption(createAliasOption('Key to alias the secret with', false).makeOptionMandatory(true)).action(async (_options, command)=>{
33
+ const options = command.optsWithGlobals();
34
+ const { alias } = options;
35
+ const value = Fr.random();
36
+ const hash = computeSecretHash(value);
37
+ await db.storeAlias('secrets', alias, Buffer.from(value.toString()), log);
38
+ await db.storeAlias('secrets', `${alias}:hash`, Buffer.from(hash.toString()), log);
39
+ });
40
+ return program;
41
+ }
42
+ /** 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;
45
+ const db = WalletDB.getInstance();
46
+ const pxeWrapper = new PXEWrapper();
47
+ 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
+ }
65
+ await db.init(await openStoreAt(dataDir));
66
+ });
67
+ injectCommands(program, userLog, debugLogger, db, pxeWrapper);
68
+ injectInternalCommands(program, userLog, db);
69
+ await program.parseAsync(process.argv);
70
+ }
71
+ main().catch((err)=>{
72
+ debugLogger.error(`Error in command execution`);
73
+ debugLogger.error(err + '\n' + err.stack);
74
+ process.exit(1);
75
+ });
@@ -0,0 +1,4 @@
1
+ import type { AccountWalletWithSecretKey, AuthWitness, AztecAddress } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ export declare function addAuthwit(wallet: AccountWalletWithSecretKey, authwit: AuthWitness, authorizer: AztecAddress, log: LogFn): Promise<void>;
4
+ //# sourceMappingURL=add_authwit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/add_authwit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,YAAY,EACxB,GAAG,EAAE,KAAK,iBAKX"}
@@ -0,0 +1,4 @@
1
+ export async function addAuthwit(wallet, authwit, authorizer, log) {
2
+ await wallet.addAuthWitness(authwit);
3
+ log(`Added authorization witness from ${authorizer}`);
4
+ }
@@ -0,0 +1,4 @@
1
+ import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
2
+ 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
+ //# sourceMappingURL=authorize_action.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,17 @@
1
+ import { Contract } from '@aztec/aztec.js';
2
+ import { prepTx } from '@aztec/cli/utils';
3
+ export async function authorizeAction(wallet, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
4
+ const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
5
+ if (isPrivate) {
6
+ 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
+ }
8
+ const contract = await Contract.at(contractAddress, contractArtifact, wallet);
9
+ const action = contract.methods[functionName](...functionArgs);
10
+ const setAuthwitnessInteraction = await wallet.setPublicAuthWit({
11
+ caller,
12
+ action
13
+ }, true);
14
+ const witness = await setAuthwitnessInteraction.send().wait();
15
+ log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
16
+ return witness;
17
+ }
@@ -0,0 +1,6 @@
1
+ import { type PXE } from '@aztec/aztec.js';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import type { LogFn, Logger } from '@aztec/foundation/log';
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
@@ -0,0 +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"}
@@ -0,0 +1,52 @@
1
+ import { L1FeeJuicePortalManager } from '@aztec/aztec.js';
2
+ import { prettyPrintJSON } from '@aztec/cli/utils';
3
+ import { createEthereumChain, createL1Clients } 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) {
6
+ // Prepare L1 client
7
+ 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
+ // Setup portal manager
11
+ const portal = await L1FeeJuicePortalManager.new(pxe, publicClient, walletClient, debugLogger);
12
+ const { claimAmount, claimSecret, messageHash, messageLeafIndex } = await portal.bridgeTokensPublic(recipient, amount, mint);
13
+ if (json) {
14
+ const out = {
15
+ claimAmount,
16
+ claimSecret,
17
+ messageLeafIndex
18
+ };
19
+ log(prettyPrintJSON(out));
20
+ } else {
21
+ if (mint) {
22
+ log(`Minted ${claimAmount} fee juice on L1 and pushed to L2 portal`);
23
+ } else {
24
+ log(`Bridged ${claimAmount} fee juice to L2 portal`);
25
+ }
26
+ log(`claimAmount=${claimAmount},claimSecret=${claimSecret},messageHash=${messageHash},messageLeafIndex=${messageLeafIndex}\n`);
27
+ log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
28
+ if (wait) {
29
+ log(`This command will now continually poll every ${interval / 1000}s for the inclusion of the newly created L1 to L2 message`);
30
+ }
31
+ }
32
+ if (wait) {
33
+ const delayedCheck = (delay)=>{
34
+ return new Promise((resolve, reject)=>{
35
+ setTimeout(()=>{
36
+ void pxe.getL1ToL2MembershipWitness(feeJuiceAddress, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
37
+ }, delay);
38
+ });
39
+ };
40
+ let witness;
41
+ while(!witness){
42
+ witness = await delayedCheck(interval);
43
+ if (!witness) {
44
+ log(`No L1 to L2 message found yet, checking again in ${interval / 1000}s`);
45
+ }
46
+ }
47
+ }
48
+ return [
49
+ claimSecret,
50
+ messageLeafIndex
51
+ ];
52
+ }
@@ -0,0 +1,11 @@
1
+ import { type AccountWalletWithSecretKey, type FeePaymentMethod, type TxHash } from '@aztec/aztec.js';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import type { LogFn } from '@aztec/foundation/log';
4
+ import { GasFees, GasSettings } from '@aztec/stdlib/gas';
5
+ export declare function cancelTx(wallet: AccountWalletWithSecretKey, { txHash, gasSettings: prevTxGasSettings, nonce, cancellable, }: {
6
+ txHash: TxHash;
7
+ gasSettings: GasSettings;
8
+ nonce: Fr;
9
+ cancellable: boolean;
10
+ }, paymentMethod: FeePaymentMethod, increasedFees: GasFees, maxFeesPerGas: GasFees | undefined, log: LogFn): Promise<void>;
11
+ //# sourceMappingURL=cancel_tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/cancel_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,gBAAgB,EAAU,KAAK,MAAM,EAAY,MAAM,iBAAiB,CAAC;AAExH,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEzD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,EACE,MAAM,EACN,WAAW,EAAE,iBAAiB,EAC9B,KAAK,EACL,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,EAAE,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,EAChF,aAAa,EAAE,gBAAgB,EAC/B,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,GAAG,SAAS,EAClC,GAAG,EAAE,KAAK,iBA4CX"}
@@ -0,0 +1,38 @@
1
+ import { SentTx, TxStatus } from '@aztec/aztec.js';
2
+ import { GasFees, GasSettings } from '@aztec/stdlib/gas';
3
+ export async function cancelTx(wallet, { txHash, gasSettings: prevTxGasSettings, nonce, cancellable }, paymentMethod, increasedFees, maxFeesPerGas, log) {
4
+ const receipt = await wallet.getTxReceipt(txHash);
5
+ if (receipt.status !== TxStatus.PENDING || !cancellable) {
6
+ log(`Transaction is in status ${receipt.status} and cannot be cancelled`);
7
+ return;
8
+ }
9
+ const maxPriorityFeesPerGas = new GasFees(prevTxGasSettings.maxPriorityFeesPerGas.feePerDaGas.add(increasedFees.feePerDaGas), prevTxGasSettings.maxPriorityFeesPerGas.feePerL2Gas.add(increasedFees.feePerL2Gas));
10
+ const fee = {
11
+ paymentMethod,
12
+ gasSettings: GasSettings.from({
13
+ ...prevTxGasSettings,
14
+ maxPriorityFeesPerGas,
15
+ maxFeesPerGas: maxFeesPerGas ?? prevTxGasSettings.maxFeesPerGas
16
+ })
17
+ };
18
+ const txRequest = await wallet.createTxExecutionRequest({
19
+ calls: [],
20
+ fee,
21
+ nonce,
22
+ cancellable: true
23
+ });
24
+ const txSimulationResult = await wallet.simulateTx(txRequest, true);
25
+ const txProvingResult = await wallet.proveTx(txRequest, txSimulationResult.privateExecutionResult);
26
+ const sentTx = new SentTx(wallet, wallet.sendTx(txProvingResult.toTx()));
27
+ try {
28
+ await sentTx.wait();
29
+ log('Transaction has been cancelled');
30
+ const cancelReceipt = await sentTx.getReceipt();
31
+ log(` Tx fee: ${cancelReceipt.transactionFee}`);
32
+ log(` Status: ${cancelReceipt.status}`);
33
+ log(` Block number: ${cancelReceipt.blockNumber}`);
34
+ log(` Block hash: ${cancelReceipt.blockHash?.toString()}`);
35
+ } catch (err) {
36
+ log(`Could not cancel transaction\n ${err.message}`);
37
+ }
38
+ }
@@ -0,0 +1,4 @@
1
+ import type { PXE, TxHash } from '@aztec/aztec.js';
2
+ 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
@@ -0,0 +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"}
@@ -0,0 +1,11 @@
1
+ import { inspectTx } from '@aztec/cli/inspect';
2
+ export async function checkTx(client, txHash, statusOnly, log) {
3
+ if (statusOnly) {
4
+ const receipt = await client.getTxReceipt(txHash);
5
+ return receipt.status;
6
+ } else {
7
+ await inspectTx(client, txHash, log, {
8
+ includeBlockInfo: true
9
+ });
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ import type { PXE } from '@aztec/aztec.js';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ 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<{
7
+ alias: string | undefined;
8
+ address: import("@aztec/aztec.js").AztecAddress;
9
+ secretKey: Fr;
10
+ salt: Fr;
11
+ }>;
12
+ //# sourceMappingURL=create_account.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,94 @@
1
+ import { prettyPrintJSON } from '@aztec/cli/cli-utils';
2
+ 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) {
6
+ 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;
9
+ const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
10
+ const out = {};
11
+ if (json) {
12
+ out.address = address;
13
+ out.publicKey = publicKeys;
14
+ if (secretKey) {
15
+ out.secretKey = secretKey;
16
+ }
17
+ out.partialAddress = partialAddress;
18
+ out.salt = salt;
19
+ out.initHash = account.getInstance().initializationHash;
20
+ out.deployer = account.getInstance().deployer;
21
+ } else {
22
+ log(`\nNew account:\n`);
23
+ log(`Address: ${address.toString()}`);
24
+ log(`Public key: ${publicKeys.toString()}`);
25
+ if (secretKey) {
26
+ log(`Secret key: ${secretKey.toString()}`);
27
+ }
28
+ log(`Partial address: ${partialAddress.toString()}`);
29
+ log(`Salt: ${salt.toString()}`);
30
+ log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
31
+ log(`Deployer: ${account.getInstance().deployer.toString()}`);
32
+ }
33
+ let tx;
34
+ 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)
44
+ };
45
+ if (feeOpts.estimateOnly) {
46
+ const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
47
+ if (json) {
48
+ out.fee = {
49
+ gasLimits: {
50
+ da: gas.gasLimits.daGas,
51
+ l2: gas.gasLimits.l2Gas
52
+ },
53
+ teardownGasLimits: {
54
+ da: gas.teardownGasLimits.daGas,
55
+ l2: gas.teardownGasLimits
56
+ }
57
+ };
58
+ } else {
59
+ printGasEstimates(feeOpts, gas, log);
60
+ }
61
+ } else {
62
+ tx = account.deploy(deployOpts);
63
+ const txHash = await tx.getTxHash();
64
+ debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
65
+ out.txHash = txHash;
66
+ if (wait) {
67
+ if (!json) {
68
+ log(`\nWaiting for account contract deployment...`);
69
+ }
70
+ txReceipt = await tx.wait();
71
+ out.txReceipt = {
72
+ status: txReceipt.status,
73
+ transactionFee: txReceipt.transactionFee
74
+ };
75
+ }
76
+ }
77
+ }
78
+ if (json) {
79
+ log(prettyPrintJSON(out));
80
+ } else {
81
+ if (tx) {
82
+ log(`Deploy tx hash: ${await tx.getTxHash()}`);
83
+ }
84
+ if (txReceipt) {
85
+ log(`Deploy tx fee: ${txReceipt.transactionFee}`);
86
+ }
87
+ }
88
+ return {
89
+ alias,
90
+ address,
91
+ secretKey,
92
+ salt
93
+ };
94
+ }
@@ -0,0 +1,4 @@
1
+ import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
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
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ import { Contract } from '@aztec/aztec.js';
2
+ import { prepTx } from '@aztec/cli/utils';
3
+ export async function createAuthwit(wallet, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
4
+ const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
5
+ if (!isPrivate) {
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
+ }
8
+ const contract = await Contract.at(contractAddress, contractArtifact, wallet);
9
+ const action = contract.methods[functionName](...functionArgs);
10
+ const witness = await wallet.createAuthWit({
11
+ caller,
12
+ action
13
+ });
14
+ log(`Created authorization witness for action ${functionName} on contract ${contractAddress} for caller ${caller}`);
15
+ return witness;
16
+ }
@@ -0,0 +1,6 @@
1
+ import { type AccountWalletWithSecretKey, Fr, type PXE } from '@aztec/aztec.js';
2
+ import type { LogFn, Logger } from '@aztec/foundation/log';
3
+ 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
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,83 @@
1
+ import { ContractDeployer, Fr } from '@aztec/aztec.js';
2
+ import { GITHUB_TAG_PREFIX, encodeArgs, getContractArtifact } from '@aztec/cli/utils';
3
+ import { getInitializer } from '@aztec/stdlib/abi';
4
+ import { PublicKeys } from '@aztec/stdlib/keys';
5
+ import { printGasEstimates } from '../utils/options/fees.js';
6
+ export async function deploy(client, wallet, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipPublicDeployment, skipClassRegistration, skipInitialization, universalDeploy, wait, feeOpts, debugLogger, log, logJson) {
7
+ salt ??= Fr.random();
8
+ const contractArtifact = await getContractArtifact(artifactPath, log);
9
+ const constructorArtifact = getInitializer(contractArtifact, initializer);
10
+ const nodeInfo = await client.getNodeInfo();
11
+ const expectedAztecNrVersion = `${GITHUB_TAG_PREFIX}-v${nodeInfo.nodeVersion}`;
12
+ if (contractArtifact.aztecNrVersion && contractArtifact.aztecNrVersion !== expectedAztecNrVersion) {
13
+ log(`\nWarning: Contract was compiled with a different version of Aztec.nr: ${contractArtifact.aztecNrVersion}. Consider updating Aztec.nr to ${expectedAztecNrVersion}\n`);
14
+ }
15
+ const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);
16
+ let args = [];
17
+ if (rawArgs.length > 0) {
18
+ if (!constructorArtifact) {
19
+ throw new Error(`Cannot process constructor arguments as no constructor was found`);
20
+ }
21
+ debugLogger.debug(`Input arguments: ${rawArgs.map((x)=>`"${x}"`).join(', ')}`);
22
+ args = encodeArgs(rawArgs, constructorArtifact.parameters);
23
+ debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
24
+ }
25
+ const deploy = deployer.deploy(...args);
26
+ const deployOpts = {
27
+ ...await feeOpts.toSendOpts(wallet),
28
+ contractAddressSalt: salt,
29
+ universalDeploy,
30
+ skipClassRegistration,
31
+ skipInitialization,
32
+ skipPublicDeployment
33
+ };
34
+ if (feeOpts.estimateOnly) {
35
+ const gas = await deploy.estimateGas(deployOpts);
36
+ printGasEstimates(feeOpts, gas, log);
37
+ return;
38
+ }
39
+ const tx = deploy.send(deployOpts);
40
+ const txHash = await tx.getTxHash();
41
+ debugLogger.debug(`Deploy tx sent with hash ${txHash}`);
42
+ if (wait) {
43
+ const deployed = await tx.wait();
44
+ const { address, partialAddress, instance } = deployed.contract;
45
+ if (json) {
46
+ logJson({
47
+ address: address.toString(),
48
+ partialAddress: (await partialAddress).toString(),
49
+ initializationHash: instance.initializationHash.toString(),
50
+ salt: salt.toString(),
51
+ transactionFee: deployed.transactionFee?.toString()
52
+ });
53
+ } else {
54
+ log(`Contract deployed at ${address.toString()}`);
55
+ log(`Contract partial address ${(await partialAddress).toString()}`);
56
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
57
+ log(`Deployment tx hash: ${txHash.toString()}`);
58
+ log(`Deployment salt: ${salt.toString()}`);
59
+ log(`Deployment fee: ${deployed.transactionFee}`);
60
+ }
61
+ } else {
62
+ const { address, partialAddress } = deploy;
63
+ const instance = await deploy.getInstance();
64
+ if (json) {
65
+ logJson({
66
+ address: address?.toString() ?? 'N/A',
67
+ partialAddress: (await partialAddress)?.toString() ?? 'N/A',
68
+ txHash: txHash.toString(),
69
+ initializationHash: instance.initializationHash.toString(),
70
+ salt: salt.toString(),
71
+ deployer: instance.deployer.toString()
72
+ });
73
+ } else {
74
+ log(`Contract deployed at ${address?.toString()}`);
75
+ log(`Contract partial address ${(await partialAddress)?.toString()}`);
76
+ log(`Contract init hash ${instance.initializationHash.toString()}`);
77
+ log(`Deployment tx hash: ${txHash.toString()}`);
78
+ log(`Deployment salt: ${salt.toString()}`);
79
+ log(`Deployer: ${instance.deployer.toString()}`);
80
+ }
81
+ }
82
+ return deploy.address;
83
+ }
@@ -0,0 +1,9 @@
1
+ import type { AccountManager } from '@aztec/aztec.js';
2
+ import type { LogFn, Logger } from '@aztec/foundation/log';
3
+ import { type IFeeOpts } from '../utils/options/fees.js';
4
+ export declare function deployAccount(account: AccountManager, wait: boolean, feeOpts: IFeeOpts, json: boolean, debugLogger: Logger, log: LogFn): Promise<{
5
+ address: import("@aztec/aztec.js").AztecAddress;
6
+ secretKey: import("@aztec/aztec.js").Fr;
7
+ salt: import("@aztec/aztec.js").Fr;
8
+ }>;
9
+ //# sourceMappingURL=deploy_account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy_account.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy_account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,iBAAiB,CAAC;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAE5E,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;GA+EX"}
@@ -0,0 +1,80 @@
1
+ import { prettyPrintJSON } from '@aztec/cli/cli-utils';
2
+ import { printGasEstimates } from '../utils/options/fees.js';
3
+ export async function deployAccount(account, wait, feeOpts, json, debugLogger, log) {
4
+ const out = {};
5
+ const { address, partialAddress, publicKeys } = await account.getCompleteAddress();
6
+ const { initializationHash, deployer, salt } = account.getInstance();
7
+ const wallet = await account.getWallet();
8
+ const secretKey = wallet.getSecretKey();
9
+ if (json) {
10
+ out.address = address;
11
+ out.partialAddress = partialAddress;
12
+ out.salt = salt;
13
+ out.initHash = initializationHash;
14
+ out.deployer = deployer;
15
+ } else {
16
+ log(`\nNew account:\n`);
17
+ log(`Address: ${address.toString()}`);
18
+ log(`Public key: ${publicKeys.toString()}`);
19
+ if (secretKey) {
20
+ log(`Secret key: ${secretKey.toString()}`);
21
+ }
22
+ log(`Partial address: ${partialAddress.toString()}`);
23
+ log(`Salt: ${salt.toString()}`);
24
+ log(`Init hash: ${initializationHash.toString()}`);
25
+ log(`Deployer: ${deployer.toString()}`);
26
+ }
27
+ let tx;
28
+ let txReceipt;
29
+ const deployOpts = {
30
+ ...await feeOpts.toDeployAccountOpts(wallet),
31
+ skipInitialization: false
32
+ };
33
+ if (feeOpts.estimateOnly) {
34
+ const gas = await (await account.getDeployMethod(deployOpts.deployWallet)).estimateGas(deployOpts);
35
+ if (json) {
36
+ out.fee = {
37
+ gasLimits: {
38
+ da: gas.gasLimits.daGas,
39
+ l2: gas.gasLimits.l2Gas
40
+ },
41
+ teardownGasLimits: {
42
+ da: gas.teardownGasLimits.daGas,
43
+ l2: gas.teardownGasLimits
44
+ }
45
+ };
46
+ } else {
47
+ printGasEstimates(feeOpts, gas, log);
48
+ }
49
+ } else {
50
+ tx = account.deploy(deployOpts);
51
+ const txHash = await tx.getTxHash();
52
+ debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
53
+ out.txHash = txHash;
54
+ if (wait) {
55
+ if (!json) {
56
+ log(`\nWaiting for account contract deployment...`);
57
+ }
58
+ txReceipt = await tx.wait();
59
+ out.txReceipt = {
60
+ status: txReceipt.status,
61
+ transactionFee: txReceipt.transactionFee
62
+ };
63
+ }
64
+ }
65
+ if (json) {
66
+ log(prettyPrintJSON(out));
67
+ } else {
68
+ if (tx) {
69
+ log(`Deploy tx hash: ${await tx.getTxHash()}`);
70
+ }
71
+ if (txReceipt) {
72
+ log(`Deploy tx fee: ${txReceipt.transactionFee}`);
73
+ }
74
+ }
75
+ return {
76
+ address,
77
+ secretKey,
78
+ salt
79
+ };
80
+ }
@@ -0,0 +1,5 @@
1
+ import { type PXE } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import type { WalletDB } from '../storage/wallet_db.js';
4
+ export declare function importTestAccounts(client: PXE, db: WalletDB, json: boolean, log: LogFn): Promise<void>;
5
+ //# sourceMappingURL=import_test_accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import_test_accounts.d.ts","sourceRoot":"","sources":["../../src/cmds/import_test_accounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,iBAsC5F"}