@aztec/cli-wallet 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +30 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +38 -23
- package/dest/cmds/authorize_action.d.ts +4 -3
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +6 -7
- package/dest/cmds/bridge_fee_juice.d.ts +4 -4
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +9 -7
- package/dest/cmds/check_tx.d.ts +5 -3
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +144 -6
- package/dest/cmds/create_account.d.ts +7 -6
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +36 -48
- package/dest/cmds/create_authwit.d.ts +4 -3
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/create_authwit.js +6 -6
- package/dest/cmds/deploy.d.ts +7 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +57 -46
- package/dest/cmds/deploy_account.d.ts +6 -8
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +36 -51
- package/dest/cmds/import_test_accounts.d.ts +3 -3
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +6 -9
- package/dest/cmds/index.d.ts +3 -3
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +73 -112
- package/dest/cmds/profile.d.ts +7 -4
- package/dest/cmds/profile.d.ts.map +1 -1
- package/dest/cmds/profile.js +9 -4
- package/dest/cmds/register_contract.d.ts +7 -3
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +5 -6
- package/dest/cmds/register_sender.d.ts +4 -3
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +8 -9
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +27 -24
- package/dest/cmds/simulate.d.ts +7 -4
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +9 -4
- package/dest/storage/wallet_db.d.ts +6 -16
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +2 -23
- package/dest/utils/authorizations.d.ts +3 -2
- package/dest/utils/authorizations.d.ts.map +1 -1
- package/dest/utils/authorizations.js +1 -1
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
- package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
- package/dest/utils/ecdsa.d.ts +1 -1
- package/dest/utils/options/fees.d.ts +22 -28
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +66 -133
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +4 -3
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/wallet.d.ts +36 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +195 -0
- package/package.json +17 -14
- package/src/bin/index.ts +38 -31
- package/src/cmds/authorize_action.ts +14 -6
- package/src/cmds/bridge_fee_juice.ts +15 -11
- package/src/cmds/check_tx.ts +181 -5
- package/src/cmds/create_account.ts +43 -53
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +58 -56
- package/src/cmds/deploy_account.ts +43 -51
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +120 -206
- package/src/cmds/profile.ts +14 -6
- package/src/cmds/register_contract.ts +9 -11
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +22 -32
- package/src/cmds/simulate.ts +14 -6
- package/src/storage/wallet_db.ts +3 -31
- package/src/utils/authorizations.ts +3 -1
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/options/fees.ts +88 -178
- package/src/utils/options/options.ts +3 -2
- package/src/utils/wallet.ts +266 -0
- package/dest/cmds/cancel_tx.d.ts +0 -11
- package/dest/cmds/cancel_tx.d.ts.map +0 -1
- package/dest/cmds/cancel_tx.js +0 -43
- package/dest/utils/accounts.d.ts +0 -9
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -61
- package/dest/utils/pxe_wrapper.d.ts +0 -12
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -26
- package/src/cmds/cancel_tx.ts +0 -66
- package/src/utils/accounts.ts +0 -77
- package/src/utils/pxe_wrapper.ts +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/utils/options/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/utils/options/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAKtE,eAAO,MAAM,oBAAoB,wKACsI,CAAC;AAExK,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,GAAG,SAA0B,EAC7B,GAAG,SAA0B,UAU9B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAQzE;A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Address, 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 '../wallet.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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvcHJvZmlsaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFrQixlQUFlLEVBQXFCLE1BQU0sa0JBQWtCLENBQUM7QUFVekcsd0JBQWdCLGtCQUFrQixDQUNoQyxLQUFLLEVBQUUsWUFBWSxHQUFHLGVBQWUsRUFDckMsR0FBRyxFQUFFLEtBQUssRUFDVixZQUFZLEdBQUUsT0FBZSxFQUM3QixjQUFjLENBQUMsRUFBRSxvQkFBb0IsRUFBRSxRQTZJeEMifQ==
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Account } from '@aztec/aztec.js/account';
|
|
2
|
+
import { type InteractionFeeOptions } from '@aztec/aztec.js/contracts';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
4
|
+
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
7
|
+
import type { PXEConfig } from '@aztec/pxe/config';
|
|
8
|
+
import type { PXE } from '@aztec/pxe/server';
|
|
9
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
11
|
+
import type { NotesFilter } from '@aztec/stdlib/note';
|
|
12
|
+
import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
13
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
14
|
+
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
15
|
+
import type { WalletDB } from '../storage/wallet_db.js';
|
|
16
|
+
export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
17
|
+
export type AccountType = (typeof AccountTypes)[number];
|
|
18
|
+
export declare const MIN_FEE_PADDING = 0.5;
|
|
19
|
+
export declare class CLIWallet extends BaseWallet {
|
|
20
|
+
private userLog;
|
|
21
|
+
private db?;
|
|
22
|
+
private accountCache;
|
|
23
|
+
constructor(pxe: PXE, node: AztecNode, userLog: LogFn, db?: WalletDB | undefined);
|
|
24
|
+
static create(node: AztecNode, log: LogFn, db?: WalletDB, overridePXEConfig?: Partial<PXEConfig>): Promise<CLIWallet>;
|
|
25
|
+
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
26
|
+
private createCancellationTxExecutionRequest;
|
|
27
|
+
proveCancellationTx(from: AztecAddress, txNonce: Fr, increasedFee: InteractionFeeOptions): Promise<TxProvingResult>;
|
|
28
|
+
getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
29
|
+
private createAccount;
|
|
30
|
+
createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
|
|
31
|
+
private getFakeAccountDataFor;
|
|
32
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
33
|
+
getContracts(): Promise<AztecAddress[]>;
|
|
34
|
+
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBMkMsTUFBTSx5QkFBeUIsQ0FBQztBQUNoRyxPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFHM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFNUYsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25EL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GAAG,EACR,IAAI,EAAE,SAAS,EACP,OAAO,EAAE,KAAK,EACd,EAAE,CAAC,sBAAU,EAItB;IAED,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;IAqB5C,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,oBAgBzD;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;YAEa,qBAAqB;IAmBpB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmDhH;IAID,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAEtC;IAID,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;CACF"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
+
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
+
import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
|
|
4
|
+
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
|
+
import { SignerlessAccount } from '@aztec/aztec.js/account';
|
|
6
|
+
import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
7
|
+
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
|
+
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
10
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
12
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
13
|
+
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
14
|
+
import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
|
|
15
|
+
import { printGasEstimates } from './options/fees.js';
|
|
16
|
+
export const AccountTypes = [
|
|
17
|
+
'schnorr',
|
|
18
|
+
'ecdsasecp256r1',
|
|
19
|
+
'ecdsasecp256r1ssh',
|
|
20
|
+
'ecdsasecp256k1'
|
|
21
|
+
];
|
|
22
|
+
export const MIN_FEE_PADDING = 0.5;
|
|
23
|
+
export class CLIWallet extends BaseWallet {
|
|
24
|
+
userLog;
|
|
25
|
+
db;
|
|
26
|
+
accountCache;
|
|
27
|
+
constructor(pxe, node, userLog, db){
|
|
28
|
+
super(pxe, node), this.userLog = userLog, this.db = db, this.accountCache = new Map();
|
|
29
|
+
this.cancellableTransactions = true;
|
|
30
|
+
}
|
|
31
|
+
static async create(node, log, db, overridePXEConfig) {
|
|
32
|
+
const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig);
|
|
33
|
+
const pxe = await createPXE(node, pxeConfig);
|
|
34
|
+
return new CLIWallet(pxe, node, log, db);
|
|
35
|
+
}
|
|
36
|
+
async getAccounts() {
|
|
37
|
+
const accounts = await this.db?.listAliases('accounts') ?? [];
|
|
38
|
+
return Promise.resolve(accounts.map(({ key, value })=>({
|
|
39
|
+
alias: value,
|
|
40
|
+
item: AztecAddress.fromString(key)
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
44
|
+
const executionPayload = ExecutionPayload.empty();
|
|
45
|
+
const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
|
|
46
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
47
|
+
const fromAccount = await this.getAccountFromAddress(from);
|
|
48
|
+
const executionOptions = {
|
|
49
|
+
txNonce,
|
|
50
|
+
cancellable: this.cancellableTransactions,
|
|
51
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
52
|
+
};
|
|
53
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, executionOptions);
|
|
54
|
+
}
|
|
55
|
+
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
56
|
+
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
57
|
+
return await this.pxe.proveTx(cancellationTxRequest);
|
|
58
|
+
}
|
|
59
|
+
async getAccountFromAddress(address) {
|
|
60
|
+
let account;
|
|
61
|
+
if (address.equals(AztecAddress.ZERO)) {
|
|
62
|
+
const chainInfo = await this.getChainInfo();
|
|
63
|
+
account = new SignerlessAccount(chainInfo);
|
|
64
|
+
} else if (this.accountCache.has(address.toString())) {
|
|
65
|
+
return this.accountCache.get(address.toString());
|
|
66
|
+
} else {
|
|
67
|
+
const accountManager = await this.createOrRetrieveAccount(address);
|
|
68
|
+
account = await accountManager.getAccount();
|
|
69
|
+
}
|
|
70
|
+
if (!account) {
|
|
71
|
+
throw new Error(`Account not found in wallet for address: ${address}`);
|
|
72
|
+
}
|
|
73
|
+
return account;
|
|
74
|
+
}
|
|
75
|
+
async createAccount(secret, salt, contract) {
|
|
76
|
+
const accountManager = await AccountManager.create(this, secret, contract, salt);
|
|
77
|
+
const instance = accountManager.getInstance();
|
|
78
|
+
const artifact = await contract.getContractArtifact();
|
|
79
|
+
await this.registerContract(instance, artifact, secret);
|
|
80
|
+
this.accountCache.set(accountManager.address.toString(), await accountManager.getAccount());
|
|
81
|
+
return accountManager;
|
|
82
|
+
}
|
|
83
|
+
async createOrRetrieveAccount(address, secretKey, type = 'schnorr', salt, publicKey) {
|
|
84
|
+
let account;
|
|
85
|
+
salt ??= Fr.ZERO;
|
|
86
|
+
if (this.db && address) {
|
|
87
|
+
({ type, secretKey, salt } = await this.db.retrieveAccount(address));
|
|
88
|
+
}
|
|
89
|
+
if (!secretKey) {
|
|
90
|
+
throw new Error('Cannot retrieve/create wallet without secret key');
|
|
91
|
+
}
|
|
92
|
+
switch(type){
|
|
93
|
+
case 'schnorr':
|
|
94
|
+
{
|
|
95
|
+
account = await this.createAccount(secretKey, salt, new SchnorrAccountContract(deriveSigningKey(secretKey)));
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'ecdsasecp256r1':
|
|
99
|
+
{
|
|
100
|
+
account = await this.createAccount(secretKey, salt, new EcdsaRAccountContract(deriveSigningKey(secretKey).toBuffer()));
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case 'ecdsasecp256r1ssh':
|
|
104
|
+
{
|
|
105
|
+
let publicSigningKey;
|
|
106
|
+
if (this.db && address) {
|
|
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');
|
|
117
|
+
}
|
|
118
|
+
account = await this.createAccount(secretKey, salt, new EcdsaRSSHAccountContract(publicSigningKey));
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
{
|
|
123
|
+
throw new Error(`Unsupported account type: ${type}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return account;
|
|
127
|
+
}
|
|
128
|
+
async getFakeAccountDataFor(address) {
|
|
129
|
+
const chainInfo = await this.getChainInfo();
|
|
130
|
+
const originalAccount = await this.getAccountFromAddress(address);
|
|
131
|
+
const originalAddress = originalAccount.getCompleteAddress();
|
|
132
|
+
const { contractInstance } = await this.pxe.getContractMetadata(originalAddress.address);
|
|
133
|
+
if (!contractInstance) {
|
|
134
|
+
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
135
|
+
}
|
|
136
|
+
const stubAccount = createStubAccount(originalAddress, chainInfo);
|
|
137
|
+
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
|
|
138
|
+
salt: Fr.random()
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
account: stubAccount,
|
|
142
|
+
instance,
|
|
143
|
+
artifact: StubAccountContractArtifact
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async simulateTx(executionPayload, opts) {
|
|
147
|
+
let simulationResults;
|
|
148
|
+
const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
|
|
149
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
150
|
+
const executionOptions = {
|
|
151
|
+
txNonce: Fr.random(),
|
|
152
|
+
cancellable: this.cancellableTransactions,
|
|
153
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
154
|
+
};
|
|
155
|
+
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
156
|
+
feeExecutionPayload,
|
|
157
|
+
executionPayload
|
|
158
|
+
]) : executionPayload;
|
|
159
|
+
// Kernelless simulations using the multicall entrypoints are not currently supported,
|
|
160
|
+
// since we only override proper account contracts.
|
|
161
|
+
// TODO: allow disabling kernels even when no overrides are necessary
|
|
162
|
+
if (opts.from.equals(AztecAddress.ZERO)) {
|
|
163
|
+
const fromAccount = await this.getAccountFromAddress(opts.from);
|
|
164
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
165
|
+
simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
|
|
166
|
+
} else {
|
|
167
|
+
const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(opts.from);
|
|
168
|
+
const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, executionOptions);
|
|
169
|
+
const contractOverrides = {
|
|
170
|
+
[opts.from.toString()]: {
|
|
171
|
+
instance,
|
|
172
|
+
artifact
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
simulationResults = await this.pxe.simulateTx(txRequest, true, true, true, {
|
|
176
|
+
contracts: contractOverrides
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (opts.fee?.estimateGas) {
|
|
180
|
+
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
181
|
+
printGasEstimates(feeOptions, limits, this.userLog);
|
|
182
|
+
}
|
|
183
|
+
return simulationResults;
|
|
184
|
+
}
|
|
185
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
186
|
+
// this is just a CLI wallet.
|
|
187
|
+
getContracts() {
|
|
188
|
+
return this.pxe.getContracts();
|
|
189
|
+
}
|
|
190
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
191
|
+
// this is just a CLI wallet.
|
|
192
|
+
getNotes(filter) {
|
|
193
|
+
return this.pxe.debug.getNotes(filter);
|
|
194
|
+
}
|
|
195
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli-wallet",
|
|
3
|
-
"version": "4.0.0-nightly.
|
|
3
|
+
"version": "4.0.0-nightly.20260108",
|
|
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": "4.0.0-nightly.
|
|
71
|
-
"@aztec/aztec.js": "4.0.0-nightly.
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/noir-
|
|
79
|
-
"@aztec/
|
|
80
|
-
"@aztec/
|
|
70
|
+
"@aztec/accounts": "4.0.0-nightly.20260108",
|
|
71
|
+
"@aztec/aztec.js": "4.0.0-nightly.20260108",
|
|
72
|
+
"@aztec/bb.js": "4.0.0-nightly.20260108",
|
|
73
|
+
"@aztec/cli": "4.0.0-nightly.20260108",
|
|
74
|
+
"@aztec/entrypoints": "4.0.0-nightly.20260108",
|
|
75
|
+
"@aztec/ethereum": "4.0.0-nightly.20260108",
|
|
76
|
+
"@aztec/foundation": "4.0.0-nightly.20260108",
|
|
77
|
+
"@aztec/kv-store": "4.0.0-nightly.20260108",
|
|
78
|
+
"@aztec/noir-contracts.js": "4.0.0-nightly.20260108",
|
|
79
|
+
"@aztec/noir-noirc_abi": "4.0.0-nightly.20260108",
|
|
80
|
+
"@aztec/pxe": "4.0.0-nightly.20260108",
|
|
81
|
+
"@aztec/stdlib": "4.0.0-nightly.20260108",
|
|
82
|
+
"@aztec/wallet-sdk": "4.0.0-nightly.20260108",
|
|
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.20251126.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,25 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
4
|
+
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
5
|
+
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
2
6
|
import { LOCALHOST } from '@aztec/cli/cli-utils';
|
|
3
7
|
import { type LogFn, createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
4
8
|
import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
|
|
5
|
-
import type {
|
|
9
|
+
import type { PXEConfig } from '@aztec/pxe/config';
|
|
6
10
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
7
11
|
|
|
8
12
|
import { Argument, Command, Option } from 'commander';
|
|
9
|
-
import { mkdirSync } from 'fs';
|
|
10
13
|
import { homedir } from 'os';
|
|
11
|
-
import {
|
|
14
|
+
import { join } from 'path';
|
|
12
15
|
|
|
13
16
|
import { injectCommands } from '../cmds/index.js';
|
|
14
17
|
import { Aliases, WalletDB } from '../storage/wallet_db.js';
|
|
18
|
+
import { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
15
19
|
import { createAliasOption } from '../utils/options/index.js';
|
|
16
|
-
import {
|
|
20
|
+
import { CLIWallet } from '../utils/wallet.js';
|
|
17
21
|
|
|
18
22
|
const userLog = createConsoleLogger();
|
|
19
23
|
const debugLogger = createLogger('wallet');
|
|
20
24
|
|
|
21
25
|
const { WALLET_DATA_DIRECTORY = join(homedir(), '.aztec/wallet') } = process.env;
|
|
22
26
|
|
|
27
|
+
// TODO: This function is only used in 1 place so we could just inline this
|
|
23
28
|
function injectInternalCommands(program: Command, log: LogFn, db: WalletDB) {
|
|
24
29
|
program
|
|
25
30
|
.command('alias')
|
|
@@ -70,7 +75,7 @@ async function main() {
|
|
|
70
75
|
const walletVersion = getPackageVersion() ?? '0.0.0';
|
|
71
76
|
|
|
72
77
|
const db = WalletDB.getInstance();
|
|
73
|
-
const
|
|
78
|
+
const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
|
|
74
79
|
|
|
75
80
|
const program = new Command('wallet');
|
|
76
81
|
program
|
|
@@ -78,45 +83,45 @@ async function main() {
|
|
|
78
83
|
.version(walletVersion)
|
|
79
84
|
.option('-d, --data-dir <string>', 'Storage directory for wallet data', WALLET_DATA_DIRECTORY)
|
|
80
85
|
.addOption(
|
|
81
|
-
new Option('-p, --prover <string>', 'The type of prover the wallet uses
|
|
86
|
+
new Option('-p, --prover <string>', 'The type of prover the wallet uses')
|
|
82
87
|
.choices(['wasm', 'native', 'none'])
|
|
83
88
|
.env('PXE_PROVER')
|
|
84
89
|
.default('native'),
|
|
85
90
|
)
|
|
86
|
-
.addOption(
|
|
87
|
-
new Option('--remote-pxe', 'Connect to an external PXE RPC server instead of the local one')
|
|
88
|
-
.env('REMOTE_PXE')
|
|
89
|
-
.default(false)
|
|
90
|
-
.conflicts('rpc-url'),
|
|
91
|
-
)
|
|
92
91
|
.addOption(
|
|
93
92
|
new Option('-n, --node-url <string>', 'URL of the Aztec node to connect to')
|
|
94
93
|
.env('AZTEC_NODE_URL')
|
|
95
94
|
.default(`http://${LOCALHOST}:8080`),
|
|
96
95
|
)
|
|
97
96
|
.hook('preSubcommand', async command => {
|
|
98
|
-
|
|
97
|
+
// Skip initialization if user is just requesting help
|
|
98
|
+
if (command.args.includes('--help') || command.args.includes('-h')) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
debugLogger.info('Using local PXE service');
|
|
104
|
+
const proverEnabled = prover !== 'none';
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
switch (prover) {
|
|
107
|
+
case 'native':
|
|
108
|
+
await Barretenberg.initSingleton({ backend: BackendType.NativeUnixSocket });
|
|
109
|
+
break;
|
|
110
|
+
case 'wasm':
|
|
111
|
+
await Barretenberg.initSingleton({ backend: BackendType.Wasm });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
104
114
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const bbWorkingDirectory = dataDir + '/bb';
|
|
110
|
-
mkdirSync(bbWorkingDirectory, { recursive: true });
|
|
115
|
+
const overridePXEConfig: Partial<PXEConfig> = {
|
|
116
|
+
proverEnabled,
|
|
117
|
+
dataDirectory: join(dataDir, 'pxe'),
|
|
118
|
+
};
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
120
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
121
|
+
const wallet = await CLIWallet.create(node, userLog, db, overridePXEConfig);
|
|
122
|
+
|
|
123
|
+
walletAndNodeWrapper.setNodeAndWallet(node, wallet);
|
|
117
124
|
|
|
118
|
-
pxeWrapper.prepare(nodeUrl, join(dataDir, 'pxe'), overridePXEConfig);
|
|
119
|
-
}
|
|
120
125
|
await db.init(await openStoreAt(dataDir));
|
|
121
126
|
let protocolContractsRegistered;
|
|
122
127
|
try {
|
|
@@ -137,9 +142,11 @@ async function main() {
|
|
|
137
142
|
}
|
|
138
143
|
});
|
|
139
144
|
|
|
140
|
-
injectCommands(program, userLog, debugLogger,
|
|
145
|
+
injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
|
|
141
146
|
injectInternalCommands(program, userLog, db);
|
|
142
147
|
await program.parseAsync(process.argv);
|
|
148
|
+
|
|
149
|
+
await Barretenberg.destroySingleton();
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
main().catch(err => {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { SetPublicAuthwitContractInteraction } from '@aztec/aztec.js/authorization';
|
|
3
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
5
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
6
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
7
|
|
|
5
|
-
import { DEFAULT_TX_TIMEOUT_S } from '../utils/
|
|
8
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
6
9
|
|
|
7
10
|
export async function authorizeAction(
|
|
8
|
-
wallet:
|
|
11
|
+
wallet: Wallet,
|
|
9
12
|
from: AztecAddress,
|
|
10
13
|
functionName: string,
|
|
11
14
|
caller: AztecAddress,
|
|
@@ -27,11 +30,16 @@ export async function authorizeAction(
|
|
|
27
30
|
);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
const contract =
|
|
33
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
31
34
|
const action = contract.methods[functionName](...functionArgs);
|
|
32
35
|
|
|
33
|
-
const setAuthwitnessInteraction = await
|
|
34
|
-
|
|
36
|
+
const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(
|
|
37
|
+
wallet,
|
|
38
|
+
from,
|
|
39
|
+
{ caller, action },
|
|
40
|
+
true,
|
|
41
|
+
);
|
|
42
|
+
const witness = await setAuthwitnessInteraction.send().wait({ timeout: DEFAULT_TX_TIMEOUT_S });
|
|
35
43
|
|
|
36
44
|
log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
37
45
|
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { L1FeeJuicePortalManager
|
|
1
|
+
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
2
4
|
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
3
|
-
import { createEthereumChain
|
|
4
|
-
import {
|
|
5
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
6
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
8
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
6
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
+
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
7
11
|
|
|
8
12
|
export async function bridgeL1FeeJuice(
|
|
9
13
|
amount: bigint,
|
|
10
14
|
recipient: AztecAddress,
|
|
11
|
-
|
|
15
|
+
node: AztecNode,
|
|
12
16
|
l1RpcUrls: string[],
|
|
13
17
|
chainId: number,
|
|
14
18
|
privateKey: string | undefined,
|
|
@@ -24,12 +28,8 @@ export async function bridgeL1FeeJuice(
|
|
|
24
28
|
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
25
29
|
const client = createExtendedL1Client(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
|
|
26
30
|
|
|
27
|
-
const {
|
|
28
|
-
protocolContractAddresses: { feeJuice: feeJuiceAddress },
|
|
29
|
-
} = await pxe.getPXEInfo();
|
|
30
|
-
|
|
31
31
|
// Setup portal manager
|
|
32
|
-
const portal = await L1FeeJuicePortalManager.new(
|
|
32
|
+
const portal = await L1FeeJuicePortalManager.new(node, client, debugLogger);
|
|
33
33
|
const { claimAmount, claimSecret, messageHash, messageLeafIndex } = await portal.bridgeTokensPublic(
|
|
34
34
|
recipient,
|
|
35
35
|
amount,
|
|
@@ -66,8 +66,12 @@ export async function bridgeL1FeeJuice(
|
|
|
66
66
|
const delayedCheck = (delay: number) => {
|
|
67
67
|
return new Promise((resolve, reject) => {
|
|
68
68
|
setTimeout(() => {
|
|
69
|
-
void
|
|
70
|
-
|
|
69
|
+
void getNonNullifiedL1ToL2MessageWitness(
|
|
70
|
+
node,
|
|
71
|
+
ProtocolContractAddress.FeeJuice,
|
|
72
|
+
Fr.fromHexString(messageHash),
|
|
73
|
+
claimSecret,
|
|
74
|
+
)
|
|
71
75
|
.then(witness => resolve(witness))
|
|
72
76
|
.catch(err => reject(err));
|
|
73
77
|
}, delay);
|