@aztec/cli-wallet 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e
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/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/check_tx.d.ts +1 -1
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +45 -14
- package/dest/cmds/create_account.d.ts +4 -3
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +42 -25
- 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 +4 -3
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +56 -29
- 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 +37 -20
- 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/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +30 -14
- package/dest/cmds/send.d.ts +5 -4
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +32 -16
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +3 -3
- package/dest/storage/wallet_db.d.ts +6 -1
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +60 -31
- 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 +32 -9
- package/dest/utils/options/options.d.ts +2 -2
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/profiling.d.ts.map +1 -1
- package/dest/utils/profiling.js +9 -1
- package/dest/utils/wallet.d.ts +12 -5
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +87 -47
- package/package.json +15 -15
- package/src/cmds/authorize_action.ts +1 -1
- package/src/cmds/check_tx.ts +50 -19
- package/src/cmds/create_account.ts +44 -24
- package/src/cmds/deploy.ts +55 -27
- package/src/cmds/deploy_account.ts +38 -19
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/index.ts +57 -4
- package/src/cmds/send.ts +32 -12
- package/src/cmds/simulate.ts +4 -7
- package/src/storage/wallet_db.ts +63 -36
- package/src/utils/options/fees.ts +39 -9
- package/src/utils/profiling.ts +15 -1
- package/src/utils/wallet.ts +99 -63
|
@@ -9,6 +9,7 @@ export const Aliases = [
|
|
|
9
9
|
'authwits'
|
|
10
10
|
];
|
|
11
11
|
export class WalletDB {
|
|
12
|
+
#store;
|
|
12
13
|
#accounts;
|
|
13
14
|
#aliases;
|
|
14
15
|
#bridgedFeeJuice;
|
|
@@ -21,6 +22,7 @@ export class WalletDB {
|
|
|
21
22
|
return WalletDB.instance;
|
|
22
23
|
}
|
|
23
24
|
async init(store) {
|
|
25
|
+
this.#store = store;
|
|
24
26
|
this.#accounts = store.openMap('accounts');
|
|
25
27
|
this.#aliases = store.openMap('aliases');
|
|
26
28
|
this.#bridgedFeeJuice = store.openMap('bridgedFeeJuice');
|
|
@@ -33,13 +35,15 @@ export class WalletDB {
|
|
|
33
35
|
]));
|
|
34
36
|
}
|
|
35
37
|
async pushBridgedFeeJuice(recipient, secret, amount, leafIndex, log) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
stackPointer
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
await this.#store.transactionAsync(async ()=>{
|
|
39
|
+
let stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
|
|
40
|
+
stackPointer++;
|
|
41
|
+
await this.#bridgedFeeJuice.set(`${recipient.toString()}:${stackPointer}`, Buffer.from(`${amount.toString()}:${secret.toString()}:${leafIndex.toString()}`));
|
|
42
|
+
await this.#bridgedFeeJuice.set(`${recipient.toString()}:stackPointer`, Buffer.from([
|
|
43
|
+
stackPointer
|
|
44
|
+
]));
|
|
45
|
+
log(`Pushed ${amount} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
|
|
46
|
+
});
|
|
43
47
|
}
|
|
44
48
|
async popBridgedFeeJuice(recipient, log) {
|
|
45
49
|
let stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
|
|
@@ -58,18 +62,37 @@ export class WalletDB {
|
|
|
58
62
|
leafIndex: BigInt(leafIndexStr)
|
|
59
63
|
};
|
|
60
64
|
}
|
|
61
|
-
async
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
async peekBridgedFeeJuice(recipient, log) {
|
|
66
|
+
const stackPointer = (await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:stackPointer`))?.readInt8() || 0;
|
|
67
|
+
const result = await this.#bridgedFeeJuice.getAsync(`${recipient.toString()}:${stackPointer}`);
|
|
68
|
+
if (!result) {
|
|
69
|
+
throw new Error(`No stored fee juice available for recipient ${recipient.toString()}. Please provide claim amount and secret. Stack pointer ${stackPointer}`);
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
const [amountStr, secretStr, leafIndexStr] = result.toString().split(':');
|
|
72
|
+
log(`Peeked ${amountStr} fee juice for recipient ${recipient.toString()}. Stack pointer ${stackPointer}`);
|
|
73
|
+
return {
|
|
74
|
+
amount: BigInt(amountStr),
|
|
75
|
+
secret: secretStr,
|
|
76
|
+
leafIndex: BigInt(leafIndexStr)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async storeAccount(address, { type, secretKey, salt, alias, publicKey }, log) {
|
|
80
|
+
let publicSigningKey;
|
|
68
81
|
if (type === 'ecdsasecp256r1ssh' && publicKey) {
|
|
69
|
-
|
|
70
|
-
await this.storeAccountMetadata(address, 'publicSigningKey', publicSigningKey);
|
|
82
|
+
publicSigningKey = extractECDSAPublicKeyFromBase64String(publicKey);
|
|
71
83
|
}
|
|
72
|
-
await this.#
|
|
84
|
+
await this.#store.transactionAsync(async ()=>{
|
|
85
|
+
if (alias) {
|
|
86
|
+
await this.#aliases.set(`accounts:${alias}`, Buffer.from(address.toString()));
|
|
87
|
+
}
|
|
88
|
+
await this.#accounts.set(`${address.toString()}:type`, Buffer.from(type));
|
|
89
|
+
await this.#accounts.set(`${address.toString()}:sk`, secretKey.toBuffer());
|
|
90
|
+
await this.#accounts.set(`${address.toString()}:salt`, salt.toBuffer());
|
|
91
|
+
if (publicSigningKey) {
|
|
92
|
+
await this.#accounts.set(`${address.toString()}:publicSigningKey`, publicSigningKey);
|
|
93
|
+
}
|
|
94
|
+
await this.#aliases.set('accounts:last', Buffer.from(address.toString()));
|
|
95
|
+
});
|
|
73
96
|
log(`Account stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
|
|
74
97
|
await this.refreshAliasCache();
|
|
75
98
|
}
|
|
@@ -79,29 +102,35 @@ export class WalletDB {
|
|
|
79
102
|
await this.refreshAliasCache();
|
|
80
103
|
}
|
|
81
104
|
async storeContract(address, artifactPath, log, alias) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
await this.#store.transactionAsync(async ()=>{
|
|
106
|
+
if (alias) {
|
|
107
|
+
await this.#aliases.set(`contracts:${alias}`, Buffer.from(address.toString()));
|
|
108
|
+
await this.#aliases.set(`artifacts:${alias}`, Buffer.from(artifactPath));
|
|
109
|
+
}
|
|
110
|
+
await this.#aliases.set(`contracts:last`, Buffer.from(address.toString()));
|
|
111
|
+
await this.#aliases.set(`artifacts:last`, Buffer.from(artifactPath));
|
|
112
|
+
await this.#aliases.set(`artifacts:${address.toString()}`, Buffer.from(artifactPath));
|
|
113
|
+
});
|
|
89
114
|
log(`Contract stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
|
|
90
115
|
await this.refreshAliasCache();
|
|
91
116
|
}
|
|
92
117
|
async storeAuthwitness(authWit, log, alias) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
118
|
+
await this.#store.transactionAsync(async ()=>{
|
|
119
|
+
if (alias) {
|
|
120
|
+
await this.#aliases.set(`authwits:${alias}`, Buffer.from(authWit.toString()));
|
|
121
|
+
}
|
|
122
|
+
await this.#aliases.set(`authwits:last`, Buffer.from(authWit.toString()));
|
|
123
|
+
});
|
|
97
124
|
log(`Authorization witness stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
|
|
98
125
|
await this.refreshAliasCache();
|
|
99
126
|
}
|
|
100
127
|
async storeTx({ txHash }, log, alias) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
128
|
+
await this.#store.transactionAsync(async ()=>{
|
|
129
|
+
if (alias) {
|
|
130
|
+
await this.#aliases.set(`transactions:${alias}`, Buffer.from(txHash.toString()));
|
|
131
|
+
}
|
|
132
|
+
await this.#aliases.set(`transactions:last`, Buffer.from(txHash.toString()));
|
|
133
|
+
});
|
|
105
134
|
log(`Transaction hash stored in database with alias${alias ? `es last & ${alias}` : ' last'}`);
|
|
106
135
|
await this.refreshAliasCache();
|
|
107
136
|
}
|
|
@@ -20,7 +20,7 @@ export type ParsedFeeOptions = {
|
|
|
20
20
|
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
21
21
|
};
|
|
22
22
|
export declare function getPaymentMethodOption(): Option;
|
|
23
|
-
export declare function parsePaymentMethod(payment: string, log: LogFn, db?: WalletDB): (wallet: Wallet, from: AztecAddress, gasSettings: GasSettings) => Promise<FeePaymentMethod | undefined>;
|
|
23
|
+
export declare function parsePaymentMethod(payment: string, log: LogFn, db?: WalletDB, estimateOnly?: boolean): (wallet: Wallet, from: AztecAddress, gasSettings: GasSettings) => Promise<FeePaymentMethod | undefined>;
|
|
24
24
|
export declare function parseGasFees(gasFees: string): GasFees;
|
|
25
25
|
export declare class CLIFeeArgs {
|
|
26
26
|
estimateOnly: boolean;
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL29wdGlvbnMvZmVlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRXJELE9BQU8sS0F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QW1CLENBQUMsRUFDbEUsR0FBRyxFQUFFLEtBQUssUUFJWCJ9
|
|
@@ -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,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,EAAqB,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,MAAM,MAAM,aAAa,GAAG;IAC1B,eAA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K,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';
|
|
@@ -70,7 +70,7 @@ function parseGasSettings(args) {
|
|
|
70
70
|
maxPriorityFeesPerGas
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
export function parsePaymentMethod(payment, log, db) {
|
|
73
|
+
export function parsePaymentMethod(payment, log, db, estimateOnly) {
|
|
74
74
|
const parsed = payment.split(',').reduce((acc, item)=>{
|
|
75
75
|
const [dimension, value] = item.split('=');
|
|
76
76
|
acc[dimension] = value ?? 1;
|
|
@@ -95,15 +95,15 @@ export function parsePaymentMethod(payment, log, db) {
|
|
|
95
95
|
if (parsed.claim || parsed.claimSecret && parsed.claimAmount && parsed.messageLeafIndex) {
|
|
96
96
|
let claimAmount, claimSecret, messageLeafIndex;
|
|
97
97
|
if (parsed.claim && db) {
|
|
98
|
-
({ amount: claimAmount, secret: claimSecret, leafIndex: messageLeafIndex } = await db.popBridgedFeeJuice(from, log));
|
|
98
|
+
({ amount: claimAmount, secret: claimSecret, leafIndex: messageLeafIndex } = estimateOnly ? await db.peekBridgedFeeJuice(from, log) : await db.popBridgedFeeJuice(from, log));
|
|
99
99
|
} else {
|
|
100
100
|
({ claimAmount, claimSecret, messageLeafIndex } = parsed);
|
|
101
101
|
}
|
|
102
102
|
log(`Using Fee Juice for fee payments with claim for ${claimAmount} tokens`);
|
|
103
103
|
const { FeeJuicePaymentMethodWithClaim } = await import('@aztec/aztec.js/fee');
|
|
104
104
|
return new FeeJuicePaymentMethodWithClaim(from, {
|
|
105
|
-
claimAmount: (typeof claimAmount === 'string' ? Fr.
|
|
106
|
-
claimSecret: Fr.
|
|
105
|
+
claimAmount: (typeof claimAmount === 'string' ? Fr.fromString(claimAmount) : new Fr(claimAmount)).toBigInt(),
|
|
106
|
+
claimSecret: typeof claimSecret === 'string' ? Fr.fromString(claimSecret) : claimSecret,
|
|
107
107
|
messageLeafIndex: BigInt(messageLeafIndex)
|
|
108
108
|
});
|
|
109
109
|
} else {
|
|
@@ -115,6 +115,7 @@ export function parsePaymentMethod(payment, log, db) {
|
|
|
115
115
|
{
|
|
116
116
|
const fpc = getFpc();
|
|
117
117
|
const asset = getAsset();
|
|
118
|
+
log(`WARNING: fpc-public is deprecated and will not work on mainnet alpha. Use fee_juice or fpc-sponsored instead.`);
|
|
118
119
|
log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
119
120
|
const { PublicFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
120
121
|
return new PublicFeePaymentMethod(fpc, from, wallet, gasSettings);
|
|
@@ -123,6 +124,7 @@ export function parsePaymentMethod(payment, log, db) {
|
|
|
123
124
|
{
|
|
124
125
|
const fpc = getFpc();
|
|
125
126
|
const asset = getAsset();
|
|
127
|
+
log(`WARNING: fpc-private is deprecated and will not work on mainnet alpha. Use fee_juice or fpc-sponsored instead.`);
|
|
126
128
|
log(`Using private fee payment with asset ${asset} via paymaster ${fpc}`);
|
|
127
129
|
const { PrivateFeePaymentMethod } = await import('@aztec/aztec.js/fee');
|
|
128
130
|
return new PrivateFeePaymentMethod(fpc, from, wallet, gasSettings);
|
|
@@ -190,8 +192,9 @@ export class CLIFeeArgs {
|
|
|
190
192
|
this.gasSettings = gasSettings;
|
|
191
193
|
}
|
|
192
194
|
async toUserFeeOptions(node, wallet, from) {
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
+
const minFees = await this.getMinFees(node);
|
|
196
|
+
const maxFeesPerGas = minFees.mul(1 + MIN_FEE_PADDING);
|
|
197
|
+
const gasSettings = GasSettings.fallback({
|
|
195
198
|
...this.gasSettings,
|
|
196
199
|
maxFeesPerGas
|
|
197
200
|
});
|
|
@@ -201,8 +204,28 @@ export class CLIFeeArgs {
|
|
|
201
204
|
gasSettings
|
|
202
205
|
};
|
|
203
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
209
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
210
|
+
*/ async getMinFees(node) {
|
|
211
|
+
try {
|
|
212
|
+
const predicted = await node.getPredictedMinFees(ManaUsageEstimate.Limit);
|
|
213
|
+
if (predicted.length === 0) {
|
|
214
|
+
return node.getCurrentMinFees();
|
|
215
|
+
}
|
|
216
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
219
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
220
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
221
|
+
return node.getCurrentMinFees();
|
|
222
|
+
}
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
204
226
|
static parse(args, log, db) {
|
|
205
|
-
|
|
227
|
+
const estimateOnly = !!args.estimateGasOnly;
|
|
228
|
+
return new CLIFeeArgs(estimateOnly, parsePaymentMethod(args.payment ?? 'method=fee_juice', log, db, estimateOnly), parseGasSettings(args));
|
|
206
229
|
}
|
|
207
230
|
static getOptions() {
|
|
208
231
|
return getFeeOptions();
|
|
@@ -217,7 +240,7 @@ function formatGasEstimate(estimate) {
|
|
|
217
240
|
return `da=${estimate.gasLimits.daGas},l2=${estimate.gasLimits.l2Gas},teardownDA=${estimate.teardownGasLimits.daGas},teardownL2=${estimate.teardownGasLimits.l2Gas}`;
|
|
218
241
|
}
|
|
219
242
|
function getEstimatedCost(estimate, maxFeesPerGas) {
|
|
220
|
-
return GasSettings.
|
|
243
|
+
return GasSettings.fallback({
|
|
221
244
|
...estimate,
|
|
222
245
|
maxFeesPerGas
|
|
223
246
|
}).getFeeLimit().toBigInt();
|
|
@@ -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 aliasedSecretKeyParser(sk: string, db?: WalletDB): import("
|
|
11
|
+
export declare function aliasedSecretKeyParser(sk: string, db?: WalletDB): import("@aztec/foundation/schemas").Fr;
|
|
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,eyJ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LENBRTVGIn0=
|
|
@@ -1 +1 @@
|
|
|
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;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,iBAYpE;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,gBAQ5F;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ
|
|
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,E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B,8BAA8B,CAClD,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,EACpC,eAAe,EAAE,YAAY,EAC7B,EAAE,CAAC,EAAE,QAAQ,mBAWd;AAED,wBAAgB,oBAAoB,CAAC,EAAE,CAAC,EAAE,QAAQ,UAIjD;AA6BD,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,SAAS,GAAG,WAAW,EAAE,CAE5F"}
|
|
@@ -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=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvcHJvZmlsaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFrQixlQUFlLEVBQXFCLE1BQU0sa0JBQWtCLENBQUM7QUFVekcsd0JBQWdCLGtCQUFrQixDQUNoQyxLQUFLLEVBQUUsWUFBWSxHQUFHLGVBQWUsRUFDckMsR0FBRyxFQUFFLEtBQUssRUFDVixZQUFZLEdBQUUsT0FBZSxFQUM3QixjQUFjLENBQUMsRUFBRSxvQkFBb0IsRUFBRSxRQTJKeEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAUzG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAUzG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,QA2JxC"}
|
package/dest/utils/profiling.js
CHANGED
|
@@ -35,7 +35,7 @@ export function printProfileResult(stats, log, printOracles = false, executionSt
|
|
|
35
35
|
}
|
|
36
36
|
if (stats.nodeRPCCalls) {
|
|
37
37
|
log(format('\nRPC calls:\n'));
|
|
38
|
-
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls)){
|
|
38
|
+
for (const [method, { times }] of Object.entries(stats.nodeRPCCalls.perMethod)){
|
|
39
39
|
const calls = times.length;
|
|
40
40
|
const total = times.reduce((acc, time)=>acc + time, 0);
|
|
41
41
|
const avg = total / calls;
|
|
@@ -43,6 +43,14 @@ export function printProfileResult(stats, log, printOracles = false, executionSt
|
|
|
43
43
|
const max = Math.max(...times);
|
|
44
44
|
log(format(method.padEnd(ORACLE_NAME_PADDING), `${calls} calls`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `${total.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `min: ${min.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `avg: ${avg.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `max: ${max.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH)));
|
|
45
45
|
}
|
|
46
|
+
const { roundTrips } = stats.nodeRPCCalls;
|
|
47
|
+
log(format('\nRound trips (actual blocking waits):\n'));
|
|
48
|
+
log(format('Round trips:'.padEnd(25), `${roundTrips.roundTrips}`.padStart(COLUMN_MAX_WIDTH)));
|
|
49
|
+
log(format('Total blocking time:'.padEnd(25), `${roundTrips.totalBlockingTime.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
50
|
+
if (roundTrips.roundTrips > 0) {
|
|
51
|
+
const avgRoundTrip = roundTrips.totalBlockingTime / roundTrips.roundTrips;
|
|
52
|
+
log(format('Avg round trip:'.padEnd(25), `${avgRoundTrip.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
log(format('\nSync time:'.padEnd(25), `${timings.sync?.toFixed(2)}ms`.padStart(16)));
|
|
48
56
|
log(format('Private simulation time:'.padEnd(25), `${timings.perFunction.reduce((acc, { time })=>acc + time, 0).toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
|
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -2,16 +2,17 @@ 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
4
|
import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
5
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
|
+
import type { NotesFilter } from '@aztec/pxe/client/lazy';
|
|
7
9
|
import type { PXEConfig } from '@aztec/pxe/config';
|
|
8
10
|
import type { PXE } from '@aztec/pxe/server';
|
|
9
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
12
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
11
|
-
import type {
|
|
12
|
-
import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
13
|
+
import type { TxProvingResult } from '@aztec/stdlib/tx';
|
|
13
14
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
14
|
-
import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
|
|
15
|
+
import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
|
|
15
16
|
import type { WalletDB } from '../storage/wallet_db.js';
|
|
16
17
|
import type { AccountType } from './constants.js';
|
|
17
18
|
export declare class CLIWallet extends BaseWallet {
|
|
@@ -27,8 +28,14 @@ export declare class CLIWallet extends BaseWallet {
|
|
|
27
28
|
private createAccount;
|
|
28
29
|
createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
|
|
29
30
|
private getFakeAccountDataFor;
|
|
30
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<
|
|
31
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
32
|
+
/**
|
|
33
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
34
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
35
|
+
*/
|
|
36
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
31
37
|
getContracts(): Promise<AztecAddress[]>;
|
|
32
38
|
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
39
|
+
getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
|
|
33
40
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBaUMsTUFBTSx5QkFBeUIsQ0FBQztBQUN0RixPQUFPLEVBQ0wsS0FBSyxxQkFBcUIsRUFHM0IsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUYsT0FBTyxFQUFFLCtCQUErQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHekUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQz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n0=
|
|
@@ -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,EACL,KAAK,qBAAqB,EAG3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,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;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAA2C,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,qBAAa,SAAU,SAAQ,UAAU;IAMrC,OA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AAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
|
package/dest/utils/wallet.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
2
|
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
3
|
-
import {
|
|
3
|
+
import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/stub/ecdsa';
|
|
4
|
+
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
|
|
4
5
|
import { getIdentities } from '@aztec/accounts/utils';
|
|
5
|
-
import {
|
|
6
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
6
7
|
import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
|
|
7
8
|
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
10
|
+
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
8
11
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
12
|
import { createPXE, getPXEConfig } from '@aztec/pxe/server';
|
|
10
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -28,33 +31,39 @@ export class CLIWallet extends BaseWallet {
|
|
|
28
31
|
}
|
|
29
32
|
async getAccounts() {
|
|
30
33
|
const accounts = await this.db?.listAliases('accounts') ?? [];
|
|
31
|
-
return Promise.resolve(accounts.map(({ key, value })=>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
return Promise.resolve(accounts.map(({ key, value })=>{
|
|
35
|
+
const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key;
|
|
36
|
+
return {
|
|
37
|
+
alias,
|
|
38
|
+
item: AztecAddress.fromString(value)
|
|
39
|
+
};
|
|
40
|
+
}));
|
|
35
41
|
}
|
|
36
42
|
async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
|
|
37
43
|
const executionPayload = ExecutionPayload.empty();
|
|
38
|
-
const feeOptions = await this.completeFeeOptions(
|
|
44
|
+
const feeOptions = await this.completeFeeOptions({
|
|
45
|
+
from,
|
|
46
|
+
feePayer: executionPayload.feePayer,
|
|
47
|
+
gasSettings: increasedFee.gasSettings
|
|
48
|
+
});
|
|
39
49
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
40
50
|
const fromAccount = await this.getAccountFromAddress(from);
|
|
51
|
+
const chainInfo = await this.getChainInfo();
|
|
41
52
|
const executionOptions = {
|
|
42
53
|
txNonce,
|
|
43
54
|
cancellable: this.cancellableTransactions,
|
|
55
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
44
56
|
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
45
57
|
};
|
|
46
|
-
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, executionOptions);
|
|
58
|
+
return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
47
59
|
}
|
|
48
60
|
async proveCancellationTx(from, txNonce, increasedFee) {
|
|
49
61
|
const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
|
|
50
|
-
return await this.pxe.proveTx(cancellationTxRequest);
|
|
62
|
+
return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
|
|
51
63
|
}
|
|
52
64
|
async getAccountFromAddress(address) {
|
|
53
65
|
let account;
|
|
54
|
-
if (address.
|
|
55
|
-
const chainInfo = await this.getChainInfo();
|
|
56
|
-
account = new SignerlessAccount(chainInfo);
|
|
57
|
-
} else if (this.accountCache.has(address.toString())) {
|
|
66
|
+
if (this.accountCache.has(address.toString())) {
|
|
58
67
|
return this.accountCache.get(address.toString());
|
|
59
68
|
} else {
|
|
60
69
|
const accountManager = await this.createOrRetrieveAccount(address);
|
|
@@ -118,62 +127,88 @@ export class CLIWallet extends BaseWallet {
|
|
|
118
127
|
}
|
|
119
128
|
return account;
|
|
120
129
|
}
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Creates a stub account that impersonates the given address, allowing kernelless simulations
|
|
132
|
+
* to bypass the account's authorization mechanisms via contract overrides.
|
|
133
|
+
* @param address - The address of the account to impersonate
|
|
134
|
+
* @returns The stub account, contract instance, and artifact for simulation
|
|
135
|
+
*/ async getFakeAccountDataFor(address) {
|
|
123
136
|
const originalAccount = await this.getAccountFromAddress(address);
|
|
124
137
|
const originalAddress = originalAccount.getCompleteAddress();
|
|
125
|
-
const
|
|
138
|
+
const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
|
|
126
139
|
if (!contractInstance) {
|
|
127
140
|
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
|
|
128
141
|
}
|
|
129
|
-
const
|
|
130
|
-
const
|
|
142
|
+
const { type } = await this.db.retrieveAccount(address);
|
|
143
|
+
const isSchnorr = type === 'schnorr';
|
|
144
|
+
const artifact = isSchnorr ? StubSchnorrAccountContractArtifact : StubEcdsaAccountContractArtifact;
|
|
145
|
+
const stubAccount = isSchnorr ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
|
|
146
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, {
|
|
131
147
|
salt: Fr.random()
|
|
132
148
|
});
|
|
133
149
|
return {
|
|
134
150
|
account: stubAccount,
|
|
135
151
|
instance,
|
|
136
|
-
artifact
|
|
152
|
+
artifact
|
|
137
153
|
};
|
|
138
154
|
}
|
|
139
155
|
async simulateTx(executionPayload, opts) {
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
/**
|
|
169
|
+
* Uses a stub account for kernelless simulation, bypassing real account authorization.
|
|
170
|
+
* Uses DefaultEntrypoint directly for NO_FROM transactions.
|
|
171
|
+
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
172
|
+
const { from, feeOptions, additionalScopes } = opts;
|
|
173
|
+
const scopes = this.scopesFrom(from, additionalScopes);
|
|
142
174
|
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
143
|
-
const executionOptions = {
|
|
144
|
-
txNonce: Fr.random(),
|
|
145
|
-
cancellable: this.cancellableTransactions,
|
|
146
|
-
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
147
|
-
};
|
|
148
175
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
149
176
|
feeExecutionPayload,
|
|
150
177
|
executionPayload
|
|
151
178
|
]) : executionPayload;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
simulationResults = await this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
|
|
179
|
+
const chainInfo = await this.getChainInfo();
|
|
180
|
+
let overrides;
|
|
181
|
+
let txRequest;
|
|
182
|
+
if (from === NO_FROM) {
|
|
183
|
+
const entrypoint = new DefaultEntrypoint();
|
|
184
|
+
txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
|
|
159
185
|
} else {
|
|
160
|
-
const { account
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
|
|
187
|
+
overrides = {
|
|
188
|
+
contracts: {
|
|
189
|
+
[from.toString()]: {
|
|
190
|
+
instance,
|
|
191
|
+
artifact
|
|
192
|
+
}
|
|
166
193
|
}
|
|
167
194
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
195
|
+
const executionOptions = {
|
|
196
|
+
txNonce: Fr.random(),
|
|
197
|
+
cancellable: this.cancellableTransactions,
|
|
198
|
+
// If from is an address, feeOptions include the way the account contract should handle the fee payment
|
|
199
|
+
feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
|
|
200
|
+
};
|
|
201
|
+
txRequest = await account.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
|
|
175
202
|
}
|
|
176
|
-
|
|
203
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
204
|
+
simulatePublic: true,
|
|
205
|
+
skipFeeEnforcement: true,
|
|
206
|
+
skipTxValidation: true,
|
|
207
|
+
overrides,
|
|
208
|
+
scopes
|
|
209
|
+
});
|
|
210
|
+
const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
|
|
211
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
177
212
|
}
|
|
178
213
|
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
179
214
|
// this is just a CLI wallet.
|
|
@@ -185,4 +220,9 @@ export class CLIWallet extends BaseWallet {
|
|
|
185
220
|
getNotes(filter) {
|
|
186
221
|
return this.pxe.debug.getNotes(filter);
|
|
187
222
|
}
|
|
223
|
+
// Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
|
|
224
|
+
// this is just a CLI wallet.
|
|
225
|
+
getContractArtifact(id) {
|
|
226
|
+
return this.pxe.getContractArtifact(id);
|
|
227
|
+
}
|
|
188
228
|
}
|