@aztec/cli-wallet 0.0.0-test.1 → 0.0.1-commit.b655e406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dest/bin/index.js +48 -26
- package/dest/cmds/authorize_action.d.ts +3 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +8 -4
- package/dest/cmds/bridge_fee_juice.d.ts +2 -2
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +8 -7
- package/dest/cmds/check_tx.d.ts +4 -2
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +145 -6
- package/dest/cmds/create_account.d.ts +6 -5
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +46 -27
- package/dest/cmds/create_authwit.d.ts +3 -2
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/create_authwit.js +5 -5
- package/dest/cmds/deploy.d.ts +6 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +71 -54
- package/dest/cmds/deploy_account.d.ts +5 -7
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +46 -29
- package/dest/cmds/import_test_accounts.d.ts +2 -2
- 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 +2 -2
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +83 -115
- package/dest/cmds/profile.d.ts +8 -0
- package/dest/cmds/profile.d.ts.map +1 -0
- package/dest/cmds/profile.js +28 -0
- package/dest/cmds/register_contract.d.ts +6 -2
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +20 -7
- package/dest/cmds/register_sender.d.ts +3 -2
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +7 -8
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +31 -20
- package/dest/cmds/simulate.d.ts +6 -2
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +25 -19
- package/dest/storage/wallet_db.d.ts +4 -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 +6 -0
- package/dest/utils/authorizations.d.ts.map +1 -0
- package/dest/utils/authorizations.js +28 -0
- 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 +0 -2
- package/dest/utils/ecdsa.d.ts.map +1 -1
- package/dest/utils/options/fees.d.ts +20 -27
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +85 -144
- package/dest/utils/options/options.d.ts +8 -4
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +26 -14
- 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/wallet.d.ts +35 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +193 -0
- package/package.json +24 -20
- package/src/bin/index.ts +56 -32
- package/src/cmds/authorize_action.ts +15 -4
- package/src/cmds/bridge_fee_juice.ts +14 -11
- package/src/cmds/check_tx.ts +182 -5
- package/src/cmds/create_account.ts +55 -32
- package/src/cmds/create_authwit.ts +8 -4
- package/src/cmds/deploy.ts +79 -62
- package/src/cmds/deploy_account.ts +57 -28
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +256 -220
- package/src/cmds/profile.ts +48 -0
- package/src/cmds/register_contract.ts +28 -5
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +31 -17
- package/src/cmds/simulate.ts +39 -23
- package/src/storage/wallet_db.ts +3 -31
- package/src/utils/authorizations.ts +51 -0
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/options/fees.ts +134 -206
- package/src/utils/options/options.ts +41 -19
- package/src/utils/profiling.ts +158 -0
- package/src/utils/wallet.ts +264 -0
- 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/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 -38
- package/dest/utils/accounts.d.ts +0 -11
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -87
- package/dest/utils/pxe_wrapper.d.ts +0 -10
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -21
- package/src/cmds/add_authwit.ts +0 -13
- package/src/cmds/cancel_tx.ts +0 -62
- package/src/utils/accounts.ts +0 -102
- package/src/utils/pxe_wrapper.ts +0 -26
package/dest/cmds/index.js
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
|
-
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';
|
|
7
5
|
import { Option } from 'commander';
|
|
8
6
|
import inquirer from 'inquirer';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error(`A db is required to store the imported test accounts.`);
|
|
16
|
-
}
|
|
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;
|
|
17
13
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
18
|
-
|
|
19
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
20
|
-
await importTestAccounts(client, db, json, log);
|
|
14
|
+
await importTestAccounts(wallet, db, json, log);
|
|
21
15
|
});
|
|
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', '
|
|
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.
|
|
23
17
|
// 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
|
-
addOptions(createAccountCommand,
|
|
18
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').addOption(createVerboseOption());
|
|
19
|
+
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command)=>{
|
|
26
20
|
const { createAccount } = await import('./create_account.js');
|
|
27
21
|
const options = command.optsWithGlobals();
|
|
28
|
-
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy,
|
|
22
|
+
const { type, from: parsedFromAddress, secretKey, wait, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
29
23
|
let { publicKey } = options;
|
|
30
24
|
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
31
25
|
const identities = await getIdentities();
|
|
@@ -39,8 +33,8 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
39
33
|
]);
|
|
40
34
|
publicKey = answers.identity.split(' ')[1];
|
|
41
35
|
}
|
|
42
|
-
const
|
|
43
|
-
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);
|
|
44
38
|
if (db) {
|
|
45
39
|
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
46
40
|
await db.storeAccount(address, {
|
|
@@ -52,113 +46,105 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
52
46
|
}, log);
|
|
53
47
|
}
|
|
54
48
|
});
|
|
55
|
-
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.
|
|
56
50
|
// 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
|
-
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)=>{
|
|
59
53
|
const { deployAccount } = await import('./deploy_account.js');
|
|
60
54
|
const options = command.optsWithGlobals();
|
|
61
|
-
const {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
await deployAccount(account, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, 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);
|
|
65
58
|
});
|
|
66
|
-
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.
|
|
67
60
|
// 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
|
-
addOptions(deployCommand,
|
|
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());
|
|
62
|
+
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
70
63
|
const { deploy } = await import('./deploy.js');
|
|
71
64
|
const options = command.optsWithGlobals();
|
|
72
|
-
const { json, publicKey, args, salt, wait,
|
|
73
|
-
const
|
|
74
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
75
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
65
|
+
const { json, publicKey, args, salt, wait, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
66
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
76
67
|
const artifactPath = await artifactPathPromise;
|
|
77
|
-
debugLogger.info(`Using wallet with address ${
|
|
78
|
-
const address = await deploy(
|
|
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);
|
|
79
70
|
if (db && address) {
|
|
80
71
|
await db.storeContract(address, artifactPath, log, alias);
|
|
81
72
|
}
|
|
82
73
|
});
|
|
83
|
-
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(
|
|
84
|
-
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)=>{
|
|
85
76
|
const { send } = await import('./send.js');
|
|
86
77
|
const options = command.optsWithGlobals();
|
|
87
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait,
|
|
88
|
-
const
|
|
89
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
90
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
78
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, alias, authWitness: authWitnessArray, verbose } = options;
|
|
79
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
91
80
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
92
|
-
debugLogger.info(`Using wallet with address ${
|
|
93
|
-
const
|
|
81
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
82
|
+
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
83
|
+
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
94
84
|
if (db && sentTx) {
|
|
95
|
-
const txAlias = alias ? alias : `${functionName}-${
|
|
85
|
+
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString()}`;
|
|
96
86
|
await db.storeTx(sentTx, log, txAlias);
|
|
97
87
|
}
|
|
98
88
|
});
|
|
99
|
-
program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(
|
|
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)=>{
|
|
100
91
|
const { simulate } = await import('./simulate.js');
|
|
101
92
|
const options = command.optsWithGlobals();
|
|
102
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress,
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
93
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, verbose, authWitness } = options;
|
|
94
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
95
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
96
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
97
|
+
await simulate(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
98
|
+
});
|
|
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)=>{
|
|
101
|
+
const { profile } = await import('./profile.js');
|
|
102
|
+
const options = command.optsWithGlobals();
|
|
103
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, debugExecutionStepsDir, authWitness } = options;
|
|
104
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
106
105
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
107
|
-
|
|
106
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
107
|
+
await profile(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, debugExecutionStepsDir, CLIFeeArgs.parse(options, log, db), authWitnesses, log);
|
|
108
108
|
});
|
|
109
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(','), [
|
|
110
110
|
ETHEREUM_HOSTS
|
|
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(
|
|
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.
|
|
112
112
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
113
|
-
.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)=>{
|
|
114
114
|
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
115
|
-
const {
|
|
116
|
-
const
|
|
117
|
-
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);
|
|
118
117
|
if (db) {
|
|
119
118
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
120
119
|
}
|
|
121
120
|
});
|
|
122
|
-
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)=>{
|
|
123
122
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
124
123
|
const options = command.optsWithGlobals();
|
|
125
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress,
|
|
126
|
-
const
|
|
127
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
128
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
124
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, alias } = options;
|
|
125
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
129
126
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
130
|
-
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
127
|
+
const witness = await createAuthwit(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
131
128
|
if (db) {
|
|
132
129
|
await db.storeAuthwitness(witness, log, alias);
|
|
133
130
|
}
|
|
134
131
|
});
|
|
135
|
-
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)=>{
|
|
136
133
|
const { authorizeAction } = await import('./authorize_action.js');
|
|
137
134
|
const options = command.optsWithGlobals();
|
|
138
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress
|
|
139
|
-
const
|
|
140
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
141
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
135
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress } = options;
|
|
136
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
142
137
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
143
|
-
await authorizeAction(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
138
|
+
await authorizeAction(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
144
139
|
});
|
|
145
|
-
program.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);
|
|
154
|
-
});
|
|
155
|
-
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)=>{
|
|
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)=>{
|
|
156
141
|
const { checkTx } = await import('./check_tx.js');
|
|
157
|
-
const {
|
|
142
|
+
const { pageSize } = options;
|
|
158
143
|
let { page } = options;
|
|
159
|
-
const
|
|
144
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
145
|
+
const node = walletAndNodeWrapper.node;
|
|
160
146
|
if (txHash) {
|
|
161
|
-
await checkTx(
|
|
147
|
+
await checkTx(wallet, node, txHash, false, log);
|
|
162
148
|
} else if (db) {
|
|
163
149
|
const aliases = await db.listAliases('transactions');
|
|
164
150
|
const totalPages = Math.ceil(aliases.length / pageSize);
|
|
@@ -166,55 +152,37 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
166
152
|
const dataRows = await Promise.all(aliases.slice(page * pageSize, pageSize * (1 + page)).map(async ({ key, value })=>({
|
|
167
153
|
alias: key,
|
|
168
154
|
txHash: value,
|
|
169
|
-
|
|
170
|
-
status: await checkTx(client, TxHash.fromString(value), true, log)
|
|
155
|
+
status: await checkTx(wallet, node, TxHash.fromString(value), true, log)
|
|
171
156
|
})));
|
|
172
157
|
log(`Recent transactions:`);
|
|
173
158
|
log('');
|
|
174
159
|
log(`${'Alias'.padEnd(32, ' ')} | ${'TxHash'.padEnd(64, ' ')} | ${'Cancellable'.padEnd(12, ' ')} | Status`);
|
|
175
|
-
log(''.padEnd(32 + 64 +
|
|
176
|
-
for (const { alias, txHash, status
|
|
177
|
-
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${
|
|
178
|
-
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, '-'));
|
|
179
164
|
}
|
|
180
165
|
log(`Displaying ${Math.min(pageSize, aliases.length)} rows, page ${page + 1}/${totalPages}`);
|
|
181
166
|
} else {
|
|
182
167
|
log('Recent transactions are not available, please provide a specific transaction hash');
|
|
183
168
|
}
|
|
184
169
|
});
|
|
185
|
-
program.command('
|
|
186
|
-
const { cancelTx } = await import('./cancel_tx.js');
|
|
187
|
-
const { from: parsedFromAddress, rpcUrl, secretKey, payment, increasedFees, maxFeesPerGas } = options;
|
|
188
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
189
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
190
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
191
|
-
const txData = await db?.retrieveTxData(txHash);
|
|
192
|
-
if (!txData) {
|
|
193
|
-
throw new Error('Transaction data not found in the database, cannot reuse nonce');
|
|
194
|
-
}
|
|
195
|
-
const paymentMethod = await parsePaymentMethod(payment, false, log, db)(wallet);
|
|
196
|
-
await cancelTx(wallet, txData, paymentMethod, increasedFees, maxFeesPerGas, log);
|
|
197
|
-
});
|
|
198
|
-
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)=>{
|
|
199
171
|
const { registerSender } = await import('./register_sender.js');
|
|
200
|
-
const {
|
|
201
|
-
const
|
|
202
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
203
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
172
|
+
const { alias } = options;
|
|
173
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
204
174
|
await registerSender(wallet, address, log);
|
|
205
175
|
if (db && alias) {
|
|
206
176
|
await db.storeSender(address, alias, log);
|
|
207
177
|
}
|
|
208
178
|
});
|
|
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).
|
|
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)=>{
|
|
210
180
|
const { registerContract } = await import('./register_contract.js');
|
|
211
|
-
const {
|
|
212
|
-
const
|
|
213
|
-
const node =
|
|
214
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
215
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
181
|
+
const { alias, init, publicKey, salt, deployer, args } = command.optsWithGlobals();
|
|
182
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
183
|
+
const node = walletAndNodeWrapper.node;
|
|
216
184
|
const artifactPath = await artifactPathPromise;
|
|
217
|
-
const instance = await registerContract(wallet, node, address, artifactPath, log);
|
|
185
|
+
const instance = await registerContract(wallet, node, address, artifactPath, log, init, publicKey, args, salt, deployer);
|
|
218
186
|
if (db && alias) {
|
|
219
187
|
await db.storeContract(instance.address, artifactPath, log, alias);
|
|
220
188
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
4
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
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=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
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, node, from, 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 { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, from);
|
|
12
|
+
const result = await call.profile({
|
|
13
|
+
fee: {
|
|
14
|
+
gasSettings,
|
|
15
|
+
paymentMethod
|
|
16
|
+
},
|
|
17
|
+
from,
|
|
18
|
+
profileMode: 'full',
|
|
19
|
+
authWitnesses,
|
|
20
|
+
skipProofGeneration: false
|
|
21
|
+
});
|
|
22
|
+
printProfileResult(result.stats, log, true, result.executionSteps);
|
|
23
|
+
if (debugOutputPath) {
|
|
24
|
+
const ivcInputsPath = path.join(debugOutputPath, 'ivc-inputs.msgpack');
|
|
25
|
+
log(`Debug output written to ${ivcInputsPath}.`);
|
|
26
|
+
await fs.writeFile(ivcInputsPath, serializePrivateExecutionSteps(result.executionSteps));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
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:
|
|
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>;
|
|
4
8
|
//# 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,EAAE,
|
|
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,14 +1,27 @@
|
|
|
1
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { PublicKeys } from '@aztec/aztec.js/keys';
|
|
1
4
|
import { getContractArtifact } from '@aztec/cli/cli-utils';
|
|
2
|
-
|
|
5
|
+
import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
|
|
6
|
+
export async function registerContract(wallet, node, address, artifactPath, log, initializer, publicKeys, rawArgs, salt, deployer) {
|
|
3
7
|
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
4
|
-
const
|
|
8
|
+
const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
|
|
9
|
+
const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
|
|
10
|
+
let contractInstance = await node.getContract(address);
|
|
5
11
|
if (!contractInstance) {
|
|
6
|
-
|
|
12
|
+
log(`Contract not found in the node at ${address}. Computing instance locally...`);
|
|
13
|
+
contractInstance = await getContractInstanceFromInstantiationParams(contractArtifact, {
|
|
14
|
+
constructorArtifact,
|
|
15
|
+
publicKeys: publicKeys ?? PublicKeys.default(),
|
|
16
|
+
constructorArgs: rawArgs,
|
|
17
|
+
salt: salt ?? Fr.ZERO,
|
|
18
|
+
deployer
|
|
19
|
+
});
|
|
7
20
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
if (!contractInstance.address.equals(address)) {
|
|
22
|
+
throw new Error(`Contract address mismatch: expected ${address}, got ${contractInstance.address}`);
|
|
23
|
+
}
|
|
24
|
+
await wallet.registerContract(contractInstance, contractArtifact);
|
|
12
25
|
log(`Contract registered: at ${contractInstance.address}`);
|
|
13
26
|
return contractInstance;
|
|
14
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
|
+
export declare function registerSender(wallet: Wallet, address: AztecAddress, log: LogFn): Promise<void>;
|
|
4
5
|
//# sourceMappingURL=register_sender.d.ts.map
|
|
@@ -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("@aztec/aztec.js").TxHash;
|
|
7
|
-
nonce: 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("@aztec/aztec.js/tx").TxHash;
|
|
10
9
|
} | undefined>;
|
|
11
10
|
//# sourceMappingURL=send.d.ts.map
|
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,EAAE,
|
|
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,29 +1,47 @@
|
|
|
1
|
-
import { Contract
|
|
1
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export async function send(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, log) {
|
|
3
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
4
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
5
|
+
export async function send(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, verbose, log) {
|
|
6
6
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
7
7
|
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
8
8
|
const call = contract.methods[functionName](...functionArgs);
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(node, wallet, from);
|
|
10
|
+
const sendOptions = {
|
|
11
|
+
fee: {
|
|
12
|
+
paymentMethod,
|
|
13
|
+
gasSettings
|
|
14
|
+
},
|
|
15
|
+
from,
|
|
16
|
+
authWitnesses
|
|
17
|
+
};
|
|
18
|
+
const { estimatedGas, stats } = await call.simulate({
|
|
19
|
+
...sendOptions,
|
|
20
|
+
fee: {
|
|
21
|
+
...sendOptions.fee,
|
|
22
|
+
estimateGas: true
|
|
23
|
+
}
|
|
11
24
|
});
|
|
12
|
-
printGasEstimates(feeOpts, gasLimits, log);
|
|
13
25
|
if (feeOpts.estimateOnly) {
|
|
14
26
|
return;
|
|
15
27
|
}
|
|
16
|
-
const nonce = Fr.random();
|
|
17
28
|
const tx = call.send({
|
|
18
|
-
...
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
...sendOptions,
|
|
30
|
+
fee: {
|
|
31
|
+
...sendOptions.fee,
|
|
32
|
+
gasSettings: estimatedGas
|
|
33
|
+
}
|
|
21
34
|
});
|
|
35
|
+
if (verbose) {
|
|
36
|
+
printProfileResult(stats, log);
|
|
37
|
+
}
|
|
22
38
|
const txHash = await tx.getTxHash();
|
|
23
39
|
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
24
40
|
if (wait) {
|
|
25
41
|
try {
|
|
26
|
-
await tx.wait(
|
|
42
|
+
await tx.wait({
|
|
43
|
+
timeout: DEFAULT_TX_TIMEOUT_S
|
|
44
|
+
});
|
|
27
45
|
log('Transaction has been mined');
|
|
28
46
|
const receipt = await tx.getReceipt();
|
|
29
47
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
@@ -36,14 +54,7 @@ export async function send(wallet, functionName, functionArgsIn, contractArtifac
|
|
|
36
54
|
} else {
|
|
37
55
|
log('Transaction pending. Check status with check-tx');
|
|
38
56
|
}
|
|
39
|
-
const gasSettings = GasSettings.from({
|
|
40
|
-
...feeOpts.gasSettings,
|
|
41
|
-
...gasLimits
|
|
42
|
-
});
|
|
43
57
|
return {
|
|
44
|
-
txHash
|
|
45
|
-
nonce,
|
|
46
|
-
cancellable,
|
|
47
|
-
gasSettings
|
|
58
|
+
txHash
|
|
48
59
|
};
|
|
49
60
|
}
|
package/dest/cmds/simulate.d.ts
CHANGED
|
@@ -1,4 +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
|
-
|
|
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>;
|
|
4
8
|
//# 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,
|
|
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"}
|