@aztec/cli-wallet 0.0.1-commit.a89ec08 → 0.0.1-commit.aa0c64f
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/check_tx.js +13 -12
- package/dest/cmds/create_account.d.ts +4 -2
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +26 -10
- package/dest/cmds/deploy.d.ts +3 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +23 -21
- package/dest/cmds/deploy_account.js +4 -7
- 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 +10 -9
- package/dest/cmds/send.js +3 -6
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +2 -1
- package/dest/storage/wallet_db.d.ts +7 -4
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +15 -1
- package/dest/utils/constants.d.ts +2 -2
- package/dest/utils/constants.d.ts.map +1 -1
- package/dest/utils/constants.js +1 -0
- package/dest/utils/options/fees.d.ts +2 -1
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +26 -3
- package/dest/utils/options/options.d.ts +2 -2
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +5 -5
- package/dest/utils/wallet.d.ts +28 -5
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +132 -75
- package/package.json +16 -15
- package/src/bin/index.ts +1 -1
- package/src/cmds/check_tx.ts +14 -13
- package/src/cmds/create_account.ts +27 -15
- package/src/cmds/deploy.ts +22 -23
- package/src/cmds/deploy_account.ts +4 -4
- package/src/cmds/import_test_accounts.ts +12 -1
- package/src/cmds/index.ts +14 -11
- package/src/cmds/send.ts +3 -3
- package/src/cmds/simulate.ts +2 -1
- package/src/storage/wallet_db.ts +24 -2
- package/src/utils/constants.ts +7 -1
- package/src/utils/options/fees.ts +28 -4
- package/src/utils/options/options.ts +5 -5
- package/src/utils/wallet.ts +171 -92
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
2
3
|
import { extractECDSAPublicKeyFromBase64String } from '../utils/ecdsa.js';
|
|
3
4
|
export const Aliases = [
|
|
4
5
|
'accounts',
|
|
@@ -76,7 +77,13 @@ export class WalletDB {
|
|
|
76
77
|
leafIndex: BigInt(leafIndexStr)
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
|
-
async storeAccount(address, { type, secretKey, salt, alias, publicKey }, log) {
|
|
80
|
+
async storeAccount(address, { type, signingKey, secretKey, salt, alias, publicKey }, log) {
|
|
81
|
+
// Even though the privacy secret key is sometimes derived from the signing key, we store it in the database
|
|
82
|
+
// regardless as that is not always the case. Local-key accounts also store their signing key, while external-key
|
|
83
|
+
// accounts such as SSH store only the privacy secret.
|
|
84
|
+
if (!secretKey) {
|
|
85
|
+
throw new Error('Cannot store account without a secret key');
|
|
86
|
+
}
|
|
80
87
|
let publicSigningKey;
|
|
81
88
|
if (type === 'ecdsasecp256r1ssh' && publicKey) {
|
|
82
89
|
publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
|
|
@@ -87,6 +94,9 @@ export class WalletDB {
|
|
|
87
94
|
}
|
|
88
95
|
await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
|
|
89
96
|
await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
|
|
97
|
+
if (signingKey) {
|
|
98
|
+
await this.#accounts.set(`${address.toString()}:signing`, signingKey.toBuffer());
|
|
99
|
+
}
|
|
90
100
|
await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
|
|
91
101
|
if (publicSigningKey) {
|
|
92
102
|
await this.#accounts.set(`${address.toString()}:publicSigningKey`, publicSigningKey);
|
|
@@ -198,11 +208,15 @@ export class WalletDB {
|
|
|
198
208
|
if (!secretKeyBuffer) {
|
|
199
209
|
throw new Error(`Could not find ${address}:sk. Account "${address.toString}" does not exist on this wallet.`);
|
|
200
210
|
}
|
|
211
|
+
const signingKeyBuffer = await this.#accounts.getAsync(`${address.toString()}:signing`);
|
|
201
212
|
const secretKey = Fr.fromBuffer(secretKeyBuffer);
|
|
213
|
+
// External-key accounts (e.g. SSH) store no signing key.
|
|
214
|
+
const signingKey = signingKeyBuffer ? GrumpkinScalar.fromBuffer(signingKeyBuffer) : undefined;
|
|
202
215
|
const salt = Fr.fromBuffer(await this.#accounts.getAsync(`${address.toString()}:salt`));
|
|
203
216
|
const type = (await this.#accounts.getAsync(`${address.toString()}:type`)).toString('utf8');
|
|
204
217
|
return {
|
|
205
218
|
address,
|
|
219
|
+
signingKey,
|
|
206
220
|
secretKey,
|
|
207
221
|
salt,
|
|
208
222
|
type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const MIN_FEE_PADDING = 0.5;
|
|
2
|
-
export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
2
|
+
export declare const AccountTypes: readonly ["schnorr", "schnorr_initializerless", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
|
|
3
3
|
export type AccountType = (typeof AccountTypes)[number];
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGVBQU8sTUFBTSxlQUFlLE1BQU0sQ0FBQztBQUVuQyxlQUFPLE1BQU0sWUFBWSwwR0FNZixDQUFDO0FBQ1gsTUFBTSxNQUFNLFdBQVcsR0FBRyxDQUFDLE9BQU8sWUFBWSxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,YAAY,0GAMf,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dest/utils/constants.js
CHANGED
|
@@ -28,8 +28,9 @@ export declare class CLIFeeArgs {
|
|
|
28
28
|
private gasSettings;
|
|
29
29
|
constructor(estimateOnly: boolean, paymentMethod: (wallet: Wallet, feePayer: AztecAddress, gasSettings: GasSettings) => Promise<FeePaymentMethod | undefined>, gasSettings: Partial<FieldsOf<GasSettings>>);
|
|
30
30
|
toUserFeeOptions(node: AztecNode, wallet: Wallet, from: AztecAddress): Promise<ParsedFeeOptions>;
|
|
31
|
+
private getMinFees;
|
|
31
32
|
static parse(args: RawCliFeeArgs, log: LogFn, db?: WalletDB): CLIFeeArgs;
|
|
32
33
|
static getOptions(): Option[];
|
|
33
34
|
}
|
|
34
35
|
export declare function printGasEstimates(feeOpts: FeeOptions, gasEstimates: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>, log: LogFn): void;
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2Z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FZLEdBQUcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBV3JHO1lBTWEsVUFBVTtJQWlCeEIsTUFBTSxDQUFDLEtBQUssQ0FBQyxJQUFJLEVBQUUsYUFBYSxFQUFFLEdBQUcsRUFBRSxLQUFLLEVBQUUsRUFBRSxDQUFDLEVBQUUsUUFBUSxHQUFHLFVBQVUsQ0FPdkU7SUFFRCxNQUFNLENBQUMsVUFBVSxhQUVoQjtDQUNGO0FBSUQsd0JBQWdCLGlCQUFpQixDQUMvQixPQUFPLEVBQUUsVUFBVSxFQUNuQixZQUFZLEVBQUUsSUFBSSxDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsbUJBQW1CLENBQUMsRUFDbEUsR0FBRyxFQUFFLEtBQUssUUFJWCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/utils/options/fees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAO,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/utils/options/fees.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,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,EAAE,OAAO,EACpB,aAAa,EAAE,CACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,WAAW,KACrB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,EAClC,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EACjD;IAEE,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWrG;YAMa,UAAU;IAiBxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,UAAU,CAOvE;IAED,MAAM,CAAC,UAAU,aAEhB;CACF;AAID,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,EACnB,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,EAClE,GAAG,EAAE,KAAK,QAIX"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
3
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
4
4
|
import { Option } from 'commander';
|
|
5
5
|
import { MIN_FEE_PADDING } from '../constants.js';
|
|
6
6
|
import { aliasedAddressParser } from './options.js';
|
|
@@ -86,7 +86,7 @@ export function parsePaymentMethod(payment, log, db, estimateOnly) {
|
|
|
86
86
|
if (!parsed.asset) {
|
|
87
87
|
throw new Error('Missing "asset" in payment option');
|
|
88
88
|
}
|
|
89
|
-
return AztecAddress.
|
|
89
|
+
return AztecAddress.fromStringUnsafe(parsed.asset);
|
|
90
90
|
};
|
|
91
91
|
return async (wallet, from, gasSettings)=>{
|
|
92
92
|
switch(parsed.method){
|
|
@@ -192,9 +192,13 @@ export class CLIFeeArgs {
|
|
|
192
192
|
this.gasSettings = gasSettings;
|
|
193
193
|
}
|
|
194
194
|
async toUserFeeOptions(node, wallet, from) {
|
|
195
|
-
const
|
|
195
|
+
const minFees = await this.getMinFees(node);
|
|
196
|
+
const maxFeesPerGas = minFees.mul(1 + MIN_FEE_PADDING);
|
|
197
|
+
const { txsLimits } = await node.getNodeInfo();
|
|
198
|
+
const gasLimits = this.gasSettings.gasLimits ?? Gas.from(txsLimits.gas);
|
|
196
199
|
const gasSettings = GasSettings.fallback({
|
|
197
200
|
...this.gasSettings,
|
|
201
|
+
gasLimits,
|
|
198
202
|
maxFeesPerGas
|
|
199
203
|
});
|
|
200
204
|
const paymentMethod = await this.paymentMethod(wallet, from, gasSettings);
|
|
@@ -203,6 +207,25 @@ export class CLIFeeArgs {
|
|
|
203
207
|
gasSettings
|
|
204
208
|
};
|
|
205
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
212
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
213
|
+
*/ async getMinFees(node) {
|
|
214
|
+
try {
|
|
215
|
+
const predicted = await node.getPredictedMinFees(ManaUsageEstimate.Limit);
|
|
216
|
+
if (predicted.length === 0) {
|
|
217
|
+
return node.getCurrentMinFees();
|
|
218
|
+
}
|
|
219
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
220
|
+
} catch (err) {
|
|
221
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
222
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
223
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
224
|
+
return node.getCurrentMinFees();
|
|
225
|
+
}
|
|
226
|
+
throw err;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
206
229
|
static parse(args, log, db) {
|
|
207
230
|
const estimateOnly = !!args.estimateGasOnly;
|
|
208
231
|
return new CLIFeeArgs(estimateOnly, parsePaymentMethod(args.payment ?? 'method=fee_juice', log, db, estimateOnly), parseGasSettings(args));
|
|
@@ -8,7 +8,7 @@ export declare function integerArgParser(value: string, argName: string, min?: n
|
|
|
8
8
|
export declare function aliasedTxHashParser(txHash: string, db?: WalletDB): TxHash;
|
|
9
9
|
export declare function aliasedAuthWitParser(witnesses: string, db?: WalletDB): AuthWitness[];
|
|
10
10
|
export declare function aliasedAddressParser(defaultPrefix: AliasType, address: string, db?: WalletDB): AztecAddress;
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function aliasedSigningKeyParser(sk: string, db?: WalletDB): import("@aztec/foundation/schemas").Fq;
|
|
12
12
|
export declare function createAliasOption(description: string, hide: boolean): Option;
|
|
13
13
|
export declare function createAccountOption(description: string, hide: boolean, db?: WalletDB): Option;
|
|
14
14
|
export declare function createAuthwitnessOption(description: string, hide: boolean, db?: WalletDB): Option;
|
|
@@ -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=data:application/json;base64,
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL29wdGlvbnMvb3B0aW9ucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENB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parseAztecAddress,
|
|
1
|
+
import { parseAztecAddress, parseSigningKey, 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';
|
|
@@ -45,13 +45,13 @@ export function aliasedAddressParser(defaultPrefix, address, db) {
|
|
|
45
45
|
return parseAztecAddress(rawAddress);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
export function
|
|
48
|
+
export function aliasedSigningKeyParser(sk, db) {
|
|
49
49
|
if (sk.startsWith('0x')) {
|
|
50
|
-
return
|
|
50
|
+
return parseSigningKey(sk);
|
|
51
51
|
} else {
|
|
52
|
-
const prefixed = `${sk.startsWith('accounts') ? '' : 'accounts'}:${sk.endsWith(':
|
|
52
|
+
const prefixed = `${sk.startsWith('accounts') ? '' : 'accounts'}:${sk.endsWith(':signing') ? sk : `${sk}:signing`}`;
|
|
53
53
|
const rawSk = db ? db.tryRetrieveAlias(prefixed) : sk;
|
|
54
|
-
return
|
|
54
|
+
return parseSigningKey(rawSk);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
export function createAliasOption(description, hide) {
|
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
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
|
|
4
|
+
import { AccountManager, type Aliased } from '@aztec/aztec.js/wallet';
|
|
5
5
|
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
+
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
7
8
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
9
|
import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
9
10
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
10
11
|
import type { PXE } from '@aztec/pxe/server';
|
|
11
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
+
import type { Gas, GasUsed } from '@aztec/stdlib/gas';
|
|
12
14
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
13
15
|
import type { TxProvingResult } from '@aztec/stdlib/tx';
|
|
14
16
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
@@ -19,16 +21,37 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
19
21
|
private userLog;
|
|
20
22
|
private db?;
|
|
21
23
|
private accountCache;
|
|
24
|
+
private stubClassIds;
|
|
22
25
|
constructor(pxe: PXE, node: AztecNode, userLog: LogFn, db?: WalletDB | undefined);
|
|
23
26
|
static create(node: AztecNode, log: LogFn, db?: WalletDB, overridePXEConfig?: Partial<PXEConfig>): Promise<CLIWallet>;
|
|
27
|
+
private registerAuthRegistry;
|
|
28
|
+
private initStubClasses;
|
|
24
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
|
+
}>;
|
|
25
39
|
private createCancellationTxExecutionRequest;
|
|
26
40
|
proveCancellationTx(from: AztecAddress, txNonce: Fr, increasedFee: InteractionFeeOptions): Promise<TxProvingResult>;
|
|
27
41
|
getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
30
54
|
private getFakeAccountDataFor;
|
|
31
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
32
55
|
/**
|
|
33
56
|
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
34
57
|
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
@@ -38,4 +61,4 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
38
61
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
39
62
|
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
40
63
|
}
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBaUMsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RixPQUFPLEVBRUwsS0FBSyxxQkFBcUIsRUFFM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUU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LGFBQWEsQ0FDakIsSUFBSSxFQUFFLFdBQVcsRUFDakIsVUFBVSxFQUFFLGNBQWMsR0FBRyxTQUFTLEVBQ3RDLFNBQVMsRUFBRSxFQUFFLEdBQUcsU0FBUyxFQUN6QixJQUFJLEdBQUUsRUFBWSxFQUNsQixTQUFTLENBQUMsRUFBRSxNQUFNLEdBQ2pCLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FJekI7SUFFRDs7T0FFRztJQUNHLGVBQWUsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FjcEU7WUFFYSxZQUFZO1lBcUNaLDBCQUEwQjtZQWMxQixrQkFBa0I7WUErQmxCLHFCQUFxQjtJQXNCbkM7OztPQUdHO0lBQ0gsVUFBeUIscUJBQXFCLENBQzVDLGdCQUFnQixFQUFFLGdCQUFnQixFQUNsQyxJQUFJLEVBQUUsNEJBQTRCLEdBQ2pDLE9BQU8sQ0FBQywrQkFBK0IsQ0FBQyxDQTJDMUM7SUFJRCxZQUFZLElBQUksT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBRXRDO0lBSUQsUUFBUSxDQUFDLE1BQU0sRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDLENBRWhEO0lBSUQsbUJBQW1CLENBQUMsRUFBRSxFQUFFLEVBQUUscUVBRXpCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,qB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E,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;IAID,mBAAmB,CAAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
|
package/dest/utils/wallet.js
CHANGED
|
@@ -1,33 +1,59 @@
|
|
|
1
|
-
import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub
|
|
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';
|
|
5
5
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
6
6
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
7
|
-
import {
|
|
7
|
+
import { ContractFunctionInteraction, getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
|
|
8
8
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
9
9
|
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
10
10
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
11
11
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
12
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
13
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
13
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
15
15
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
16
|
-
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
16
|
+
import { BaseWallet, getGasLimits } from '@aztec/wallet-sdk/base-wallet';
|
|
17
17
|
import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
|
|
18
|
-
|
|
18
|
+
/** Padding the CLI wallet applies to simulated gas usage when deriving declared gas limits. */ const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
|
|
19
19
|
export class CLIWallet extends BaseWallet {
|
|
20
20
|
userLog;
|
|
21
21
|
db;
|
|
22
22
|
accountCache;
|
|
23
|
+
// Stub class ids, populated on wallet startup
|
|
24
|
+
// to avoid redundant work per simulation
|
|
25
|
+
stubClassIds;
|
|
23
26
|
constructor(pxe, node, userLog, db){
|
|
24
|
-
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();
|
|
25
28
|
this.cancellableTransactions = true;
|
|
26
29
|
}
|
|
27
30
|
static async create(node, log, db, overridePXEConfig) {
|
|
28
31
|
const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig);
|
|
29
32
|
const pxe = await createPXE(node, pxeConfig);
|
|
30
|
-
|
|
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);
|
|
31
57
|
}
|
|
32
58
|
async getAccounts() {
|
|
33
59
|
const accounts = await this.db?.listAliases('accounts') ?? [];
|
|
@@ -35,10 +61,18 @@ export class CLIWallet extends BaseWallet {
|
|
|
35
61
|
const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key;
|
|
36
62
|
return {
|
|
37
63
|
alias,
|
|
38
|
-
item: AztecAddress.
|
|
64
|
+
item: AztecAddress.fromStringUnsafe(value)
|
|
39
65
|
};
|
|
40
66
|
}));
|
|
41
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);
|
|
75
|
+
}
|
|
42
76
|
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
43
77
|
const executionPayload = ExecutionPayload.empty();
|
|
44
78
|
const feeOptions = await this.completeFeeOptions({
|
|
@@ -59,14 +93,17 @@ export class CLIWallet extends BaseWallet {
|
|
|
59
93
|
}
|
|
60
94
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
61
95
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
62
|
-
return await this.pxe.proveTx(cancellationTxRequest,
|
|
96
|
+
return await this.pxe.proveTx(cancellationTxRequest, {
|
|
97
|
+
scopes: this.scopesFrom(from, [], undefined),
|
|
98
|
+
senderForTags: from
|
|
99
|
+
});
|
|
63
100
|
}
|
|
64
101
|
async getAccountFromAddress(address) {
|
|
65
102
|
let account;
|
|
66
103
|
if (this.accountCache.has(address.toString())) {
|
|
67
104
|
return this.accountCache.get(address.toString());
|
|
68
105
|
} else {
|
|
69
|
-
const accountManager = await this.
|
|
106
|
+
const accountManager = await this.retrieveAccount(address);
|
|
70
107
|
account = await accountManager.getAccount();
|
|
71
108
|
}
|
|
72
109
|
if (!account) {
|
|
@@ -74,58 +111,89 @@ export class CLIWallet extends BaseWallet {
|
|
|
74
111
|
}
|
|
75
112
|
return account;
|
|
76
113
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
await this.
|
|
82
|
-
this.
|
|
83
|
-
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);
|
|
84
120
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (this.db
|
|
89
|
-
(
|
|
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');
|
|
90
126
|
}
|
|
91
|
-
|
|
92
|
-
|
|
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.`);
|
|
93
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) {
|
|
94
135
|
switch(type){
|
|
95
136
|
case 'schnorr':
|
|
96
|
-
|
|
97
|
-
account = await this.createAccount(secretKey, salt, new SchnorrAccountContract(deriveSigningKey(secretKey)));
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
137
|
+
case 'schnorr_initializerless':
|
|
100
138
|
case 'ecdsasecp256r1':
|
|
139
|
+
case 'ecdsasecp256k1':
|
|
101
140
|
{
|
|
102
|
-
|
|
103
|
-
|
|
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);
|
|
104
146
|
}
|
|
105
147
|
case 'ecdsasecp256r1ssh':
|
|
106
148
|
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
publicSigningKey = await this.db.retrieveAccountMetadata(address, 'publicSigningKey');
|
|
110
|
-
} else if (publicKey) {
|
|
111
|
-
const identities = await getIdentities();
|
|
112
|
-
const foundIdentity = identities.find((identity)=>identity.type === 'ecdsa-sha2-nistp256' && identity.publicKey === publicKey);
|
|
113
|
-
if (!foundIdentity) {
|
|
114
|
-
throw new Error(`Identity for public key ${publicKey} not found in the SSH agent`);
|
|
115
|
-
}
|
|
116
|
-
publicSigningKey = extractECDSAPublicKeyFromBase64String(foundIdentity.publicKey);
|
|
117
|
-
} else {
|
|
118
|
-
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');
|
|
119
151
|
}
|
|
120
|
-
|
|
121
|
-
break;
|
|
152
|
+
return await this.materializeAccount(secretKey, salt, new EcdsaRSSHAccountContract(publicSigningKey));
|
|
122
153
|
}
|
|
123
154
|
default:
|
|
124
155
|
{
|
|
125
156
|
throw new Error(`Unsupported account type: ${type}`);
|
|
126
157
|
}
|
|
127
158
|
}
|
|
128
|
-
|
|
159
|
+
}
|
|
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;
|
|
129
197
|
}
|
|
130
198
|
/**
|
|
131
199
|
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
@@ -140,37 +208,26 @@ export class CLIWallet extends BaseWallet {
|
|
|
140
208
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
141
209
|
}
|
|
142
210
|
const { type } = await this.db.retrieveAccount(address);
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
};
|
|
149
220
|
return {
|
|
150
221
|
account: stubAccount,
|
|
151
|
-
instance
|
|
152
|
-
artifact
|
|
222
|
+
instance
|
|
153
223
|
};
|
|
154
224
|
}
|
|
155
|
-
async simulateTx(executionPayload, opts) {
|
|
156
|
-
const simulationResults = await super.simulateTx(executionPayload, opts);
|
|
157
|
-
if (opts.fee?.estimateGas) {
|
|
158
|
-
const feeOptions = await this.completeFeeOptions({
|
|
159
|
-
from: opts.from,
|
|
160
|
-
feePayer: executionPayload.feePayer,
|
|
161
|
-
gasSettings: opts.fee?.gasSettings
|
|
162
|
-
});
|
|
163
|
-
const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
|
|
164
|
-
printGasEstimates(feeOptions, limits, this.userLog);
|
|
165
|
-
}
|
|
166
|
-
return simulationResults;
|
|
167
|
-
}
|
|
168
225
|
/**
|
|
169
226
|
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
170
227
|
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
171
228
|
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
172
|
-
const { from, feeOptions, additionalScopes } = opts;
|
|
173
|
-
const scopes = this.scopesFrom(from, additionalScopes);
|
|
229
|
+
const { from, feeOptions, additionalScopes, sendMessagesAs } = opts;
|
|
230
|
+
const scopes = this.scopesFrom(from, additionalScopes ?? [], sendMessagesAs);
|
|
174
231
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
175
232
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
176
233
|
feeExecutionPayload,
|
|
@@ -183,12 +240,11 @@ export class CLIWallet extends BaseWallet {
|
|
|
183
240
|
const entrypoint = new DefaultEntrypoint();
|
|
184
241
|
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
185
242
|
} else {
|
|
186
|
-
const { account, instance
|
|
243
|
+
const { account, instance } = await this.getFakeAccountDataFor(from);
|
|
187
244
|
overrides = {
|
|
188
245
|
contracts: {
|
|
189
246
|
[from.toString()]: {
|
|
190
|
-
instance
|
|
191
|
-
artifact
|
|
247
|
+
instance
|
|
192
248
|
}
|
|
193
249
|
}
|
|
194
250
|
};
|
|
@@ -205,7 +261,8 @@ export class CLIWallet extends BaseWallet {
|
|
|
205
261
|
skipFeeEnforcement: true,
|
|
206
262
|
skipTxValidation: true,
|
|
207
263
|
overrides,
|
|
208
|
-
scopes
|
|
264
|
+
scopes,
|
|
265
|
+
senderForTags: this.senderForTagsFrom(from, sendMessagesAs)
|
|
209
266
|
});
|
|
210
267
|
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
211
268
|
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|