@aztec/cli-wallet 0.0.0-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +75 -0
- package/dest/cmds/add_authwit.d.ts +4 -0
- package/dest/cmds/add_authwit.d.ts.map +1 -0
- package/dest/cmds/add_authwit.js +4 -0
- package/dest/cmds/authorize_action.d.ts +4 -0
- package/dest/cmds/authorize_action.d.ts.map +1 -0
- package/dest/cmds/authorize_action.js +17 -0
- package/dest/cmds/bridge_fee_juice.d.ts +6 -0
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -0
- package/dest/cmds/bridge_fee_juice.js +52 -0
- package/dest/cmds/cancel_tx.d.ts +11 -0
- package/dest/cmds/cancel_tx.d.ts.map +1 -0
- package/dest/cmds/cancel_tx.js +38 -0
- package/dest/cmds/check_tx.d.ts +4 -0
- package/dest/cmds/check_tx.d.ts.map +1 -0
- package/dest/cmds/check_tx.js +11 -0
- package/dest/cmds/create_account.d.ts +12 -0
- package/dest/cmds/create_account.d.ts.map +1 -0
- package/dest/cmds/create_account.js +94 -0
- package/dest/cmds/create_authwit.d.ts +4 -0
- package/dest/cmds/create_authwit.d.ts.map +1 -0
- package/dest/cmds/create_authwit.js +16 -0
- package/dest/cmds/deploy.d.ts +6 -0
- package/dest/cmds/deploy.d.ts.map +1 -0
- package/dest/cmds/deploy.js +83 -0
- package/dest/cmds/deploy_account.d.ts +9 -0
- package/dest/cmds/deploy_account.d.ts.map +1 -0
- package/dest/cmds/deploy_account.js +80 -0
- package/dest/cmds/import_test_accounts.d.ts +5 -0
- package/dest/cmds/import_test_accounts.d.ts.map +1 -0
- package/dest/cmds/import_test_accounts.js +42 -0
- package/dest/cmds/index.d.ts +6 -0
- package/dest/cmds/index.d.ts.map +1 -0
- package/dest/cmds/index.js +223 -0
- package/dest/cmds/register_contract.d.ts +4 -0
- package/dest/cmds/register_contract.d.ts.map +1 -0
- package/dest/cmds/register_contract.js +14 -0
- package/dest/cmds/register_sender.d.ts +4 -0
- package/dest/cmds/register_sender.d.ts.map +1 -0
- package/dest/cmds/register_sender.js +4 -0
- package/dest/cmds/send.d.ts +11 -0
- package/dest/cmds/send.d.ts.map +1 -0
- package/dest/cmds/send.js +49 -0
- package/dest/cmds/simulate.d.ts +4 -0
- package/dest/cmds/simulate.d.ts.map +1 -0
- package/dest/cmds/simulate.js +26 -0
- package/dest/storage/wallet_db.d.ts +65 -0
- package/dest/storage/wallet_db.d.ts.map +1 -0
- package/dest/storage/wallet_db.js +209 -0
- package/dest/utils/accounts.d.ts +11 -0
- package/dest/utils/accounts.d.ts.map +1 -0
- package/dest/utils/accounts.js +87 -0
- package/dest/utils/ecdsa.d.ts +4 -0
- package/dest/utils/ecdsa.d.ts.map +1 -0
- package/dest/utils/ecdsa.js +13 -0
- package/dest/utils/options/fees.d.ts +41 -0
- package/dest/utils/options/fees.d.ts.map +1 -0
- package/dest/utils/options/fees.js +283 -0
- package/dest/utils/options/index.d.ts +3 -0
- package/dest/utils/options/index.d.ts.map +1 -0
- package/dest/utils/options/index.js +2 -0
- package/dest/utils/options/options.d.ts +20 -0
- package/dest/utils/options/options.d.ts.map +1 -0
- package/dest/utils/options/options.js +122 -0
- package/dest/utils/pxe_wrapper.d.ts +10 -0
- package/dest/utils/pxe_wrapper.d.ts.map +1 -0
- package/dest/utils/pxe_wrapper.js +21 -0
- package/package.json +102 -0
- package/src/bin/index.ts +127 -0
- package/src/cmds/add_authwit.ts +13 -0
- package/src/cmds/authorize_action.ts +36 -0
- package/src/cmds/bridge_fee_juice.ts +88 -0
- package/src/cmds/cancel_tx.ts +62 -0
- package/src/cmds/check_tx.ts +12 -0
- package/src/cmds/create_account.ts +120 -0
- package/src/cmds/create_authwit.ts +35 -0
- package/src/cmds/deploy.ts +113 -0
- package/src/cmds/deploy_account.ts +92 -0
- package/src/cmds/import_test_accounts.ts +47 -0
- package/src/cmds/index.ts +641 -0
- package/src/cmds/register_contract.ts +20 -0
- package/src/cmds/register_sender.ts +7 -0
- package/src/cmds/send.ts +62 -0
- package/src/cmds/simulate.ts +42 -0
- package/src/storage/wallet_db.ts +243 -0
- package/src/utils/accounts.ts +102 -0
- package/src/utils/ecdsa.ts +15 -0
- package/src/utils/options/fees.ts +365 -0
- package/src/utils/options/index.ts +2 -0
- package/src/utils/options/options.ts +175 -0
- package/src/utils/pxe_wrapper.ts +26 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js';
|
|
4
|
+
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
5
|
+
export async function importTestAccounts(client, db, json, log) {
|
|
6
|
+
const testAccounts = await getInitialTestAccounts();
|
|
7
|
+
const accounts = await Promise.all(testAccounts.map(({ secret, signingKey, salt })=>getSchnorrAccount(client, secret, signingKey, salt)));
|
|
8
|
+
const out = {};
|
|
9
|
+
await Promise.all(accounts.map(async (account, i)=>{
|
|
10
|
+
const alias = `test${i}`;
|
|
11
|
+
const secret = testAccounts[i].secret;
|
|
12
|
+
const salt = new Fr(account.salt);
|
|
13
|
+
const address = account.getAddress();
|
|
14
|
+
await account.register();
|
|
15
|
+
await db.storeAccount(address, {
|
|
16
|
+
type: 'schnorr',
|
|
17
|
+
secretKey: secret,
|
|
18
|
+
salt,
|
|
19
|
+
alias,
|
|
20
|
+
publicKey: undefined
|
|
21
|
+
}, log);
|
|
22
|
+
if (json) {
|
|
23
|
+
out[alias] = {
|
|
24
|
+
alias,
|
|
25
|
+
address,
|
|
26
|
+
secret,
|
|
27
|
+
salt
|
|
28
|
+
};
|
|
29
|
+
} else {
|
|
30
|
+
log(`\nTest account:`);
|
|
31
|
+
log(`Alias: ${alias}`);
|
|
32
|
+
log(`Address: ${address}`);
|
|
33
|
+
log(`Secret key: ${secret}`);
|
|
34
|
+
log(`Salt: ${salt}`);
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
if (json) {
|
|
38
|
+
log(prettyPrintJSON(out));
|
|
39
|
+
} else {
|
|
40
|
+
log(`\n${testAccounts.length} test accounts imported to wallet db.\n`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Command } from 'commander';
|
|
3
|
+
import type { WalletDB } from '../storage/wallet_db.js';
|
|
4
|
+
import type { PXEWrapper } from '../utils/pxe_wrapper.js';
|
|
5
|
+
export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger, db?: WalletDB, pxeWrapper?: PXEWrapper): Command;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAsBxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,EACnB,EAAE,CAAC,EAAE,QAAQ,EACb,UAAU,CAAC,EAAE,UAAU,WA6kBxB"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { getIdentities } from '@aztec/accounts/utils';
|
|
2
|
+
import { createCompatibleClient } from '@aztec/aztec.js/rpc';
|
|
3
|
+
import { TxHash } from '@aztec/aztec.js/tx_hash';
|
|
4
|
+
import { ETHEREUM_HOSTS, PRIVATE_KEY, addOptions, createSecretKeyOption, l1ChainIdOption, logJson, parseBigint, parseFieldFromHexString, parsePublicKey, pxeOption } from '@aztec/cli/utils';
|
|
5
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
|
+
import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
7
|
+
import { Option } from 'commander';
|
|
8
|
+
import inquirer from 'inquirer';
|
|
9
|
+
import { addScopeToWallet, createOrRetrieveAccount, getWalletWithScopes } from '../utils/accounts.js';
|
|
10
|
+
import { FeeOpts, FeeOptsWithFeePayer } from '../utils/options/fees.js';
|
|
11
|
+
import { ARTIFACT_DESCRIPTION, aliasedAddressParser, aliasedAuthWitParser, aliasedSecretKeyParser, aliasedTxHashParser, artifactPathFromPromiseOrAlias, artifactPathParser, createAccountOption, createAliasOption, createArgsOption, createArtifactOption, createContractAddressOption, createProfileOption, createTypeOption, integerArgParser, parseGasFees, parsePaymentMethod } from '../utils/options/index.js';
|
|
12
|
+
export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
|
|
13
|
+
program.command('import-test-accounts').description('Import test accounts from pxe.').addOption(pxeOption).option('--json', 'Emit output as json').action(async (options)=>{
|
|
14
|
+
if (!db) {
|
|
15
|
+
throw new Error(`A db is required to store the imported test accounts.`);
|
|
16
|
+
}
|
|
17
|
+
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
18
|
+
const { rpcUrl, json } = options;
|
|
19
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
20
|
+
await importTestAccounts(client, db, json, log);
|
|
21
|
+
});
|
|
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', 'Publicly deploys the account and registers the class if needed.').option('-p, --public-key <string>', 'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.').addOption(pxeOption).addOption(createSecretKeyOption('Secret key for account. Uses random by default.', false, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('public-key')).addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db)).addOption(createTypeOption(true)).option('--register-only', 'Just register the account on the PXE. Do not deploy or initialize the account contract.').option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
23
|
+
// 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, FeeOptsWithFeePayer.getOptions()).action(async (_options, command)=>{
|
|
26
|
+
const { createAccount } = await import('./create_account.js');
|
|
27
|
+
const options = command.optsWithGlobals();
|
|
28
|
+
const { type, secretKey, wait, registerOnly, skipInitialization, publicDeploy, rpcUrl, alias, json } = options;
|
|
29
|
+
let { publicKey } = options;
|
|
30
|
+
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
31
|
+
const identities = await getIdentities();
|
|
32
|
+
const answers = await inquirer.prompt([
|
|
33
|
+
{
|
|
34
|
+
type: 'list',
|
|
35
|
+
name: 'identity',
|
|
36
|
+
message: 'What public key to use?',
|
|
37
|
+
choices: identities.map((key)=>`${key.type} ${key.publicKey} ${key.comment}`)
|
|
38
|
+
}
|
|
39
|
+
]);
|
|
40
|
+
publicKey = answers.identity.split(' ')[1];
|
|
41
|
+
}
|
|
42
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
43
|
+
const accountCreationResult = await createAccount(client, type, secretKey, publicKey, alias, registerOnly, skipInitialization, publicDeploy, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, debugLogger, log);
|
|
44
|
+
if (db) {
|
|
45
|
+
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
46
|
+
await db.storeAccount(address, {
|
|
47
|
+
type,
|
|
48
|
+
secretKey,
|
|
49
|
+
salt,
|
|
50
|
+
alias,
|
|
51
|
+
publicKey
|
|
52
|
+
}, log);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
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 to deploy', !db, db)).addOption(pxeOption).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
56
|
+
// 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, FeeOptsWithFeePayer.getOptions()).action(async (_options, command)=>{
|
|
59
|
+
const { deployAccount } = await import('./deploy_account.js');
|
|
60
|
+
const options = command.optsWithGlobals();
|
|
61
|
+
const { rpcUrl, wait, from: parsedFromAddress, json } = options;
|
|
62
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
63
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db);
|
|
64
|
+
await deployAccount(account, wait, await FeeOptsWithFeePayer.fromCli(options, client, log, db), json, debugLogger, log);
|
|
65
|
+
});
|
|
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(pxeOption).addOption(createArgsOption(true, db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to deploy from', !db, db)).addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
67
|
+
// 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, FeeOpts.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
70
|
+
const { deploy } = await import('./deploy.js');
|
|
71
|
+
const options = command.optsWithGlobals();
|
|
72
|
+
const { json, publicKey, args, salt, wait, secretKey, classRegistration, init, publicDeployment, universal, rpcUrl, from: parsedFromAddress, alias } = options;
|
|
73
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
74
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
75
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
76
|
+
const artifactPath = await artifactPathPromise;
|
|
77
|
+
debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
|
|
78
|
+
const address = await deploy(client, wallet, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, universal, wait, await FeeOpts.fromCli(options, client, log, db), debugLogger, log, logJson(log));
|
|
79
|
+
if (db && address) {
|
|
80
|
+
await db.storeContract(address, artifactPath, log, alias);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createArtifactOption(db)).addOption(createContractAddressOption(db)).addOption(createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)).option('--no-wait', 'Print transaction hash without waiting for it to be mined').option('--no-cancel', 'Do not allow the transaction to be cancelled. This makes for cheaper transactions.');
|
|
84
|
+
addOptions(sendCommand, FeeOpts.getOptions()).action(async (functionName, _options, command)=>{
|
|
85
|
+
const { send } = await import('./send.js');
|
|
86
|
+
const options = command.optsWithGlobals();
|
|
87
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, rpcUrl, secretKey, alias, cancel } = options;
|
|
88
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
89
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
90
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
91
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
92
|
+
debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
|
|
93
|
+
const sentTx = await send(wallet, functionName, args, artifactPath, contractAddress, wait, cancel, await FeeOpts.fromCli(options, client, log, db), log);
|
|
94
|
+
if (db && sentTx) {
|
|
95
|
+
const txAlias = alias ? alias : `${functionName}-${sentTx.nonce.toString().slice(-4)}`;
|
|
96
|
+
await db.storeTx(sentTx, log, txAlias);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(pxeOption).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createProfileOption()).action(async (functionName, _options, command)=>{
|
|
100
|
+
const { simulate } = await import('./simulate.js');
|
|
101
|
+
const options = command.optsWithGlobals();
|
|
102
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey, profile } = options;
|
|
103
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
104
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
105
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
106
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
107
|
+
await simulate(wallet, functionName, args, artifactPath, contractAddress, profile, log);
|
|
108
|
+
});
|
|
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
|
+
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(pxeOption).addOption(l1ChainIdOption).option('--json', 'Output the claim in JSON format')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
112
|
+
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
113
|
+
.option('--no-wait', 'Wait for the brigded funds to be available in L2, polling every 60 seconds').addOption(new Option('--interval <number>', 'The polling interval in seconds for the bridged funds').default('60').conflicts('wait')).action(async (amount, recipient, options)=>{
|
|
114
|
+
const { bridgeL1FeeJuice } = await import('./bridge_fee_juice.js');
|
|
115
|
+
const { rpcUrl, l1ChainId, l1RpcUrls, l1PrivateKey, mnemonic, mint, json, wait, interval: intervalS } = options;
|
|
116
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
117
|
+
const [secret, messageLeafIndex] = await bridgeL1FeeJuice(amount, recipient, client, l1RpcUrls, l1ChainId, l1PrivateKey, mnemonic, mint, json, wait, intervalS * 1000, log, debugLogger);
|
|
118
|
+
if (db) {
|
|
119
|
+
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
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(pxeOption).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the authorization witness. Used for easy reference in subsequent commands.', !db)).action(async (functionName, caller, _options, command)=>{
|
|
123
|
+
const { createAuthwit } = await import('./create_authwit.js');
|
|
124
|
+
const options = command.optsWithGlobals();
|
|
125
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey, alias } = options;
|
|
126
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
127
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
128
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
129
|
+
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
130
|
+
const witness = await createAuthwit(wallet, functionName, caller, args, artifactPath, contractAddress, log);
|
|
131
|
+
if (db) {
|
|
132
|
+
await db.storeAuthwitness(witness, log, alias);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
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(pxeOption).addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).action(async (functionName, caller, _options, command)=>{
|
|
136
|
+
const { authorizeAction } = await import('./authorize_action.js');
|
|
137
|
+
const options = command.optsWithGlobals();
|
|
138
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey } = options;
|
|
139
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
140
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
141
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
142
|
+
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
|
+
});
|
|
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)=>{
|
|
156
|
+
const { checkTx } = await import('./check_tx.js');
|
|
157
|
+
const { rpcUrl, pageSize } = options;
|
|
158
|
+
let { page } = options;
|
|
159
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
160
|
+
if (txHash) {
|
|
161
|
+
await checkTx(client, txHash, false, log);
|
|
162
|
+
} else if (db) {
|
|
163
|
+
const aliases = await db.listAliases('transactions');
|
|
164
|
+
const totalPages = Math.ceil(aliases.length / pageSize);
|
|
165
|
+
page = Math.min(page - 1, totalPages - 1);
|
|
166
|
+
const dataRows = await Promise.all(aliases.slice(page * pageSize, pageSize * (1 + page)).map(async ({ key, value })=>({
|
|
167
|
+
alias: key,
|
|
168
|
+
txHash: value,
|
|
169
|
+
cancellable: (await db.retrieveTxData(TxHash.fromString(value))).cancellable,
|
|
170
|
+
status: await checkTx(client, TxHash.fromString(value), true, log)
|
|
171
|
+
})));
|
|
172
|
+
log(`Recent transactions:`);
|
|
173
|
+
log('');
|
|
174
|
+
log(`${'Alias'.padEnd(32, ' ')} | ${'TxHash'.padEnd(64, ' ')} | ${'Cancellable'.padEnd(12, ' ')} | Status`);
|
|
175
|
+
log(''.padEnd(32 + 64 + 12 + 20, '-'));
|
|
176
|
+
for (const { alias, txHash, status, cancellable } of dataRows){
|
|
177
|
+
log(`${alias.padEnd(32, ' ')} | ${txHash} | ${cancellable.toString()?.padEnd(12, ' ')} | ${status}`);
|
|
178
|
+
log(''.padEnd(32 + 64 + 12 + 20, '-'));
|
|
179
|
+
}
|
|
180
|
+
log(`Displaying ${Math.min(pageSize, aliases.length)} rows, page ${page + 1}/${totalPages}`);
|
|
181
|
+
} else {
|
|
182
|
+
log('Recent transactions are not available, please provide a specific transaction hash');
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
program.command('cancel-tx').description('Cancels a pending tx by reusing its nonce with a higher fee and an empty payload').argument('<txHash>', 'A transaction hash to cancel.', (txHash)=>aliasedTxHashParser(txHash, db)).addOption(pxeOption).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(FeeOpts.paymentMethodOption().default('method=fee_juice')).option('-i --increased-fees <da=1,l2=1>', 'The amounts by which the fees are increased', (value)=>parseGasFees(value), new GasFees(1, 1)).option('--max-fees-per-gas <da=100,l2=100>', 'Maximum fees per gas unit for DA and L2 computation.', (value)=>parseGasFees(value)).action(async (txHash, options)=>{
|
|
186
|
+
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)=>{
|
|
199
|
+
const { registerSender } = await import('./register_sender.js');
|
|
200
|
+
const { from: parsedFromAddress, rpcUrl, secretKey, alias } = options;
|
|
201
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
202
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
203
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
204
|
+
await registerSender(wallet, address, log);
|
|
205
|
+
if (db && alias) {
|
|
206
|
+
await db.storeSender(address, alias, log);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
program.command('register-contract').description("Registers a contract in this wallet's PXE").argument('[address]', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).addOption(createArgsOption(true, db)).addOption(pxeOption).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)).action(async (address, artifactPathPromise, _options, command)=>{
|
|
210
|
+
const { registerContract } = await import('./register_contract.js');
|
|
211
|
+
const { from: parsedFromAddress, rpcUrl, nodeUrl, secretKey, alias } = command.optsWithGlobals();
|
|
212
|
+
const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
|
|
213
|
+
const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
|
|
214
|
+
const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
|
|
215
|
+
const wallet = await getWalletWithScopes(account, db);
|
|
216
|
+
const artifactPath = await artifactPathPromise;
|
|
217
|
+
const instance = await registerContract(wallet, node, address, artifactPath, log);
|
|
218
|
+
if (db && alias) {
|
|
219
|
+
await db.storeContract(instance.address, artifactPath, log, alias);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return program;
|
|
223
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AccountWalletWithSecretKey, AztecAddress, AztecNode } from '@aztec/aztec.js';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
export declare function registerContract(wallet: AccountWalletWithSecretKey, node: AztecNode, address: AztecAddress, artifactPath: string, log: LogFn): Promise<import("@aztec/aztec.js").ContractInstanceWithAddress>;
|
|
4
|
+
//# sourceMappingURL=register_contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,0BAA0B,EAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,kEAUX"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getContractArtifact } from '@aztec/cli/cli-utils';
|
|
2
|
+
export async function registerContract(wallet, node, address, artifactPath, log) {
|
|
3
|
+
const contractArtifact = await getContractArtifact(artifactPath, log);
|
|
4
|
+
const contractInstance = await node.getContract(address);
|
|
5
|
+
if (!contractInstance) {
|
|
6
|
+
throw new Error(`Contract not found at address: ${address}`);
|
|
7
|
+
}
|
|
8
|
+
await wallet.registerContract({
|
|
9
|
+
instance: contractInstance,
|
|
10
|
+
artifact: contractArtifact
|
|
11
|
+
});
|
|
12
|
+
log(`Contract registered: at ${contractInstance.address}`);
|
|
13
|
+
return contractInstance;
|
|
14
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AccountWalletWithSecretKey, AztecAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
export declare function registerSender(wallet: AccountWalletWithSecretKey, address: AztecAddress, log: LogFn): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=register_sender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register_sender.d.ts","sourceRoot":"","sources":["../../src/cmds/register_sender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,cAAc,CAAC,MAAM,EAAE,0BAA0B,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,iBAGzG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AccountWalletWithSecretKey, type AztecAddress, Fr } from '@aztec/aztec.js';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
4
|
+
import { type IFeeOpts } from '../utils/options/fees.js';
|
|
5
|
+
export declare function send(wallet: AccountWalletWithSecretKey, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: IFeeOpts, log: LogFn): Promise<{
|
|
6
|
+
txHash: import("@aztec/aztec.js").TxHash;
|
|
7
|
+
nonce: Fr;
|
|
8
|
+
cancellable: boolean;
|
|
9
|
+
gasSettings: GasSettings;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,YAAY,EAAY,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAEnG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAE5E,wBAAsB,IAAI,CACxB,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,QAAQ,EACjB,GAAG,EAAE,KAAK;;;;;eA6CX"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Contract, Fr } from '@aztec/aztec.js';
|
|
2
|
+
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
4
|
+
import { printGasEstimates } from '../utils/options/fees.js';
|
|
5
|
+
export async function send(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, log) {
|
|
6
|
+
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
7
|
+
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
8
|
+
const call = contract.methods[functionName](...functionArgs);
|
|
9
|
+
const gasLimits = await call.estimateGas({
|
|
10
|
+
...await feeOpts.toSendOpts(wallet)
|
|
11
|
+
});
|
|
12
|
+
printGasEstimates(feeOpts, gasLimits, log);
|
|
13
|
+
if (feeOpts.estimateOnly) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const nonce = Fr.random();
|
|
17
|
+
const tx = call.send({
|
|
18
|
+
...await feeOpts.toSendOpts(wallet),
|
|
19
|
+
nonce,
|
|
20
|
+
cancellable
|
|
21
|
+
});
|
|
22
|
+
const txHash = await tx.getTxHash();
|
|
23
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
24
|
+
if (wait) {
|
|
25
|
+
try {
|
|
26
|
+
await tx.wait();
|
|
27
|
+
log('Transaction has been mined');
|
|
28
|
+
const receipt = await tx.getReceipt();
|
|
29
|
+
log(` Tx fee: ${receipt.transactionFee}`);
|
|
30
|
+
log(` Status: ${receipt.status}`);
|
|
31
|
+
log(` Block number: ${receipt.blockNumber}`);
|
|
32
|
+
log(` Block hash: ${receipt.blockHash?.toString()}`);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
log(`Transaction failed\n ${err.message}`);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
log('Transaction pending. Check status with check-tx');
|
|
38
|
+
}
|
|
39
|
+
const gasSettings = GasSettings.from({
|
|
40
|
+
...feeOpts.gasSettings,
|
|
41
|
+
...gasLimits
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
txHash,
|
|
45
|
+
nonce,
|
|
46
|
+
cancellable,
|
|
47
|
+
gasSettings
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
export declare function simulate(wallet: AccountWalletWithSecretKey, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, profile: boolean, log: LogFn): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=simulate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,YAAY,EAAgC,MAAM,iBAAiB,CAAC;AAEnH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAkBnD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,iBAcX"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Contract } from '@aztec/aztec.js';
|
|
2
|
+
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
+
import { format } from 'util';
|
|
4
|
+
function printProfileResult(result, log) {
|
|
5
|
+
log(format('\nSimulation result:'));
|
|
6
|
+
log(format('Return value:', JSON.stringify(result.returnValues, null, 2)));
|
|
7
|
+
log(format('\nGate count per circuit:'));
|
|
8
|
+
let acc = 0;
|
|
9
|
+
result.gateCounts.forEach((r)=>{
|
|
10
|
+
acc += r.gateCount;
|
|
11
|
+
log(format(' ', r.circuitName.padEnd(50), 'Gates:', r.gateCount.toLocaleString(), '\tAcc:', acc.toLocaleString()));
|
|
12
|
+
});
|
|
13
|
+
log(format('\nTotal gates:', acc.toLocaleString()));
|
|
14
|
+
}
|
|
15
|
+
export async function simulate(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, profile, log) {
|
|
16
|
+
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
17
|
+
const contract = await Contract.at(contractAddress, contractArtifact, wallet);
|
|
18
|
+
const call = contract.methods[functionName](...functionArgs);
|
|
19
|
+
if (profile) {
|
|
20
|
+
const result = await call.simulateWithProfile();
|
|
21
|
+
printProfileResult(result, log);
|
|
22
|
+
} else {
|
|
23
|
+
const result = await call.simulate();
|
|
24
|
+
log(format('\nSimulation result: ', result, '\n'));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
5
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
7
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
9
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
10
|
+
import type { AccountType } from '../utils/accounts.js';
|
|
11
|
+
export declare const Aliases: readonly ["accounts", "contracts", "artifacts", "secrets", "transactions", "authwits"];
|
|
12
|
+
export type AliasType = (typeof Aliases)[number];
|
|
13
|
+
export declare class WalletDB {
|
|
14
|
+
#private;
|
|
15
|
+
private static instance;
|
|
16
|
+
private aliasCache;
|
|
17
|
+
static getInstance(): WalletDB;
|
|
18
|
+
init(store: AztecAsyncKVStore): Promise<void>;
|
|
19
|
+
private refreshAliasCache;
|
|
20
|
+
pushBridgedFeeJuice(recipient: AztecAddress, secret: Fr, amount: bigint, leafIndex: bigint, log: LogFn): Promise<void>;
|
|
21
|
+
popBridgedFeeJuice(recipient: AztecAddress, log: LogFn): Promise<{
|
|
22
|
+
amount: bigint;
|
|
23
|
+
secret: string;
|
|
24
|
+
leafIndex: bigint;
|
|
25
|
+
}>;
|
|
26
|
+
storeAccount(address: AztecAddress, { type, secretKey, salt, alias, publicKey, }: {
|
|
27
|
+
type: AccountType;
|
|
28
|
+
secretKey: Fr;
|
|
29
|
+
salt: Fr;
|
|
30
|
+
alias: string | undefined;
|
|
31
|
+
publicKey: string | undefined;
|
|
32
|
+
}, log: LogFn): Promise<void>;
|
|
33
|
+
storeSender(address: AztecAddress, alias: string, log: LogFn): Promise<void>;
|
|
34
|
+
storeContract(address: AztecAddress, artifactPath: string, log: LogFn, alias?: string): Promise<void>;
|
|
35
|
+
storeAuthwitness(authWit: AuthWitness, log: LogFn, alias?: string): Promise<void>;
|
|
36
|
+
storeTx({ txHash, nonce, cancellable, gasSettings, }: {
|
|
37
|
+
txHash: TxHash;
|
|
38
|
+
nonce: Fr;
|
|
39
|
+
cancellable: boolean;
|
|
40
|
+
gasSettings: GasSettings;
|
|
41
|
+
}, log: LogFn, alias?: string): Promise<void>;
|
|
42
|
+
retrieveTxData(txHash: TxHash): Promise<{
|
|
43
|
+
txHash: TxHash;
|
|
44
|
+
nonce: Fr;
|
|
45
|
+
cancellable: boolean;
|
|
46
|
+
gasSettings: GasSettings;
|
|
47
|
+
}>;
|
|
48
|
+
tryRetrieveAlias(arg: string): string;
|
|
49
|
+
retrieveAliasFromCache(arg: string): string;
|
|
50
|
+
retrieveAlias(arg: string): Promise<string>;
|
|
51
|
+
listAliases(type?: AliasType): Promise<{
|
|
52
|
+
key: string;
|
|
53
|
+
value: string;
|
|
54
|
+
}[]>;
|
|
55
|
+
storeAccountMetadata(aliasOrAddress: AztecAddress | string, metadataKey: string, metadata: Buffer): Promise<void>;
|
|
56
|
+
retrieveAccountMetadata(aliasOrAddress: AztecAddress | string, metadataKey: string): Promise<Buffer>;
|
|
57
|
+
retrieveAccount(address: AztecAddress | string): Promise<{
|
|
58
|
+
address: string | AztecAddress;
|
|
59
|
+
secretKey: Fr;
|
|
60
|
+
salt: Fr;
|
|
61
|
+
type: "schnorr" | "ecdsasecp256r1ssh" | "ecdsasecp256k1";
|
|
62
|
+
}>;
|
|
63
|
+
storeAlias(type: AliasType, key: string, value: Buffer, log: LogFn): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=wallet_db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet_db.d.ts","sourceRoot":"","sources":["../../src/storage/wallet_db.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,eAAO,MAAM,OAAO,wFAAyF,CAAC;AAC9G,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,qBAAa,QAAQ;;IAMnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAW;IAElC,OAAO,CAAC,UAAU,CAA6B;IAE/C,MAAM,CAAC,WAAW;IAQZ,IAAI,CAAC,KAAK,EAAE,iBAAiB;YASrB,iBAAiB;IAIzB,mBAAmB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;IAWtG,kBAAkB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK;;;;;IActD,YAAY,CAChB,OAAO,EAAE,YAAY,EACrB,EACE,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,SAAS,GACV,EAAE;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,SAAS,EAAE,EAAE,CAAC;QAAC,IAAI,EAAE,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,EAC3G,GAAG,EAAE,KAAK;IAkBN,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;IAO5D,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM;IAarF,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM;IAUjE,OAAO,CACX,EACE,MAAM,EACN,KAAK,EACL,WAAW,EACX,WAAW,GACZ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,EAAE,CAAC;QAAC,WAAW,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,WAAW,CAAA;KAAE,EAChF,GAAG,EAAE,KAAK,EACV,KAAK,CAAC,EAAE,MAAM;IAcV,cAAc,CAAC,MAAM,EAAE,MAAM;;;;;;IAanC,gBAAgB,CAAC,GAAG,EAAE,MAAM;IAQrB,sBAAsB,CAAC,GAAG,EAAE,MAAM;IAcnC,aAAa,CAAC,GAAG,EAAE,MAAM;IAazB,WAAW,CAAC,IAAI,CAAC,EAAE,SAAS;;;;IAa5B,oBAAoB,CAAC,cAAc,EAAE,YAAY,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAKjG,uBAAuB,CAAC,cAAc,EAAE,YAAY,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM;IASlF,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM;;;;;;IAW9C,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;CAOzE"}
|