@aztec/cli-wallet 0.0.1-commit.a072138 → 0.0.1-commit.a5db02d
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/bin/index.js +1 -1
- 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 +50 -21
- package/dest/cmds/create_account.d.ts +6 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +54 -27
- package/dest/cmds/deploy.d.ts +5 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +44 -38
- 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 +29 -21
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- package/dest/cmds/import_test_accounts.d.ts +1 -1
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +2 -1
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +36 -19
- package/dest/cmds/send.d.ts +4 -3
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +28 -27
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +2 -1
- package/dest/storage/wallet_db.d.ts +12 -4
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +29 -1
- package/dest/utils/constants.d.ts +2 -2
- package/dest/utils/constants.d.ts.map +1 -1
- package/dest/utils/constants.js +1 -0
- package/dest/utils/options/fees.d.ts +3 -2
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +36 -10
- package/dest/utils/options/options.d.ts +2 -2
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +5 -5
- package/dest/utils/wallet.d.ts +37 -8
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +178 -97
- package/package.json +16 -15
- package/src/bin/index.ts +1 -1
- package/src/cmds/check_tx.ts +57 -24
- package/src/cmds/create_account.ts +55 -29
- package/src/cmds/deploy.ts +41 -33
- package/src/cmds/deploy_account.ts +28 -15
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +12 -1
- package/src/cmds/index.ts +71 -15
- package/src/cmds/send.ts +25 -17
- package/src/cmds/simulate.ts +3 -2
- package/src/storage/wallet_db.ts +38 -2
- package/src/utils/constants.ts +7 -1
- package/src/utils/options/fees.ts +42 -10
- package/src/utils/options/options.ts +5 -5
- package/src/utils/wallet.ts +221 -130
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import { waitForTx } from '@aztec/aztec.js/node';
|
|
3
4
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
4
5
|
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
6
|
import { printProfileResult } from '../utils/profiling.js';
|
|
6
|
-
export async function deployAccount(wallet, aztecNode, address, wait, deployer, registerClass, publicDeploy, skipInitialization, feeOpts, json, verbose, debugLogger, log) {
|
|
7
|
+
export async function deployAccount(wallet, aztecNode, address, wait, deployer, registerClass, publicDeploy, skipInitialization, feeOpts, waitForStatus, json, verbose, debugLogger, log) {
|
|
7
8
|
const out = {};
|
|
8
|
-
const account = await wallet.
|
|
9
|
+
const account = await wallet.retrieveAccount(address);
|
|
9
10
|
const { partialAddress, publicKeys } = await account.getCompleteAddress();
|
|
10
11
|
const { initializationHash, salt } = account.getInstance();
|
|
11
12
|
if (json) {
|
|
@@ -26,7 +27,7 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
26
27
|
let txReceipt;
|
|
27
28
|
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
28
29
|
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
29
|
-
const from = delegatedDeployment ? deployer :
|
|
30
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
30
31
|
const deployAccountOpts = {
|
|
31
32
|
skipClassPublication: !registerClass,
|
|
32
33
|
skipInstancePublication: !publicDeploy,
|
|
@@ -37,14 +38,15 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
37
38
|
gasSettings
|
|
38
39
|
}
|
|
39
40
|
};
|
|
41
|
+
const localStart = performance.now();
|
|
40
42
|
const deployMethod = await account.getDeployMethod();
|
|
41
|
-
const
|
|
43
|
+
const sim = await deployMethod.simulate({
|
|
42
44
|
...deployAccountOpts,
|
|
43
|
-
|
|
44
|
-
...deployAccountOpts.fee,
|
|
45
|
-
estimateGas: true
|
|
46
|
-
}
|
|
45
|
+
includeMetadata: true
|
|
47
46
|
});
|
|
47
|
+
// includeMetadata: true guarantees these fields are present
|
|
48
|
+
const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed);
|
|
49
|
+
const stats = sim.stats;
|
|
48
50
|
if (feeOpts.estimateOnly) {
|
|
49
51
|
if (json) {
|
|
50
52
|
out.fee = {
|
|
@@ -65,27 +67,33 @@ export async function deployAccount(wallet, aztecNode, address, wait, deployer,
|
|
|
65
67
|
if (!json) {
|
|
66
68
|
log(`\nWaiting for account contract deployment...`);
|
|
67
69
|
}
|
|
68
|
-
const
|
|
70
|
+
const sendOpts = {
|
|
69
71
|
...deployAccountOpts,
|
|
70
72
|
fee: deployAccountOpts.fee ? {
|
|
71
73
|
...deployAccountOpts.fee,
|
|
72
74
|
gasSettings: estimatedGas
|
|
73
|
-
} : undefined
|
|
74
|
-
|
|
75
|
+
} : undefined
|
|
76
|
+
};
|
|
77
|
+
({ txHash } = await deployMethod.send({
|
|
78
|
+
...sendOpts,
|
|
79
|
+
wait: NO_WAIT
|
|
80
|
+
}));
|
|
81
|
+
const localTimeMs = performance.now() - localStart;
|
|
82
|
+
if (wait) {
|
|
83
|
+
const nodeStart = performance.now();
|
|
84
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
75
85
|
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const isReceipt = (data)=>'txHash' in data;
|
|
80
|
-
if (isReceipt(result)) {
|
|
81
|
-
txReceipt = result;
|
|
82
|
-
txHash = result.txHash;
|
|
86
|
+
waitForStatus
|
|
87
|
+
});
|
|
88
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
83
89
|
out.txReceipt = {
|
|
84
90
|
status: txReceipt.status,
|
|
85
91
|
transactionFee: txReceipt.transactionFee
|
|
86
92
|
};
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
if (!json) {
|
|
94
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
95
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
91
99
|
out.txHash = txHash;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
4
|
+
export declare function getFeeJuiceBalanceCmd(node: AztecNode, address: AztecAddress, json: boolean, exact: boolean, log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X2ZlZV9qdWljZV9iYWxhbmNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY21kcy9nZXRfZmVlX2p1aWNlX2JhbGFuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFHdEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFtQm5ELHdCQUFzQixxQkFBcUIsQ0FDekMsSUFBSSxFQUFFLFNBQVMsRUFDZixPQUFPLEVBQUUsWUFBWSxFQUNyQixJQUFJLEVBQUUsT0FBTyxFQUNiLEtBQUssRUFBRSxPQUFPLEVBQ2QsR0FBRyxFQUFFLEtBQUssaUJBUVgifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_fee_juice_balance.d.ts","sourceRoot":"","sources":["../../src/cmds/get_fee_juice_balance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAmBnD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,KAAK,iBAQX"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getFeeJuiceBalance } from '@aztec/aztec.js/utils';
|
|
2
|
+
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
3
|
+
const FEE_JUICE_DECIMALS = 18;
|
|
4
|
+
const FEE_JUICE_UNIT = 10n ** BigInt(FEE_JUICE_DECIMALS);
|
|
5
|
+
/** Formats a raw FeeJuice balance (18 decimals) for human-readable display. */ function formatFeeJuice(raw, exact) {
|
|
6
|
+
const whole = raw / FEE_JUICE_UNIT;
|
|
7
|
+
const fractional = raw % FEE_JUICE_UNIT;
|
|
8
|
+
const fracStr = fractional.toString().padStart(FEE_JUICE_DECIMALS, '0');
|
|
9
|
+
if (exact) {
|
|
10
|
+
return `${whole}.${fracStr} FJ`;
|
|
11
|
+
}
|
|
12
|
+
if (fractional === 0n) {
|
|
13
|
+
return `${whole} FJ`;
|
|
14
|
+
}
|
|
15
|
+
return `${whole}.${fracStr.replace(/0+$/, '')} FJ`;
|
|
16
|
+
}
|
|
17
|
+
export async function getFeeJuiceBalanceCmd(node, address, json, exact, log) {
|
|
18
|
+
const balance = await getFeeJuiceBalance(address, node);
|
|
19
|
+
if (json) {
|
|
20
|
+
log(prettyPrintJSON({
|
|
21
|
+
address: address.toString(),
|
|
22
|
+
balance: balance.toString()
|
|
23
|
+
}));
|
|
24
|
+
} else {
|
|
25
|
+
log(`Fee Juice balance for ${address.toString()}: ${formatFeeJuice(balance, exact)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -2,4 +2,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
2
2
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
3
3
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
4
4
|
export declare function importTestAccounts(wallet: CLIWallet, db: WalletDB, json: boolean, log: LogFn): Promise<void>;
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1wb3J0X3Rlc3RfYWNjb3VudHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2ltcG9ydF90ZXN0X2FjY291bnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3hELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixrQkFBa0IsQ0FBQyxNQUFNLEVBQUUsU0FBUyxFQUFFLEVBQUUsRUFBRSxRQUFRLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxpQkE2Q2xHIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_test_accounts.d.ts","sourceRoot":"","sources":["../../src/cmds/import_test_accounts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"import_test_accounts.d.ts","sourceRoot":"","sources":["../../src/cmds/import_test_accounts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,iBA6ClG"}
|
|
@@ -10,7 +10,8 @@ export async function importTestAccounts(wallet, db, json, log) {
|
|
|
10
10
|
const salt = new Fr(account.salt);
|
|
11
11
|
const address = account.address;
|
|
12
12
|
await db.storeAccount(address, {
|
|
13
|
-
type: '
|
|
13
|
+
type: 'schnorr_initializerless',
|
|
14
|
+
signingKey: account.signingKey,
|
|
14
15
|
secretKey: secret,
|
|
15
16
|
salt,
|
|
16
17
|
alias,
|
package/dest/cmds/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { type Command } from 'commander';
|
|
|
3
3
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
4
4
|
import type { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
5
|
export declare function injectCommands(program: Command, log: LogFn, debugLogger: Logger, walletAndNodeWrapper: CliWalletAndNodeWrapper, db: WalletDB): Command;
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUczRCxPQUFPLEVBQUUsS0FBSyxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQW1DdkYsd0JBQWdCLGNBQWMsQ0FDNUIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsR0FBRyxFQUFFLEtBQUssRUFDVixXQUFXLEVBQUUsTUFBTSxFQUNuQixvQkFBb0IsRUFBRSx1QkFBdUIsRUFDN0MsRUFBRSxFQUFFLFFBQVEsV0FncUJiIn0=
|
package/dest/cmds/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAmCvF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,uBAAuB,EAC7C,EAAE,EAAE,QAAQ,WAgqBb"}
|
package/dest/cmds/index.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
2
2
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
3
|
-
import { ETHEREUM_HOSTS, PRIVATE_KEY, addOptions,
|
|
3
|
+
import { ETHEREUM_HOSTS, PRIVATE_KEY, addOptions, createSigningKeyOption, 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
|
-
import { ARTIFACT_DESCRIPTION, CLIFeeArgs, aliasedAddressParser,
|
|
8
|
+
import { ARTIFACT_DESCRIPTION, CLIFeeArgs, aliasedAddressParser, aliasedSigningKeyParser, 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
|
|
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(createSigningKeyOption('Signing key for account. Uses random by default.', false, (sk)=>aliasedSigningKeyParser(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,
|
|
33
|
+
const { type, from: parsedFromAddress, signingKey, 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,11 +45,12 @@ 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,
|
|
48
|
+
const accountCreationResult = await createAccount(wallet, node, type, signingKey, 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
|
-
const { address, alias, secretKey, salt } = accountCreationResult;
|
|
50
|
+
const { address, alias, signingKey, secretKey, salt } = accountCreationResult;
|
|
40
51
|
await db.storeAccount(address, {
|
|
41
52
|
type,
|
|
53
|
+
signingKey,
|
|
42
54
|
secretKey,
|
|
43
55
|
salt,
|
|
44
56
|
alias,
|
|
@@ -48,45 +60,45 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
48
60
|
});
|
|
49
61
|
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
62
|
// 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());
|
|
63
|
+
.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
64
|
addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command)=>{
|
|
53
65
|
const { deployAccount } = await import('./deploy_account.js');
|
|
54
66
|
const options = command.optsWithGlobals();
|
|
55
|
-
const { wait, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
67
|
+
const { wait, waitForStatus: waitForStatusStr, from: parsedFromAddress, json, registerClass, skipInitialization, publicDeploy, verbose } = options;
|
|
56
68
|
const { wallet, node } = walletAndNodeWrapper;
|
|
57
|
-
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), json, verbose, debugLogger, log);
|
|
69
|
+
await deployAccount(wallet, node, parsedAccount, wait, parsedFromAddress, registerClass, publicDeploy, skipInitialization, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), json, verbose, debugLogger, log);
|
|
58
70
|
});
|
|
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.
|
|
71
|
+
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
72
|
// 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());
|
|
73
|
+
.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
74
|
addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command)=>{
|
|
63
75
|
const { deploy } = await import('./deploy.js');
|
|
64
76
|
const options = command.optsWithGlobals();
|
|
65
|
-
const { json, publicKey, args, salt, wait, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
77
|
+
const { json, publicKey, args, salt, wait, waitForStatus: waitForStatusStr, classRegistration, init, publicDeployment, universal, from: parsedFromAddress, alias, timeout, verbose } = options;
|
|
66
78
|
const { wallet, node } = walletAndNodeWrapper;
|
|
67
79
|
const artifactPath = await artifactPathPromise;
|
|
68
|
-
debugLogger.info(`Using wallet with address ${parsedFromAddress
|
|
69
|
-
const address = await deploy(wallet, node,
|
|
80
|
+
debugLogger.info(`Using wallet with address ${parsedFromAddress?.toString() ?? '<none>'}`);
|
|
81
|
+
const address = await deploy(wallet, node, parsedFromAddress, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, CLIFeeArgs.parse(options, log, db), parseWaitForStatus(waitForStatusStr), verbose, timeout, debugLogger, log, universal);
|
|
70
82
|
if (db && address) {
|
|
71
83
|
await db.storeContract(address, artifactPath, log, alias);
|
|
72
84
|
}
|
|
73
85
|
});
|
|
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());
|
|
86
|
+
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
87
|
addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
76
88
|
const { send } = await import('./send.js');
|
|
77
89
|
const options = command.optsWithGlobals();
|
|
78
|
-
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, alias, authWitness: authWitnessArray, verbose } = options;
|
|
90
|
+
const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, wait, waitForStatus: waitForStatusStr, alias, authWitness: authWitnessArray, verbose } = options;
|
|
79
91
|
const { wallet, node } = walletAndNodeWrapper;
|
|
80
92
|
const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
|
|
81
93
|
debugLogger.info(`Using wallet with address ${parsedFromAddress.toString()}`);
|
|
82
94
|
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);
|
|
95
|
+
const sentTx = await send(wallet, node, parsedFromAddress, functionName, args, artifactPath, contractAddress, wait, alias, CLIFeeArgs.parse(options, log, db), authWitnesses, parseWaitForStatus(waitForStatusStr), verbose, log);
|
|
84
96
|
if (db && sentTx) {
|
|
85
97
|
const txAlias = alias ? alias : `${functionName}-${randomBytes(16).toString('hex')}`;
|
|
86
98
|
await db.storeTx(sentTx, log, txAlias);
|
|
87
99
|
}
|
|
88
100
|
});
|
|
89
|
-
const simulateCommand = program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(
|
|
101
|
+
const simulateCommand = program.command('simulate').description('Simulates the execution of a function on an Aztec contract.').argument('<functionName>', 'Name of function to simulate').addOption(createArgsOption(false, db)).addOption(createContractAddressOption(db)).addOption(createArtifactOption(db)).addOption(createSigningKeyOption("The sender's signing key", !db, (sk)=>aliasedSigningKeyParser(sk, db)).conflicts('account')).addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db)).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createVerboseOption());
|
|
90
102
|
addOptions(simulateCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command)=>{
|
|
91
103
|
const { simulate } = await import('./simulate.js');
|
|
92
104
|
const options = command.optsWithGlobals();
|
|
@@ -118,6 +130,11 @@ export function injectCommands(program, log, debugLogger, walletAndNodeWrapper,
|
|
|
118
130
|
await db.pushBridgedFeeJuice(recipient, secret, amount, messageLeafIndex, log);
|
|
119
131
|
}
|
|
120
132
|
});
|
|
133
|
+
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)=>{
|
|
134
|
+
const { getFeeJuiceBalanceCmd } = await import('./get_fee_juice_balance.js');
|
|
135
|
+
const { json, exact } = options;
|
|
136
|
+
await getFeeJuiceBalanceCmd(walletAndNodeWrapper.node, address, json, exact, log);
|
|
137
|
+
});
|
|
121
138
|
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
139
|
const { createAuthwit } = await import('./create_authwit.js');
|
|
123
140
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvc2VuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUM5RCxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFFNUQsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUFhLE1BQU0sc0JBQXNCLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRzVDLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVwRCx3QkFBc0IsSUFBSSxDQUN4QixNQUFNLEVBQUUsU0FBUyxFQUNqQixJQUFJLEVBQUUsU0FBUyxFQUNmLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixJQUFJLEVBQUUsT0FBTyxFQUNiLFdBQVcsRUFBRSxPQUFPLEVBQ3BCLE9BQU8sRUFBRSxVQUFVLEVBQ25CLGFBQWEsRUFBRSxXQUFXLEVBQUUsRUFDNUIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsR0FBRyxFQUFFLEtBQUs7O2VBb0VYIn0=
|
package/dest/cmds/send.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/cmds/send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,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,46 @@ 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
|
-
|
|
21
|
-
...sendOptions.fee,
|
|
22
|
-
estimateGas: true
|
|
23
|
-
}
|
|
23
|
+
includeMetadata: true
|
|
24
24
|
});
|
|
25
|
+
// includeMetadata: true guarantees these fields are present
|
|
26
|
+
const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed);
|
|
27
|
+
const stats = sim.stats;
|
|
25
28
|
if (feeOpts.estimateOnly) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
if (verbose) {
|
|
29
32
|
printProfileResult(stats, log);
|
|
30
33
|
}
|
|
34
|
+
const { txHash } = await call.send({
|
|
35
|
+
...sendOptions,
|
|
36
|
+
fee: {
|
|
37
|
+
...sendOptions.fee,
|
|
38
|
+
gasSettings: estimatedGas
|
|
39
|
+
},
|
|
40
|
+
wait: NO_WAIT
|
|
41
|
+
});
|
|
42
|
+
const localTimeMs = performance.now() - localStart;
|
|
43
|
+
log(`\nTransaction hash: ${txHash.toString()}`);
|
|
31
44
|
if (wait) {
|
|
32
45
|
try {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
gasSettings: estimatedGas
|
|
38
|
-
},
|
|
39
|
-
wait: {
|
|
40
|
-
timeout: DEFAULT_TX_TIMEOUT_S
|
|
41
|
-
}
|
|
46
|
+
const nodeStart = performance.now();
|
|
47
|
+
const receipt = await waitForTx(node, txHash, {
|
|
48
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
49
|
+
waitForStatus
|
|
42
50
|
});
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
log(
|
|
51
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
52
|
+
const statusLabel = waitForStatus === TxStatus.PROPOSED ? 'proposed' : 'checkpointed';
|
|
53
|
+
log(`Transaction has been ${statusLabel}`);
|
|
46
54
|
log(` Tx fee: ${receipt.transactionFee}`);
|
|
47
55
|
log(` Status: ${receipt.status}`);
|
|
48
56
|
log(` Block number: ${receipt.blockNumber}`);
|
|
49
57
|
log(` Block hash: ${receipt.blockHash?.toString()}`);
|
|
58
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
59
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
50
60
|
return {
|
|
51
61
|
txHash
|
|
52
62
|
};
|
|
@@ -55,15 +65,6 @@ export async function send(wallet, node, from, functionName, functionArgsIn, con
|
|
|
55
65
|
throw err;
|
|
56
66
|
}
|
|
57
67
|
} 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
68
|
log('Transaction pending. Check status with check-tx');
|
|
68
69
|
return {
|
|
69
70
|
txHash
|
package/dest/cmds/simulate.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
5
5
|
import type { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
6
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
7
7
|
export declare function simulate(wallet: CLIWallet, node: AztecNode, from: AztecAddress, functionName: string, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, feeOpts: CLIFeeArgs, authWitnesses: AuthWitness[], verbose: boolean, log: LogFn): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJza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E,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,iBA8BX"}
|
package/dest/cmds/simulate.js
CHANGED
|
@@ -23,7 +23,8 @@ export async function simulate(wallet, node, from, functionName, functionArgsIn,
|
|
|
23
23
|
if (!metadata.instance) {
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
|
-
const
|
|
26
|
+
const classId = metadata.updatedContractClassId ?? metadata.instance.originalContractClassId;
|
|
27
|
+
const artifact = await wallet.getContractArtifact(classId);
|
|
27
28
|
return artifact;
|
|
28
29
|
}, log);
|
|
29
30
|
printProfileResult(simulationResult.stats, log);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
2
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
5
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -20,9 +21,15 @@ export declare class WalletDB {
|
|
|
20
21
|
secret: string;
|
|
21
22
|
leafIndex: bigint;
|
|
22
23
|
}>;
|
|
23
|
-
|
|
24
|
+
peekBridgedFeeJuice(recipient: AztecAddress, log: LogFn): Promise<{
|
|
25
|
+
amount: bigint;
|
|
26
|
+
secret: string;
|
|
27
|
+
leafIndex: bigint;
|
|
28
|
+
}>;
|
|
29
|
+
storeAccount(address: AztecAddress, { type, signingKey, secretKey, salt, alias, publicKey }: {
|
|
24
30
|
type: AccountType;
|
|
25
|
-
|
|
31
|
+
signingKey?: GrumpkinScalar;
|
|
32
|
+
secretKey?: Fr;
|
|
26
33
|
salt: Fr;
|
|
27
34
|
alias: string | undefined;
|
|
28
35
|
publicKey: string | undefined;
|
|
@@ -44,10 +51,11 @@ export declare class WalletDB {
|
|
|
44
51
|
retrieveAccountMetadata(aliasOrAddress: AztecAddress | string, metadataKey: string): Promise<Buffer<ArrayBufferLike>>;
|
|
45
52
|
retrieveAccount(address: AztecAddress | string): Promise<{
|
|
46
53
|
address: string | AztecAddress;
|
|
54
|
+
signingKey: import("@aztec/foundation/curves/bn254").Fq | undefined;
|
|
47
55
|
secretKey: Fr;
|
|
48
56
|
salt: Fr;
|
|
49
|
-
type: "ecdsasecp256k1" | "ecdsasecp256r1" | "ecdsasecp256r1ssh" | "schnorr";
|
|
57
|
+
type: "ecdsasecp256k1" | "ecdsasecp256r1" | "ecdsasecp256r1ssh" | "schnorr" | "schnorr_initializerless";
|
|
50
58
|
}>;
|
|
51
59
|
storeAlias(type: AliasType, key: string, value: Buffer, log: LogFn): Promise<void>;
|
|
52
60
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0X2RiLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3RvcmFnZS93YWxsZXRfZGIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUM5RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUvQyxPQUFPLEtBQUssRUFB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;IAEK,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM;;;;;;OAYnD;IAEK,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAMvE;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
2
3
|
import { extractECDSAPublicKeyFromBase64String } from '../utils/ecdsa.js';
|
|
3
4
|
export const Aliases = [
|
|
4
5
|
'accounts',
|
|
@@ -62,7 +63,27 @@ export class WalletDB {
|
|
|
62
63
|
leafIndex: BigInt(leafIndexStr)
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
|
-
async
|
|
66
|
+
async peekBridgedFeeJuice(recipient, log) {
|
|
67
|
+
const stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
|
|
68
|
+
const result = await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:${stackPointer}`);
|
|
69
|
+
if (!result) {
|
|
70
|
+
throw new Error(`No stored fee juice available for recipient ${recipient.toString()}. Please provide claim amount and secret. Stack pointer ${stackPointer}`);
|
|
71
|
+
}
|
|
72
|
+
const [amountStr, secretStr, leafIndexStr] = result.toString().split(':');
|
|
73
|
+
log(`Peeked ${amountStr} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
|
|
74
|
+
return {
|
|
75
|
+
amount: BigInt(amountStr),
|
|
76
|
+
secret: secretStr,
|
|
77
|
+
leafIndex: BigInt(leafIndexStr)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async storeAccount(address, { type, signingKey, secretKey, salt, alias, publicKey }, log) {
|
|
81
|
+
// Even though the privacy secret key is sometimes derived from the signing key, we store it in the database
|
|
82
|
+
// regardless as that is not always the case. Local-key accounts also store their signing key, while external-key
|
|
83
|
+
// accounts such as SSH store only the privacy secret.
|
|
84
|
+
if (!secretKey) {
|
|
85
|
+
throw new Error('Cannot store account without a secret key');
|
|
86
|
+
}
|
|
66
87
|
let publicSigningKey;
|
|
67
88
|
if (type === 'ecdsasecp256r1ssh' && publicKey) {
|
|
68
89
|
publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
|
|
@@ -73,6 +94,9 @@ export class WalletDB {
|
|
|
73
94
|
}
|
|
74
95
|
await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
|
|
75
96
|
await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
|
|
97
|
+
if (signingKey) {
|
|
98
|
+
await this.#accounts.set(`${address.toString()}:signing`, signingKey.toBuffer());
|
|
99
|
+
}
|
|
76
100
|
await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
|
|
77
101
|
if (publicSigningKey) {
|
|
78
102
|
await this.#accounts.set(`${address.toString()}:publicSigningKey`, publicSigningKey);
|
|
@@ -184,11 +208,15 @@ export class WalletDB {
|
|
|
184
208
|
if (!secretKeyBuffer) {
|
|
185
209
|
throw new Error(`Could not find ${address}:sk. Account "${address.toString}" does not exist on this wallet.`);
|
|
186
210
|
}
|
|
211
|
+
const signingKeyBuffer = await this.#accounts.getAsync(`${address.toString()}:signing`);
|
|
187
212
|
const secretKey = Fr.fromBuffer(secretKeyBuffer);
|
|
213
|
+
// External-key accounts (e.g. SSH) store no signing key.
|
|
214
|
+
const signingKey = signingKeyBuffer ? GrumpkinScalar.fromBuffer(signingKeyBuffer) : undefined;
|
|
188
215
|
const salt = Fr.fromBuffer(await this.#accounts.getAsync(`${address.toString()}:salt`));
|
|
189
216
|
const type = (await this.#accounts.getAsync(`${address.toString()}:type`)).toString('utf8');
|
|
190
217
|
return {
|
|
191
218
|
address,
|
|
219
|
+
signingKey,
|
|
192
220
|
secretKey,
|
|
193
221
|
salt,
|
|
194
222
|
type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const MIN_FEE_PADDING = 0.5;
|
|
2
|
-
export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
2
|
+
export declare const AccountTypes: readonly ["schnorr", "schnorr_initializerless", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
3
3
|
export type AccountType = (typeof AccountTypes)[number];
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGVBQU8sTUFBTSxlQUFlLE1BQU0sQ0FBQztBQUVuQyxlQUFPLE1BQU0sWUFBWSwwR0FNZixDQUFDO0FBQ1gsTUFBTSxNQUFNLFdBQVcsR0FBRyxDQUFDLE9BQU8sWUFBWSxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,YAAY,0GAMf,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC"}
|