@aztec/cli-wallet 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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/authorize_action.js +4 -2
- 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 +57 -25
- package/dest/cmds/create_account.d.ts +9 -5
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +65 -32
- package/dest/cmds/create_authwit.d.ts +2 -2
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/deploy.d.ts +5 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +65 -36
- 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 +39 -25
- 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 +37 -20
- package/dest/cmds/send.d.ts +5 -4
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +33 -20
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +4 -3
- package/dest/storage/wallet_db.d.ts +14 -6
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +75 -32
- package/dest/utils/constants.d.ts +4 -0
- package/dest/utils/constants.d.ts.map +1 -0
- package/dest/utils/constants.js +8 -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 +38 -12
- 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 +6 -6
- 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 +40 -12
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +194 -104
- package/package.json +17 -16
- package/src/bin/index.ts +1 -1
- package/src/cmds/authorize_action.ts +1 -1
- package/src/cmds/bridge_fee_juice.ts +3 -2
- package/src/cmds/check_tx.ts +63 -31
- package/src/cmds/create_account.ts +70 -37
- package/src/cmds/deploy.ts +64 -37
- package/src/cmds/deploy_account.ts +40 -21
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +12 -1
- package/src/cmds/index.ts +73 -17
- package/src/cmds/send.ts +33 -13
- package/src/cmds/simulate.ts +5 -7
- package/src/storage/wallet_db.ts +88 -39
- package/src/utils/constants.ts +10 -0
- package/src/utils/options/fees.ts +44 -12
- package/src/utils/options/options.ts +6 -6
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +241 -130
|
@@ -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,36 +1,64 @@
|
|
|
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 { AccountManager, type Aliased
|
|
5
|
-
import {
|
|
4
|
+
import { AccountManager, type Aliased } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
6
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
6
8
|
import type { LogFn } from '@aztec/foundation/log';
|
|
9
|
+
import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
7
10
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
8
11
|
import type { PXE } from '@aztec/pxe/server';
|
|
9
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
+
import type { Gas, GasUsed } from '@aztec/stdlib/gas';
|
|
10
14
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
11
|
-
import type {
|
|
12
|
-
import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
15
|
+
import type { TxProvingResult } from '@aztec/stdlib/tx';
|
|
13
16
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
14
|
-
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
17
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
15
18
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
16
|
-
|
|
17
|
-
export type AccountType = (typeof AccountTypes)[number];
|
|
18
|
-
export declare const BASE_FEE_PADDING = 0.5;
|
|
19
|
+
import type { AccountType } from './constants.js';
|
|
19
20
|
export declare class CLIWallet extends BaseWallet {
|
|
20
21
|
private userLog;
|
|
21
22
|
private db?;
|
|
22
23
|
private accountCache;
|
|
24
|
+
private stubClassIds;
|
|
23
25
|
constructor(pxe: PXE, node: AztecNode, userLog: LogFn, db?: WalletDB | undefined);
|
|
24
26
|
static create(node: AztecNode, log: LogFn, db?: WalletDB, overridePXEConfig?: Partial<PXEConfig>): Promise<CLIWallet>;
|
|
27
|
+
private registerAuthRegistry;
|
|
28
|
+
private initStubClasses;
|
|
25
29
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Derives suggested total and teardown gas limits from simulated gas usage, padded and clamped to the
|
|
32
|
+
* network's per-tx admission limits.
|
|
33
|
+
* @param gasUsed - The gas consumed during simulation (from a `simulate({ includeMetadata: true })` result).
|
|
34
|
+
*/
|
|
35
|
+
estimateGasLimits(gasUsed: GasUsed): Promise<{
|
|
36
|
+
gasLimits: Gas;
|
|
37
|
+
teardownGasLimits: Gas;
|
|
38
|
+
}>;
|
|
26
39
|
private createCancellationTxExecutionRequest;
|
|
27
40
|
proveCancellationTx(from: AztecAddress, txNonce: Fr, increasedFee: InteractionFeeOptions): Promise<TxProvingResult>;
|
|
28
41
|
getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Creates an account from freshly supplied keys. SSH accounts sign with a key held in the agent (resolved from
|
|
44
|
+
* `publicKey`), every other type is rooted on `signingKey`, with `secretKey` as its privacy secret.
|
|
45
|
+
*/
|
|
46
|
+
createAccount(type: AccountType, signingKey: GrumpkinScalar | undefined, secretKey: Fr | undefined, salt?: Fr, publicKey?: string): Promise<AccountManager>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves a previously stored account by address, loading its keys, type and salt from the wallet database.
|
|
49
|
+
*/
|
|
50
|
+
retrieveAccount(address: AztecAddress): Promise<AccountManager>;
|
|
51
|
+
private buildAccount;
|
|
52
|
+
private resolveSshPublicSigningKey;
|
|
53
|
+
private materializeAccount;
|
|
31
54
|
private getFakeAccountDataFor;
|
|
32
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
57
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
58
|
+
*/
|
|
59
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
33
60
|
getContracts(): Promise<AztecAddress[]>;
|
|
34
61
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
62
|
+
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
35
63
|
}
|
|
36
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBaUMsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RixPQUFPLEVBRUwsS0FBSyxxQkFBcUIsRUFFM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDdEUsT0FBTyxFQUFFLCtCQUErQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHekUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssRUFBRSxHQUFHLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUc3QyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFL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UUFBUSxDQUFDLE1BQU0sRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDLENBRWhEO0lBSUQsbUJBQW1CLENBQUMsRUFBRSxFQUFFLEVBQUUscUVBRXpCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAA2C,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,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GAAE,EAAY,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAIzB;IAED;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAcpE;YAEa,YAAY;YAqCZ,0BAA0B;YAc1B,kBAAkB;YA+BlB,qBAAqB;IAsBnC;;;OAGG;IACH,UAAyB,qBAAqB,CAC5C,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,+BAA+B,CAAC,CA2C1C;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
|
@@ -1,70 +1,109 @@
|
|
|
1
|
-
import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { EcdsaKAccountContract, EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
+
import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/ecdsa/stub';
|
|
3
|
+
import { SchnorrAccountContract, SchnorrInitializerlessAccountContract } from '@aztec/accounts/schnorr';
|
|
4
|
+
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/schnorr/stub';
|
|
4
5
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
7
|
+
import { ContractFunctionInteraction, getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
|
|
7
8
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
8
|
-
import {
|
|
9
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
10
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
11
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
12
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
13
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
10
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
12
15
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
|
-
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
16
|
+
import { BaseWallet, getGasLimits } from '@aztec/wallet-sdk/base-wallet';
|
|
14
17
|
import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
|
|
15
|
-
|
|
16
|
-
export const AccountTypes = [
|
|
17
|
-
'schnorr',
|
|
18
|
-
'ecdsasecp256r1',
|
|
19
|
-
'ecdsasecp256r1ssh',
|
|
20
|
-
'ecdsasecp256k1'
|
|
21
|
-
];
|
|
22
|
-
export const BASE_FEE_PADDING = 0.5;
|
|
18
|
+
/** Padding the CLI wallet applies to simulated gas usage when deriving declared gas limits. */ const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
23
19
|
export class CLIWallet extends BaseWallet {
|
|
24
20
|
userLog;
|
|
25
21
|
db;
|
|
26
22
|
accountCache;
|
|
23
|
+
// Stub class ids, populated on wallet startup
|
|
24
|
+
// to avoid redundant work per simulation
|
|
25
|
+
stubClassIds;
|
|
27
26
|
constructor(pxe, node, userLog, db){
|
|
28
|
-
super(pxe, node), this.userLog = userLog, this.db = db, this.accountCache = new Map();
|
|
27
|
+
super(pxe, node), this.userLog = userLog, this.db = db, this.accountCache = new Map(), this.stubClassIds = new Map();
|
|
29
28
|
this.cancellableTransactions = true;
|
|
30
29
|
}
|
|
31
30
|
static async create(node, log, db, overridePXEConfig) {
|
|
32
31
|
const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig);
|
|
33
32
|
const pxe = await createPXE(node, pxeConfig);
|
|
34
|
-
|
|
33
|
+
const wallet = new CLIWallet(pxe, node, log, db);
|
|
34
|
+
await wallet.initStubClasses();
|
|
35
|
+
await wallet.registerAuthRegistry();
|
|
36
|
+
return wallet;
|
|
37
|
+
}
|
|
38
|
+
async registerAuthRegistry() {
|
|
39
|
+
const { instance, artifact } = await getStandardAuthRegistry();
|
|
40
|
+
await this.pxe.registerContractClass(artifact);
|
|
41
|
+
await this.pxe.registerContract(instance);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hashes and registers the stub class for every supported account type with PXE, populating
|
|
45
|
+
* stubClassIds. Called on wallet initialization.
|
|
46
|
+
*/ async initStubClasses() {
|
|
47
|
+
const { id: schnorrClassId } = await getContractClassFromArtifact(StubSchnorrAccountContractArtifact);
|
|
48
|
+
await this.pxe.registerContractClass(StubSchnorrAccountContractArtifact);
|
|
49
|
+
// ecdsa stubs share the same class id
|
|
50
|
+
const { id: ecdsaClassId } = await getContractClassFromArtifact(StubEcdsaAccountContractArtifact);
|
|
51
|
+
await this.pxe.registerContractClass(StubEcdsaAccountContractArtifact);
|
|
52
|
+
this.stubClassIds.set('schnorr', schnorrClassId);
|
|
53
|
+
this.stubClassIds.set('schnorr_initializerless', schnorrClassId);
|
|
54
|
+
this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
|
|
55
|
+
this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
|
|
56
|
+
this.stubClassIds.set('ecdsasecp256r1ssh', ecdsaClassId);
|
|
35
57
|
}
|
|
36
58
|
async getAccounts() {
|
|
37
59
|
const accounts = await this.db?.listAliases('accounts') ?? [];
|
|
38
|
-
return Promise.resolve(accounts.map(({ key, value })=>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
return Promise.resolve(accounts.map(({ key, value })=>{
|
|
61
|
+
const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key;
|
|
62
|
+
return {
|
|
63
|
+
alias,
|
|
64
|
+
item: AztecAddress.fromStringUnsafe(value)
|
|
65
|
+
};
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Derives suggested total and teardown gas limits from simulated gas usage, padded and clamped to the
|
|
70
|
+
* network's per-tx admission limits.
|
|
71
|
+
* @param gasUsed - The gas consumed during simulation (from a `simulate({ includeMetadata: true })` result).
|
|
72
|
+
*/ async estimateGasLimits(gasUsed) {
|
|
73
|
+
const maxTxGasLimits = await this.getMaxTxGasLimits();
|
|
74
|
+
return getGasLimits(gasUsed, maxTxGasLimits, DEFAULT_ESTIMATED_GAS_PADDING);
|
|
42
75
|
}
|
|
43
76
|
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
44
77
|
const executionPayload = ExecutionPayload.empty();
|
|
45
|
-
const feeOptions = await this.completeFeeOptions(
|
|
78
|
+
const feeOptions = await this.completeFeeOptions({
|
|
79
|
+
from,
|
|
80
|
+
feePayer: executionPayload.feePayer,
|
|
81
|
+
gasSettings: increasedFee.gasSettings
|
|
82
|
+
});
|
|
46
83
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
47
84
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
85
|
+
const chainInfo = await this.getChainInfo();
|
|
48
86
|
const executionOptions = {
|
|
49
87
|
txNonce,
|
|
50
88
|
cancellable: this.cancellableTransactions,
|
|
89
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
51
90
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
52
91
|
};
|
|
53
|
-
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, executionOptions);
|
|
92
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
54
93
|
}
|
|
55
94
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
56
95
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
57
|
-
return await this.pxe.proveTx(cancellationTxRequest
|
|
96
|
+
return await this.pxe.proveTx(cancellationTxRequest, {
|
|
97
|
+
scopes: this.scopesFrom(from, [], undefined),
|
|
98
|
+
senderForTags: from
|
|
99
|
+
});
|
|
58
100
|
}
|
|
59
101
|
async getAccountFromAddress(address) {
|
|
60
102
|
let account;
|
|
61
|
-
if (address.
|
|
62
|
-
const chainInfo = await this.getChainInfo();
|
|
63
|
-
account = new SignerlessAccount(chainInfo);
|
|
64
|
-
} else if (this.accountCache.has(address.toString())) {
|
|
103
|
+
if (this.accountCache.has(address.toString())) {
|
|
65
104
|
return this.accountCache.get(address.toString());
|
|
66
105
|
} else {
|
|
67
|
-
const accountManager = await this.
|
|
106
|
+
const accountManager = await this.retrieveAccount(address);
|
|
68
107
|
account = await accountManager.getAccount();
|
|
69
108
|
}
|
|
70
109
|
if (!account) {
|
|
@@ -72,115 +111,161 @@ export class CLIWallet extends BaseWallet {
|
|
|
72
111
|
}
|
|
73
112
|
return account;
|
|
74
113
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await this.
|
|
80
|
-
this.
|
|
81
|
-
return accountManager;
|
|
114
|
+
/**
|
|
115
|
+
* Creates an account from freshly supplied keys. SSH accounts sign with a key held in the agent (resolved from
|
|
116
|
+
* `publicKey`), every other type is rooted on `signingKey`, with `secretKey` as its privacy secret.
|
|
117
|
+
*/ async createAccount(type, signingKey, secretKey, salt = Fr.ZERO, publicKey) {
|
|
118
|
+
const publicSigningKey = type === 'ecdsasecp256r1ssh' ? await this.resolveSshPublicSigningKey(publicKey) : undefined;
|
|
119
|
+
return this.buildAccount(type, salt, signingKey, secretKey, publicSigningKey);
|
|
82
120
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (this.db
|
|
87
|
-
(
|
|
121
|
+
/**
|
|
122
|
+
* Retrieves a previously stored account by address, loading its keys, type and salt from the wallet database.
|
|
123
|
+
*/ async retrieveAccount(address) {
|
|
124
|
+
if (!this.db) {
|
|
125
|
+
throw new Error('Cannot retrieve an account without a wallet database');
|
|
88
126
|
}
|
|
89
|
-
|
|
90
|
-
|
|
127
|
+
const { type, signingKey, secretKey, salt } = await this.db.retrieveAccount(address);
|
|
128
|
+
if (type !== 'ecdsasecp256r1ssh' && !signingKey) {
|
|
129
|
+
throw new Error(`Account ${address} has no stored signing key: it was created with an older version of aztec-wallet and is ` + `incompatible with this one. Create a new account to continue.`);
|
|
91
130
|
}
|
|
131
|
+
const publicSigningKey = type === 'ecdsasecp256r1ssh' ? await this.db.retrieveAccountMetadata(address, 'publicSigningKey') : undefined;
|
|
132
|
+
return this.buildAccount(type, salt, signingKey, secretKey, publicSigningKey);
|
|
133
|
+
}
|
|
134
|
+
async buildAccount(type, salt, signingKey, secretKey, publicSigningKey) {
|
|
92
135
|
switch(type){
|
|
93
136
|
case 'schnorr':
|
|
94
|
-
|
|
95
|
-
account = await this.createAccount(secretKey, salt, new SchnorrAccountContract(deriveSigningKey(secretKey)));
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
137
|
+
case 'schnorr_initializerless':
|
|
98
138
|
case 'ecdsasecp256r1':
|
|
139
|
+
case 'ecdsasecp256k1':
|
|
99
140
|
{
|
|
100
|
-
|
|
101
|
-
|
|
141
|
+
if (!signingKey || !secretKey) {
|
|
142
|
+
throw new Error('Cannot build account without signing key and secret key');
|
|
143
|
+
}
|
|
144
|
+
const contract = type === 'schnorr' ? new SchnorrAccountContract(signingKey) : type === 'schnorr_initializerless' ? new SchnorrInitializerlessAccountContract(signingKey) : type === 'ecdsasecp256r1' ? new EcdsaRAccountContract(signingKey.toBuffer()) : new EcdsaKAccountContract(signingKey.toBuffer());
|
|
145
|
+
return await this.materializeAccount(secretKey, salt, contract);
|
|
102
146
|
}
|
|
103
147
|
case 'ecdsasecp256r1ssh':
|
|
104
148
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
publicSigningKey = await this.db.retrieveAccountMetadata(address, 'publicSigningKey');
|
|
108
|
-
} else if (publicKey) {
|
|
109
|
-
const identities = await getIdentities();
|
|
110
|
-
const foundIdentity = identities.find((identity)=>identity.type === 'ecdsa-sha2-nistp256' && identity.publicKey === publicKey);
|
|
111
|
-
if (!foundIdentity) {
|
|
112
|
-
throw new Error(`Identity for public key ${publicKey} not found in the SSH agent`);
|
|
113
|
-
}
|
|
114
|
-
publicSigningKey = extractECDSAPublicKeyFromBase64String(foundIdentity.publicKey);
|
|
115
|
-
} else {
|
|
116
|
-
throw new Error('Public key must be provided for ECDSA SSH account');
|
|
149
|
+
if (!secretKey || !publicSigningKey) {
|
|
150
|
+
throw new Error('Cannot build SSH account without secret key and public signing key');
|
|
117
151
|
}
|
|
118
|
-
|
|
119
|
-
break;
|
|
152
|
+
return await this.materializeAccount(secretKey, salt, new EcdsaRSSHAccountContract(publicSigningKey));
|
|
120
153
|
}
|
|
121
154
|
default:
|
|
122
155
|
{
|
|
123
156
|
throw new Error(`Unsupported account type: ${type}`);
|
|
124
157
|
}
|
|
125
158
|
}
|
|
126
|
-
return account;
|
|
127
159
|
}
|
|
128
|
-
async
|
|
129
|
-
|
|
160
|
+
async resolveSshPublicSigningKey(publicKey) {
|
|
161
|
+
if (!publicKey) {
|
|
162
|
+
throw new Error('Public key must be provided for ECDSA SSH account');
|
|
163
|
+
}
|
|
164
|
+
const identities = await getIdentities();
|
|
165
|
+
const foundIdentity = identities.find((identity)=>identity.type === 'ecdsa-sha2-nistp256' && identity.publicKey === publicKey);
|
|
166
|
+
if (!foundIdentity) {
|
|
167
|
+
throw new Error(`Identity for public key ${publicKey} not found in the SSH agent`);
|
|
168
|
+
}
|
|
169
|
+
return extractECDSAPublicKeyFromBase64String(foundIdentity.publicKey);
|
|
170
|
+
}
|
|
171
|
+
async materializeAccount(secret, salt, contract) {
|
|
172
|
+
const accountManager = await AccountManager.create(this, secret, contract, {
|
|
173
|
+
salt
|
|
174
|
+
});
|
|
175
|
+
const instance = accountManager.getInstance();
|
|
176
|
+
const artifact = await contract.getContractArtifact();
|
|
177
|
+
await this.registerContract(instance, artifact, secret);
|
|
178
|
+
this.accountCache.set(accountManager.address.toString(), await accountManager.getAccount());
|
|
179
|
+
// Initializerless accounts have no deployment tx; their address commits to the signing public key
|
|
180
|
+
// (via the contract's immutablesHash, resolved by AccountManager.create) and the constructor's
|
|
181
|
+
// storage writes are materialized locally via a simulated "store" call here.
|
|
182
|
+
if (contract instanceof SchnorrInitializerlessAccountContract) {
|
|
183
|
+
const constructorAbi = artifact.functions.find((f)=>f.name === 'constructor');
|
|
184
|
+
if (!constructorAbi) {
|
|
185
|
+
throw new Error('Could not create SchnorrInitializerlessAccount: constructor ABI not found');
|
|
186
|
+
}
|
|
187
|
+
const { x, y } = await contract.getSigningPublicKey();
|
|
188
|
+
const storeCall = new ContractFunctionInteraction(this, instance.address, constructorAbi, [
|
|
189
|
+
x,
|
|
190
|
+
y
|
|
191
|
+
]);
|
|
192
|
+
await storeCall.simulate({
|
|
193
|
+
from: instance.address
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return accountManager;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
200
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
201
|
+
* @param address - The address of the account to impersonate
|
|
202
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
203
|
+
*/ async getFakeAccountDataFor(address) {
|
|
130
204
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
131
205
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
132
|
-
const
|
|
206
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
133
207
|
if (!contractInstance) {
|
|
134
208
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
135
209
|
}
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
210
|
+
const { type } = await this.db.retrieveAccount(address);
|
|
211
|
+
const stubAccount = type === 'schnorr' || type === 'schnorr_initializerless' ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
|
|
212
|
+
const stubClassId = this.stubClassIds.get(type);
|
|
213
|
+
if (!stubClassId) {
|
|
214
|
+
throw new Error(`Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`);
|
|
215
|
+
}
|
|
216
|
+
const instance = {
|
|
217
|
+
...contractInstance,
|
|
218
|
+
currentContractClassId: stubClassId
|
|
219
|
+
};
|
|
140
220
|
return {
|
|
141
221
|
account: stubAccount,
|
|
142
|
-
instance
|
|
143
|
-
artifact: StubAccountContractArtifact
|
|
222
|
+
instance
|
|
144
223
|
};
|
|
145
224
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
227
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
228
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
229
|
+
const { from, feeOptions, additionalScopes, sendMessagesAs } = opts;
|
|
230
|
+
const scopes = this.scopesFrom(from, additionalScopes ?? [], sendMessagesAs);
|
|
149
231
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
150
|
-
const executionOptions = {
|
|
151
|
-
txNonce: Fr.random(),
|
|
152
|
-
cancellable: this.cancellableTransactions,
|
|
153
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
154
|
-
};
|
|
155
232
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
156
233
|
feeExecutionPayload,
|
|
157
234
|
executionPayload
|
|
158
235
|
]) : executionPayload;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
|
|
236
|
+
const chainInfo = await this.getChainInfo();
|
|
237
|
+
let overrides;
|
|
238
|
+
let txRequest;
|
|
239
|
+
if (from === NO_FROM) {
|
|
240
|
+
const entrypoint = new DefaultEntrypoint();
|
|
241
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
166
242
|
} else {
|
|
167
|
-
const { account
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
243
|
+
const { account, instance } = await this.getFakeAccountDataFor(from);
|
|
244
|
+
overrides = {
|
|
245
|
+
contracts: {
|
|
246
|
+
[from.toString()]: {
|
|
247
|
+
instance
|
|
248
|
+
}
|
|
173
249
|
}
|
|
174
250
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
251
|
+
const executionOptions = {
|
|
252
|
+
txNonce: Fr.random(),
|
|
253
|
+
cancellable: this.cancellableTransactions,
|
|
254
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
255
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
256
|
+
};
|
|
257
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
182
258
|
}
|
|
183
|
-
|
|
259
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
260
|
+
simulatePublic: true,
|
|
261
|
+
skipFeeEnforcement: true,
|
|
262
|
+
skipTxValidation: true,
|
|
263
|
+
overrides,
|
|
264
|
+
scopes,
|
|
265
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs)
|
|
266
|
+
});
|
|
267
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
268
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
184
269
|
}
|
|
185
270
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
186
271
|
// this is just a CLI wallet.
|
|
@@ -190,6 +275,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
190
275
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
191
276
|
// this is just a CLI wallet.
|
|
192
277
|
getNotes(filter) {
|
|
193
|
-
return this.pxe.getNotes(filter);
|
|
278
|
+
return this.pxe.debug.getNotes(filter);
|
|
279
|
+
}
|
|
280
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
281
|
+
// this is just a CLI wallet.
|
|
282
|
+
getContractArtifact(id) {
|
|
283
|
+
return this.pxe.getContractArtifact(id);
|
|
194
284
|
}
|
|
195
285
|
}
|
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.d58ff9d0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/cmds/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"start": "node --no-warnings ./dest/bin",
|
|
21
21
|
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
|
|
22
|
-
"dev": "LOG_LEVEL
|
|
22
|
+
"dev": "LOG_LEVEL=\"debug; info: json-rpc, simulator\" node ./dest/bin",
|
|
23
23
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
24
24
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
25
25
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
@@ -67,19 +67,20 @@
|
|
|
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/
|
|
82
|
-
"@aztec/
|
|
70
|
+
"@aztec/accounts": "0.0.1-commit.d58ff9d0",
|
|
71
|
+
"@aztec/aztec.js": "0.0.1-commit.d58ff9d0",
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.d58ff9d0",
|
|
73
|
+
"@aztec/cli": "0.0.1-commit.d58ff9d0",
|
|
74
|
+
"@aztec/entrypoints": "0.0.1-commit.d58ff9d0",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.d58ff9d0",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.d58ff9d0",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.d58ff9d0",
|
|
78
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d58ff9d0",
|
|
79
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.d58ff9d0",
|
|
80
|
+
"@aztec/pxe": "0.0.1-commit.d58ff9d0",
|
|
81
|
+
"@aztec/standard-contracts": "0.0.1-commit.d58ff9d0",
|
|
82
|
+
"@aztec/stdlib": "0.0.1-commit.d58ff9d0",
|
|
83
|
+
"@aztec/wallet-sdk": "0.0.1-commit.d58ff9d0",
|
|
83
84
|
"commander": "^12.1.0",
|
|
84
85
|
"inquirer": "^10.1.8",
|
|
85
86
|
"source-map-support": "^0.5.21",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"@types/jest": "^30.0.0",
|
|
91
92
|
"@types/node": "^22.15.17",
|
|
92
93
|
"@types/source-map-support": "^0.5.10",
|
|
93
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
94
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
94
95
|
"jest": "^30.0.0",
|
|
95
96
|
"jest-mock-extended": "^4.0.0",
|
|
96
97
|
"ts-jest": "^29.4.0",
|
package/src/bin/index.ts
CHANGED
|
@@ -73,7 +73,7 @@ function injectInternalCommands(program: Command, log: LogFn, db: WalletDB) {
|
|
|
73
73
|
|
|
74
74
|
/** CLI wallet main entrypoint */
|
|
75
75
|
async function main() {
|
|
76
|
-
const walletVersion = getPackageVersion()
|
|
76
|
+
const walletVersion = getPackageVersion();
|
|
77
77
|
|
|
78
78
|
const db = WalletDB.getInstance();
|
|
79
79
|
const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
|
|
@@ -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';
|