@aztec/cli-wallet 0.0.1-commit.dbf9cec → 0.0.1-commit.e0f15ab9b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/cmds/authorize_action.d.ts +2 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/check_tx.d.ts +1 -1
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +34 -8
- package/dest/cmds/create_account.d.ts +4 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +32 -21
- package/dest/cmds/deploy.d.ts +4 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +27 -23
- package/dest/cmds/deploy_account.d.ts +4 -3
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +27 -16
- 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/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +30 -14
- package/dest/cmds/send.d.ts +4 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +27 -23
- package/dest/utils/options/fees.d.ts +1 -1
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +2 -0
- package/dest/utils/wallet.d.ts +5 -5
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +29 -28
- package/package.json +14 -14
- package/src/cmds/check_tx.ts +40 -9
- package/src/cmds/create_account.ts +32 -18
- package/src/cmds/deploy.ts +24 -15
- package/src/cmds/deploy_account.ts +26 -13
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/index.ts +56 -3
- package/src/cmds/send.ts +24 -16
- package/src/cmds/simulate.ts +1 -1
- package/src/utils/options/fees.ts +6 -0
- package/src/utils/wallet.ts +38 -48
package/dest/cmds/index.js
CHANGED
|
@@ -2,9 +2,20 @@ import { getIdentities } from '@aztec/accounts/utils';
|
|
|
2
2
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
3
3
|
import { ETHEREUM_HOSTS, PRIVATE_KEY, addOptions, createSecretKeyOption, l1ChainIdOption, parseBigint, parseFieldFromHexString, parsePublicKey } from '@aztec/cli/utils';
|
|
4
4
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
5
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
5
6
|
import { Option } from 'commander';
|
|
6
7
|
import inquirer from 'inquirer';
|
|
7
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
|
+
}
|
|
8
19
|
// TODO: This function is only used in 1 place so we could just inline this
|
|
9
20
|
export function injectCommands(program, log, debugLogger, walletAndNodeWrapper, db) {
|
|
10
21
|
program.command('import-test-accounts').description('Import test accounts from pxe.').option('--json', 'Emit output as json').action(async (options)=>{
|
|
@@ -13,13 +24,13 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
13
24
|
const { importTestAccounts } = await import('./import_test_accounts.js');
|
|
14
25
|
await importTestAccounts(wallet, db, json, log);
|
|
15
26
|
});
|
|
16
|
-
const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr 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('--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.
|
|
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.
|
|
17
28
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
18
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').addOption(createVerboseOption());
|
|
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());
|
|
19
30
|
addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command)=>{
|
|
20
31
|
const { createAccount } = await import('./create_account.js');
|
|
21
32
|
const options = command.optsWithGlobals();
|
|
22
|
-
const { type, from: parsedFromAddress, secretKey, wait, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
33
|
+
const { type, from: parsedFromAddress, secretKey, salt, wait, waitForStatus: waitForStatusStr, registerOnly, skipInitialization, publicDeploy, registerClass, alias, json, verbose } = options;
|
|
23
34
|
let { publicKey } = options;
|
|
24
35
|
if (type === 'ecdsasecp256r1ssh' && !publicKey) {
|
|
25
36
|
const identities = await getIdentities();
|
|
@@ -34,7 +45,7 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
34
45
|
publicKey = answers.identity.split(' ')[1];
|
|
35
46
|
}
|
|
36
47
|
const { wallet, node } = walletAndNodeWrapper;
|
|
37
|
-
const accountCreationResult = await createAccount(wallet, node, type, secretKey, publicKey, alias, parsedFromAddress, registerOnly, skipInitialization, publicDeploy, registerClass, wait, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
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);
|
|
38
49
|
if (db) {
|
|
39
50
|
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
40
51
|
await db.storeAccount(address, {
|
|
@@ -48,39 +59,39 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
48
59
|
});
|
|
49
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.
|
|
50
61
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
51
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').addOption(createVerboseOption());
|
|
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());
|
|
52
63
|
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command)=>{
|
|
53
64
|
const { deployAccount } = await import('./deploy_account.js');
|
|
54
65
|
const options = command.optsWithGlobals();
|
|
55
|
-
const { wait, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
66
|
+
const { wait, waitForStatus: waitForStatusStr, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
56
67
|
const { wallet, node } = walletAndNodeWrapper;
|
|
57
|
-
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
68
|
+
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), json, verbose, debugLogger, log);
|
|
58
69
|
});
|
|
59
|
-
const deployCommand = program.command('deploy').description('Deploys a compiled Aztec.nr contract to Aztec.').argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').option('--no-init', 'Leave the contract uninitialized').option('-k, --public-key <string>', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', parsePublicKey).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address.', parseFieldFromHexString).option('--universal', 'Do not mix the sender address into the deployment.').addOption(createArgsOption(true, db)).addOption(createAccountOption('Alias or address of the account to deploy from', !db, db)).addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
|
|
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.
|
|
60
71
|
// https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
|
|
61
|
-
.option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode").addOption(new Option('--timeout <number>', 'The amount of time in seconds to wait for the deployment to post to L2').conflicts('wait')).addOption(createVerboseOption());
|
|
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());
|
|
62
73
|
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
63
74
|
const { deploy } = await import('./deploy.js');
|
|
64
75
|
const options = command.optsWithGlobals();
|
|
65
|
-
const { json, publicKey, args, salt, wait, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
76
|
+
const { json, publicKey, args, salt, wait, waitForStatus: waitForStatusStr, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
66
77
|
const { wallet, node } = walletAndNodeWrapper;
|
|
67
78
|
const artifactPath = await artifactPathPromise;
|
|
68
79
|
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
69
|
-
const address = await deploy(wallet, node, universal ? undefined : parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db),
|
|
80
|
+
const address = await deploy(wallet, node, universal ? undefined : parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), verbose, timeout, debugLogger, log);
|
|
70
81
|
if (db && address) {
|
|
71
82
|
await db.storeContract(address, artifactPath, log, alias);
|
|
72
83
|
}
|
|
73
84
|
});
|
|
74
|
-
const sendCommand = program.command('send').description('Calls a function on an Aztec contract.').argument('<functionName>', 'Name of function to execute').addOption(createArgsOption(false, db)).addOption(createArtifactOption(db)).addOption(createContractAddressOption(db)).addOption(createAliasOption('Alias for the transaction hash. Used for easy reference in subsequent commands.', !db)).addOption(createAuthwitnessOption('Authorization witness to use for the transaction. If using multiple, pass a comma separated string', !db, db)).addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)).option('--no-wait', 'Print transaction hash without waiting for it to be mined').addOption(createVerboseOption());
|
|
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());
|
|
75
86
|
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
76
87
|
const { send } = await import('./send.js');
|
|
77
88
|
const options = command.optsWithGlobals();
|
|
78
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, alias, authWitness: authWitnessArray, verbose } = options;
|
|
89
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, waitForStatus: waitForStatusStr, alias, authWitness: authWitnessArray, verbose } = options;
|
|
79
90
|
const { wallet, node } = walletAndNodeWrapper;
|
|
80
91
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
81
92
|
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
82
93
|
const authWitnesses = cleanupAuthWitnesses(authWitnessArray);
|
|
83
|
-
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, verbose, log);
|
|
94
|
+
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, parseWaitForStatus(waitForStatusStr), verbose, log);
|
|
84
95
|
if (db && sentTx) {
|
|
85
96
|
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString('hex')}`;
|
|
86
97
|
await db.storeTx(sentTx, log, txAlias);
|
|
@@ -118,6 +129,11 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
118
129
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
119
130
|
}
|
|
120
131
|
});
|
|
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
|
+
});
|
|
121
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)=>{
|
|
122
138
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
123
139
|
const options = command.optsWithGlobals();
|
package/dest/cmds/send.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { AuthWitness } from '@aztec/aztec.js/authorization';
|
|
3
|
-
import type
|
|
3
|
+
import { type AztecNode } from '@aztec/aztec.js/node';
|
|
4
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
5
6
|
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
7
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
7
|
-
export declare function send(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<{
|
|
8
|
+
export declare function send(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, wait: boolean, cancellable: boolean, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], waitForStatus: TxStatus, verbose: boolean, log: LogFn): Promise<{
|
|
8
9
|
txHash: import("@aztec/stdlib/tx").TxHash;
|
|
9
10
|
} | undefined>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvc2VuZC50cyJdLCJuYW1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A2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,IAAI,CACxB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,WAAW,EAAE,EAC5B,aAAa,EAAE,QAAQ,EACvB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK;;eAoEX"}
|
package/dest/cmds/send.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Contract, NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
2
3
|
import { prepTx } from '@aztec/cli/utils';
|
|
4
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
3
5
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
4
6
|
import { printProfileResult } from '../utils/profiling.js';
|
|
5
|
-
export async function send(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, verbose, log) {
|
|
7
|
+
export async function send(wallet, node, from, functionName, functionArgsIn, contractArtifactPath, contractAddress, wait, cancellable, feeOpts, authWitnesses, waitForStatus, verbose, log) {
|
|
6
8
|
const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
7
9
|
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
8
10
|
const call = contract.methods[functionName](...functionArgs);
|
|
@@ -15,38 +17,49 @@ export async function send(wallet, node, from, functionName, functionArgsIn, con
|
|
|
15
17
|
from,
|
|
16
18
|
authWitnesses
|
|
17
19
|
};
|
|
18
|
-
const
|
|
20
|
+
const localStart = performance.now();
|
|
21
|
+
const sim = await call.simulate({
|
|
19
22
|
...sendOptions,
|
|
20
23
|
fee: {
|
|
21
24
|
...sendOptions.fee,
|
|
22
25
|
estimateGas: true
|
|
23
26
|
}
|
|
24
27
|
});
|
|
28
|
+
// estimateGas: true guarantees these fields are present
|
|
29
|
+
const estimatedGas = sim.estimatedGas;
|
|
30
|
+
const stats = sim.stats;
|
|
25
31
|
if (feeOpts.estimateOnly) {
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
34
|
if (verbose) {
|
|
29
35
|
printProfileResult(stats, log);
|
|
30
36
|
}
|
|
37
|
+
const { txHash } = await call.send({
|
|
38
|
+
...sendOptions,
|
|
39
|
+
fee: {
|
|
40
|
+
...sendOptions.fee,
|
|
41
|
+
gasSettings: estimatedGas
|
|
42
|
+
},
|
|
43
|
+
wait: NO_WAIT
|
|
44
|
+
});
|
|
45
|
+
const localTimeMs = performance.now() - localStart;
|
|
46
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
31
47
|
if (wait) {
|
|
32
48
|
try {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
gasSettings: estimatedGas
|
|
38
|
-
},
|
|
39
|
-
wait: {
|
|
40
|
-
timeout: DEFAULT_TX_TIMEOUT_S
|
|
41
|
-
}
|
|
49
|
+
const nodeStart = performance.now();
|
|
50
|
+
const receipt = await waitForTx(node, txHash, {
|
|
51
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
52
|
+
waitForStatus
|
|
42
53
|
});
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
log(
|
|
54
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
55
|
+
const statusLabel = waitForStatus === TxStatus.PROPOSED ? 'proposed' : 'checkpointed';
|
|
56
|
+
log(`Transaction has been ${statusLabel}`);
|
|
46
57
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
47
58
|
log(` Status: ${receipt.status}`);
|
|
48
59
|
log(` Block number: ${receipt.blockNumber}`);
|
|
49
60
|
log(` Block hash: ${receipt.blockHash?.toString()}`);
|
|
61
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
62
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
50
63
|
return {
|
|
51
64
|
txHash
|
|
52
65
|
};
|
|
@@ -55,15 +68,6 @@ export async function send(wallet, node, from, functionName, functionArgsIn, con
|
|
|
55
68
|
throw err;
|
|
56
69
|
}
|
|
57
70
|
} else {
|
|
58
|
-
const txHash = await call.send({
|
|
59
|
-
...sendOptions,
|
|
60
|
-
fee: {
|
|
61
|
-
...sendOptions.fee,
|
|
62
|
-
gasSettings: estimatedGas
|
|
63
|
-
},
|
|
64
|
-
wait: NO_WAIT
|
|
65
|
-
});
|
|
66
|
-
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
67
71
|
log('Transaction pending. Check status with check-tx');
|
|
68
72
|
return {
|
|
69
73
|
txHash
|
|
@@ -32,4 +32,4 @@ export declare class CLIFeeArgs {
|
|
|
32
32
|
static getOptions(): Option[];
|
|
33
33
|
}
|
|
34
34
|
export declare function printGasEstimates(feeOpts: FeeOptions, gasEstimates: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>, log: LogFn): void;
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL29wdGlvbnMvZmVlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXJELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3hELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUMzRCxPQUFPLEVBQU8sT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRWhFLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFFbkMsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFJM0QsTUFBTSxNQUFNLGFBQWEsR0FBRztJQUMxQixlQUFlLEVBQUUsT0FBTyxDQUFDO0lBQ3pCLFNBQVMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQU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,CAAC,CAQrG;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,UAAU,CAMvE;IAED,MAAM,CAAC,UAAU,aAEhB;CACF;AAID,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,EAClE,GAAG,EAAE,KAAK,QAIX"}
|
|
@@ -115,6 +115,7 @@ export function parsePaymentMethod(payment, log, db) {
|
|
|
115
115
|
{
|
|
116
116
|
const fpc = getFpc();
|
|
117
117
|
const asset = getAsset();
|
|
118
|
+
log(`WARNING: fpc-public is deprecated and will not work on mainnet alpha. Use fee_juice or fpc-sponsored instead.`);
|
|
118
119
|
log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
119
120
|
const { PublicFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
120
121
|
return new PublicFeePaymentMethod(fpc, from, wallet, gasSettings);
|
|
@@ -123,6 +124,7 @@ export function parsePaymentMethod(payment, log, db) {
|
|
|
123
124
|
{
|
|
124
125
|
const fpc = getFpc();
|
|
125
126
|
const asset = getAsset();
|
|
127
|
+
log(`WARNING: fpc-private is deprecated and will not work on mainnet alpha. Use fee_juice or fpc-sponsored instead.`);
|
|
126
128
|
log(`Using private fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
127
129
|
const { PrivateFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
128
130
|
return new PrivateFeePaymentMethod(fpc, from, wallet, gasSettings);
|
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import type { AztecNode } from '@aztec/aztec.js/node';
|
|
|
4
4
|
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
7
|
-
import type {
|
|
7
|
+
import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
8
8
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
9
9
|
import type { PXE } from '@aztec/pxe/server';
|
|
10
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
11
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
12
12
|
import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
13
13
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
14
|
-
import { BaseWallet, type
|
|
14
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
15
15
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
16
16
|
import type { AccountType } from './constants.js';
|
|
17
17
|
export declare class CLIWallet extends BaseWallet {
|
|
@@ -30,11 +30,11 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
30
30
|
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
31
31
|
/**
|
|
32
32
|
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
33
|
-
*
|
|
33
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
34
34
|
*/
|
|
35
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload,
|
|
35
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
36
36
|
getContracts(): Promise<AztecAddress[]>;
|
|
37
37
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
38
38
|
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
39
39
|
}
|
|
40
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VS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LEVBQUUsRUFDVCxTQUFTLENBQUMsRUFBRSxNQUFNLEdBQ2pCLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FtRHpCO1lBUWEscUJBQXFCO0lBa0JwQixVQUFVLENBQUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQUUsSUFBSSxFQUFFLGVBQWUsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FTaEg7SUFFRDs7O09BR0c7SUFDSCxVQUF5QixxQkFBcUIsQ0FDNUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLElBQUksRUFBRSw0QkFBNEIsR0FDakMsT0FBTyxDQUFDLGtCQUFrQixDQUFDLENBdUM3QjtJQUlELFlBQVksSUFBSSxPQUFPLENBQUMsWUFBWSxFQUFFLENBQUMsQ0FFdEM7SUFJRCxRQUFRLENBQUMsTUFBTSxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsT0FBTyxFQUFFLENBQUMsQ0FFaEQ7SUFJRCxtQkFBbUIsQ0FBQyxFQUFFLEVBQUUsRUFBRSxxRUFFekI7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,yBAAyB,CAAC;AACtF,OAAO,EACL,KAAK,qBAAqB,EAG3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG5F,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,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,eAAe,CAAC,CAG1B;IAEc,qBAAqB,CAAC,OAAO,EAAE,YAAY,oBAazD;YAEa,aAAa;IAWrB,uBAAuB,CAC3B,OAAO,CAAC,EAAE,YAAY,EACtB,SAAS,CAAC,EAAE,EAAE,EACd,IAAI,GAAE,WAAuB,EAC7B,IAAI,CAAC,EAAE,EAAE,EACT,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAmDzB;YAQa,qBAAqB;IAkBpB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAShH;IAED;;;OAGG;IACH,UAAyB,qBAAqB,CAC5C,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAuC7B;IAID,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAEtC;IAID,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;IAID,mBAAmB,CAAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
|
package/dest/utils/wallet.js
CHANGED
|
@@ -2,9 +2,10 @@ import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts
|
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
3
|
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
4
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
6
6
|
import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
7
7
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
8
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
10
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
10
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -42,6 +43,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
42
43
|
const executionOptions = {
|
|
43
44
|
txNonce,
|
|
44
45
|
cancellable: this.cancellableTransactions,
|
|
46
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
45
47
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
46
48
|
};
|
|
47
49
|
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
@@ -52,9 +54,7 @@ export class CLIWallet extends BaseWallet {
|
|
|
52
54
|
}
|
|
53
55
|
async getAccountFromAddress(address) {
|
|
54
56
|
let account;
|
|
55
|
-
if (address.
|
|
56
|
-
account = new SignerlessAccount();
|
|
57
|
-
} else if (this.accountCache.has(address.toString())) {
|
|
57
|
+
if (this.accountCache.has(address.toString())) {
|
|
58
58
|
return this.accountCache.get(address.toString());
|
|
59
59
|
} else {
|
|
60
60
|
const accountManager = await this.createOrRetrieveAccount(address);
|
|
@@ -125,12 +125,6 @@ export class CLIWallet extends BaseWallet {
|
|
|
125
125
|
* @returns The stub account, contract instance, and artifact for simulation
|
|
126
126
|
*/ async getFakeAccountDataFor(address) {
|
|
127
127
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
128
|
-
// Account contracts can only be overridden if they have an associated address
|
|
129
|
-
// Overwriting SignerlessAccount is not supported, and does not really make sense
|
|
130
|
-
// since it has no authorization mechanism.
|
|
131
|
-
if (originalAccount instanceof SignerlessAccount) {
|
|
132
|
-
throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
|
|
133
|
-
}
|
|
134
128
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
135
129
|
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
136
130
|
if (!contractInstance) {
|
|
@@ -157,36 +151,43 @@ export class CLIWallet extends BaseWallet {
|
|
|
157
151
|
}
|
|
158
152
|
/**
|
|
159
153
|
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
160
|
-
*
|
|
161
|
-
*/ async simulateViaEntrypoint(executionPayload,
|
|
162
|
-
|
|
163
|
-
return super.simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement);
|
|
164
|
-
}
|
|
154
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
155
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
156
|
+
const { from, feeOptions, scopes } = opts;
|
|
165
157
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
166
|
-
const executionOptions = {
|
|
167
|
-
txNonce: Fr.random(),
|
|
168
|
-
cancellable: this.cancellableTransactions,
|
|
169
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
170
|
-
};
|
|
171
158
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
172
159
|
feeExecutionPayload,
|
|
173
160
|
executionPayload
|
|
174
161
|
]) : executionPayload;
|
|
175
|
-
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
176
162
|
const chainInfo = await this.getChainInfo();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
163
|
+
let overrides;
|
|
164
|
+
let txRequest;
|
|
165
|
+
if (from === NO_FROM) {
|
|
166
|
+
const entrypoint = new DefaultEntrypoint();
|
|
167
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
168
|
+
} else {
|
|
169
|
+
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
170
|
+
overrides = {
|
|
183
171
|
contracts: {
|
|
184
172
|
[from.toString()]: {
|
|
185
173
|
instance,
|
|
186
174
|
artifact
|
|
187
175
|
}
|
|
188
176
|
}
|
|
189
|
-
}
|
|
177
|
+
};
|
|
178
|
+
const executionOptions = {
|
|
179
|
+
txNonce: Fr.random(),
|
|
180
|
+
cancellable: this.cancellableTransactions,
|
|
181
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
182
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
183
|
+
};
|
|
184
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
185
|
+
}
|
|
186
|
+
return this.pxe.simulateTx(txRequest, {
|
|
187
|
+
simulatePublic: true,
|
|
188
|
+
skipFeeEnforcement: true,
|
|
189
|
+
skipTxValidation: true,
|
|
190
|
+
overrides,
|
|
190
191
|
scopes
|
|
191
192
|
});
|
|
192
193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli-wallet",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.e0f15ab9b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -67,19 +67,19 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
71
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
72
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
73
|
-
"@aztec/cli": "0.0.1-commit.
|
|
74
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
75
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
76
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
77
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
79
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
80
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
81
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.e0f15ab9b",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.e0f15ab9b",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.e0f15ab9b",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.e0f15ab9b",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.e0f15ab9b",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.e0f15ab9b",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.e0f15ab9b",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.e0f15ab9b",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.e0f15ab9b",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.e0f15ab9b",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.e0f15ab9b",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.e0f15ab9b",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.e0f15ab9b",
|
|
83
83
|
"commander": "^12.1.0",
|
|
84
84
|
"inquirer": "^10.1.8",
|
|
85
85
|
"source-map-support": "^0.5.21",
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -5,7 +5,11 @@ import type { AztecNode } from '@aztec/aztec.js/node';
|
|
|
5
5
|
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
6
6
|
import type { TxHash } from '@aztec/aztec.js/tx';
|
|
7
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
computeSiloedPrivateInitializationNullifier,
|
|
10
|
+
computeSiloedPublicInitializationNullifier,
|
|
11
|
+
siloNullifier,
|
|
12
|
+
} from '@aztec/stdlib/hash';
|
|
9
13
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
10
14
|
|
|
11
15
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
@@ -144,22 +148,49 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
|
|
|
144
148
|
|
|
145
149
|
async function getKnownNullifiers(wallet: CLIWallet, artifactMap: ArtifactMap) {
|
|
146
150
|
const knownContracts = await wallet.getContracts();
|
|
147
|
-
|
|
148
|
-
const
|
|
151
|
+
|
|
152
|
+
const [contractResults, classResults] = await Promise.all([
|
|
153
|
+
Promise.all(knownContracts.map(contract => getContractNullifiers(wallet, contract))),
|
|
154
|
+
Promise.all(Object.values(artifactMap).map(artifact => getClassNullifier(artifact))),
|
|
155
|
+
]);
|
|
156
|
+
|
|
149
157
|
const initNullifiers: Record<string, AztecAddress> = {};
|
|
150
158
|
const deployNullifiers: Record<string, AztecAddress> = {};
|
|
151
159
|
const classNullifiers: Record<string, string> = {};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
deployNullifiers[
|
|
160
|
+
|
|
161
|
+
for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults) {
|
|
162
|
+
deployNullifiers[deployNullifier.toString()] = contract;
|
|
163
|
+
if (privateInitNullifier) {
|
|
164
|
+
initNullifiers[privateInitNullifier.toString()] = contract;
|
|
165
|
+
}
|
|
166
|
+
initNullifiers[publicInitNullifier.toString()] = contract;
|
|
155
167
|
}
|
|
156
|
-
for (const
|
|
157
|
-
classNullifiers[
|
|
158
|
-
`${artifact.name}Class<${artifact.classId}>`;
|
|
168
|
+
for (const { nullifier, label } of classResults) {
|
|
169
|
+
classNullifiers[nullifier.toString()] = label;
|
|
159
170
|
}
|
|
171
|
+
|
|
160
172
|
return { initNullifiers, deployNullifiers, classNullifiers };
|
|
161
173
|
}
|
|
162
174
|
|
|
175
|
+
async function getContractNullifiers(wallet: CLIWallet, contract: AztecAddress) {
|
|
176
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
177
|
+
const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
|
|
178
|
+
|
|
179
|
+
const metadata = await wallet.getContractMetadata(contract);
|
|
180
|
+
const privateInitNullifier = metadata.instance
|
|
181
|
+
? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash)
|
|
182
|
+
: undefined;
|
|
183
|
+
const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
|
|
184
|
+
|
|
185
|
+
return { contract, deployNullifier, privateInitNullifier, publicInitNullifier };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function getClassNullifier(artifact: ContractArtifactWithClassId) {
|
|
189
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
190
|
+
const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
|
|
191
|
+
return { nullifier, label: `${artifact.name}Class<${artifact.classId}>` };
|
|
192
|
+
}
|
|
193
|
+
|
|
163
194
|
type ArtifactMap = Record<string, ContractArtifactWithClassId>;
|
|
164
195
|
type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
|
|
165
196
|
|