@aztec/wallet-sdk 0.0.1-commit.f650c0a5c → 0.0.1-commit.f7ea82942
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/base-wallet/base_wallet.d.ts +25 -9
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +54 -11
- package/dest/base-wallet/utils.d.ts +3 -2
- package/dest/base-wallet/utils.d.ts.map +1 -1
- package/dest/base-wallet/utils.js +3 -1
- package/package.json +8 -8
- package/src/base-wallet/base_wallet.ts +67 -12
- package/src/base-wallet/utils.ts +6 -4
|
@@ -2,7 +2,7 @@ import type { Account, NoFrom } from '@aztec/aztec.js/account';
|
|
|
2
2
|
import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
5
|
-
import { type Aliased, type AppCapabilities, type BatchResults, type BatchedMethod, ContractInitializationStatus, type ExecuteUtilityOptions, type PrivateEvent, type PrivateEventFilter, type ProfileOptions, type SendOptions, type SimulateOptions, type Wallet, type WalletCapabilities } from '@aztec/aztec.js/wallet';
|
|
5
|
+
import { type Aliased, type AppCapabilities, type BatchResults, type BatchedMethod, ContractInitializationStatus, type ExecuteUtilityOptions, type PrivateEvent, type PrivateEventFilter, type ProfileOptions, type SendOptions, type SimulateOptions, TxSimulationResultWithAppOffset, type Wallet, type WalletCapabilities } from '@aztec/aztec.js/wallet';
|
|
6
6
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
7
7
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -12,10 +12,9 @@ import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall
|
|
|
12
12
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
13
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
14
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
15
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
15
|
+
import { GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
16
16
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
17
|
-
import { type TxExecutionRequest, type TxProfileResult,
|
|
18
|
-
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
17
|
+
import { ExecutionPayload, type TxExecutionRequest, type TxProfileResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
19
18
|
/**
|
|
20
19
|
* Options to configure fee payment for a transaction
|
|
21
20
|
*/
|
|
@@ -34,8 +33,6 @@ export type FeeOptions = {
|
|
|
34
33
|
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
35
34
|
/** Fee options for the entrypoint */
|
|
36
35
|
feeOptions: FeeOptions;
|
|
37
|
-
/** Scopes to use for the simulation */
|
|
38
|
-
scopes: AztecAddress[];
|
|
39
36
|
};
|
|
40
37
|
/** Options for `completeFeeOptions`. */
|
|
41
38
|
export type CompleteFeeOptionsConfig = {
|
|
@@ -47,6 +44,11 @@ export type CompleteFeeOptionsConfig = {
|
|
|
47
44
|
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
48
45
|
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
49
46
|
forEstimation?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Assumed network congestion level for fee prediction. Controls how aggressively the wallet
|
|
49
|
+
* estimates future fees. Defaults to Limit (worst case) when not specified.
|
|
50
|
+
*/
|
|
51
|
+
congestionEstimate?: ManaUsageEstimate;
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
52
54
|
* A base class for Wallet implementations
|
|
@@ -57,6 +59,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
57
59
|
protected log: import("@aztec/foundation/log").Logger;
|
|
58
60
|
protected minFeePadding: number;
|
|
59
61
|
protected cancellableTransactions: boolean;
|
|
62
|
+
private nodeInfoPromise;
|
|
60
63
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
61
64
|
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
62
65
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
@@ -92,6 +95,12 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
92
95
|
* @param config - Fee completion config.
|
|
93
96
|
*/
|
|
94
97
|
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
100
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
101
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
102
|
+
*/
|
|
103
|
+
protected getMinFees(estimate?: ManaUsageEstimate): Promise<GasFees>;
|
|
95
104
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
96
105
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
97
106
|
/**
|
|
@@ -99,7 +108,14 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
99
108
|
* @param executionPayload - The execution payload to simulate.
|
|
100
109
|
* @param opts - Simulation options.
|
|
101
110
|
*/
|
|
102
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<
|
|
111
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
112
|
+
/**
|
|
113
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
114
|
+
* calls, N+1 = app).
|
|
115
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
116
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
117
|
+
*/
|
|
118
|
+
protected computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number>;
|
|
103
119
|
/**
|
|
104
120
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
105
121
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -108,7 +124,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
108
124
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
109
125
|
* @returns The merged simulation result.
|
|
110
126
|
*/
|
|
111
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<
|
|
127
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
112
128
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
113
129
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
114
130
|
/**
|
|
@@ -135,4 +151,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
135
151
|
isContractClassPubliclyRegistered: boolean;
|
|
136
152
|
}>;
|
|
137
153
|
}
|
|
138
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
154
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUU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AI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAalG;IAEY,MAAM,CAAC,CAAC,SAAS,sBAAsB,GAAG,SAAS,EAC9D,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAuCxB;IAED;;;OAGG;IACH,UAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAOlF;IAED,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAYpE;IAED,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAE/F;IAEK,gBAAgB,CAAC,CAAC,EACtB,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,kBAAkB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAe5B;IAED;;;OAGG;IACG,mBAAmB,CAAC,OAAO,EAAE,YAAY;;;;;;OAiC9C;IAEK,wBAAwB,CAAC,EAAE,EAAE,EAAE;;;OAMpC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
2
|
import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
|
|
3
3
|
import { waitForTx } from '@aztec/aztec.js/node';
|
|
4
|
-
import { ContractInitializationStatus } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { ContractInitializationStatus, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
5
5
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
6
6
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
7
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -11,7 +11,7 @@ import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
|
11
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
13
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
14
|
-
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
14
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
15
15
|
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
16
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
17
17
|
import { inspect } from 'util';
|
|
@@ -24,6 +24,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
24
24
|
log;
|
|
25
25
|
minFeePadding;
|
|
26
26
|
cancellableTransactions;
|
|
27
|
+
// A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
|
|
28
|
+
// We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
|
|
29
|
+
nodeInfoPromise;
|
|
27
30
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
28
31
|
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
29
32
|
this.pxe = pxe;
|
|
@@ -56,7 +59,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
56
59
|
}));
|
|
57
60
|
}
|
|
58
61
|
async getChainInfo() {
|
|
59
|
-
|
|
62
|
+
if (!this.nodeInfoPromise) {
|
|
63
|
+
this.nodeInfoPromise = this.aztecNode.getNodeInfo();
|
|
64
|
+
}
|
|
65
|
+
const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
|
|
60
66
|
return {
|
|
61
67
|
chainId: new Fr(l1ChainId),
|
|
62
68
|
version: new Fr(rollupVersion)
|
|
@@ -126,8 +132,8 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
126
132
|
* Completes partial user-provided fee options with wallet defaults.
|
|
127
133
|
* @param config - Fee completion config.
|
|
128
134
|
*/ async completeFeeOptions(config) {
|
|
129
|
-
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
130
|
-
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.
|
|
135
|
+
const { from, feePayer, gasSettings, forEstimation, congestionEstimate } = config;
|
|
136
|
+
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.getMinFees(congestionEstimate)).mul(1 + this.minFeePadding);
|
|
131
137
|
let accountFeePaymentMethodOptions;
|
|
132
138
|
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
133
139
|
// account contract entrypoint to use
|
|
@@ -158,6 +164,26 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
158
164
|
accountFeePaymentMethodOptions
|
|
159
165
|
};
|
|
160
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
169
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
170
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
171
|
+
*/ async getMinFees(estimate = ManaUsageEstimate.Limit) {
|
|
172
|
+
try {
|
|
173
|
+
const predicted = await this.aztecNode.getPredictedMinFees(estimate);
|
|
174
|
+
if (predicted.length === 0) {
|
|
175
|
+
return this.aztecNode.getCurrentMinFees();
|
|
176
|
+
}
|
|
177
|
+
return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
180
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
181
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
182
|
+
return this.aztecNode.getCurrentMinFees();
|
|
183
|
+
}
|
|
184
|
+
throw err;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
161
187
|
registerSender(address, _alias = '') {
|
|
162
188
|
return this.pxe.registerSender(address);
|
|
163
189
|
}
|
|
@@ -199,12 +225,26 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
199
225
|
* @param opts - Simulation options.
|
|
200
226
|
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
201
227
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
202
|
-
|
|
228
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
203
229
|
simulatePublic: true,
|
|
204
230
|
skipTxValidation: opts.skipTxValidation,
|
|
205
231
|
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
206
|
-
scopes: opts.
|
|
232
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
207
233
|
});
|
|
234
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
235
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
239
|
+
* calls, N+1 = app).
|
|
240
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
241
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
242
|
+
*/ async computeAppCallOffset(from, feeOptions) {
|
|
243
|
+
if (from === NO_FROM) {
|
|
244
|
+
return 0;
|
|
245
|
+
}
|
|
246
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
247
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
208
248
|
}
|
|
209
249
|
/**
|
|
210
250
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
@@ -218,7 +258,8 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
218
258
|
from: opts.from,
|
|
219
259
|
feePayer: executionPayload.feePayer,
|
|
220
260
|
gasSettings: opts.fee?.gasSettings,
|
|
221
|
-
forEstimation: true
|
|
261
|
+
forEstimation: true,
|
|
262
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
222
263
|
});
|
|
223
264
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
224
265
|
const remainingPayload = {
|
|
@@ -240,7 +281,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
240
281
|
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
241
282
|
from: opts.from,
|
|
242
283
|
feeOptions,
|
|
243
|
-
|
|
284
|
+
additionalScopes: opts.additionalScopes,
|
|
244
285
|
skipTxValidation: opts.skipTxValidation,
|
|
245
286
|
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
246
287
|
}) : Promise.resolve(null)
|
|
@@ -251,7 +292,8 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
251
292
|
const feeOptions = await this.completeFeeOptions({
|
|
252
293
|
from: opts.from,
|
|
253
294
|
feePayer: executionPayload.feePayer,
|
|
254
|
-
gasSettings: opts.fee?.gasSettings
|
|
295
|
+
gasSettings: opts.fee?.gasSettings,
|
|
296
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
255
297
|
});
|
|
256
298
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
257
299
|
return this.pxe.profileTx(txRequest, {
|
|
@@ -264,7 +306,8 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
264
306
|
const feeOptions = await this.completeFeeOptions({
|
|
265
307
|
from: opts.from,
|
|
266
308
|
feePayer: executionPayload.feePayer,
|
|
267
|
-
gasSettings: opts.fee?.gasSettings
|
|
309
|
+
gasSettings: opts.fee?.gasSettings,
|
|
310
|
+
congestionEstimate: opts.fee?.congestionEstimate
|
|
268
311
|
});
|
|
269
312
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
270
313
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
3
4
|
import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
|
|
4
5
|
import { type FunctionCall } from '@aztec/stdlib/abi';
|
|
@@ -45,5 +46,5 @@ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: Func
|
|
|
45
46
|
* @param normalResult - Result from normal simulation (null if all calls were optimized).
|
|
46
47
|
* @returns A single TxSimulationResult with return values in original call order.
|
|
47
48
|
*/
|
|
48
|
-
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult:
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxSimulationResultWithAppOffset | null): TxSimulationResultWithAppOffset;
|
|
50
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsK0JBQStCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RSxPQUFPLEt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yxnQkFBZ0IsRUFBRSxrQkFBa0IsRUFBRSxFQUN0QyxZQUFZLEVBQUUsK0JBQStCLEdBQUcsSUFBSSxHQUNuRCwrQkFBK0IsQ0FxQmpDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAOrB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,gBAAgB,GAAG;IAC9E,uEAAuE;IACvE,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,2BAA2B;IAC3B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAOA;AAuGD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,EACf,iBAAiB,EAAE,YAAY,EAAE,EACjC,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,kBAAkB,qBAAgB,EAClC,eAAe,EAAE,oBAAoB,GACpC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAwB/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,YAAY,EAAE,+BAA+B,GAAG,IAAI,GACnD,+BAA+B,CAqBjC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
1
2
|
import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
|
|
2
3
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -127,5 +128,6 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
|
|
|
127
128
|
...baseResult.publicOutput,
|
|
128
129
|
publicReturnValues: allReturnValues
|
|
129
130
|
} : undefined;
|
|
130
|
-
|
|
131
|
+
const merged = new TxSimulationResult(baseResult.privateExecutionResult, baseResult.publicInputs, mergedPublicOutput, normalResult?.stats);
|
|
132
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(merged, normalResult?.appCallOffset ?? 0);
|
|
131
133
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/wallet-sdk",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallet-sdk",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.f7ea82942",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./base-wallet": "./dest/base-wallet/index.js",
|
|
@@ -75,15 +75,15 @@
|
|
|
75
75
|
]
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
79
|
-
"@aztec/constants": "0.0.1-commit.
|
|
80
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
81
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
82
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
83
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
78
|
+
"@aztec/aztec.js": "0.0.1-commit.f7ea82942",
|
|
79
|
+
"@aztec/constants": "0.0.1-commit.f7ea82942",
|
|
80
|
+
"@aztec/entrypoints": "0.0.1-commit.f7ea82942",
|
|
81
|
+
"@aztec/foundation": "0.0.1-commit.f7ea82942",
|
|
82
|
+
"@aztec/pxe": "0.0.1-commit.f7ea82942",
|
|
83
|
+
"@aztec/stdlib": "0.0.1-commit.f7ea82942"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f7ea82942",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/node": "^22.15.17",
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type ProfileOptions,
|
|
22
22
|
type SendOptions,
|
|
23
23
|
type SimulateOptions,
|
|
24
|
+
TxSimulationResultWithAppOffset,
|
|
24
25
|
type Wallet,
|
|
25
26
|
type WalletCapabilities,
|
|
26
27
|
} from '@aztec/aztec.js/wallet';
|
|
@@ -42,11 +43,12 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
42
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
43
44
|
import {
|
|
44
45
|
type ContractInstanceWithAddress,
|
|
46
|
+
type NodeInfo,
|
|
45
47
|
computePartialAddress,
|
|
46
48
|
getContractClassFromArtifact,
|
|
47
49
|
} from '@aztec/stdlib/contract';
|
|
48
50
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
49
|
-
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
51
|
+
import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
50
52
|
import {
|
|
51
53
|
computeSiloedPrivateInitializationNullifier,
|
|
52
54
|
computeSiloedPublicInitializationNullifier,
|
|
@@ -54,12 +56,12 @@ import {
|
|
|
54
56
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
55
57
|
import {
|
|
56
58
|
BlockHeader,
|
|
59
|
+
ExecutionPayload,
|
|
57
60
|
type TxExecutionRequest,
|
|
58
61
|
type TxProfileResult,
|
|
59
|
-
TxSimulationResult,
|
|
60
62
|
type UtilityExecutionResult,
|
|
63
|
+
mergeExecutionPayloads,
|
|
61
64
|
} from '@aztec/stdlib/tx';
|
|
62
|
-
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
63
65
|
|
|
64
66
|
import { inspect } from 'util';
|
|
65
67
|
|
|
@@ -87,8 +89,6 @@ export type SimulateViaEntrypointOptions = Pick<
|
|
|
87
89
|
> & {
|
|
88
90
|
/** Fee options for the entrypoint */
|
|
89
91
|
feeOptions: FeeOptions;
|
|
90
|
-
/** Scopes to use for the simulation */
|
|
91
|
-
scopes: AztecAddress[];
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
/** Options for `completeFeeOptions`. */
|
|
@@ -101,6 +101,11 @@ export type CompleteFeeOptionsConfig = {
|
|
|
101
101
|
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
102
102
|
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
103
103
|
forEstimation?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Assumed network congestion level for fee prediction. Controls how aggressively the wallet
|
|
106
|
+
* estimates future fees. Defaults to Limit (worst case) when not specified.
|
|
107
|
+
*/
|
|
108
|
+
congestionEstimate?: ManaUsageEstimate;
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
/**
|
|
@@ -109,6 +114,9 @@ export type CompleteFeeOptionsConfig = {
|
|
|
109
114
|
export abstract class BaseWallet implements Wallet {
|
|
110
115
|
protected minFeePadding = 0.5;
|
|
111
116
|
protected cancellableTransactions = false;
|
|
117
|
+
// A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
|
|
118
|
+
// We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
|
|
119
|
+
private nodeInfoPromise: Promise<NodeInfo> | undefined;
|
|
112
120
|
|
|
113
121
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
114
122
|
protected constructor(
|
|
@@ -140,7 +148,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
async getChainInfo(): Promise<ChainInfo> {
|
|
143
|
-
|
|
151
|
+
if (!this.nodeInfoPromise) {
|
|
152
|
+
this.nodeInfoPromise = this.aztecNode.getNodeInfo();
|
|
153
|
+
}
|
|
154
|
+
const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
|
|
144
155
|
return { chainId: new Fr(l1ChainId), version: new Fr(rollupVersion) };
|
|
145
156
|
}
|
|
146
157
|
|
|
@@ -224,9 +235,9 @@ export abstract class BaseWallet implements Wallet {
|
|
|
224
235
|
* @param config - Fee completion config.
|
|
225
236
|
*/
|
|
226
237
|
protected async completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions> {
|
|
227
|
-
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
238
|
+
const { from, feePayer, gasSettings, forEstimation, congestionEstimate } = config;
|
|
228
239
|
const maxFeesPerGas =
|
|
229
|
-
gasSettings?.maxFeesPerGas ?? (await this.
|
|
240
|
+
gasSettings?.maxFeesPerGas ?? (await this.getMinFees(congestionEstimate)).mul(1 + this.minFeePadding);
|
|
230
241
|
let accountFeePaymentMethodOptions;
|
|
231
242
|
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
232
243
|
// account contract entrypoint to use
|
|
@@ -262,6 +273,28 @@ export abstract class BaseWallet implements Wallet {
|
|
|
262
273
|
};
|
|
263
274
|
}
|
|
264
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Returns the worst-case min fee across predicted future slots.
|
|
278
|
+
* Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
|
|
279
|
+
* @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
|
|
280
|
+
*/
|
|
281
|
+
protected async getMinFees(estimate: ManaUsageEstimate = ManaUsageEstimate.Limit): Promise<GasFees> {
|
|
282
|
+
try {
|
|
283
|
+
const predicted = await this.aztecNode.getPredictedMinFees(estimate);
|
|
284
|
+
if (predicted.length === 0) {
|
|
285
|
+
return this.aztecNode.getCurrentMinFees();
|
|
286
|
+
}
|
|
287
|
+
return predicted.reduce((worst, fees) => (fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst));
|
|
288
|
+
} catch (err: any) {
|
|
289
|
+
// Fallback for old nodes that don't support getPredictedMinFees.
|
|
290
|
+
// Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
|
|
291
|
+
if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
|
|
292
|
+
return this.aztecNode.getCurrentMinFees();
|
|
293
|
+
}
|
|
294
|
+
throw err;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
265
298
|
registerSender(address: AztecAddress, _alias: string = ''): Promise<AztecAddress> {
|
|
266
299
|
return this.pxe.registerSender(address);
|
|
267
300
|
}
|
|
@@ -315,12 +348,28 @@ export abstract class BaseWallet implements Wallet {
|
|
|
315
348
|
opts.from,
|
|
316
349
|
opts.feeOptions,
|
|
317
350
|
);
|
|
318
|
-
|
|
351
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
319
352
|
simulatePublic: true,
|
|
320
353
|
skipTxValidation: opts.skipTxValidation,
|
|
321
354
|
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
322
|
-
scopes: opts.
|
|
355
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
323
356
|
});
|
|
357
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
358
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
363
|
+
* calls, N+1 = app).
|
|
364
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
365
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
366
|
+
*/
|
|
367
|
+
protected async computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number> {
|
|
368
|
+
if (from === NO_FROM) {
|
|
369
|
+
return 0;
|
|
370
|
+
}
|
|
371
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
372
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
324
373
|
}
|
|
325
374
|
|
|
326
375
|
/**
|
|
@@ -331,12 +380,16 @@ export abstract class BaseWallet implements Wallet {
|
|
|
331
380
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
332
381
|
* @returns The merged simulation result.
|
|
333
382
|
*/
|
|
334
|
-
async simulateTx(
|
|
383
|
+
async simulateTx(
|
|
384
|
+
executionPayload: ExecutionPayload,
|
|
385
|
+
opts: SimulateOptions,
|
|
386
|
+
): Promise<TxSimulationResultWithAppOffset> {
|
|
335
387
|
const feeOptions = await this.completeFeeOptions({
|
|
336
388
|
from: opts.from,
|
|
337
389
|
feePayer: executionPayload.feePayer,
|
|
338
390
|
gasSettings: opts.fee?.gasSettings,
|
|
339
391
|
forEstimation: true,
|
|
392
|
+
congestionEstimate: opts.fee?.congestionEstimate,
|
|
340
393
|
});
|
|
341
394
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
342
395
|
const remainingPayload = { ...executionPayload, calls: remainingCalls };
|
|
@@ -369,7 +422,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
369
422
|
? this.simulateViaEntrypoint(remainingPayload, {
|
|
370
423
|
from: opts.from,
|
|
371
424
|
feeOptions,
|
|
372
|
-
|
|
425
|
+
additionalScopes: opts.additionalScopes,
|
|
373
426
|
skipTxValidation: opts.skipTxValidation,
|
|
374
427
|
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
375
428
|
})
|
|
@@ -384,6 +437,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
384
437
|
from: opts.from,
|
|
385
438
|
feePayer: executionPayload.feePayer,
|
|
386
439
|
gasSettings: opts.fee?.gasSettings,
|
|
440
|
+
congestionEstimate: opts.fee?.congestionEstimate,
|
|
387
441
|
});
|
|
388
442
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
389
443
|
return this.pxe.profileTx(txRequest, {
|
|
@@ -401,6 +455,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
401
455
|
from: opts.from,
|
|
402
456
|
feePayer: executionPayload.feePayer,
|
|
403
457
|
gasSettings: opts.fee?.gasSettings,
|
|
458
|
+
congestionEstimate: opts.fee?.congestionEstimate,
|
|
404
459
|
});
|
|
405
460
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
406
461
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
package/src/base-wallet/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
|
|
3
4
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
4
5
|
import { makeTuple } from '@aztec/foundation/array';
|
|
@@ -214,13 +215,13 @@ export async function simulateViaNode(
|
|
|
214
215
|
*/
|
|
215
216
|
export function buildMergedSimulationResult(
|
|
216
217
|
optimizedResults: TxSimulationResult[],
|
|
217
|
-
normalResult:
|
|
218
|
-
):
|
|
218
|
+
normalResult: TxSimulationResultWithAppOffset | null,
|
|
219
|
+
): TxSimulationResultWithAppOffset {
|
|
219
220
|
const optimizedReturnValues = optimizedResults.flatMap(r => r.publicOutput?.publicReturnValues ?? []);
|
|
220
221
|
const normalReturnValues = normalResult?.publicOutput?.publicReturnValues ?? [];
|
|
221
222
|
const allReturnValues = [...optimizedReturnValues, ...normalReturnValues];
|
|
222
223
|
|
|
223
|
-
const baseResult = normalResult ?? optimizedResults[0];
|
|
224
|
+
const baseResult: TxSimulationResult = normalResult ?? optimizedResults[0];
|
|
224
225
|
|
|
225
226
|
const mergedPublicOutput: PublicSimulationOutput | undefined = baseResult.publicOutput
|
|
226
227
|
? {
|
|
@@ -229,10 +230,11 @@ export function buildMergedSimulationResult(
|
|
|
229
230
|
}
|
|
230
231
|
: undefined;
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
const merged = new TxSimulationResult(
|
|
233
234
|
baseResult.privateExecutionResult,
|
|
234
235
|
baseResult.publicInputs,
|
|
235
236
|
mergedPublicOutput,
|
|
236
237
|
normalResult?.stats,
|
|
237
238
|
);
|
|
239
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(merged, normalResult?.appCallOffset ?? 0);
|
|
238
240
|
}
|