@aztec/wallet-sdk 0.0.1-commit.9ef841308 → 0.0.1-commit.a89ec08
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 +26 -31
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +54 -37
- package/dest/base-wallet/index.d.ts +2 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- 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 +77 -62
- package/src/base-wallet/index.ts +6 -1
- package/src/base-wallet/utils.ts +6 -4
|
@@ -2,12 +2,11 @@ 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';
|
|
9
9
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
10
|
-
import { type AccessScopes } from '@aztec/pxe/client/lazy';
|
|
11
10
|
import type { PXE } from '@aztec/pxe/server';
|
|
12
11
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
13
12
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -15,7 +14,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
15
14
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
15
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
17
16
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
18
|
-
import { type TxExecutionRequest, type TxProfileResult,
|
|
17
|
+
import { type TxExecutionRequest, type TxProfileResult, type UtilityExecutionResult } from '@aztec/stdlib/tx';
|
|
19
18
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
20
19
|
/**
|
|
21
20
|
* Options to configure fee payment for a transaction
|
|
@@ -35,8 +34,17 @@ export type FeeOptions = {
|
|
|
35
34
|
export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'additionalScopes' | 'skipTxValidation' | 'skipFeeEnforcement'> & {
|
|
36
35
|
/** Fee options for the entrypoint */
|
|
37
36
|
feeOptions: FeeOptions;
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
};
|
|
38
|
+
/** Options for `completeFeeOptions`. */
|
|
39
|
+
export type CompleteFeeOptionsConfig = {
|
|
40
|
+
/** The address where the transaction is being sent from. */
|
|
41
|
+
from: AztecAddress | NoFrom;
|
|
42
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
43
|
+
feePayer?: AztecAddress;
|
|
44
|
+
/** User-provided partial gas settings. */
|
|
45
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
46
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
47
|
+
forEstimation?: boolean;
|
|
40
48
|
};
|
|
41
49
|
/**
|
|
42
50
|
* A base class for Wallet implementations
|
|
@@ -47,6 +55,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
47
55
|
protected log: import("@aztec/foundation/log").Logger;
|
|
48
56
|
protected minFeePadding: number;
|
|
49
57
|
protected cancellableTransactions: boolean;
|
|
58
|
+
private nodeInfoPromise;
|
|
50
59
|
protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
|
|
51
60
|
protected scopesFrom(from: AztecAddress | NoFrom, additionalScopes?: AztecAddress[]): AztecAddress[];
|
|
52
61
|
protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
|
|
@@ -79,30 +88,9 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
79
88
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
80
89
|
/**
|
|
81
90
|
* Completes partial user-provided fee options with wallet defaults.
|
|
82
|
-
* @param
|
|
83
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
84
|
-
* @param gasSettings - User-provided partial gas settings
|
|
85
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
86
|
-
*/
|
|
87
|
-
protected completeFeeOptions(from: AztecAddress | NoFrom, feePayer?: AztecAddress, gasSettings?: Partial<FieldsOf<GasSettings>>): Promise<FeeOptions>;
|
|
88
|
-
/**
|
|
89
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
90
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
91
|
-
* to avoid running out of gas during estimation.
|
|
92
|
-
* @param from - The address where the transaction is being sent from
|
|
93
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
94
|
-
* @param gasSettings - User-provided partial gas settings
|
|
91
|
+
* @param config - Fee completion config.
|
|
95
92
|
*/
|
|
96
|
-
protected
|
|
97
|
-
/**
|
|
98
|
-
* A wallet-provided fallback fee payment method that is used only if the transaction that is being constructed
|
|
99
|
-
* doesn't already include one
|
|
100
|
-
*/
|
|
101
|
-
walletFeePaymentMethod?: FeePaymentMethod | undefined;
|
|
102
|
-
/** Configuration options for the account to properly handle the selected fee payment method */
|
|
103
|
-
accountFeePaymentMethodOptions?: AccountFeePaymentMethodOptions | undefined;
|
|
104
|
-
gasSettings: GasSettings;
|
|
105
|
-
}>;
|
|
93
|
+
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
106
94
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
107
95
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
108
96
|
/**
|
|
@@ -110,7 +98,14 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
110
98
|
* @param executionPayload - The execution payload to simulate.
|
|
111
99
|
* @param opts - Simulation options.
|
|
112
100
|
*/
|
|
113
|
-
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<
|
|
101
|
+
protected simulateViaEntrypoint(executionPayload: ExecutionPayload, opts: SimulateViaEntrypointOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
102
|
+
/**
|
|
103
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
104
|
+
* calls, N+1 = app).
|
|
105
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
106
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
107
|
+
*/
|
|
108
|
+
protected computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number>;
|
|
114
109
|
/**
|
|
115
110
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
116
111
|
* on the node while sending the remaining calls through the standard PXE path.
|
|
@@ -119,7 +114,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
119
114
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
120
115
|
* @returns The merged simulation result.
|
|
121
116
|
*/
|
|
122
|
-
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<
|
|
117
|
+
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
|
|
123
118
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
124
119
|
sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
|
|
125
120
|
/**
|
|
@@ -146,4 +141,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
146
141
|
isContractClassPubliclyRegistered: boolean;
|
|
147
142
|
}>;
|
|
148
143
|
}
|
|
149
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
144
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sRUFDTCxLQUFLLE9BQU8sRUFDWixLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssYUFBYSxFQUNsQiw0Q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
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/base-wallet/base_wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,UAAU,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,+BAA+B,EAC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AC,CAAC,SAAS,sBAAsB,GAAG,SAAS,EAC9D,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAsCxB;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,8 +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';
|
|
5
|
-
import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
4
|
+
import { ContractInitializationStatus, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
|
|
6
5
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
7
6
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
8
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -12,7 +11,7 @@ import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
|
12
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
12
|
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
14
13
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
15
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
14
|
+
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
16
15
|
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
|
|
17
16
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
18
17
|
import { inspect } from 'util';
|
|
@@ -25,6 +24,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
25
24
|
log;
|
|
26
25
|
minFeePadding;
|
|
27
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;
|
|
28
30
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
29
31
|
constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
|
|
30
32
|
this.pxe = pxe;
|
|
@@ -57,7 +59,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
57
59
|
}));
|
|
58
60
|
}
|
|
59
61
|
async getChainInfo() {
|
|
60
|
-
|
|
62
|
+
if (!this.nodeInfoPromise) {
|
|
63
|
+
this.nodeInfoPromise = this.aztecNode.getNodeInfo();
|
|
64
|
+
}
|
|
65
|
+
const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
|
|
61
66
|
return {
|
|
62
67
|
chainId: new Fr(l1ChainId),
|
|
63
68
|
version: new Fr(rollupVersion)
|
|
@@ -125,11 +130,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
132
|
* Completes partial user-provided fee options with wallet defaults.
|
|
128
|
-
* @param
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
132
|
-
*/ async completeFeeOptions(from, feePayer, gasSettings) {
|
|
133
|
+
* @param config - Fee completion config.
|
|
134
|
+
*/ async completeFeeOptions(config) {
|
|
135
|
+
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
133
136
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
134
137
|
let accountFeePaymentMethodOptions;
|
|
135
138
|
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
@@ -145,10 +148,15 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
145
148
|
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
const gasSettingsOverrides = {
|
|
152
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
153
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
154
|
+
maxFeesPerGas,
|
|
155
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty()
|
|
156
|
+
};
|
|
157
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
158
|
+
// When sending for real, use protocol max limits that the network will actually accept.
|
|
159
|
+
const fullGasSettings = forEstimation ? GasSettings.forEstimation(gasSettingsOverrides) : GasSettings.fallback(gasSettingsOverrides);
|
|
152
160
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
153
161
|
return {
|
|
154
162
|
gasSettings: fullGasSettings,
|
|
@@ -156,24 +164,6 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
156
164
|
accountFeePaymentMethodOptions
|
|
157
165
|
};
|
|
158
166
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
161
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
162
|
-
* to avoid running out of gas during estimation.
|
|
163
|
-
* @param from - The address where the transaction is being sent from
|
|
164
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
165
|
-
* @param gasSettings - User-provided partial gas settings
|
|
166
|
-
*/ async completeFeeOptionsForEstimation(from, feePayer, gasSettings) {
|
|
167
|
-
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
168
|
-
const { gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas } } = defaultFeeOptions;
|
|
169
|
-
// Use unrealistically high gas limits for estimation to avoid running out of gas.
|
|
170
|
-
// They will be tuned down after the simulation.
|
|
171
|
-
const gasSettingsForEstimation = new GasSettings(new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT), new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT), maxFeesPerGas, maxPriorityFeesPerGas);
|
|
172
|
-
return {
|
|
173
|
-
...defaultFeeOptions,
|
|
174
|
-
gasSettings: gasSettingsForEstimation
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
167
|
registerSender(address, _alias = '') {
|
|
178
168
|
return this.pxe.registerSender(address);
|
|
179
169
|
}
|
|
@@ -215,12 +205,26 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
215
205
|
* @param opts - Simulation options.
|
|
216
206
|
*/ async simulateViaEntrypoint(executionPayload, opts) {
|
|
217
207
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
|
|
218
|
-
|
|
208
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
219
209
|
simulatePublic: true,
|
|
220
210
|
skipTxValidation: opts.skipTxValidation,
|
|
221
211
|
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
222
|
-
scopes: opts.
|
|
212
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes)
|
|
223
213
|
});
|
|
214
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
215
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
219
|
+
* calls, N+1 = app).
|
|
220
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
221
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
222
|
+
*/ async computeAppCallOffset(from, feeOptions) {
|
|
223
|
+
if (from === NO_FROM) {
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
227
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
224
228
|
}
|
|
225
229
|
/**
|
|
226
230
|
* Simulates a transaction, optimizing leading public static calls by running them directly
|
|
@@ -230,7 +234,12 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
230
234
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
231
235
|
* @returns The merged simulation result.
|
|
232
236
|
*/ async simulateTx(executionPayload, opts) {
|
|
233
|
-
const feeOptions =
|
|
237
|
+
const feeOptions = await this.completeFeeOptions({
|
|
238
|
+
from: opts.from,
|
|
239
|
+
feePayer: executionPayload.feePayer,
|
|
240
|
+
gasSettings: opts.fee?.gasSettings,
|
|
241
|
+
forEstimation: true
|
|
242
|
+
});
|
|
234
243
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
235
244
|
const remainingPayload = {
|
|
236
245
|
...executionPayload,
|
|
@@ -251,7 +260,7 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
251
260
|
remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
|
|
252
261
|
from: opts.from,
|
|
253
262
|
feeOptions,
|
|
254
|
-
|
|
263
|
+
additionalScopes: opts.additionalScopes,
|
|
255
264
|
skipTxValidation: opts.skipTxValidation,
|
|
256
265
|
skipFeeEnforcement: opts.skipFeeEnforcement ?? true
|
|
257
266
|
}) : Promise.resolve(null)
|
|
@@ -259,7 +268,11 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
259
268
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
260
269
|
}
|
|
261
270
|
async profileTx(executionPayload, opts) {
|
|
262
|
-
const feeOptions = await this.completeFeeOptions(
|
|
271
|
+
const feeOptions = await this.completeFeeOptions({
|
|
272
|
+
from: opts.from,
|
|
273
|
+
feePayer: executionPayload.feePayer,
|
|
274
|
+
gasSettings: opts.fee?.gasSettings
|
|
275
|
+
});
|
|
263
276
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
264
277
|
return this.pxe.profileTx(txRequest, {
|
|
265
278
|
profileMode: opts.profileMode,
|
|
@@ -268,7 +281,11 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
268
281
|
});
|
|
269
282
|
}
|
|
270
283
|
async sendTx(executionPayload, opts) {
|
|
271
|
-
const feeOptions = await this.completeFeeOptions(
|
|
284
|
+
const feeOptions = await this.completeFeeOptions({
|
|
285
|
+
from: opts.from,
|
|
286
|
+
feePayer: executionPayload.feePayer,
|
|
287
|
+
gasSettings: opts.fee?.gasSettings
|
|
288
|
+
});
|
|
272
289
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
273
290
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
274
291
|
const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { BaseWallet, type FeeOptions, type SimulateViaEntrypointOptions } from './base_wallet.js';
|
|
1
|
+
export { BaseWallet, type CompleteFeeOptionsConfig, type FeeOptions, type SimulateViaEntrypointOptions, } from './base_wallet.js';
|
|
2
2
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsVUFBVSxFQUNWLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssVUFBVSxFQUNmLEtBQUssNEJBQTRCLEdBQ2xDLE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsK0JBQ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ozs7Ozs7OztHQVNHO0FBQ0gsd0JBQWdCLDJCQUEyQixDQUN6QyxnQkFBZ0IsRUFBRSxrQkFBa0IsRUFBRSxFQUN0QyxZQUFZLEVBQUUsK0JBQStCLEdBQUcsSUFBSSxHQUNuRCwrQkFBK0IsQ0FxQmpDIn0=
|
|
@@ -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.a89ec08",
|
|
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.a89ec08",
|
|
79
|
+
"@aztec/constants": "0.0.1-commit.a89ec08",
|
|
80
|
+
"@aztec/entrypoints": "0.0.1-commit.a89ec08",
|
|
81
|
+
"@aztec/foundation": "0.0.1-commit.a89ec08",
|
|
82
|
+
"@aztec/pxe": "0.0.1-commit.a89ec08",
|
|
83
|
+
"@aztec/stdlib": "0.0.1-commit.a89ec08"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.a89ec08",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/node": "^22.15.17",
|
|
@@ -21,22 +21,17 @@ 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';
|
|
27
|
-
import {
|
|
28
|
-
GAS_ESTIMATION_DA_GAS_LIMIT,
|
|
29
|
-
GAS_ESTIMATION_L2_GAS_LIMIT,
|
|
30
|
-
GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT,
|
|
31
|
-
GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT,
|
|
32
|
-
} from '@aztec/constants';
|
|
33
28
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
34
29
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
35
30
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
36
31
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
37
32
|
import { createLogger } from '@aztec/foundation/log';
|
|
38
33
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
39
|
-
import {
|
|
34
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
40
35
|
import type { PXE, PackedPrivateEvent } from '@aztec/pxe/server';
|
|
41
36
|
import {
|
|
42
37
|
type ContractArtifact,
|
|
@@ -48,11 +43,12 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
48
43
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
49
44
|
import {
|
|
50
45
|
type ContractInstanceWithAddress,
|
|
46
|
+
type NodeInfo,
|
|
51
47
|
computePartialAddress,
|
|
52
48
|
getContractClassFromArtifact,
|
|
53
49
|
} from '@aztec/stdlib/contract';
|
|
54
50
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
55
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
51
|
+
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
56
52
|
import {
|
|
57
53
|
computeSiloedPrivateInitializationNullifier,
|
|
58
54
|
computeSiloedPublicInitializationNullifier,
|
|
@@ -62,7 +58,6 @@ import {
|
|
|
62
58
|
BlockHeader,
|
|
63
59
|
type TxExecutionRequest,
|
|
64
60
|
type TxProfileResult,
|
|
65
|
-
TxSimulationResult,
|
|
66
61
|
type UtilityExecutionResult,
|
|
67
62
|
} from '@aztec/stdlib/tx';
|
|
68
63
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
@@ -93,15 +88,29 @@ export type SimulateViaEntrypointOptions = Pick<
|
|
|
93
88
|
> & {
|
|
94
89
|
/** Fee options for the entrypoint */
|
|
95
90
|
feeOptions: FeeOptions;
|
|
96
|
-
/** Scopes to use for the simulation */
|
|
97
|
-
scopes: AccessScopes;
|
|
98
91
|
};
|
|
92
|
+
|
|
93
|
+
/** Options for `completeFeeOptions`. */
|
|
94
|
+
export type CompleteFeeOptionsConfig = {
|
|
95
|
+
/** The address where the transaction is being sent from. */
|
|
96
|
+
from: AztecAddress | NoFrom;
|
|
97
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
98
|
+
feePayer?: AztecAddress;
|
|
99
|
+
/** User-provided partial gas settings. */
|
|
100
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
101
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
102
|
+
forEstimation?: boolean;
|
|
103
|
+
};
|
|
104
|
+
|
|
99
105
|
/**
|
|
100
106
|
* A base class for Wallet implementations
|
|
101
107
|
*/
|
|
102
108
|
export abstract class BaseWallet implements Wallet {
|
|
103
109
|
protected minFeePadding = 0.5;
|
|
104
110
|
protected cancellableTransactions = false;
|
|
111
|
+
// A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
|
|
112
|
+
// We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
|
|
113
|
+
private nodeInfoPromise: Promise<NodeInfo> | undefined;
|
|
105
114
|
|
|
106
115
|
// Protected because we want to force wallets to instantiate their own PXE.
|
|
107
116
|
protected constructor(
|
|
@@ -133,7 +142,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
133
142
|
}
|
|
134
143
|
|
|
135
144
|
async getChainInfo(): Promise<ChainInfo> {
|
|
136
|
-
|
|
145
|
+
if (!this.nodeInfoPromise) {
|
|
146
|
+
this.nodeInfoPromise = this.aztecNode.getNodeInfo();
|
|
147
|
+
}
|
|
148
|
+
const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
|
|
137
149
|
return { chainId: new Fr(l1ChainId), version: new Fr(rollupVersion) };
|
|
138
150
|
}
|
|
139
151
|
|
|
@@ -214,16 +226,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
214
226
|
|
|
215
227
|
/**
|
|
216
228
|
* Completes partial user-provided fee options with wallet defaults.
|
|
217
|
-
* @param
|
|
218
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
219
|
-
* @param gasSettings - User-provided partial gas settings
|
|
220
|
-
* @returns - Complete fee options that can be used to create a transaction execution request
|
|
229
|
+
* @param config - Fee completion config.
|
|
221
230
|
*/
|
|
222
|
-
protected async completeFeeOptions(
|
|
223
|
-
from
|
|
224
|
-
feePayer?: AztecAddress,
|
|
225
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
226
|
-
): Promise<FeeOptions> {
|
|
231
|
+
protected async completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions> {
|
|
232
|
+
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
227
233
|
const maxFeesPerGas =
|
|
228
234
|
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
229
235
|
let accountFeePaymentMethodOptions;
|
|
@@ -242,7 +248,17 @@ export abstract class BaseWallet implements Wallet {
|
|
|
242
248
|
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
|
-
const
|
|
251
|
+
const gasSettingsOverrides = {
|
|
252
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
253
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
254
|
+
maxFeesPerGas,
|
|
255
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty(),
|
|
256
|
+
};
|
|
257
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
258
|
+
// When sending for real, use protocol max limits that the network will actually accept.
|
|
259
|
+
const fullGasSettings = forEstimation
|
|
260
|
+
? GasSettings.forEstimation(gasSettingsOverrides)
|
|
261
|
+
: GasSettings.fallback(gasSettingsOverrides);
|
|
246
262
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
247
263
|
return {
|
|
248
264
|
gasSettings: fullGasSettings,
|
|
@@ -251,37 +267,6 @@ export abstract class BaseWallet implements Wallet {
|
|
|
251
267
|
};
|
|
252
268
|
}
|
|
253
269
|
|
|
254
|
-
/**
|
|
255
|
-
* Completes partial user-provided fee options with unreasonably high gas limits
|
|
256
|
-
* for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
|
|
257
|
-
* to avoid running out of gas during estimation.
|
|
258
|
-
* @param from - The address where the transaction is being sent from
|
|
259
|
-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
|
|
260
|
-
* @param gasSettings - User-provided partial gas settings
|
|
261
|
-
*/
|
|
262
|
-
protected async completeFeeOptionsForEstimation(
|
|
263
|
-
from: AztecAddress | NoFrom,
|
|
264
|
-
feePayer?: AztecAddress,
|
|
265
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
266
|
-
) {
|
|
267
|
-
const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
|
|
268
|
-
const {
|
|
269
|
-
gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas },
|
|
270
|
-
} = defaultFeeOptions;
|
|
271
|
-
// Use unrealistically high gas limits for estimation to avoid running out of gas.
|
|
272
|
-
// They will be tuned down after the simulation.
|
|
273
|
-
const gasSettingsForEstimation = new GasSettings(
|
|
274
|
-
new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT),
|
|
275
|
-
new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT),
|
|
276
|
-
maxFeesPerGas,
|
|
277
|
-
maxPriorityFeesPerGas,
|
|
278
|
-
);
|
|
279
|
-
return {
|
|
280
|
-
...defaultFeeOptions,
|
|
281
|
-
gasSettings: gasSettingsForEstimation,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
|
|
285
270
|
registerSender(address: AztecAddress, _alias: string = ''): Promise<AztecAddress> {
|
|
286
271
|
return this.pxe.registerSender(address);
|
|
287
272
|
}
|
|
@@ -335,12 +320,28 @@ export abstract class BaseWallet implements Wallet {
|
|
|
335
320
|
opts.from,
|
|
336
321
|
opts.feeOptions,
|
|
337
322
|
);
|
|
338
|
-
|
|
323
|
+
const result = await this.pxe.simulateTx(txRequest, {
|
|
339
324
|
simulatePublic: true,
|
|
340
325
|
skipTxValidation: opts.skipTxValidation,
|
|
341
326
|
skipFeeEnforcement: opts.skipFeeEnforcement,
|
|
342
|
-
scopes: opts.
|
|
327
|
+
scopes: this.scopesFrom(opts.from, opts.additionalScopes),
|
|
343
328
|
});
|
|
329
|
+
const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
|
|
330
|
+
return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
|
|
335
|
+
* calls, N+1 = app).
|
|
336
|
+
* @param from - The sender address, or NO_FROM for the default entrypoint.
|
|
337
|
+
* @param feeOptions - Fee options containing the wallet fee payment method.
|
|
338
|
+
*/
|
|
339
|
+
protected async computeAppCallOffset(from: AztecAddress | NoFrom, feeOptions: FeeOptions): Promise<number> {
|
|
340
|
+
if (from === NO_FROM) {
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
343
|
+
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
|
|
344
|
+
return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
/**
|
|
@@ -351,10 +352,16 @@ export abstract class BaseWallet implements Wallet {
|
|
|
351
352
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
352
353
|
* @returns The merged simulation result.
|
|
353
354
|
*/
|
|
354
|
-
async simulateTx(
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
async simulateTx(
|
|
356
|
+
executionPayload: ExecutionPayload,
|
|
357
|
+
opts: SimulateOptions,
|
|
358
|
+
): Promise<TxSimulationResultWithAppOffset> {
|
|
359
|
+
const feeOptions = await this.completeFeeOptions({
|
|
360
|
+
from: opts.from,
|
|
361
|
+
feePayer: executionPayload.feePayer,
|
|
362
|
+
gasSettings: opts.fee?.gasSettings,
|
|
363
|
+
forEstimation: true,
|
|
364
|
+
});
|
|
358
365
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
359
366
|
const remainingPayload = { ...executionPayload, calls: remainingCalls };
|
|
360
367
|
|
|
@@ -386,7 +393,7 @@ export abstract class BaseWallet implements Wallet {
|
|
|
386
393
|
? this.simulateViaEntrypoint(remainingPayload, {
|
|
387
394
|
from: opts.from,
|
|
388
395
|
feeOptions,
|
|
389
|
-
|
|
396
|
+
additionalScopes: opts.additionalScopes,
|
|
390
397
|
skipTxValidation: opts.skipTxValidation,
|
|
391
398
|
skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
|
|
392
399
|
})
|
|
@@ -397,7 +404,11 @@ export abstract class BaseWallet implements Wallet {
|
|
|
397
404
|
}
|
|
398
405
|
|
|
399
406
|
async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
|
|
400
|
-
const feeOptions = await this.completeFeeOptions(
|
|
407
|
+
const feeOptions = await this.completeFeeOptions({
|
|
408
|
+
from: opts.from,
|
|
409
|
+
feePayer: executionPayload.feePayer,
|
|
410
|
+
gasSettings: opts.fee?.gasSettings,
|
|
411
|
+
});
|
|
401
412
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
402
413
|
return this.pxe.profileTx(txRequest, {
|
|
403
414
|
profileMode: opts.profileMode,
|
|
@@ -410,7 +421,11 @@ export abstract class BaseWallet implements Wallet {
|
|
|
410
421
|
executionPayload: ExecutionPayload,
|
|
411
422
|
opts: SendOptions<W>,
|
|
412
423
|
): Promise<SendReturn<W>> {
|
|
413
|
-
const feeOptions = await this.completeFeeOptions(
|
|
424
|
+
const feeOptions = await this.completeFeeOptions({
|
|
425
|
+
from: opts.from,
|
|
426
|
+
feePayer: executionPayload.feePayer,
|
|
427
|
+
gasSettings: opts.fee?.gasSettings,
|
|
428
|
+
});
|
|
414
429
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
415
430
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
416
431
|
const offchainOutput = extractOffchainOutput(
|
package/src/base-wallet/index.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
BaseWallet,
|
|
3
|
+
type CompleteFeeOptionsConfig,
|
|
4
|
+
type FeeOptions,
|
|
5
|
+
type SimulateViaEntrypointOptions,
|
|
6
|
+
} from './base_wallet.js';
|
|
2
7
|
export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
|
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
|
}
|