@aztec/cli-wallet 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/README.md +30 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +38 -23
- package/dest/cmds/authorize_action.d.ts +4 -3
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +6 -7
- package/dest/cmds/bridge_fee_juice.d.ts +4 -4
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +9 -7
- package/dest/cmds/check_tx.d.ts +5 -3
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +144 -6
- package/dest/cmds/create_account.d.ts +7 -6
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +36 -48
- package/dest/cmds/create_authwit.d.ts +4 -3
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/create_authwit.js +6 -6
- package/dest/cmds/deploy.d.ts +7 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +57 -46
- package/dest/cmds/deploy_account.d.ts +6 -8
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +36 -51
- package/dest/cmds/import_test_accounts.d.ts +3 -3
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +6 -9
- package/dest/cmds/index.d.ts +3 -3
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +73 -112
- package/dest/cmds/profile.d.ts +7 -4
- package/dest/cmds/profile.d.ts.map +1 -1
- package/dest/cmds/profile.js +9 -4
- package/dest/cmds/register_contract.d.ts +7 -3
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +5 -6
- package/dest/cmds/register_sender.d.ts +4 -3
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +8 -9
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +27 -24
- package/dest/cmds/simulate.d.ts +7 -4
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +9 -4
- package/dest/storage/wallet_db.d.ts +6 -16
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +2 -23
- package/dest/utils/authorizations.d.ts +3 -2
- package/dest/utils/authorizations.d.ts.map +1 -1
- package/dest/utils/authorizations.js +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
- package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
- package/dest/utils/ecdsa.d.ts +1 -1
- package/dest/utils/options/fees.d.ts +22 -28
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +66 -133
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +4 -3
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/wallet.d.ts +36 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +195 -0
- package/package.json +17 -14
- package/src/bin/index.ts +38 -31
- package/src/cmds/authorize_action.ts +14 -6
- package/src/cmds/bridge_fee_juice.ts +15 -11
- package/src/cmds/check_tx.ts +181 -5
- package/src/cmds/create_account.ts +43 -53
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +58 -56
- package/src/cmds/deploy_account.ts +43 -51
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +120 -206
- package/src/cmds/profile.ts +14 -6
- package/src/cmds/register_contract.ts +9 -11
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +22 -32
- package/src/cmds/simulate.ts +14 -6
- package/src/storage/wallet_db.ts +3 -31
- package/src/utils/authorizations.ts +3 -1
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/options/fees.ts +88 -178
- package/src/utils/options/options.ts +3 -2
- package/src/utils/wallet.ts +266 -0
- package/dest/cmds/cancel_tx.d.ts +0 -11
- package/dest/cmds/cancel_tx.d.ts.map +0 -1
- package/dest/cmds/cancel_tx.js +0 -43
- package/dest/utils/accounts.d.ts +0 -9
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -61
- package/dest/utils/pxe_wrapper.d.ts +0 -12
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -26
- package/src/cmds/cancel_tx.ts +0 -66
- package/src/utils/accounts.ts +0 -77
- package/src/utils/pxe_wrapper.ts +0 -32
package/dest/cmds/index.js
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
import { CopyCatAccountWallet } from '@aztec/accounts/copy-cat';
|
|
2
1
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
7
|
-
import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
2
|
+
import { TxHash } from '@aztec/aztec.js/tx';
|
|
3
|
+
import { ETHEREUM_HOSTS, PRIVATE_KEY, addOptions, createSecretKeyOption, l1ChainIdOption, parseBigint, parseFieldFromHexString, parsePublicKey } from '@aztec/cli/utils';
|
|
4
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
8
5
|
import { Option } from 'commander';
|
|
9
6
|
import inquirer from 'inquirer';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
throw new Error(`A db is required to store the imported test accounts.`);
|
|
17
|
-
}
|
|
7
|
+
import { ARTIFACT_DESCRIPTION, CLIFeeArgs, aliasedAddressParser, aliasedSecretKeyParser, aliasedTxHashParser, artifactPathFromPromiseOrAlias, artifactPathParser, cleanupAuthWitnesses, createAccountOption, createAliasOption, createArgsOption, createArtifactOption, createAuthwitnessOption, createContractAddressOption, createDebugExecutionStepsDirOption, createTypeOption, createVerboseOption, integerArgParser } from '../utils/options/index.js';
|
|
8
|
+
// TODO: This function is only used in 1 place so we could just inline this
|
|
9
|
+
export function injectCommands(program, log, debugLogger, walletAndNodeWrapper, db) {
|
|
10
|
+
program.command('import-test-accounts').description('Import test accounts from pxe.').option('--json', 'Emit output as json').action(async (options)=>{
|
|
11
|
+
const { json } = options;
|
|
12
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
18
13
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
19
|
-
|
|
20
|
-
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
21
|
-
await importTestAccounts(client, db, json, log);
|
|
14
|
+
await importTestAccounts(wallet, db, json, log);
|
|
22
15
|
});
|
|
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(
|
|
16
|
+
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.').addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db)).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('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').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(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 Wallet. 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.
|
|
24
17
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
25
18
|
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').addOption(createVerboseOption());
|
|
26
|
-
addOptions(createAccountCommand,
|
|
19
|
+
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command)=>{
|
|
27
20
|
const { createAccount } = await import('./create_account.js');
|
|
28
21
|
const options = command.optsWithGlobals();
|
|
29
|
-
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy,
|
|
22
|
+
const { type, from: parsedFromAddress, secretKey, wait, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
30
23
|
let { publicKey } = options;
|
|
31
24
|
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
32
25
|
const identities = await getIdentities();
|
|
@@ -40,8 +33,8 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
40
33
|
]);
|
|
41
34
|
publicKey = answers.identity.split(' ')[1];
|
|
42
35
|
}
|
|
43
|
-
const
|
|
44
|
-
const accountCreationResult = await createAccount(
|
|
36
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
37
|
+
const accountCreationResult = await createAccount(wallet, node, type, secretKey, publicKey, alias, parsedFromAddress, registerOnly, skipInitialization, publicDeploy, registerClass, wait, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
45
38
|
if (db) {
|
|
46
39
|
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
47
40
|
await db.storeAccount(address, {
|
|
@@ -53,119 +46,105 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
53
46
|
}, log);
|
|
54
47
|
}
|
|
55
48
|
});
|
|
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
|
|
49
|
+
const deployAccountCommand = program.command('deploy-account').description('Deploys an already registered aztec account that can be used for sending transactions.').argument('<address>', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createAccountOption('Alias or address of the account performing the deployment', !db, db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
57
50
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
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());
|
|
59
|
-
addOptions(deployAccountCommand,
|
|
51
|
+
.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.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').addOption(createVerboseOption());
|
|
52
|
+
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command)=>{
|
|
60
53
|
const { deployAccount } = await import('./deploy_account.js');
|
|
61
54
|
const options = command.optsWithGlobals();
|
|
62
|
-
const {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
await deployAccount(account, wait, registerClass, publicDeploy, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, verbose, debugLogger, log);
|
|
55
|
+
const { wait, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
56
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
57
|
+
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
66
58
|
});
|
|
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(
|
|
59
|
+
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(createArgsOption(true, db)).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.
|
|
68
60
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
69
61
|
.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());
|
|
70
|
-
addOptions(deployCommand,
|
|
62
|
+
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
71
63
|
const { deploy } = await import('./deploy.js');
|
|
72
64
|
const options = command.optsWithGlobals();
|
|
73
|
-
const { json, publicKey, args, salt, wait,
|
|
74
|
-
const
|
|
75
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
76
|
-
const wallet = await account.getWallet();
|
|
65
|
+
const { json, publicKey, args, salt, wait, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
66
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
77
67
|
const artifactPath = await artifactPathPromise;
|
|
78
|
-
debugLogger.info(`Using wallet with address ${
|
|
79
|
-
const address = await deploy(wallet, universal ? undefined :
|
|
68
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
69
|
+
const address = await deploy(wallet, node, universal ? undefined : parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db), timeout, verbose, debugLogger, log);
|
|
80
70
|
if (db && address) {
|
|
81
71
|
await db.storeContract(address, artifactPath, log, alias);
|
|
82
72
|
}
|
|
83
73
|
});
|
|
84
|
-
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(
|
|
85
|
-
addOptions(sendCommand,
|
|
74
|
+
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').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(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').addOption(createVerboseOption());
|
|
75
|
+
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
86
76
|
const { send } = await import('./send.js');
|
|
87
77
|
const options = command.optsWithGlobals();
|
|
88
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait,
|
|
89
|
-
const
|
|
90
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
91
|
-
const wallet = await account.getWallet();
|
|
78
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, alias, authWitness: authWitnessArray, verbose } = options;
|
|
79
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
92
80
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
93
|
-
debugLogger.info(`Using wallet with address ${
|
|
81
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
94
82
|
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
95
|
-
const sentTx = await send(wallet, functionName, args, artifactPath, contractAddress, wait,
|
|
83
|
+
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
96
84
|
if (db && sentTx) {
|
|
97
|
-
const txAlias = alias ? alias : `${functionName}-${
|
|
85
|
+
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString('hex')}`;
|
|
98
86
|
await db.storeTx(sentTx, log, txAlias);
|
|
99
87
|
}
|
|
100
88
|
});
|
|
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(
|
|
102
|
-
addOptions(simulateCommand,
|
|
89
|
+
const simulateCommand = program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').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());
|
|
90
|
+
addOptions(simulateCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
103
91
|
const { simulate } = await import('./simulate.js');
|
|
104
92
|
const options = command.optsWithGlobals();
|
|
105
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress,
|
|
106
|
-
const
|
|
107
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
108
|
-
const originalWallet = await account.getWallet();
|
|
109
|
-
const wallet = await CopyCatAccountWallet.create(client, originalWallet);
|
|
93
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, verbose, authWitness } = options;
|
|
94
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
110
95
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
111
96
|
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
112
|
-
await simulate(wallet, functionName, args, artifactPath, contractAddress,
|
|
97
|
+
await simulate(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
113
98
|
});
|
|
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(
|
|
115
|
-
addOptions(profileCommand,
|
|
99
|
+
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(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createDebugExecutionStepsDirOption()).addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db)).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db));
|
|
100
|
+
addOptions(profileCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
116
101
|
const { profile } = await import('./profile.js');
|
|
117
102
|
const options = command.optsWithGlobals();
|
|
118
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress,
|
|
119
|
-
const
|
|
120
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
121
|
-
const wallet = await account.getWallet();
|
|
103
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, debugExecutionStepsDir, authWitness } = options;
|
|
104
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
122
105
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
123
106
|
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
124
|
-
await profile(wallet, functionName, args, artifactPath, contractAddress, debugExecutionStepsDir,
|
|
107
|
+
await profile(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, debugExecutionStepsDir, CLIFeeArgs.parse(options, log, db), authWitnesses, log);
|
|
125
108
|
});
|
|
126
109
|
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(','), [
|
|
127
110
|
ETHEREUM_HOSTS
|
|
128
|
-
]).option('-m, --mnemonic <string>', 'The mnemonic to use for deriving the Ethereum address that will mint and bridge', 'test test test test test test test test test test test junk').option('--mint', 'Mint the tokens on L1', false).option('--l1-private-key <string>', 'The private key to the eth account bridging', PRIVATE_KEY).addOption(
|
|
111
|
+
]).option('-m, --mnemonic <string>', 'The mnemonic to use for deriving the Ethereum address that will mint and bridge', 'test test test test test test test test test test test junk').option('--mint', 'Mint the tokens on L1', false).option('--l1-private-key <string>', 'The private key to the eth account bridging', PRIVATE_KEY).addOption(l1ChainIdOption).option('--json', 'Output the claim in JSON format')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
129
112
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
130
|
-
.option('--no-wait', 'Wait for the
|
|
113
|
+
.option('--no-wait', 'Wait for the bridged 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)=>{
|
|
131
114
|
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
132
|
-
const {
|
|
133
|
-
const
|
|
134
|
-
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(amount, recipient, client, l1RpcUrls, l1ChainId, l1PrivateKey, mnemonic, mint, json, wait, intervalS * 1000, log, debugLogger);
|
|
115
|
+
const { l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
116
|
+
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(amount, recipient, walletAndNodeWrapper.node, l1RpcUrls, l1ChainId, l1PrivateKey, mnemonic, mint, json, wait, intervalS * 1000, log, debugLogger);
|
|
135
117
|
if (db) {
|
|
136
118
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
137
119
|
}
|
|
138
120
|
});
|
|
139
|
-
program.command('create-authwit').description('Creates an authorization witness that can be privately sent to a caller so they can perform an action on behalf of the provided account').argument('<functionName>', 'Name of function to authorize').argument('<caller>', 'Account to be authorized to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(
|
|
121
|
+
program.command('create-authwit').description('Creates an authorization witness that can be privately sent to a caller so they can perform an action on behalf of the provided account').argument('<functionName>', 'Name of function to authorize').argument('<caller>', 'Account to be authorized to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).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 (functionName, caller, _options, command)=>{
|
|
140
122
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
141
123
|
const options = command.optsWithGlobals();
|
|
142
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress,
|
|
143
|
-
const
|
|
144
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
145
|
-
const wallet = await account.getWallet();
|
|
124
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, alias } = options;
|
|
125
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
146
126
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
147
|
-
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
127
|
+
const witness = await createAuthwit(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
148
128
|
if (db) {
|
|
149
129
|
await db.storeAuthwitness(witness, log, alias);
|
|
150
130
|
}
|
|
151
131
|
});
|
|
152
|
-
program.command('authorize-action').description('Authorizes a public call on the caller, so they can perform an action on behalf of the provided account').argument('<functionName>', 'Name of function to authorize').argument('<caller>', 'Account to be authorized to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(
|
|
132
|
+
program.command('authorize-action').description('Authorizes a public call on the caller, so they can perform an action on behalf of the provided account').argument('<functionName>', 'Name of function to authorize').argument('<caller>', 'Account to be authorized to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).action(async (functionName, caller, _options, command)=>{
|
|
153
133
|
const { authorizeAction } = await import('./authorize_action.js');
|
|
154
134
|
const options = command.optsWithGlobals();
|
|
155
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress
|
|
156
|
-
const
|
|
157
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
158
|
-
const wallet = await account.getWallet();
|
|
135
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress } = options;
|
|
136
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
159
137
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
160
|
-
await authorizeAction(wallet,
|
|
138
|
+
await authorizeAction(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
161
139
|
});
|
|
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)).
|
|
140
|
+
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)).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)=>{
|
|
163
141
|
const { checkTx } = await import('./check_tx.js');
|
|
164
|
-
const {
|
|
142
|
+
const { pageSize } = options;
|
|
165
143
|
let { page } = options;
|
|
166
|
-
const
|
|
144
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
145
|
+
const node = walletAndNodeWrapper.node;
|
|
167
146
|
if (txHash) {
|
|
168
|
-
await checkTx(
|
|
147
|
+
await checkTx(wallet, node, txHash, false, log);
|
|
169
148
|
} else if (db) {
|
|
170
149
|
const aliases = await db.listAliases('transactions');
|
|
171
150
|
const totalPages = Math.ceil(aliases.length / pageSize);
|
|
@@ -173,53 +152,35 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
173
152
|
const dataRows = await Promise.all(aliases.slice(page * pageSize, pageSize * (1 + page)).map(async ({ key, value })=>({
|
|
174
153
|
alias: key,
|
|
175
154
|
txHash: value,
|
|
176
|
-
|
|
177
|
-
status: await checkTx(client, TxHash.fromString(value), true, log)
|
|
155
|
+
status: await checkTx(wallet, node, TxHash.fromString(value), true, log)
|
|
178
156
|
})));
|
|
179
157
|
log(`Recent transactions:`);
|
|
180
158
|
log('');
|
|
181
159
|
log(`${'Alias'.padEnd(32, ' ')} | ${'TxHash'.padEnd(64, ' ')} | ${'Cancellable'.padEnd(12, ' ')} | Status`);
|
|
182
|
-
log(''.padEnd(32 + 64 +
|
|
183
|
-
for (const { alias, txHash, status
|
|
184
|
-
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${
|
|
185
|
-
log(''.padEnd(32 + 64 +
|
|
160
|
+
log(''.padEnd(32 + 64 + 20, '-'));
|
|
161
|
+
for (const { alias, txHash, status } of dataRows){
|
|
162
|
+
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${status}`);
|
|
163
|
+
log(''.padEnd(32 + 64 + 20, '-'));
|
|
186
164
|
}
|
|
187
165
|
log(`Displaying ${Math.min(pageSize, aliases.length)} rows, page ${page + 1}/${totalPages}`);
|
|
188
166
|
} else {
|
|
189
167
|
log('Recent transactions are not available, please provide a specific transaction hash');
|
|
190
168
|
}
|
|
191
169
|
});
|
|
192
|
-
program.command('
|
|
193
|
-
const { cancelTx } = await import('./cancel_tx.js');
|
|
194
|
-
const { from: parsedFromAddress, rpcUrl, secretKey, payment, increasedFees, maxFeesPerGas } = options;
|
|
195
|
-
const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
196
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
197
|
-
const wallet = await account.getWallet();
|
|
198
|
-
const txData = await db?.retrieveTxData(txHash);
|
|
199
|
-
if (!txData) {
|
|
200
|
-
throw new Error('Transaction data not found in the database, cannot reuse nonce');
|
|
201
|
-
}
|
|
202
|
-
const paymentMethod = await parsePaymentMethod(payment, false, log, db)(wallet);
|
|
203
|
-
await cancelTx(wallet, txData, paymentMethod, increasedFees, maxFeesPerGas, log);
|
|
204
|
-
});
|
|
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)=>{
|
|
170
|
+
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(createAliasOption('Alias for the sender. Used for easy reference in subsequent commands.', !db)).action(async (address, options)=>{
|
|
206
171
|
const { registerSender } = await import('./register_sender.js');
|
|
207
|
-
const {
|
|
208
|
-
const
|
|
209
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
210
|
-
const wallet = await account.getWallet();
|
|
172
|
+
const { alias } = options;
|
|
173
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
211
174
|
await registerSender(wallet, address, log);
|
|
212
175
|
if (db && alias) {
|
|
213
176
|
await db.storeSender(address, alias, log);
|
|
214
177
|
}
|
|
215
178
|
});
|
|
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(
|
|
179
|
+
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(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)).action(async (address, artifactPathPromise, _options, command)=>{
|
|
217
180
|
const { registerContract } = await import('./register_contract.js');
|
|
218
|
-
const {
|
|
219
|
-
const
|
|
220
|
-
const node =
|
|
221
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
222
|
-
const wallet = await account.getWallet();
|
|
181
|
+
const { alias, init, publicKey, salt, deployer, args } = command.optsWithGlobals();
|
|
182
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
183
|
+
const node = walletAndNodeWrapper.node;
|
|
223
184
|
const artifactPath = await artifactPathPromise;
|
|
224
185
|
const instance = await registerContract(wallet, node, address, artifactPath, log, init, publicKey, args, salt, deployer);
|
|
225
186
|
if (db && alias) {
|
package/dest/cmds/profile.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
7
|
+
export declare function profile(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, debugOutputPath: string | undefined, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], log: LogFn): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvcHJvZmlsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFNUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFdEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFNbkQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFM0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFcEQsd0JBQXNCLE9BQU8sQ0FDM0IsTUFBTSxFQUFFLFNBQVMsRUFDakIsSUFBSSxFQUFFLFNBQVMsRUFDZixJQUFJLEVBQUUsWUFBWSxFQUNsQixZQUFZLEVBQUUsTUFBTSxFQUNwQixjQUFjLEVBQUUsR0FBRyxFQUFFLEVBQ3JCLG9CQUFvQixFQUFFLE1BQU0sRUFDNUIsZUFBZSxFQUFFLFlBQVksRUFDN0IsZUFBZSxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQ25DLE9BQU8sRUFBRSxVQUFVLEVBQ25CLGFBQWEsRUFBRSxXQUFXLEVBQUUsRUFDNUIsR0FBRyxFQUFFLEtBQUssaUJBcUJYIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/cmds/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/cmds/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,YAAY,EAClB,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,UAAU,EACnB,aAAa,EAAE,WAAW,EAAE,EAC5B,GAAG,EAAE,KAAK,iBAqBX"}
|
package/dest/cmds/profile.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { Contract } from '@aztec/aztec.js';
|
|
1
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
3
|
import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
4
4
|
import { promises as fs } from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { printProfileResult } from '../utils/profiling.js';
|
|
7
|
-
export async function profile(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, debugOutputPath, feeOpts, authWitnesses, log) {
|
|
7
|
+
export async function profile(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, debugOutputPath, feeOpts, authWitnesses, log) {
|
|
8
8
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
9
|
-
const contract =
|
|
9
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
10
10
|
const call = contract.methods[functionName](...functionArgs);
|
|
11
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, from);
|
|
11
12
|
const result = await call.profile({
|
|
12
|
-
|
|
13
|
+
fee: {
|
|
14
|
+
gasSettings,
|
|
15
|
+
paymentMethod
|
|
16
|
+
},
|
|
17
|
+
from,
|
|
13
18
|
profileMode: 'full',
|
|
14
19
|
authWitnesses,
|
|
15
20
|
skipProofGeneration: false
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { PublicKeys } from '@aztec/aztec.js/keys';
|
|
4
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
5
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function registerContract(wallet:
|
|
4
|
-
//# sourceMappingURL=
|
|
7
|
+
export declare function registerContract(wallet: Wallet, node: AztecNode, address: AztecAddress, artifactPath: string, log: LogFn, initializer?: string, publicKeys?: PublicKeys, rawArgs?: any[], salt?: Fr, deployer?: AztecAddress): Promise<import("@aztec/aztec.js/contracts").ContractInstanceWithAddress>;
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVnaXN0ZXJfY29udHJhY3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL3JlZ2lzdGVyX2NvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTlELE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUM1QyxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDbEQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFckQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsd0JBQXNCLGdCQUFnQixDQUNwQyxNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxTQUFTLEVBQ2YsT0FBTyxFQUFFLFlBQVksRUFDckIsWUFBWSxFQUFFLE1BQU0sRUFDcEIsR0FBRyxFQUFFLEtBQUssRUFDVixXQUFXLENBQUMsRUFBRSxNQUFNLEVBQ3BCLFVBQVUsQ0FBQyxFQUFFLFVBQVUsRUFDdkIsT0FBTyxDQUFDLEVBQUUsR0FBRyxFQUFFLEVBQ2YsSUFBSSxDQUFDLEVBQUUsRUFBRSxFQUNULFFBQVEsQ0FBQyxFQUFFLFlBQVksNEVBc0J4QiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,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,4EAsBxB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { PublicKeys } from '@aztec/aztec.js/keys';
|
|
2
4
|
import { getContractArtifact } from '@aztec/cli/cli-utils';
|
|
3
5
|
import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
4
6
|
export async function registerContract(wallet, node, address, artifactPath, log, initializer, publicKeys, rawArgs, salt, deployer) {
|
|
@@ -12,17 +14,14 @@ export async function registerContract(wallet, node, address, artifactPath, log,
|
|
|
12
14
|
constructorArtifact,
|
|
13
15
|
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
14
16
|
constructorArgs: rawArgs,
|
|
15
|
-
salt,
|
|
17
|
+
salt: salt ?? Fr.ZERO,
|
|
16
18
|
deployer
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
21
|
if (!contractInstance.address.equals(address)) {
|
|
20
22
|
throw new Error(`Contract address mismatch: expected ${address}, got ${contractInstance.address}`);
|
|
21
23
|
}
|
|
22
|
-
await wallet.registerContract(
|
|
23
|
-
instance: contractInstance,
|
|
24
|
-
artifact: contractArtifact
|
|
25
|
-
});
|
|
24
|
+
await wallet.registerContract(contractInstance, contractArtifact);
|
|
26
25
|
log(`Contract registered: at ${contractInstance.address}`);
|
|
27
26
|
return contractInstance;
|
|
28
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function registerSender(wallet:
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
export declare function registerSender(wallet: Wallet, address: AztecAddress, log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVnaXN0ZXJfc2VuZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY21kcy9yZWdpc3Rlcl9zZW5kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3JELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELHdCQUFzQixjQUFjLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxPQUFPLEVBQUUsWUFBWSxFQUFFLEdBQUcsRUFBRSxLQUFLLGlCQUdyRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register_sender.d.ts","sourceRoot":"","sources":["../../src/cmds/register_sender.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"register_sender.d.ts","sourceRoot":"","sources":["../../src/cmds/register_sender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,iBAGrF"}
|
package/dest/cmds/send.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export declare function send(wallet:
|
|
6
|
-
txHash: import("
|
|
7
|
-
txNonce: Fr;
|
|
8
|
-
cancellable: boolean;
|
|
9
|
-
gasSettings: GasSettings;
|
|
5
|
+
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
7
|
+
export declare function send(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<{
|
|
8
|
+
txHash: import("../../../stdlib/dest/tx/tx_hash.js").TxHash;
|
|
10
9
|
} | undefined>;
|
|
11
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvc2VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFNUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFdEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRXRELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixJQUFJLENBQ3hCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLElBQUksRUFBRSxTQUFTLEVBQ2YsSUFBSSxFQUFFLFlBQVksRUFDbEIsWUFBWSxFQUFFLE1BQU0sRUFDcEIsY0FBYyxFQUFFLEdBQUcsRUFBRSxFQUNyQixvQkFBb0IsRUFBRSxNQUFNLEVBQzVCLGVBQWUsRUFBRSxZQUFZLEVBQzdCLElBQUksRUFBRSxPQUFPLEVBQ2IsV0FBVyxFQUFFLE9BQU8sRUFDcEIsT0FBTyxFQUFFLFVBQVUsRUFDbkIsYUFBYSxFQUFFLFdBQVcsRUFBRSxFQUM1QixPQUFPLEVBQUUsT0FBTyxFQUNoQixHQUFHLEVBQUUsS0FBSzs7ZUFrRFgifQ==
|
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,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,IAAI,CACxB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,YAAY,EAClB,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,UAAU,EACnB,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK;;eAkDX"}
|
package/dest/cmds/send.js
CHANGED
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
import { Contract
|
|
1
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
-
import {
|
|
4
|
-
import { printGasEstimates } from '../utils/options/fees.js';
|
|
3
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
4
|
import { printProfileResult } from '../utils/profiling.js';
|
|
6
|
-
|
|
7
|
-
export async function send(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, verbose, log) {
|
|
5
|
+
export async function send(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, verbose, log) {
|
|
8
6
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
9
|
-
const contract =
|
|
7
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
10
8
|
const call = contract.methods[functionName](...functionArgs);
|
|
11
|
-
const
|
|
9
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, from);
|
|
12
10
|
const sendOptions = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
fee: {
|
|
12
|
+
paymentMethod,
|
|
13
|
+
gasSettings
|
|
14
|
+
},
|
|
15
|
+
from,
|
|
16
|
+
authWitnesses
|
|
17
17
|
};
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const { estimatedGas, stats } = await call.simulate({
|
|
19
|
+
...sendOptions,
|
|
20
|
+
fee: {
|
|
21
|
+
...sendOptions.fee,
|
|
22
|
+
estimateGas: true
|
|
23
|
+
}
|
|
24
|
+
});
|
|
20
25
|
if (feeOpts.estimateOnly) {
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
|
-
const
|
|
28
|
+
const tx = call.send({
|
|
29
|
+
...sendOptions,
|
|
30
|
+
fee: {
|
|
31
|
+
...sendOptions.fee,
|
|
32
|
+
gasSettings: estimatedGas
|
|
33
|
+
}
|
|
34
|
+
});
|
|
24
35
|
if (verbose) {
|
|
25
|
-
printProfileResult(
|
|
36
|
+
printProfileResult(stats, log);
|
|
26
37
|
}
|
|
27
|
-
const tx = provenTx.send();
|
|
28
38
|
const txHash = await tx.getTxHash();
|
|
29
39
|
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
30
40
|
if (wait) {
|
|
@@ -44,14 +54,7 @@ export async function send(wallet, functionName, functionArgsIn, contractArtifac
|
|
|
44
54
|
} else {
|
|
45
55
|
log('Transaction pending. Check status with check-tx');
|
|
46
56
|
}
|
|
47
|
-
const gasSettings = GasSettings.from({
|
|
48
|
-
...feeOpts.gasSettings,
|
|
49
|
-
...gasLimits
|
|
50
|
-
});
|
|
51
57
|
return {
|
|
52
|
-
txHash
|
|
53
|
-
txNonce,
|
|
54
|
-
cancellable,
|
|
55
|
-
gasSettings
|
|
58
|
+
txHash
|
|
56
59
|
};
|
|
57
60
|
}
|
package/dest/cmds/simulate.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
7
|
+
export declare function simulate(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltdWxhdGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL3NpbXVsYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQzlELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUU1RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUtuRCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUUzRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVwRCx3QkFBc0IsUUFBUSxDQUM1QixNQUFNLEVBQUUsU0FBUyxFQUNqQixJQUFJLEVBQUUsU0FBUyxFQUNmLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixPQUFPLEVBQUUsVUFBVSxFQUNuQixhQUFhLEVBQUUsV0FBVyxFQUFFLEVBQzVCLE9BQU8sRUFBRSxPQUFPLEVBQ2hCLEdBQUcsRUFBRSxLQUFLLGlCQWdDWCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,iBAgCX"}
|