@aztec/cli-wallet 0.0.0-test.1 → 0.0.1-commit.017a351
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 +2 -1
- package/dest/bin/index.js +58 -26
- 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 +11 -5
- 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 +10 -8
- 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 +174 -6
- package/dest/cmds/create_account.d.ts +10 -7
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +74 -38
- 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 +8 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +108 -59
- package/dest/cmds/deploy_account.d.ts +7 -8
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +70 -36
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- 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 +99 -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 +7 -3
- 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 +4 -3
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +9 -9
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +54 -27
- package/dest/cmds/simulate.d.ts +7 -3
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +26 -20
- package/dest/storage/wallet_db.d.ts +12 -19
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +63 -55
- 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/constants.d.ts +4 -0
- package/dest/utils/constants.d.ts.map +1 -0
- package/dest/utils/constants.js +7 -0
- package/dest/utils/ecdsa.d.ts +1 -3
- package/dest/utils/ecdsa.d.ts.map +1 -1
- package/dest/utils/options/fees.d.ts +23 -28
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +112 -148
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +9 -5
- 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 +68 -0
- package/dest/utils/wallet.d.ts +44 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +263 -0
- package/package.json +31 -23
- package/src/bin/index.ts +63 -33
- package/src/cmds/authorize_action.ts +16 -5
- package/src/cmds/bridge_fee_juice.ts +16 -12
- package/src/cmds/check_tx.ts +212 -5
- package/src/cmds/create_account.ts +89 -45
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +115 -71
- package/src/cmds/deploy_account.ts +84 -36
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +312 -222
- 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 +59 -25
- package/src/cmds/simulate.ts +37 -24
- package/src/storage/wallet_db.ts +67 -68
- package/src/utils/authorizations.ts +51 -0
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/constants.ts +4 -0
- package/src/utils/options/fees.ts +169 -210
- package/src/utils/options/options.ts +41 -19
- package/src/utils/profiling.ts +172 -0
- package/src/utils/wallet.ts +330 -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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
2
|
+
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
3
|
+
const FEE_JUICE_DECIMALS = 18;
|
|
4
|
+
const FEE_JUICE_UNIT = 10n ** BigInt(FEE_JUICE_DECIMALS);
|
|
5
|
+
/** Formats a raw FeeJuice balance (18 decimals) for human-readable display. */ function formatFeeJuice(raw, exact) {
|
|
6
|
+
const whole = raw / FEE_JUICE_UNIT;
|
|
7
|
+
const fractional = raw % FEE_JUICE_UNIT;
|
|
8
|
+
const fracStr = fractional.toString().padStart(FEE_JUICE_DECIMALS, '0');
|
|
9
|
+
if (exact) {
|
|
10
|
+
return `${whole}.${fracStr} FJ`;
|
|
11
|
+
}
|
|
12
|
+
if (fractional === 0n) {
|
|
13
|
+
return `${whole} FJ`;
|
|
14
|
+
}
|
|
15
|
+
return `${whole}.${fracStr.replace(/0+$/, '')} FJ`;
|
|
16
|
+
}
|
|
17
|
+
export async function getFeeJuiceBalanceCmd(node, address, json, exact, log) {
|
|
18
|
+
const balance = await getFeeJuiceBalance(address, node);
|
|
19
|
+
if (json) {
|
|
20
|
+
log(prettyPrintJSON({
|
|
21
|
+
address: address.toString(),
|
|
22
|
+
balance: balance.toString()
|
|
23
|
+
}));
|
|
24
|
+
} else {
|
|
25
|
+
log(`Fee Juice balance for ${address.toString()}: ${formatFeeJuice(balance, exact)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type PXE } from '@aztec/aztec.js';
|
|
2
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
2
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
4
|
+
export declare function importTestAccounts(wallet: CLIWallet, db: WalletDB, json: boolean, log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0X3Rlc3RfYWNjb3VudHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2ltcG9ydF90ZXN0X2FjY291bnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3hELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixrQkFBa0IsQ0FBQyxNQUFNLEVBQUUsU0FBUyxFQUFFLEVBQUUsRUFBRSxRQUFRLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxpQkFrQ2xHIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_test_accounts.d.ts","sourceRoot":"","sources":["../../src/cmds/import_test_accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import_test_accounts.d.ts","sourceRoot":"","sources":["../../src/cmds/import_test_accounts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,iBAkClG"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
3
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
5
|
-
export async function importTestAccounts(
|
|
6
|
-
const testAccounts = await
|
|
7
|
-
const accounts = await Promise.all(testAccounts.map(({ secret, signingKey, salt })=>getSchnorrAccount(client, secret, signingKey, salt)));
|
|
4
|
+
export async function importTestAccounts(wallet, db, json, log) {
|
|
5
|
+
const testAccounts = await getInitialTestAccountsData();
|
|
8
6
|
const out = {};
|
|
9
|
-
await Promise.all(
|
|
7
|
+
await Promise.all(testAccounts.map(async (account, i)=>{
|
|
10
8
|
const alias = `test${i}`;
|
|
11
9
|
const secret = testAccounts[i].secret;
|
|
12
10
|
const salt = new Fr(account.salt);
|
|
13
|
-
const address = account.
|
|
14
|
-
await account.register();
|
|
11
|
+
const address = account.address;
|
|
15
12
|
await db.storeAccount(address, {
|
|
16
13
|
type: 'schnorr',
|
|
17
14
|
secretKey: secret,
|
package/dest/cmds/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { type Command } from 'commander';
|
|
3
3
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
4
|
-
import type {
|
|
5
|
-
export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger,
|
|
6
|
-
//# sourceMappingURL=
|
|
4
|
+
import type { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
|
+
export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger, walletAndNodeWrapper: CliWalletAndNodeWrapper, db: WalletDB): Command;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUczRCxPQUFPLEVBQUUsS0FBSyxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQW1DdkYsd0JBQWdCLGNBQWMsQ0FDNUIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsR0FBRyxFQUFFLEtBQUssRUFDVixXQUFXLEVBQUUsTUFBTSxFQUNuQixvQkFBb0IsRUFBRSx1QkFBdUIsRUFDN0MsRUFBRSxFQUFFLFFBQVEsV0E4cEJiIn0=
|
package/dest/cmds/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAmCvF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,uBAAuB,EAC7C,EAAE,EAAE,QAAQ,WA8pBb"}
|
package/dest/cmds/index.js
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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/random';
|
|
5
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
7
6
|
import { Option } from 'commander';
|
|
8
7
|
import inquirer from 'inquirer';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
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';
|
|
9
|
+
function parseWaitForStatus(status) {
|
|
10
|
+
switch(status){
|
|
11
|
+
case 'proposed':
|
|
12
|
+
return TxStatus.PROPOSED;
|
|
13
|
+
case 'checkpointed':
|
|
14
|
+
return TxStatus.CHECKPOINTED;
|
|
15
|
+
default:
|
|
16
|
+
throw new Error(`Invalid wait-for-status: ${status}. Use 'proposed' or 'checkpointed'.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// TODO: This function is only used in 1 place so we could just inline this
|
|
20
|
+
export function injectCommands(program, log, debugLogger, walletAndNodeWrapper, db) {
|
|
21
|
+
program.command('import-test-accounts').description('Import test accounts from pxe.').option('--json', 'Emit output as json').action(async (options)=>{
|
|
22
|
+
const { json } = options;
|
|
23
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
17
24
|
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);
|
|
25
|
+
await importTestAccounts(wallet, db, json, log);
|
|
21
26
|
});
|
|
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
|
|
27
|
+
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 account which uses an immutable key for authentication.').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('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address. Defaults to 0.', parseFieldFromHexString).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
28
|
// 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,
|
|
29
|
+
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
30
|
+
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command)=>{
|
|
26
31
|
const { createAccount } = await import('./create_account.js');
|
|
27
32
|
const options = command.optsWithGlobals();
|
|
28
|
-
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy,
|
|
33
|
+
const { type, from: parsedFromAddress, secretKey, salt, wait, waitForStatus: waitForStatusStr, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
29
34
|
let { publicKey } = options;
|
|
30
35
|
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
31
36
|
const identities = await getIdentities();
|
|
@@ -39,8 +44,8 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
39
44
|
]);
|
|
40
45
|
publicKey = answers.identity.split(' ')[1];
|
|
41
46
|
}
|
|
42
|
-
const
|
|
43
|
-
const accountCreationResult = await createAccount(
|
|
47
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
48
|
+
const accountCreationResult = await createAccount(wallet, node, type, secretKey, salt, publicKey, alias, parsedFromAddress, registerOnly, skipInitialization, publicDeploy, registerClass, wait, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), json, verbose, debugLogger, log);
|
|
44
49
|
if (db) {
|
|
45
50
|
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
46
51
|
await db.storeAccount(address, {
|
|
@@ -52,113 +57,110 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
52
57
|
}, log);
|
|
53
58
|
}
|
|
54
59
|
});
|
|
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
|
|
60
|
+
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
61
|
// 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,
|
|
62
|
+
.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.').option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
63
|
+
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command)=>{
|
|
59
64
|
const { deployAccount } = await import('./deploy_account.js');
|
|
60
65
|
const options = command.optsWithGlobals();
|
|
61
|
-
const {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
await deployAccount(account, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, debugLogger, log);
|
|
66
|
+
const { wait, waitForStatus: waitForStatusStr, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
67
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
68
|
+
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), json, verbose, debugLogger, log);
|
|
65
69
|
});
|
|
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(
|
|
70
|
+
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. Defaults to random.', 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
71
|
// 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,
|
|
72
|
+
.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')).option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
73
|
+
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
70
74
|
const { deploy } = await import('./deploy.js');
|
|
71
75
|
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);
|
|
76
|
+
const { json, publicKey, args, salt, wait, waitForStatus: waitForStatusStr, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
77
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
76
78
|
const artifactPath = await artifactPathPromise;
|
|
77
|
-
debugLogger.info(`Using wallet with address ${
|
|
78
|
-
const address = await deploy(
|
|
79
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress?.toString() ?? '<none>'}`);
|
|
80
|
+
const address = await deploy(wallet, node, parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), verbose, timeout, debugLogger, log, universal);
|
|
79
81
|
if (db && address) {
|
|
80
82
|
await db.storeContract(address, artifactPath, log, alias);
|
|
81
83
|
}
|
|
82
84
|
});
|
|
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,
|
|
85
|
+
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').option('--wait-for-status <status>', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed').addOption(createVerboseOption());
|
|
86
|
+
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
85
87
|
const { send } = await import('./send.js');
|
|
86
88
|
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);
|
|
89
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, waitForStatus: waitForStatusStr, alias, authWitness: authWitnessArray, verbose } = options;
|
|
90
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
91
91
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
92
|
-
debugLogger.info(`Using wallet with address ${
|
|
93
|
-
const
|
|
92
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
93
|
+
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
94
|
+
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, parseWaitForStatus(waitForStatusStr), verbose, log);
|
|
94
95
|
if (db && sentTx) {
|
|
95
|
-
const txAlias = alias ? alias : `${functionName}-${
|
|
96
|
+
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString('hex')}`;
|
|
96
97
|
await db.storeTx(sentTx, log, txAlias);
|
|
97
98
|
}
|
|
98
99
|
});
|
|
99
|
-
program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(
|
|
100
|
+
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());
|
|
101
|
+
addOptions(simulateCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
100
102
|
const { simulate } = await import('./simulate.js');
|
|
101
103
|
const options = command.optsWithGlobals();
|
|
102
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress,
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
104
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, verbose, authWitness } = options;
|
|
105
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
106
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
107
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
108
|
+
await simulate(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
109
|
+
});
|
|
110
|
+
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));
|
|
111
|
+
addOptions(profileCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
112
|
+
const { profile } = await import('./profile.js');
|
|
113
|
+
const options = command.optsWithGlobals();
|
|
114
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, debugExecutionStepsDir, authWitness } = options;
|
|
115
|
+
const { wallet, node } = walletAndNodeWrapper;
|
|
106
116
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
107
|
-
|
|
117
|
+
const authWitnesses = cleanupAuthWitnesses(authWitness);
|
|
118
|
+
await profile(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, debugExecutionStepsDir, CLIFeeArgs.parse(options, log, db), authWitnesses, log);
|
|
108
119
|
});
|
|
109
120
|
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
121
|
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(
|
|
122
|
+
]).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
123
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
113
|
-
.option('--no-wait', 'Wait for the
|
|
124
|
+
.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
125
|
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);
|
|
126
|
+
const { l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
127
|
+
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(amount, recipient, walletAndNodeWrapper.node, l1RpcUrls, l1ChainId, l1PrivateKey, mnemonic, mint, json, wait, intervalS * 1000, log, debugLogger);
|
|
118
128
|
if (db) {
|
|
119
129
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
120
130
|
}
|
|
121
131
|
});
|
|
122
|
-
program.command('
|
|
132
|
+
program.command('get-fee-juice-balance').description('Checks the Fee Juice balance for a given address.').argument('<address>', 'Aztec address or alias to check balance for', (address)=>aliasedAddressParser('accounts', address, db)).option('--json', 'Emit output as json').option('--exact', 'Show exact balance with all 18 decimal places').action(async (address, options)=>{
|
|
133
|
+
const { getFeeJuiceBalanceCmd } = await import('./get_fee_juice_balance.js');
|
|
134
|
+
const { json, exact } = options;
|
|
135
|
+
await getFeeJuiceBalanceCmd(walletAndNodeWrapper.node, address, json, exact, log);
|
|
136
|
+
});
|
|
137
|
+
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
138
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
124
139
|
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);
|
|
140
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, alias } = options;
|
|
141
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
129
142
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
130
|
-
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
143
|
+
const witness = await createAuthwit(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
131
144
|
if (db) {
|
|
132
145
|
await db.storeAuthwitness(witness, log, alias);
|
|
133
146
|
}
|
|
134
147
|
});
|
|
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(
|
|
148
|
+
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
149
|
const { authorizeAction } = await import('./authorize_action.js');
|
|
137
150
|
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);
|
|
151
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress } = options;
|
|
152
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
142
153
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
143
|
-
await authorizeAction(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
144
|
-
});
|
|
145
|
-
program.command('add-authwit').description('Adds an authorization witness to the provided account, granting PXE access to the notes of the authorizer so that it can be verified').argument('<authwit>', 'Authorization witness to add to the account', (witness)=>aliasedAuthWitParser(witness, db)).argument('<authorizer>', 'Account that provides the authorization to perform the action', (address)=>aliasedAddressParser('accounts', address, db)).addOption(pxeOption).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the authorization witness. Used for easy reference in subsequent commands.', !db)).action(async (authwit, authorizer, _options, command)=>{
|
|
146
|
-
const { addAuthwit } = await import('./add_authwit.js');
|
|
147
|
-
const options = command.optsWithGlobals();
|
|
148
|
-
const { from: parsedFromAddress, rpcUrl, secretKey } = options;
|
|
149
|
-
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
150
|
-
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
151
|
-
const wallet = await getWalletWithScopes(account, db);
|
|
152
|
-
await addAuthwit(wallet, authwit, authorizer, log);
|
|
153
|
-
await addScopeToWallet(wallet, authorizer, db);
|
|
154
|
+
await authorizeAction(wallet, parsedFromAddress, functionName, caller, args, artifactPath, contractAddress, log);
|
|
154
155
|
});
|
|
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)).
|
|
156
|
+
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
157
|
const { checkTx } = await import('./check_tx.js');
|
|
157
|
-
const {
|
|
158
|
+
const { pageSize } = options;
|
|
158
159
|
let { page } = options;
|
|
159
|
-
const
|
|
160
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
161
|
+
const node = walletAndNodeWrapper.node;
|
|
160
162
|
if (txHash) {
|
|
161
|
-
await checkTx(
|
|
163
|
+
await checkTx(wallet, node, txHash, false, log);
|
|
162
164
|
} else if (db) {
|
|
163
165
|
const aliases = await db.listAliases('transactions');
|
|
164
166
|
const totalPages = Math.ceil(aliases.length / pageSize);
|
|
@@ -166,55 +168,37 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
|
166
168
|
const dataRows = await Promise.all(aliases.slice(page * pageSize, pageSize * (1 + page)).map(async ({ key, value })=>({
|
|
167
169
|
alias: key,
|
|
168
170
|
txHash: value,
|
|
169
|
-
|
|
170
|
-
status: await checkTx(client, TxHash.fromString(value), true, log)
|
|
171
|
+
status: await checkTx(wallet, node, TxHash.fromString(value), true, log)
|
|
171
172
|
})));
|
|
172
173
|
log(`Recent transactions:`);
|
|
173
174
|
log('');
|
|
174
175
|
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 +
|
|
176
|
+
log(''.padEnd(32 + 64 + 20, '-'));
|
|
177
|
+
for (const { alias, txHash, status } of dataRows){
|
|
178
|
+
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${status}`);
|
|
179
|
+
log(''.padEnd(32 + 64 + 20, '-'));
|
|
179
180
|
}
|
|
180
181
|
log(`Displaying ${Math.min(pageSize, aliases.length)} rows, page ${page + 1}/${totalPages}`);
|
|
181
182
|
} else {
|
|
182
183
|
log('Recent transactions are not available, please provide a specific transaction hash');
|
|
183
184
|
}
|
|
184
185
|
});
|
|
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)=>{
|
|
186
|
+
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
187
|
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);
|
|
188
|
+
const { alias } = options;
|
|
189
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
204
190
|
await registerSender(wallet, address, log);
|
|
205
191
|
if (db && alias) {
|
|
206
192
|
await db.storeSender(address, alias, log);
|
|
207
193
|
}
|
|
208
194
|
});
|
|
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).
|
|
195
|
+
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
196
|
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);
|
|
197
|
+
const { alias, init, publicKey, salt, deployer, args } = command.optsWithGlobals();
|
|
198
|
+
const wallet = walletAndNodeWrapper.wallet;
|
|
199
|
+
const node = walletAndNodeWrapper.node;
|
|
216
200
|
const artifactPath = await artifactPathPromise;
|
|
217
|
-
const instance = await registerContract(wallet, node, address, artifactPath, log);
|
|
201
|
+
const instance = await registerContract(wallet, node, address, artifactPath, log, init, publicKey, args, salt, deployer);
|
|
218
202
|
if (db && alias) {
|
|
219
203
|
await db.storeContract(instance.address, artifactPath, log, alias);
|
|
220
204
|
}
|
|
@@ -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=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvcHJvZmlsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFNUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFdEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFNbkQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFM0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFcEQsd0JBQXNCLE9BQU8sQ0FDM0IsTUFBTSxFQUFFLFNBQVMsRUFDakIsSUFBSSxFQUFFLFNBQVMsRUFDZixJQUFJLEVBQUUsWUFBWSxFQUNsQixZQUFZLEVBQUUsTUFBTSxFQUNwQixjQUFjLEVBQUUsR0FBRyxFQUFFLEVBQ3JCLG9CQUFvQixFQUFFLE1BQU0sRUFDNUIsZUFBZSxFQUFFLFlBQVksRUFDN0IsZUFBZSxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQ25DLE9BQU8sRUFBRSxVQUFVLEVBQ25CLGFBQWEsRUFBRSxXQUFXLEVBQUUsRUFDNUIsR0FBRyxFQUFFLEtBQUssaUJBcUJYIn0=
|
|
@@ -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 = 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:
|
|
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,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
|
-
//# 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"}
|