@aztec/cli-wallet 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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.
- package/dest/bin/index.js +24 -8
- package/dest/cmds/authorize_action.d.ts +1 -1
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +7 -2
- package/dest/cmds/bridge_fee_juice.js +3 -3
- package/dest/cmds/cancel_tx.d.ts +2 -2
- package/dest/cmds/cancel_tx.d.ts.map +1 -1
- package/dest/cmds/cancel_tx.js +13 -8
- package/dest/cmds/create_account.d.ts +3 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +40 -9
- package/dest/cmds/deploy.d.ts +2 -2
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +29 -23
- package/dest/cmds/deploy_account.d.ts +3 -3
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +40 -8
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +61 -54
- package/dest/cmds/profile.d.ts +5 -0
- package/dest/cmds/profile.d.ts.map +1 -0
- package/dest/cmds/profile.js +23 -0
- package/dest/cmds/register_contract.d.ts +2 -2
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +17 -3
- package/dest/cmds/send.d.ts +3 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +20 -12
- package/dest/cmds/simulate.d.ts +3 -2
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +19 -18
- package/dest/storage/wallet_db.d.ts +5 -7
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +8 -8
- package/dest/utils/accounts.d.ts +3 -5
- package/dest/utils/accounts.d.ts.map +1 -1
- package/dest/utils/accounts.js +7 -33
- package/dest/utils/authorizations.d.ts +5 -0
- package/dest/utils/authorizations.d.ts.map +1 -0
- package/dest/utils/authorizations.js +28 -0
- package/dest/utils/ecdsa.d.ts +0 -2
- package/dest/utils/ecdsa.d.ts.map +1 -1
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +22 -14
- package/dest/utils/options/options.d.ts +7 -4
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +25 -13
- package/dest/utils/profiling.d.ts +5 -0
- package/dest/utils/profiling.d.ts.map +1 -0
- package/dest/utils/profiling.js +60 -0
- package/dest/utils/pxe_wrapper.d.ts +4 -2
- package/dest/utils/pxe_wrapper.d.ts.map +1 -1
- package/dest/utils/pxe_wrapper.js +8 -3
- package/package.json +24 -20
- package/src/bin/index.ts +31 -9
- package/src/cmds/authorize_action.ts +4 -1
- package/src/cmds/bridge_fee_juice.ts +3 -3
- package/src/cmds/cancel_tx.ts +15 -11
- package/src/cmds/create_account.ts +42 -9
- package/src/cmds/deploy.ts +40 -25
- package/src/cmds/deploy_account.ts +44 -7
- package/src/cmds/index.ts +206 -84
- package/src/cmds/profile.ts +40 -0
- package/src/cmds/register_contract.ts +28 -3
- package/src/cmds/send.ts +30 -6
- package/src/cmds/simulate.ts +30 -22
- package/src/storage/wallet_db.ts +9 -9
- package/src/utils/accounts.ts +8 -33
- package/src/utils/authorizations.ts +49 -0
- package/src/utils/options/fees.ts +50 -31
- package/src/utils/options/options.ts +38 -17
- package/src/utils/profiling.ts +158 -0
- package/src/utils/pxe_wrapper.ts +9 -3
- package/dest/cmds/add_authwit.d.ts +0 -4
- package/dest/cmds/add_authwit.d.ts.map +0 -1
- package/dest/cmds/add_authwit.js +0 -4
- package/src/cmds/add_authwit.ts +0 -13
package/dest/cmds/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CopyCatAccountWallet } from '@aztec/accounts/copy-cat';
|
|
1
2
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
2
3
|
import { createCompatibleClient } from '@aztec/aztec.js/rpc';
|
|
3
4
|
import { TxHash } from '@aztec/aztec.js/tx_hash';
|
|
@@ -6,9 +7,9 @@ import { GasFees } from '@aztec/stdlib/gas';
|
|
|
6
7
|
import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
7
8
|
import { Option } from 'commander';
|
|
8
9
|
import inquirer from 'inquirer';
|
|
9
|
-
import {
|
|
10
|
+
import { createOrRetrieveAccount } from '../utils/accounts.js';
|
|
10
11
|
import { FeeOpts, FeeOptsWithFeePayer } from '../utils/options/fees.js';
|
|
11
|
-
import { ARTIFACT_DESCRIPTION, aliasedAddressParser,
|
|
12
|
+
import { ARTIFACT_DESCRIPTION, aliasedAddressParser, aliasedSecretKeyParser, aliasedTxHashParser, artifactPathFromPromiseOrAlias, artifactPathParser, cleanupAuthWitnesses, createAccountOption, createAliasOption, createArgsOption, createArtifactOption, createAuthwitnessOption, createContractAddressOption, createDebugExecutionStepsDirOption, createTypeOption, createVerboseOption, integerArgParser, parseGasFees, parsePaymentMethod } from '../utils/options/index.js';
|
|
12
13
|
export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
13
14
|
program.command('import-test-accounts').description('Import test accounts from pxe.').addOption(pxeOption).option('--json', 'Emit output as json').action(async (options)=>{
|
|
14
15
|
if (!db) {
|
|
@@ -16,16 +17,16 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
16
17
|
}
|
|
17
18
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
18
19
|
const { rpcUrl, json } = options;
|
|
19
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
20
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
20
21
|
await importTestAccounts(client, db, json, log);
|
|
21
22
|
});
|
|
22
|
-
const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).').summary('Creates an aztec account that can be used for sending transactions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--public-deploy', '
|
|
23
|
+
const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).').summary('Creates an aztec account that can be used for sending transactions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('-p, --public-key <string>', 'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.').addOption(pxeOption).addOption(createSecretKeyOption('Secret key for account. Uses random by default.', false, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('public-key')).addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db)).addOption(createTypeOption(true)).option('--register-only', 'Just register the account on the PXE. Do not deploy or initialize the account contract.').option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
23
24
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
24
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction');
|
|
25
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').addOption(createVerboseOption());
|
|
25
26
|
addOptions(createAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command)=>{
|
|
26
27
|
const { createAccount } = await import('./create_account.js');
|
|
27
28
|
const options = command.optsWithGlobals();
|
|
28
|
-
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy, rpcUrl, alias, json } = options;
|
|
29
|
+
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy, rpcUrl, alias, json, verbose } = options;
|
|
29
30
|
let { publicKey } = options;
|
|
30
31
|
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
31
32
|
const identities = await getIdentities();
|
|
@@ -39,8 +40,8 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
39
40
|
]);
|
|
40
41
|
publicKey = answers.identity.split(' ')[1];
|
|
41
42
|
}
|
|
42
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
43
|
-
const accountCreationResult = await createAccount(client, type, secretKey, publicKey, alias, registerOnly, skipInitialization, publicDeploy, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, debugLogger, log);
|
|
43
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
44
|
+
const accountCreationResult = await createAccount(client, type, secretKey, publicKey, alias, registerOnly, skipInitialization, publicDeploy, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, verbose, debugLogger, log);
|
|
44
45
|
if (db) {
|
|
45
46
|
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
46
47
|
await db.storeAccount(address, {
|
|
@@ -54,57 +55,73 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
54
55
|
});
|
|
55
56
|
const deployAccountCommand = program.command('deploy-account').description('Deploys an already registered aztec account that can be used for sending transactions.').addOption(createAccountOption('Alias or address of the account to deploy', !db, db)).addOption(pxeOption).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
56
57
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
57
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction');
|
|
58
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').addOption(createVerboseOption());
|
|
58
59
|
addOptions(deployAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command)=>{
|
|
59
60
|
const { deployAccount } = await import('./deploy_account.js');
|
|
60
61
|
const options = command.optsWithGlobals();
|
|
61
|
-
const { rpcUrl, wait, from: parsedFromAddress, json } = options;
|
|
62
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
62
|
+
const { rpcUrl, wait, from: parsedFromAddress, json, registerClass, publicDeploy, verbose } = options;
|
|
63
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
63
64
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db);
|
|
64
|
-
await deployAccount(account, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, debugLogger, log);
|
|
65
|
+
await deployAccount(account, wait, registerClass, publicDeploy, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, verbose, debugLogger, log);
|
|
65
66
|
});
|
|
66
67
|
const deployCommand = program.command('deploy').description('Deploys a compiled Aztec.nr contract to Aztec.').argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').option('--no-init', 'Leave the contract uninitialized').option('-k, --public-key <string>', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', parsePublicKey).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address.', parseFieldFromHexString).option('--universal', 'Do not mix the sender address into the deployment.').addOption(pxeOption).addOption(createArgsOption(true, db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to deploy from', !db, db)).addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
67
68
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
68
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode");
|
|
69
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode").addOption(new Option('--timeout <number>', 'The amount of time in seconds to wait for the deployment to post to L2').conflicts('wait')).addOption(createVerboseOption());
|
|
69
70
|
addOptions(deployCommand, FeeOpts.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
70
71
|
const { deploy } = await import('./deploy.js');
|
|
71
72
|
const options = command.optsWithGlobals();
|
|
72
|
-
const { json, publicKey, args, salt, wait, secretKey, classRegistration, init, publicDeployment, universal, rpcUrl, from: parsedFromAddress, alias } = options;
|
|
73
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
73
|
+
const { json, publicKey, args, salt, wait, secretKey, classRegistration, init, publicDeployment, universal, rpcUrl, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
74
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
74
75
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
75
|
-
const wallet = await
|
|
76
|
+
const wallet = await account.getWallet();
|
|
76
77
|
const artifactPath = await artifactPathPromise;
|
|
77
78
|
debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
|
|
78
|
-
const address = await deploy(
|
|
79
|
+
const address = await deploy(wallet, universal ? undefined : wallet.getAddress(), artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, await FeeOpts.fromCli(options, client, log, db), timeout, verbose, debugLogger, log, logJson(log));
|
|
79
80
|
if (db && address) {
|
|
80
81
|
await db.storeContract(address, artifactPath, log, alias);
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
|
-
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createArtifactOption(db)).addOption(createContractAddressOption(db)).addOption(createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)).option('--no-wait', 'Print transaction hash without waiting for it to be mined').option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.');
|
|
84
|
+
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createArtifactOption(db)).addOption(createContractAddressOption(db)).addOption(createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAuthwitnessOption('Authorization witness to use for the transaction. If using multiple, pass a comma separated string', !db, db)).addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)).option('--no-wait', 'Print transaction hash without waiting for it to be mined').option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.').addOption(createVerboseOption());
|
|
84
85
|
addOptions(sendCommand, FeeOpts.getOptions()).action(async (functionName, _options, command)=>{
|
|
85
86
|
const { send } = await import('./send.js');
|
|
86
87
|
const options = command.optsWithGlobals();
|
|
87
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, rpcUrl, secretKey, alias, cancel } = options;
|
|
88
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
88
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, rpcUrl, secretKey, alias, cancel, authWitness: authWitnessArray, verbose } = options;
|
|
89
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
89
90
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
90
|
-
const wallet = await
|
|
91
|
+
const wallet = await account.getWallet();
|
|
91
92
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
92
93
|
debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
|
|
93
|
-
const
|
|
94
|
+
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
95
|
+
const sentTx = await send(wallet, functionName, args, artifactPath, contractAddress, wait, cancel, await FeeOpts.fromCli(options, client, log, db), authWitnesses, verbose, log);
|
|
94
96
|
if (db && sentTx) {
|
|
95
|
-
const txAlias = alias ? alias : `${functionName}-${sentTx.
|
|
97
|
+
const txAlias = alias ? alias : `${functionName}-${sentTx.txNonce.toString().slice(-4)}`;
|
|
96
98
|
await db.storeTx(sentTx, log, txAlias);
|
|
97
99
|
}
|
|
98
100
|
});
|
|
99
|
-
program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(
|
|
101
|
+
const simulateCommand = program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db)).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createVerboseOption());
|
|
102
|
+
addOptions(simulateCommand, FeeOpts.getOptions()).action(async (functionName, _options, command)=>{
|
|
100
103
|
const { simulate } = await import('./simulate.js');
|
|
101
104
|
const options = command.optsWithGlobals();
|
|
102
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey,
|
|
103
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
105
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey, verbose, authWitness } = options;
|
|
106
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
104
107
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
105
|
-
const
|
|
108
|
+
const originalWallet = await account.getWallet();
|
|
109
|
+
const wallet = await CopyCatAccountWallet.create(client, originalWallet);
|
|
106
110
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
107
|
-
|
|
111
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
112
|
+
await simulate(wallet, functionName, args, artifactPath, contractAddress, await FeeOpts.fromCli(options, client, log, db), authWitnesses, verbose, log);
|
|
113
|
+
});
|
|
114
|
+
const profileCommand = program.command('profile').description('Profiles a private function by counting the unconditional operations in its execution steps').argument('<functionName>', 'Name of function to simulate').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createDebugExecutionStepsDirOption()).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db)).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db));
|
|
115
|
+
addOptions(profileCommand, FeeOpts.getOptions()).action(async (functionName, _options, command)=>{
|
|
116
|
+
const { profile } = await import('./profile.js');
|
|
117
|
+
const options = command.optsWithGlobals();
|
|
118
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey, debugExecutionStepsDir, authWitness } = options;
|
|
119
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
120
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
121
|
+
const wallet = await account.getWallet();
|
|
122
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
123
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
124
|
+
await profile(wallet, functionName, args, artifactPath, contractAddress, debugExecutionStepsDir, await FeeOptsWithFeePayer.fromCli(options, client, log, db), authWitnesses, log);
|
|
108
125
|
});
|
|
109
126
|
program.command('bridge-fee-juice').description('Mints L1 Fee Juice and pushes them to L2.').argument('<amount>', 'The amount of Fee Juice to mint and bridge.', parseBigint).argument('<recipient>', 'Aztec address of the recipient.', (address)=>aliasedAddressParser('accounts', address, db)).requiredOption('--l1-rpc-urls <string>', 'List of Ethereum host URLs. Chain identifiers localhost and testnet can be used (comma separated)', (arg)=>arg.split(','), [
|
|
110
127
|
ETHEREUM_HOSTS
|
|
@@ -113,7 +130,7 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
113
130
|
.option('--no-wait', 'Wait for the brigded funds to be available in L2, polling every 60 seconds').addOption(new Option('--interval <number>', 'The polling interval in seconds for the bridged funds').default('60').conflicts('wait')).action(async (amount, recipient, options)=>{
|
|
114
131
|
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
115
132
|
const { rpcUrl, l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
116
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
133
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
117
134
|
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(amount, recipient, client, l1RpcUrls, l1ChainId, l1PrivateKey, mnemonic, mint, json, wait, intervalS * 1000, log, debugLogger);
|
|
118
135
|
if (db) {
|
|
119
136
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
@@ -123,9 +140,9 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
123
140
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
124
141
|
const options = command.optsWithGlobals();
|
|
125
142
|
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey, alias } = options;
|
|
126
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
143
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
127
144
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
128
|
-
const wallet = await
|
|
145
|
+
const wallet = await account.getWallet();
|
|
129
146
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
130
147
|
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
131
148
|
if (db) {
|
|
@@ -136,27 +153,17 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
136
153
|
const { authorizeAction } = await import('./authorize_action.js');
|
|
137
154
|
const options = command.optsWithGlobals();
|
|
138
155
|
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey } = options;
|
|
139
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
156
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
140
157
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
141
|
-
const wallet = await
|
|
158
|
+
const wallet = await account.getWallet();
|
|
142
159
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
143
|
-
await authorizeAction(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
144
|
-
});
|
|
145
|
-
program.command('add-authwit').description('Adds an authorization witness to the provided account, granting PXE access to the notes of the authorizer so that it can be verified').argument('<authwit>', 'Authorization witness to add to the account', (witness)=>aliasedAuthWitParser(witness, db)).argument('<authorizer>', 'Account that provides the authorization to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(pxeOption).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the authorization witness. Used for easy reference in subsequent commands.', !db)).action(async (authwit, authorizer, _options, command)=>{
|
|
146
|
-
const { addAuthwit } = await import('./add_authwit.js');
|
|
147
|
-
const options = command.optsWithGlobals();
|
|
148
|
-
const { from: parsedFromAddress, rpcUrl, secretKey } = options;
|
|
149
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
150
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
151
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
152
|
-
await addAuthwit(wallet, authwit, authorizer, log);
|
|
153
|
-
await addScopeToWallet(wallet, authorizer, db);
|
|
160
|
+
await authorizeAction(wallet, wallet.getAddress(), functionName, caller, args, artifactPath, contractAddress, log);
|
|
154
161
|
});
|
|
155
162
|
program.command('get-tx').description('Gets the status of the recent txs, or a detailed view if a specific transaction hash is provided').argument('[txHash]', 'A transaction hash to get the receipt for.', (txHash)=>aliasedTxHashParser(txHash, db)).addOption(pxeOption).option('-p, --page <number>', 'The page number to display', (value)=>integerArgParser(value, '--page', 1), 1).option('-s, --page-size <number>', 'The number of transactions to display per page', (value)=>integerArgParser(value, '--page-size', 1), 10).action(async (txHash, options)=>{
|
|
156
163
|
const { checkTx } = await import('./check_tx.js');
|
|
157
164
|
const { rpcUrl, pageSize } = options;
|
|
158
165
|
let { page } = options;
|
|
159
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
166
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
160
167
|
if (txHash) {
|
|
161
168
|
await checkTx(client, txHash, false, log);
|
|
162
169
|
} else if (db) {
|
|
@@ -185,9 +192,9 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
185
192
|
program.command('cancel-tx').description('Cancels a pending tx by reusing its nonce with a higher fee and an empty payload').argument('<txHash>', 'A transaction hash to cancel.', (txHash)=>aliasedTxHashParser(txHash, db)).addOption(pxeOption).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(FeeOpts.paymentMethodOption().default('method=fee_juice')).option('-i --increased-fees <da=1,l2=1>', 'The amounts by which the fees are increased', (value)=>parseGasFees(value), new GasFees(1, 1)).option('--max-fees-per-gas <da=100,l2=100>', 'Maximum fees per gas unit for DA and L2 computation.', (value)=>parseGasFees(value)).action(async (txHash, options)=>{
|
|
186
193
|
const { cancelTx } = await import('./cancel_tx.js');
|
|
187
194
|
const { from: parsedFromAddress, rpcUrl, secretKey, payment, increasedFees, maxFeesPerGas } = options;
|
|
188
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
195
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
189
196
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
190
|
-
const wallet = await
|
|
197
|
+
const wallet = await account.getWallet();
|
|
191
198
|
const txData = await db?.retrieveTxData(txHash);
|
|
192
199
|
if (!txData) {
|
|
193
200
|
throw new Error('Transaction data not found in the database, cannot reuse nonce');
|
|
@@ -198,23 +205,23 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
198
205
|
program.command('register-sender').description("Registers a sender's address in the wallet, so the note synching process will look for notes sent by them").argument('[address]', 'The address of the sender to register', (address)=>aliasedAddressParser('accounts', address, db)).addOption(pxeOption).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the sender. Used for easy reference in subsequent commands.', !db)).action(async (address, options)=>{
|
|
199
206
|
const { registerSender } = await import('./register_sender.js');
|
|
200
207
|
const { from: parsedFromAddress, rpcUrl, secretKey, alias } = options;
|
|
201
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
208
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
202
209
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
203
|
-
const wallet = await
|
|
210
|
+
const wallet = await account.getWallet();
|
|
204
211
|
await registerSender(wallet, address, log);
|
|
205
212
|
if (db && alias) {
|
|
206
213
|
await db.storeSender(address, alias, log);
|
|
207
214
|
}
|
|
208
215
|
});
|
|
209
|
-
program.command('register-contract').description("Registers a contract in this wallet's PXE").argument('[address]', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).addOption(createArgsOption(true, db)).addOption(pxeOption).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)).action(async (address, artifactPathPromise, _options, command)=>{
|
|
216
|
+
program.command('register-contract').description("Registers a contract in this wallet's PXE").argument('[address]', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').option('-k, --public-key <string>', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', parsePublicKey).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address.', parseFieldFromHexString).option('--deployer <string>', 'The address of the account that deployed the contract', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createArgsOption(true, db)).addOption(pxeOption).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)).action(async (address, artifactPathPromise, _options, command)=>{
|
|
210
217
|
const { registerContract } = await import('./register_contract.js');
|
|
211
|
-
const { from: parsedFromAddress, rpcUrl, nodeUrl, secretKey, alias } = command.optsWithGlobals();
|
|
212
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
218
|
+
const { from: parsedFromAddress, rpcUrl, nodeUrl, secretKey, alias, init, publicKey, salt, deployer, args } = command.optsWithGlobals();
|
|
219
|
+
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
213
220
|
const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
|
|
214
221
|
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
215
|
-
const wallet = await
|
|
222
|
+
const wallet = await account.getWallet();
|
|
216
223
|
const artifactPath = await artifactPathPromise;
|
|
217
|
-
const instance = await registerContract(wallet, node, address, artifactPath, log);
|
|
224
|
+
const instance = await registerContract(wallet, node, address, artifactPath, log, init, publicKey, args, salt, deployer);
|
|
218
225
|
if (db && alias) {
|
|
219
226
|
await db.storeContract(instance.address, artifactPath, log, alias);
|
|
220
227
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type AccountWalletWithSecretKey, AuthWitness, type AztecAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import type { IFeeOpts } from '../utils/options/fees.js';
|
|
4
|
+
export declare function profile(wallet: AccountWalletWithSecretKey, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, debugOutputPath: string | undefined, feeOpts: IFeeOpts, authWitnesses: AuthWitness[], log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/cmds/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,WAAW,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE5G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,WAAW,EAAE,EAC5B,GAAG,EAAE,KAAK,iBAmBX"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Contract } from '@aztec/aztec.js';
|
|
2
|
+
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
+
import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
7
|
+
export async function profile(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, debugOutputPath, feeOpts, authWitnesses, log) {
|
|
8
|
+
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
9
|
+
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
10
|
+
const call = contract.methods[functionName](...functionArgs);
|
|
11
|
+
const result = await call.profile({
|
|
12
|
+
...await feeOpts.toSendOpts(wallet),
|
|
13
|
+
profileMode: 'full',
|
|
14
|
+
authWitnesses,
|
|
15
|
+
skipProofGeneration: false
|
|
16
|
+
});
|
|
17
|
+
printProfileResult(result.stats, log, true, result.executionSteps);
|
|
18
|
+
if (debugOutputPath) {
|
|
19
|
+
const ivcInputsPath = path.join(debugOutputPath, 'ivc-inputs.msgpack');
|
|
20
|
+
log(`Debug output written to ${ivcInputsPath}.`);
|
|
21
|
+
await fs.writeFile(ivcInputsPath, serializePrivateExecutionSteps(result.executionSteps));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AccountWalletWithSecretKey, type AztecAddress, type AztecNode, type Fr, PublicKeys } from '@aztec/aztec.js';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function registerContract(wallet: AccountWalletWithSecretKey, node: AztecNode, address: AztecAddress, artifactPath: string, log: LogFn): Promise<import("@aztec/aztec.js").ContractInstanceWithAddress>;
|
|
3
|
+
export declare function registerContract(wallet: AccountWalletWithSecretKey, node: AztecNode, address: AztecAddress, artifactPath: string, log: LogFn, initializer?: string, publicKeys?: PublicKeys, rawArgs?: any[], salt?: Fr, deployer?: AztecAddress): Promise<import("@aztec/aztec.js").ContractInstanceWithAddress>;
|
|
4
4
|
//# sourceMappingURL=register_contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,EAAE,EACP,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,0BAA0B,EAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,EACV,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,UAAU,EACvB,OAAO,CAAC,EAAE,GAAG,EAAE,EACf,IAAI,CAAC,EAAE,EAAE,EACT,QAAQ,CAAC,EAAE,YAAY,kEAsBxB"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import { PublicKeys, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js';
|
|
1
2
|
import { getContractArtifact } from '@aztec/cli/cli-utils';
|
|
2
|
-
|
|
3
|
+
import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
4
|
+
export async function registerContract(wallet, node, address, artifactPath, log, initializer, publicKeys, rawArgs, salt, deployer) {
|
|
3
5
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
4
|
-
const
|
|
6
|
+
const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
|
|
7
|
+
const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
|
|
8
|
+
let contractInstance = await node.getContract(address);
|
|
5
9
|
if (!contractInstance) {
|
|
6
|
-
|
|
10
|
+
log(`Contract not found in the node at ${address}. Computing instance locally...`);
|
|
11
|
+
contractInstance = await getContractInstanceFromInstantiationParams(contractArtifact, {
|
|
12
|
+
constructorArtifact,
|
|
13
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
14
|
+
constructorArgs: rawArgs,
|
|
15
|
+
salt,
|
|
16
|
+
deployer
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (!contractInstance.address.equals(address)) {
|
|
20
|
+
throw new Error(`Contract address mismatch: expected ${address}, got ${contractInstance.address}`);
|
|
7
21
|
}
|
|
8
22
|
await wallet.registerContract({
|
|
9
23
|
instance: contractInstance,
|
package/dest/cmds/send.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type AccountWalletWithSecretKey, type AztecAddress, Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { type AccountWalletWithSecretKey, AuthWitness, type AztecAddress, Fr } from '@aztec/aztec.js';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
3
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
4
4
|
import { type IFeeOpts } from '../utils/options/fees.js';
|
|
5
|
-
export declare function send(wallet: AccountWalletWithSecretKey, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: IFeeOpts, log: LogFn): Promise<{
|
|
5
|
+
export declare function send(wallet: AccountWalletWithSecretKey, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: IFeeOpts, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<{
|
|
6
6
|
txHash: import("@aztec/aztec.js").TxHash;
|
|
7
|
-
|
|
7
|
+
txNonce: Fr;
|
|
8
8
|
cancellable: boolean;
|
|
9
9
|
gasSettings: GasSettings;
|
|
10
10
|
} | undefined>;
|
package/dest/cmds/send.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAC/B,WAAW,EACX,KAAK,YAAY,EAEjB,EAAE,EAEH,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,IAAI,CACxB,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK;;;;;eA0DX"}
|
package/dest/cmds/send.js
CHANGED
|
@@ -2,28 +2,36 @@ import { Contract, Fr } from '@aztec/aztec.js';
|
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
3
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
4
4
|
import { printGasEstimates } from '../utils/options/fees.js';
|
|
5
|
-
|
|
5
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
6
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
|
|
7
|
+
export async function send(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, verbose, log) {
|
|
6
8
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
7
9
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
8
10
|
const call = contract.methods[functionName](...functionArgs);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const txNonce = Fr.random();
|
|
12
|
+
const sendOptions = {
|
|
13
|
+
...await feeOpts.toSendOpts(wallet),
|
|
14
|
+
authWitnesses,
|
|
15
|
+
cancellable,
|
|
16
|
+
txNonce
|
|
17
|
+
};
|
|
18
|
+
const gasLimits = await call.estimateGas(sendOptions);
|
|
12
19
|
printGasEstimates(feeOpts, gasLimits, log);
|
|
13
20
|
if (feeOpts.estimateOnly) {
|
|
14
21
|
return;
|
|
15
22
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
23
|
+
const provenTx = await call.prove(sendOptions);
|
|
24
|
+
if (verbose) {
|
|
25
|
+
printProfileResult(provenTx.stats, log);
|
|
26
|
+
}
|
|
27
|
+
const tx = provenTx.send();
|
|
22
28
|
const txHash = await tx.getTxHash();
|
|
23
29
|
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
24
30
|
if (wait) {
|
|
25
31
|
try {
|
|
26
|
-
await tx.wait(
|
|
32
|
+
await tx.wait({
|
|
33
|
+
timeout: DEFAULT_TX_TIMEOUT_S
|
|
34
|
+
});
|
|
27
35
|
log('Transaction has been mined');
|
|
28
36
|
const receipt = await tx.getReceipt();
|
|
29
37
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
@@ -42,7 +50,7 @@ export async function send(wallet, functionName, functionArgsIn, contractArtifac
|
|
|
42
50
|
});
|
|
43
51
|
return {
|
|
44
52
|
txHash,
|
|
45
|
-
|
|
53
|
+
txNonce,
|
|
46
54
|
cancellable,
|
|
47
55
|
gasSettings
|
|
48
56
|
};
|
package/dest/cmds/simulate.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
|
|
1
|
+
import { type AccountWalletWithSecretKey, AuthWitness, type AztecAddress } from '@aztec/aztec.js';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
|
|
3
|
+
import type { IFeeOpts } from '../utils/options/fees.js';
|
|
4
|
+
export declare function simulate(wallet: AccountWalletWithSecretKey, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, feeOpts: IFeeOpts, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<void>;
|
|
4
5
|
//# sourceMappingURL=simulate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,WAAW,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE5G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,iBA8BX"}
|
package/dest/cmds/simulate.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { Contract } from '@aztec/aztec.js';
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
3
|
import { format } from 'util';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
log(format('\nGate count per circuit:'));
|
|
8
|
-
let acc = 0;
|
|
9
|
-
result.gateCounts.forEach((r)=>{
|
|
10
|
-
acc += r.gateCount;
|
|
11
|
-
log(format(' ', r.circuitName.padEnd(50), 'Gates:', r.gateCount.toLocaleString(), '\tAcc:', acc.toLocaleString()));
|
|
12
|
-
});
|
|
13
|
-
log(format('\nTotal gates:', acc.toLocaleString()));
|
|
14
|
-
}
|
|
15
|
-
export async function simulate(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, profile, log) {
|
|
4
|
+
import { printAuthorizations } from '../utils/authorizations.js';
|
|
5
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
6
|
+
export async function simulate(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, feeOpts, authWitnesses, verbose, log) {
|
|
16
7
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
17
8
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
18
9
|
const call = contract.methods[functionName](...functionArgs);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
const simulationResult = await call.simulate({
|
|
11
|
+
...await feeOpts.toSendOpts(wallet),
|
|
12
|
+
authWitnesses,
|
|
13
|
+
includeMetadata: true
|
|
14
|
+
});
|
|
15
|
+
if (verbose) {
|
|
16
|
+
await printAuthorizations(simulationResult.offchainEffects, async (address)=>{
|
|
17
|
+
const metadata = await wallet.getContractMetadata(address);
|
|
18
|
+
if (!metadata.contractInstance) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const classMetadata = await wallet.getContractClassMetadata(metadata.contractInstance.currentContractClassId, true);
|
|
22
|
+
return classMetadata.artifact;
|
|
23
|
+
}, log);
|
|
24
|
+
printProfileResult(simulationResult.stats, log);
|
|
25
25
|
}
|
|
26
|
+
log(format('\nSimulation result: ', simulationResult.result, '\n'));
|
|
26
27
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
@@ -33,15 +31,15 @@ export declare class WalletDB {
|
|
|
33
31
|
storeSender(address: AztecAddress, alias: string, log: LogFn): Promise<void>;
|
|
34
32
|
storeContract(address: AztecAddress, artifactPath: string, log: LogFn, alias?: string): Promise<void>;
|
|
35
33
|
storeAuthwitness(authWit: AuthWitness, log: LogFn, alias?: string): Promise<void>;
|
|
36
|
-
storeTx({ txHash,
|
|
34
|
+
storeTx({ txHash, txNonce, cancellable, gasSettings, }: {
|
|
37
35
|
txHash: TxHash;
|
|
38
|
-
|
|
36
|
+
txNonce: Fr;
|
|
39
37
|
cancellable: boolean;
|
|
40
38
|
gasSettings: GasSettings;
|
|
41
39
|
}, log: LogFn, alias?: string): Promise<void>;
|
|
42
40
|
retrieveTxData(txHash: TxHash): Promise<{
|
|
43
41
|
txHash: TxHash;
|
|
44
|
-
|
|
42
|
+
txNonce: Fr;
|
|
45
43
|
cancellable: boolean;
|
|
46
44
|
gasSettings: GasSettings;
|
|
47
45
|
}>;
|
|
@@ -53,12 +51,12 @@ export declare class WalletDB {
|
|
|
53
51
|
value: string;
|
|
54
52
|
}[]>;
|
|
55
53
|
storeAccountMetadata(aliasOrAddress: AztecAddress | string, metadataKey: string, metadata: Buffer): Promise<void>;
|
|
56
|
-
retrieveAccountMetadata(aliasOrAddress: AztecAddress | string, metadataKey: string): Promise<Buffer
|
|
54
|
+
retrieveAccountMetadata(aliasOrAddress: AztecAddress | string, metadataKey: string): Promise<Buffer<ArrayBufferLike>>;
|
|
57
55
|
retrieveAccount(address: AztecAddress | string): Promise<{
|
|
58
56
|
address: string | AztecAddress;
|
|
59
57
|
secretKey: Fr;
|
|
60
58
|
salt: Fr;
|
|
61
|
-
type: "schnorr" | "ecdsasecp256r1ssh" | "ecdsasecp256k1";
|
|
59
|
+
type: "schnorr" | "ecdsasecp256r1" | "ecdsasecp256r1ssh" | "ecdsasecp256k1";
|
|
62
60
|
}>;
|
|
63
61
|
storeAlias(type: AliasType, key: string, value: Buffer, log: LogFn): Promise<void>;
|
|
64
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet_db.d.ts","sourceRoot":"","sources":["../../src/storage/wallet_db.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet_db.d.ts","sourceRoot":"","sources":["../../src/storage/wallet_db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,eAAO,MAAM,OAAO,wFAAyF,CAAC;AAC9G,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,qBAAa,QAAQ;;IAMnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAW;IAElC,OAAO,CAAC,UAAU,CAA6B;IAE/C,MAAM,CAAC,WAAW;IAQZ,IAAI,CAAC,KAAK,EAAE,iBAAiB;YASrB,iBAAiB;IAIzB,mBAAmB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;IAWtG,kBAAkB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK;;;;;IActD,YAAY,CAChB,OAAO,EAAE,YAAY,EACrB,EACE,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,SAAS,GACV,EAAE;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,SAAS,EAAE,EAAE,CAAC;QAAC,IAAI,EAAE,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EAC3G,GAAG,EAAE,KAAK;IAkBN,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;IAO5D,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM;IAarF,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM;IAUjE,OAAO,CACX,EACE,MAAM,EACN,OAAO,EACP,WAAW,EACX,WAAW,GACZ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;QAAC,WAAW,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,WAAW,CAAA;KAAE,EAClF,GAAG,EAAE,KAAK,EACV,KAAK,CAAC,EAAE,MAAM;IAcV,cAAc,CAAC,MAAM,EAAE,MAAM;;;;;;IAanC,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAQrB,sBAAsB,CAAC,GAAG,EAAE,MAAM;IAcnC,aAAa,CAAC,GAAG,EAAE,MAAM;IAazB,WAAW,CAAC,IAAI,CAAC,EAAE,SAAS;;;;IAa5B,oBAAoB,CAAC,cAAc,EAAE,YAAY,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAKjG,uBAAuB,CAAC,cAAc,EAAE,YAAY,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM;IASlF,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM;;;;;;IAW9C,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;CAOzE"}
|
|
@@ -100,11 +100,11 @@ export class WalletDB {
|
|
|
100
100
|
log(`Authorization witness stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
|
|
101
101
|
await this.refreshAliasCache();
|
|
102
102
|
}
|
|
103
|
-
async storeTx({ txHash,
|
|
103
|
+
async storeTx({ txHash, txNonce, cancellable, gasSettings }, log, alias) {
|
|
104
104
|
if (alias) {
|
|
105
105
|
await this.#aliases.set(`transactions:${alias}`, Buffer.from(txHash.toString()));
|
|
106
106
|
}
|
|
107
|
-
await this.#transactions.set(`${txHash.toString()}:
|
|
107
|
+
await this.#transactions.set(`${txHash.toString()}:txNonce`, txNonce.toBuffer());
|
|
108
108
|
await this.#transactions.set(`${txHash.toString()}:cancellable`, Buffer.from(cancellable ? 'true' : 'false'));
|
|
109
109
|
await this.#transactions.set(`${txHash.toString()}:gasSettings`, gasSettings.toBuffer());
|
|
110
110
|
await this.#aliases.set(`transactions:last`, Buffer.from(txHash.toString()));
|
|
@@ -112,16 +112,16 @@ export class WalletDB {
|
|
|
112
112
|
await this.refreshAliasCache();
|
|
113
113
|
}
|
|
114
114
|
async retrieveTxData(txHash) {
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
throw new Error(`Could not find ${txHash.toString()}:
|
|
115
|
+
const txNonceBuffer = await this.#transactions.getAsync(`${txHash.toString()}:txNonce`);
|
|
116
|
+
if (!txNonceBuffer) {
|
|
117
|
+
throw new Error(`Could not find ${txHash.toString()}:txNonce. Transaction with hash "${txHash.toString()}" does not exist on this wallet.`);
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const txNonce = Fr.fromBuffer(txNonceBuffer);
|
|
120
120
|
const cancellable = (await this.#transactions.getAsync(`${txHash.toString()}:cancellable`)).toString() === 'true';
|
|
121
121
|
const gasBuffer = await this.#transactions.getAsync(`${txHash.toString()}:gasSettings`);
|
|
122
122
|
return {
|
|
123
123
|
txHash,
|
|
124
|
-
|
|
124
|
+
txNonce,
|
|
125
125
|
cancellable,
|
|
126
126
|
gasSettings: GasSettings.fromBuffer(gasBuffer)
|
|
127
127
|
};
|
|
@@ -129,7 +129,7 @@ export class WalletDB {
|
|
|
129
129
|
tryRetrieveAlias(arg) {
|
|
130
130
|
try {
|
|
131
131
|
return this.retrieveAliasFromCache(arg);
|
|
132
|
-
} catch
|
|
132
|
+
} catch {
|
|
133
133
|
return arg;
|
|
134
134
|
}
|
|
135
135
|
}
|
package/dest/utils/accounts.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { AccountManager
|
|
1
|
+
import type { AccountManager } from '@aztec/aztec.js';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
5
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
6
|
-
export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
6
|
+
export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
7
7
|
export type AccountType = (typeof AccountTypes)[number];
|
|
8
|
-
export declare function createOrRetrieveAccount(pxe: PXE, address?: AztecAddress, db?: WalletDB, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string
|
|
9
|
-
export declare function addScopeToWallet(wallet: AccountWalletWithSecretKey, scope: AztecAddress, db?: WalletDB): Promise<void>;
|
|
10
|
-
export declare function getWalletWithScopes(account: AccountManager, db?: WalletDB): Promise<AccountWalletWithSecretKey>;
|
|
8
|
+
export declare function createOrRetrieveAccount(pxe: PXE, address?: AztecAddress, db?: WalletDB, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
|
|
11
9
|
//# sourceMappingURL=accounts.d.ts.map
|