@aztec/cli-wallet 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dest/bin/index.d.ts +2 -1
- package/dest/bin/index.js +20 -10
- package/dest/cmds/authorize_action.d.ts +2 -2
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +5 -3
- package/dest/cmds/bridge_fee_juice.d.ts +2 -2
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +3 -2
- 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 +44 -15
- 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 -18
- package/dest/cmds/create_authwit.d.ts +1 -1
- package/dest/cmds/create_authwit.js +1 -1
- package/dest/cmds/deploy.d.ts +1 -1
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +50 -24
- package/dest/cmds/deploy_account.d.ts +1 -1
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +31 -17
- package/dest/cmds/import_test_accounts.d.ts +1 -1
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.js +3 -3
- package/dest/cmds/profile.d.ts +1 -1
- package/dest/cmds/profile.js +1 -1
- package/dest/cmds/register_contract.d.ts +1 -1
- package/dest/cmds/register_sender.d.ts +1 -1
- package/dest/cmds/send.d.ts +2 -2
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +33 -18
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +4 -4
- package/dest/storage/wallet_db.d.ts +5 -5
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +47 -32
- package/dest/utils/authorizations.d.ts +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -1
- package/dest/utils/constants.d.ts +4 -0
- package/dest/utils/constants.d.ts.map +1 -0
- package/dest/utils/constants.js +7 -0
- package/dest/utils/ecdsa.d.ts +1 -1
- 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 +5 -3
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/profiling.d.ts.map +1 -1
- package/dest/utils/profiling.js +9 -1
- package/dest/utils/wallet.d.ts +15 -10
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +68 -47
- package/package.json +17 -14
- package/src/bin/index.ts +18 -12
- package/src/cmds/authorize_action.ts +2 -2
- package/src/cmds/bridge_fee_juice.ts +3 -2
- package/src/cmds/check_tx.ts +50 -21
- package/src/cmds/create_account.ts +32 -20
- package/src/cmds/create_authwit.ts +1 -1
- package/src/cmds/deploy.ts +45 -23
- package/src/cmds/deploy_account.ts +29 -18
- package/src/cmds/index.ts +4 -4
- package/src/cmds/profile.ts +1 -1
- package/src/cmds/send.ts +27 -12
- package/src/cmds/simulate.ts +5 -8
- package/src/storage/wallet_db.ts +51 -38
- package/src/utils/cli_wallet_and_node_wrapper.ts +1 -1
- package/src/utils/constants.ts +4 -0
- package/src/utils/options/fees.ts +11 -4
- package/src/utils/options/options.ts +1 -1
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +83 -62
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
4
4
|
import { Option } from 'commander';
|
|
5
|
-
import {
|
|
5
|
+
import { MIN_FEE_PADDING } from '../constants.js';
|
|
6
6
|
import { aliasedAddressParser } from './options.js';
|
|
7
7
|
function printOptionParams(params) {
|
|
8
8
|
const paramsWithDescription = Object.keys(params).filter((name)=>params[name].description);
|
|
@@ -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);
|
|
@@ -190,7 +192,7 @@ export class CLIFeeArgs {
|
|
|
190
192
|
this.gasSettings = gasSettings;
|
|
191
193
|
}
|
|
192
194
|
async toUserFeeOptions(node, wallet, from) {
|
|
193
|
-
const maxFeesPerGas = (await node.
|
|
195
|
+
const maxFeesPerGas = (await node.getCurrentMinFees()).mul(1 + MIN_FEE_PADDING);
|
|
194
196
|
const gasSettings = GasSettings.default({
|
|
195
197
|
...this.gasSettings,
|
|
196
198
|
maxFeesPerGas
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './fees.js';
|
|
2
2
|
export * from './options.js';
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91dGlscy9vcHRpb25zL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsY0FBYyxDQUFDIn0=
|
|
@@ -21,4 +21,4 @@ export declare function artifactPathParser(filePath: string, db?: WalletDB): Pro
|
|
|
21
21
|
export declare function artifactPathFromPromiseOrAlias(artifactPathPromise: Promise<string>, contractAddress: AztecAddress, db?: WalletDB): Promise<string>;
|
|
22
22
|
export declare function createArtifactOption(db?: WalletDB): Option;
|
|
23
23
|
export declare function cleanupAuthWitnesses(authWitnesses: AuthWitness[] | undefined): AuthWitness[];
|
|
24
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL29wdGlvbnMvb3B0aW9ucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFNUMsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFHbkMsT0FBTyxLQUFLLEVBQUUsU0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BQWdCLGdCQUFnQixDQUFDLGFBQWEsRUFBRSxPQUFPLEVBQUUsRUFBRSxDQUFDLEVBQUUsUUFBUSxVQVFyRTtBQUVELHdCQUFnQiwyQkFBMkIsQ0FBQyxFQUFFLENBQUMsRUFBRSxRQUFRLFVBSXhEO0FBRUQsd0JBQWdCLGtDQUFrQyxXQUtqRDtBQUVELHdCQUFnQixtQkFBbUIsV0FLbEM7QUFFRCx3QkFBZ0Isa0JBQWtCLENBQUMsUUFBUSxFQUFFLE1BQU0sRUFBRSxFQUFFLENBQUMsRUFBRSxRQUFRLG1CQWFqRTtBQUVELHdCQUFzQiw4QkFBOEIsQ0FDbEQsbUJBQW1CLEVBQUUsT0FBTyxDQUFDLE1BQU0sQ0FBQyxFQUNwQyxlQUFlLEVBQUUsWUFBWSxFQUM3QixFQUFFLENBQUMsRUFBRSxRQUFRLG1CQVdkO0FBRUQsd0JBQWdCLG9CQUFvQixDQUFDLEVBQUUsQ0FBQyxFQUFFLFFBQVEsVUFJakQ7QUE2QkQsd0JBQWdCLG9CQUFvQixDQUFDLGFBQWEsRUFBRSxXQUFXLEVBQUUsR0FBRyxTQUFTLEdBQUcsV0FBVyxFQUFFLENBRTVGIn0=
|
|
@@ -2,7 +2,7 @@ import { parseAztecAddress, parseSecretKey, parseTxHash } from '@aztec/cli/utils
|
|
|
2
2
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
3
|
import { Option } from 'commander';
|
|
4
4
|
import { readdir, stat } from 'fs/promises';
|
|
5
|
-
import { AccountTypes } from '../
|
|
5
|
+
import { AccountTypes } from '../constants.js';
|
|
6
6
|
const TARGET_DIR = 'target';
|
|
7
7
|
export const ARTIFACT_DESCRIPTION = "Path to a compiled Aztec contract's artifact in JSON format. If executed inside a nargo workspace, a package and contract name can be specified as package@contract";
|
|
8
8
|
export function integerArgParser(value, argName, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
|
@@ -2,4 +2,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
2
2
|
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
3
3
|
import type { ProvingStats, SimulationStats } from '@aztec/stdlib/tx';
|
|
4
4
|
export declare function printProfileResult(stats: ProvingStats | SimulationStats, log: LogFn, printOracles?: boolean, executionSteps?: PrivateExecutionStep[]): void;
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvcHJvZmlsaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFrQixlQUFlLEVBQXFCLE1BQU0sa0JBQWtCLENBQUM7QUFVekcsd0JBQWdCLGtCQUFrQixDQUNoQyxLQUFLLEVBQUUsWUFBWSxHQUFHLGVBQWUsRUFDckMsR0FBRyxFQUFFLEtBQUssRUFDVixZQUFZLEdBQUUsT0FBZSxFQUM3QixjQUFjLENBQUMsRUFBRSxvQkFBb0IsRUFBRSxRQTJKeEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAUzG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAUzG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,QA2JxC"}
|
package/dest/utils/profiling.js
CHANGED
|
@@ -35,7 +35,7 @@ export function printProfileResult(stats, log, printOracles = false, executionSt
|
|
|
35
35
|
}
|
|
36
36
|
if (stats.nodeRPCCalls) {
|
|
37
37
|
log(format('\nRPC calls:\n'));
|
|
38
|
-
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls)){
|
|
38
|
+
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls.perMethod)){
|
|
39
39
|
const calls = times.length;
|
|
40
40
|
const total = times.reduce((acc, time)=>acc + time, 0);
|
|
41
41
|
const avg = total / calls;
|
|
@@ -43,6 +43,14 @@ export function printProfileResult(stats, log, printOracles = false, executionSt
|
|
|
43
43
|
const max = Math.max(...times);
|
|
44
44
|
log(format(method.padEnd(ORACLE_NAME_PADDING), `${calls} calls`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `${total.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `min: ${min.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `avg: ${avg.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `max: ${max.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH)));
|
|
45
45
|
}
|
|
46
|
+
const { roundTrips } = stats.nodeRPCCalls;
|
|
47
|
+
log(format('\nRound trips (actual blocking waits):\n'));
|
|
48
|
+
log(format('Round trips:'.padEnd(25), `${roundTrips.roundTrips}`.padStart(COLUMN_MAX_WIDTH)));
|
|
49
|
+
log(format('Total blocking time:'.padEnd(25), `${roundTrips.totalBlockingTime.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
50
|
+
if (roundTrips.roundTrips > 0) {
|
|
51
|
+
const avgRoundTrip = roundTrips.totalBlockingTime / roundTrips.roundTrips;
|
|
52
|
+
log(format('Avg round trip:'.padEnd(25), `${avgRoundTrip.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
log(format('\nSync time:'.padEnd(25), `${timings.sync?.toFixed(2)}ms`.padStart(16)));
|
|
48
56
|
log(format('Private simulation time:'.padEnd(25), `${timings.perFunction.reduce((acc, { time })=>acc + time, 0).toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { type Account } from '@aztec/aztec.js/account';
|
|
2
2
|
import { type InteractionFeeOptions } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
7
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
7
|
+
import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
9
8
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
10
9
|
import type { PXE } from '@aztec/pxe/server';
|
|
11
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
-
import
|
|
11
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
13
12
|
import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
13
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
14
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
14
15
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
15
|
-
|
|
16
|
-
export type AccountType = (typeof AccountTypes)[number];
|
|
17
|
-
export declare const BASE_FEE_PADDING = 0.5;
|
|
16
|
+
import type { AccountType } from './constants.js';
|
|
18
17
|
export declare class CLIWallet extends BaseWallet {
|
|
19
18
|
private userLog;
|
|
20
19
|
private db?;
|
|
@@ -29,7 +28,13 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
29
28
|
createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
|
|
30
29
|
private getFakeAccountDataFor;
|
|
31
30
|
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
33
|
+
* Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
|
|
34
|
+
*/
|
|
35
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResult>;
|
|
32
36
|
getContracts(): Promise<AztecAddress[]>;
|
|
33
|
-
getNotes(filter: NotesFilter): Promise<
|
|
37
|
+
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
38
|
+
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
34
39
|
}
|
|
35
|
-
//# sourceMappingURL=
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBMkMsTUFBTSx5QkFBeUIsQ0FBQztBQUNoRyxPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFHM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFNUYsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRTdDLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUzRCxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDN0MsT0FBTyxLQUFLLEVBQXVCLGVBQWUsRUFBRSxrQkFBa0Is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OAAa,MAAM,CACjB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,KAAK,EACV,EAAE,CAAC,EAAE,QAAQ,EACb,iBAAiB,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GACrC,OAAO,CAAC,SAAS,CAAC,CAIpB;IAEc,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAG7D;YAEa,oCAAoC;IAuB5C,mBAAmB,CACvB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,qBAAqB,GAClC,OAAO,CAAC,eAAe,CAAC,CAG1B;IAEc,qBAAqB,CAAC,OAAO,EAAE,YAAY,oBAezD;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;IAwBpB,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,CAsC7B;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
|
@@ -4,21 +4,15 @@ import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/
|
|
|
4
4
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
5
|
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
6
6
|
import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
7
|
-
import { AccountManager
|
|
8
|
-
import {
|
|
9
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
7
|
+
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
9
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
11
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
11
|
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
12
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
|
+
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
13
14
|
import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
|
|
14
15
|
import { printGasEstimates } from './options/fees.js';
|
|
15
|
-
export const AccountTypes = [
|
|
16
|
-
'schnorr',
|
|
17
|
-
'ecdsasecp256r1',
|
|
18
|
-
'ecdsasecp256r1ssh',
|
|
19
|
-
'ecdsasecp256k1'
|
|
20
|
-
];
|
|
21
|
-
export const BASE_FEE_PADDING = 0.5;
|
|
22
16
|
export class CLIWallet extends BaseWallet {
|
|
23
17
|
userLog;
|
|
24
18
|
db;
|
|
@@ -40,25 +34,26 @@ export class CLIWallet extends BaseWallet {
|
|
|
40
34
|
})));
|
|
41
35
|
}
|
|
42
36
|
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
43
|
-
const
|
|
37
|
+
const executionPayload = ExecutionPayload.empty();
|
|
38
|
+
const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
|
|
44
39
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
45
40
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
41
|
+
const chainInfo = await this.getChainInfo();
|
|
46
42
|
const executionOptions = {
|
|
47
43
|
txNonce,
|
|
48
44
|
cancellable: this.cancellableTransactions,
|
|
49
45
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
50
46
|
};
|
|
51
|
-
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ??
|
|
47
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
52
48
|
}
|
|
53
49
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
54
50
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
55
|
-
return await this.pxe.proveTx(cancellationTxRequest);
|
|
51
|
+
return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
|
|
56
52
|
}
|
|
57
53
|
async getAccountFromAddress(address) {
|
|
58
54
|
let account;
|
|
59
55
|
if (address.equals(AztecAddress.ZERO)) {
|
|
60
|
-
|
|
61
|
-
account = new SignerlessAccount(chainInfo);
|
|
56
|
+
account = new SignerlessAccount();
|
|
62
57
|
} else if (this.accountCache.has(address.toString())) {
|
|
63
58
|
return this.accountCache.get(address.toString());
|
|
64
59
|
} else {
|
|
@@ -123,15 +118,25 @@ export class CLIWallet extends BaseWallet {
|
|
|
123
118
|
}
|
|
124
119
|
return account;
|
|
125
120
|
}
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
123
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
124
|
+
* @param address - The address of the account to impersonate
|
|
125
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
126
|
+
*/ async getFakeAccountDataFor(address) {
|
|
128
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
|
+
}
|
|
129
134
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
130
|
-
const
|
|
135
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
131
136
|
if (!contractInstance) {
|
|
132
137
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
133
138
|
}
|
|
134
|
-
const stubAccount = createStubAccount(originalAddress
|
|
139
|
+
const stubAccount = createStubAccount(originalAddress);
|
|
135
140
|
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
136
141
|
salt: Fr.random()
|
|
137
142
|
});
|
|
@@ -142,8 +147,35 @@ export class CLIWallet extends BaseWallet {
|
|
|
142
147
|
};
|
|
143
148
|
}
|
|
144
149
|
async simulateTx(executionPayload, opts) {
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
const simulationResults = await super.simulateTx(executionPayload, opts);
|
|
151
|
+
if (opts.fee?.estimateGas) {
|
|
152
|
+
const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
153
|
+
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
154
|
+
printGasEstimates(feeOptions, limits, this.userLog);
|
|
155
|
+
}
|
|
156
|
+
return simulationResults;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
160
|
+
* Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
|
|
161
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
162
|
+
const { from, feeOptions, scopes } = opts;
|
|
163
|
+
let overrides;
|
|
164
|
+
let fromAccount;
|
|
165
|
+
if (!from.equals(AztecAddress.ZERO)) {
|
|
166
|
+
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
167
|
+
fromAccount = account;
|
|
168
|
+
overrides = {
|
|
169
|
+
contracts: {
|
|
170
|
+
[from.toString()]: {
|
|
171
|
+
instance,
|
|
172
|
+
artifact
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
} else {
|
|
177
|
+
fromAccount = await this.getAccountFromAddress(from);
|
|
178
|
+
}
|
|
147
179
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
148
180
|
const executionOptions = {
|
|
149
181
|
txNonce: Fr.random(),
|
|
@@ -154,31 +186,15 @@ export class CLIWallet extends BaseWallet {
|
|
|
154
186
|
feeExecutionPayload,
|
|
155
187
|
executionPayload
|
|
156
188
|
]) : executionPayload;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
167
|
-
const contractOverrides = {
|
|
168
|
-
[opts.from.toString()]: {
|
|
169
|
-
instance,
|
|
170
|
-
artifact
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
simulationResults = await this.pxe.simulateTx(txRequest, true, true, true, {
|
|
174
|
-
contracts: contractOverrides
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (opts.fee?.estimateGas) {
|
|
178
|
-
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
179
|
-
printGasEstimates(feeOptions, limits, this.userLog);
|
|
180
|
-
}
|
|
181
|
-
return simulationResults;
|
|
189
|
+
const chainInfo = await this.getChainInfo();
|
|
190
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
191
|
+
return this.pxe.simulateTx(txRequest, {
|
|
192
|
+
simulatePublic: true,
|
|
193
|
+
skipFeeEnforcement: true,
|
|
194
|
+
skipTxValidation: true,
|
|
195
|
+
overrides,
|
|
196
|
+
scopes
|
|
197
|
+
});
|
|
182
198
|
}
|
|
183
199
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
184
200
|
// this is just a CLI wallet.
|
|
@@ -188,6 +204,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
188
204
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
189
205
|
// this is just a CLI wallet.
|
|
190
206
|
getNotes(filter) {
|
|
191
|
-
return this.pxe.getNotes(filter);
|
|
207
|
+
return this.pxe.debug.getNotes(filter);
|
|
208
|
+
}
|
|
209
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
210
|
+
// this is just a CLI wallet.
|
|
211
|
+
getContractArtifact(id) {
|
|
212
|
+
return this.pxe.getContractArtifact(id);
|
|
192
213
|
}
|
|
193
214
|
}
|
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.b6e433891",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"start": "node --no-warnings ./dest/bin",
|
|
21
21
|
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
|
|
22
22
|
"dev": "LOG_LEVEL=debug && node ./dest/bin",
|
|
23
|
-
"build": "yarn clean && tsc
|
|
24
|
-
"build:dev": "tsc
|
|
23
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
24
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
25
25
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
26
26
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
27
27
|
},
|
|
@@ -67,17 +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/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/noir-
|
|
79
|
-
"@aztec/
|
|
80
|
-
"@aztec/
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.b6e433891",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.b6e433891",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.b6e433891",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.b6e433891",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.b6e433891",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.b6e433891",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.b6e433891",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.b6e433891",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.b6e433891",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.b6e433891",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.b6e433891",
|
|
81
|
+
"@aztec/stdlib": "0.0.1-commit.b6e433891",
|
|
82
|
+
"@aztec/wallet-sdk": "0.0.1-commit.b6e433891",
|
|
81
83
|
"commander": "^12.1.0",
|
|
82
84
|
"inquirer": "^10.1.8",
|
|
83
85
|
"source-map-support": "^0.5.21",
|
|
@@ -88,6 +90,7 @@
|
|
|
88
90
|
"@types/jest": "^30.0.0",
|
|
89
91
|
"@types/node": "^22.15.17",
|
|
90
92
|
"@types/source-map-support": "^0.5.10",
|
|
93
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
91
94
|
"jest": "^30.0.0",
|
|
92
95
|
"jest-mock-extended": "^4.0.0",
|
|
93
96
|
"ts-jest": "^29.4.0",
|
package/src/bin/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
4
|
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
4
5
|
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
6
|
+
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
5
7
|
import { LOCALHOST } from '@aztec/cli/cli-utils';
|
|
6
8
|
import { type LogFn, createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
7
9
|
import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
|
|
@@ -9,10 +11,8 @@ import type { PXEConfig } from '@aztec/pxe/config';
|
|
|
9
11
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
12
|
|
|
11
13
|
import { Argument, Command, Option } from 'commander';
|
|
12
|
-
import { mkdirSync } from 'fs';
|
|
13
14
|
import { homedir } from 'os';
|
|
14
|
-
import {
|
|
15
|
-
import { fileURLToPath } from 'url';
|
|
15
|
+
import { join } from 'path';
|
|
16
16
|
|
|
17
17
|
import { injectCommands } from '../cmds/index.js';
|
|
18
18
|
import { Aliases, WalletDB } from '../storage/wallet_db.js';
|
|
@@ -95,22 +95,26 @@ async function main() {
|
|
|
95
95
|
.default(`http://${LOCALHOST}:8080`),
|
|
96
96
|
)
|
|
97
97
|
.hook('preSubcommand', async command => {
|
|
98
|
+
// Skip initialization if user is just requesting help
|
|
99
|
+
if (command.args.includes('--help') || command.args.includes('-h')) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
98
103
|
const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
|
|
99
104
|
|
|
100
105
|
const proverEnabled = prover !== 'none';
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
switch (prover) {
|
|
108
|
+
case 'native':
|
|
109
|
+
await Barretenberg.initSingleton({ backend: BackendType.NativeUnixSocket });
|
|
110
|
+
break;
|
|
111
|
+
case 'wasm':
|
|
112
|
+
await Barretenberg.initSingleton({ backend: BackendType.Wasm });
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
109
115
|
|
|
110
116
|
const overridePXEConfig: Partial<PXEConfig> = {
|
|
111
117
|
proverEnabled,
|
|
112
|
-
bbBinaryPath: prover === 'native' ? bbBinaryPath : undefined,
|
|
113
|
-
bbWorkingDirectory: prover === 'native' ? bbWorkingDirectory : undefined,
|
|
114
118
|
dataDirectory: join(dataDir, 'pxe'),
|
|
115
119
|
};
|
|
116
120
|
|
|
@@ -142,6 +146,8 @@ async function main() {
|
|
|
142
146
|
injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
|
|
143
147
|
injectInternalCommands(program, userLog, db);
|
|
144
148
|
await program.parseAsync(process.argv);
|
|
149
|
+
|
|
150
|
+
await Barretenberg.destroySingleton();
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
main().catch(err => {
|
|
@@ -30,7 +30,7 @@ export async function authorizeAction(
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const contract =
|
|
33
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
34
34
|
const action = contract.methods[functionName](...functionArgs);
|
|
35
35
|
|
|
36
36
|
const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
@@ -39,7 +39,7 @@ export async function authorizeAction(
|
|
|
39
39
|
{ caller, action },
|
|
40
40
|
true,
|
|
41
41
|
);
|
|
42
|
-
const witness = await setAuthwitnessInteraction.send(
|
|
42
|
+
const witness = await setAuthwitnessInteraction.send({ wait: { timeout: DEFAULT_TX_TIMEOUT_S } });
|
|
43
43
|
|
|
44
44
|
log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
45
45
|
|
|
@@ -2,8 +2,9 @@ import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
|
2
2
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
3
|
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
4
4
|
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
5
|
-
import { createEthereumChain
|
|
6
|
-
import {
|
|
5
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
6
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
8
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
10
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -5,8 +5,12 @@ 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 {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
computeSiloedPrivateInitializationNullifier,
|
|
10
|
+
computeSiloedPublicInitializationNullifier,
|
|
11
|
+
siloNullifier,
|
|
12
|
+
} from '@aztec/stdlib/hash';
|
|
13
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
10
14
|
|
|
11
15
|
import type { CLIWallet } from '../utils/wallet.js';
|
|
12
16
|
|
|
@@ -32,7 +36,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
32
36
|
const [receipt, effectsInBlock] = await Promise.all([aztecNode.getTxReceipt(txHash), aztecNode.getTxEffect(txHash)]);
|
|
33
37
|
// Base tx data
|
|
34
38
|
log(`Tx ${txHash.toString()}`);
|
|
35
|
-
log(` Status: ${receipt.status}
|
|
39
|
+
log(` Status: ${receipt.status}`);
|
|
40
|
+
if (receipt.executionResult) {
|
|
41
|
+
log(` Execution result: ${receipt.executionResult}`);
|
|
42
|
+
}
|
|
36
43
|
if (receipt.error) {
|
|
37
44
|
log(` Error: ${receipt.error}`);
|
|
38
45
|
}
|
|
@@ -85,7 +92,7 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
85
92
|
for (const nullifier of effects.nullifiers) {
|
|
86
93
|
const deployed = deployNullifiers[nullifier.toString()];
|
|
87
94
|
const note = deployed
|
|
88
|
-
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed }))[0]
|
|
95
|
+
? (await wallet.getNotes({ siloedNullifier: nullifier, contractAddress: deployed, scopes: 'ALL_SCOPES' }))[0]
|
|
89
96
|
: undefined;
|
|
90
97
|
const initialized = initNullifiers[nullifier.toString()];
|
|
91
98
|
const registered = classNullifiers[nullifier.toString()];
|
|
@@ -121,11 +128,10 @@ async function inspectTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash
|
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
function inspectNote(note:
|
|
131
|
+
function inspectNote(note: NoteDao, artifactMap: ArtifactMap, log: LogFn, text = 'Note') {
|
|
125
132
|
const artifact = artifactMap[note.contractAddress.toString()];
|
|
126
133
|
const contract = artifact?.name ?? note.contractAddress.toString();
|
|
127
134
|
log(` ${text} at ${contract}`);
|
|
128
|
-
log(` Recipient: ${toFriendlyAddress(note.recipient, artifactMap)}`);
|
|
129
135
|
for (const field of note.note.items) {
|
|
130
136
|
log(` ${field.toString()}`);
|
|
131
137
|
}
|
|
@@ -142,22 +148,49 @@ function toFriendlyAddress(address: AztecAddress, artifactMap: ArtifactMap) {
|
|
|
142
148
|
|
|
143
149
|
async function getKnownNullifiers(wallet: CLIWallet, artifactMap: ArtifactMap) {
|
|
144
150
|
const knownContracts = await wallet.getContracts();
|
|
145
|
-
|
|
146
|
-
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
|
+
|
|
147
157
|
const initNullifiers: Record<string, AztecAddress> = {};
|
|
148
158
|
const deployNullifiers: Record<string, AztecAddress> = {};
|
|
149
159
|
const classNullifiers: Record<string, string> = {};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
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;
|
|
153
167
|
}
|
|
154
|
-
for (const
|
|
155
|
-
classNullifiers[
|
|
156
|
-
`${artifact.name}Class<${artifact.classId}>`;
|
|
168
|
+
for (const { nullifier, label } of classResults) {
|
|
169
|
+
classNullifiers[nullifier.toString()] = label;
|
|
157
170
|
}
|
|
171
|
+
|
|
158
172
|
return { initNullifiers, deployNullifiers, classNullifiers };
|
|
159
173
|
}
|
|
160
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
|
+
|
|
161
194
|
type ArtifactMap = Record<string, ContractArtifactWithClassId>;
|
|
162
195
|
type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
|
|
163
196
|
|
|
@@ -165,15 +198,11 @@ async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
|
|
|
165
198
|
const knownContractAddresses = await wallet.getContracts();
|
|
166
199
|
const knownContracts = (
|
|
167
200
|
await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
|
|
168
|
-
).map(contractMetadata => contractMetadata.
|
|
201
|
+
).map(contractMetadata => contractMetadata.instance);
|
|
169
202
|
const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
|
|
170
203
|
const knownArtifacts = (
|
|
171
|
-
await Promise.all(classIds.map(classId => (classId ? wallet.
|
|
172
|
-
).map(
|
|
173
|
-
contractClassMetadata
|
|
174
|
-
? { ...contractClassMetadata.artifact, classId: contractClassMetadata.contractClass?.id }
|
|
175
|
-
: undefined,
|
|
176
|
-
);
|
|
204
|
+
await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
|
|
205
|
+
).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
|
|
177
206
|
const map: Record<string, ContractArtifactWithClassId> = {};
|
|
178
207
|
for (const instance of knownContracts) {
|
|
179
208
|
if (instance) {
|