@aztec/wallet-sdk 0.0.1-commit.f5d02921e → 0.0.1-commit.f650c0a5c
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 +15 -26
- package/dest/base-wallet/base_wallet.d.ts.map +1 -1
- package/dest/base-wallet/base_wallet.js +29 -32
- package/dest/base-wallet/index.d.ts +2 -2
- package/dest/base-wallet/index.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/base-wallet/base_wallet.ts +46 -55
- package/src/base-wallet/index.ts +6 -1
|
@@ -7,7 +7,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';
|
|
@@ -36,7 +35,18 @@ export type SimulateViaEntrypointOptions = Pick<SimulateOptions, 'from' | 'addit
|
|
|
36
35
|
/** Fee options for the entrypoint */
|
|
37
36
|
feeOptions: FeeOptions;
|
|
38
37
|
/** Scopes to use for the simulation */
|
|
39
|
-
scopes:
|
|
38
|
+
scopes: AztecAddress[];
|
|
39
|
+
};
|
|
40
|
+
/** Options for `completeFeeOptions`. */
|
|
41
|
+
export type CompleteFeeOptionsConfig = {
|
|
42
|
+
/** The address where the transaction is being sent from. */
|
|
43
|
+
from: AztecAddress | NoFrom;
|
|
44
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
45
|
+
feePayer?: AztecAddress;
|
|
46
|
+
/** User-provided partial gas settings. */
|
|
47
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
48
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
49
|
+
forEstimation?: boolean;
|
|
40
50
|
};
|
|
41
51
|
/**
|
|
42
52
|
* A base class for Wallet implementations
|
|
@@ -79,30 +89,9 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
79
89
|
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
80
90
|
/**
|
|
81
91
|
* 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
|
|
92
|
+
* @param config - Fee completion config.
|
|
95
93
|
*/
|
|
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
|
-
}>;
|
|
94
|
+
protected completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions>;
|
|
106
95
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
107
96
|
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
108
97
|
/**
|
|
@@ -146,4 +135,4 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
146
135
|
isContractClassPubliclyRegistered: boolean;
|
|
147
136
|
}>;
|
|
148
137
|
}
|
|
149
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
138
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLGVBQWUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2pGLE9BQU8sRUFDTCxLQUFLLHNCQUFzQixFQUUzQixLQUFLLFVBQVUsRUFFaEIsTUFBTSwyQkFBMkIsQ0FBQztBQUNuQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sRUFDTCxLQUFLLE9BQU8sRUFDWixLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssYUFBYSxFQUNsQiw0QkFBNEIsRUFDNUIsS0FBSyxxQkFBcUIsRUFDMUIsS0FBSyxZQUFZLEVBQ2pCLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssY0FBYyxFQUNuQixLQUFLL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,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"}
|
|
@@ -2,7 +2,6 @@ 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
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';
|
|
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';
|
|
@@ -125,11 +124,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
125
124
|
}
|
|
126
125
|
/**
|
|
127
126
|
* 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) {
|
|
127
|
+
* @param config - Fee completion config.
|
|
128
|
+
*/ async completeFeeOptions(config) {
|
|
129
|
+
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
133
130
|
const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
134
131
|
let accountFeePaymentMethodOptions;
|
|
135
132
|
// If from is an address, we need to determine the appropriate fee payment method options for the
|
|
@@ -145,10 +142,15 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
145
142
|
accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
const gasSettingsOverrides = {
|
|
146
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
147
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
148
|
+
maxFeesPerGas,
|
|
149
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty()
|
|
150
|
+
};
|
|
151
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
152
|
+
// When sending for real, use protocol max limits that the network will actually accept.
|
|
153
|
+
const fullGasSettings = forEstimation ? GasSettings.forEstimation(gasSettingsOverrides) : GasSettings.fallback(gasSettingsOverrides);
|
|
152
154
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
153
155
|
return {
|
|
154
156
|
gasSettings: fullGasSettings,
|
|
@@ -156,24 +158,6 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
156
158
|
accountFeePaymentMethodOptions
|
|
157
159
|
};
|
|
158
160
|
}
|
|
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
161
|
registerSender(address, _alias = '') {
|
|
178
162
|
return this.pxe.registerSender(address);
|
|
179
163
|
}
|
|
@@ -230,7 +214,12 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
230
214
|
* @param opts - Simulation options (from address, fee settings, etc.).
|
|
231
215
|
* @returns The merged simulation result.
|
|
232
216
|
*/ async simulateTx(executionPayload, opts) {
|
|
233
|
-
const feeOptions =
|
|
217
|
+
const feeOptions = await this.completeFeeOptions({
|
|
218
|
+
from: opts.from,
|
|
219
|
+
feePayer: executionPayload.feePayer,
|
|
220
|
+
gasSettings: opts.fee?.gasSettings,
|
|
221
|
+
forEstimation: true
|
|
222
|
+
});
|
|
234
223
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
235
224
|
const remainingPayload = {
|
|
236
225
|
...executionPayload,
|
|
@@ -259,7 +248,11 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
259
248
|
return buildMergedSimulationResult(optimizedResults, normalResult);
|
|
260
249
|
}
|
|
261
250
|
async profileTx(executionPayload, opts) {
|
|
262
|
-
const feeOptions = await this.completeFeeOptions(
|
|
251
|
+
const feeOptions = await this.completeFeeOptions({
|
|
252
|
+
from: opts.from,
|
|
253
|
+
feePayer: executionPayload.feePayer,
|
|
254
|
+
gasSettings: opts.fee?.gasSettings
|
|
255
|
+
});
|
|
263
256
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
264
257
|
return this.pxe.profileTx(txRequest, {
|
|
265
258
|
profileMode: opts.profileMode,
|
|
@@ -268,7 +261,11 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
|
|
|
268
261
|
});
|
|
269
262
|
}
|
|
270
263
|
async sendTx(executionPayload, opts) {
|
|
271
|
-
const feeOptions = await this.completeFeeOptions(
|
|
264
|
+
const feeOptions = await this.completeFeeOptions({
|
|
265
|
+
from: opts.from,
|
|
266
|
+
feePayer: executionPayload.feePayer,
|
|
267
|
+
gasSettings: opts.fee?.gasSettings
|
|
268
|
+
});
|
|
272
269
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
273
270
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
274
271
|
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"}
|
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.f650c0a5c",
|
|
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.f650c0a5c",
|
|
79
|
+
"@aztec/constants": "0.0.1-commit.f650c0a5c",
|
|
80
|
+
"@aztec/entrypoints": "0.0.1-commit.f650c0a5c",
|
|
81
|
+
"@aztec/foundation": "0.0.1-commit.f650c0a5c",
|
|
82
|
+
"@aztec/pxe": "0.0.1-commit.f650c0a5c",
|
|
83
|
+
"@aztec/stdlib": "0.0.1-commit.f650c0a5c"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f650c0a5c",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/node": "^22.15.17",
|
|
@@ -24,19 +24,13 @@ import {
|
|
|
24
24
|
type Wallet,
|
|
25
25
|
type WalletCapabilities,
|
|
26
26
|
} 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
27
|
import { AccountFeePaymentMethodOptions, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
|
|
34
28
|
import { DefaultEntrypoint } from '@aztec/entrypoints/default';
|
|
35
29
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
36
30
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
37
31
|
import { createLogger } from '@aztec/foundation/log';
|
|
38
32
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
39
|
-
import {
|
|
33
|
+
import { displayDebugLogs } from '@aztec/pxe/client/lazy';
|
|
40
34
|
import type { PXE, PackedPrivateEvent } from '@aztec/pxe/server';
|
|
41
35
|
import {
|
|
42
36
|
type ContractArtifact,
|
|
@@ -52,7 +46,7 @@ import {
|
|
|
52
46
|
getContractClassFromArtifact,
|
|
53
47
|
} from '@aztec/stdlib/contract';
|
|
54
48
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
55
|
-
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
49
|
+
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
56
50
|
import {
|
|
57
51
|
computeSiloedPrivateInitializationNullifier,
|
|
58
52
|
computeSiloedPublicInitializationNullifier,
|
|
@@ -94,8 +88,21 @@ export type SimulateViaEntrypointOptions = Pick<
|
|
|
94
88
|
/** Fee options for the entrypoint */
|
|
95
89
|
feeOptions: FeeOptions;
|
|
96
90
|
/** Scopes to use for the simulation */
|
|
97
|
-
scopes:
|
|
91
|
+
scopes: AztecAddress[];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** Options for `completeFeeOptions`. */
|
|
95
|
+
export type CompleteFeeOptionsConfig = {
|
|
96
|
+
/** The address where the transaction is being sent from. */
|
|
97
|
+
from: AztecAddress | NoFrom;
|
|
98
|
+
/** The address paying for fees (if any fee payment method is embedded in the execution payload). */
|
|
99
|
+
feePayer?: AztecAddress;
|
|
100
|
+
/** User-provided partial gas settings. */
|
|
101
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
102
|
+
/** If true, returns gas settings with high gas limits for estimation. If false, uses fallback limits. */
|
|
103
|
+
forEstimation?: boolean;
|
|
98
104
|
};
|
|
105
|
+
|
|
99
106
|
/**
|
|
100
107
|
* A base class for Wallet implementations
|
|
101
108
|
*/
|
|
@@ -214,16 +221,10 @@ export abstract class BaseWallet implements Wallet {
|
|
|
214
221
|
|
|
215
222
|
/**
|
|
216
223
|
* 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
|
|
224
|
+
* @param config - Fee completion config.
|
|
221
225
|
*/
|
|
222
|
-
protected async completeFeeOptions(
|
|
223
|
-
from
|
|
224
|
-
feePayer?: AztecAddress,
|
|
225
|
-
gasSettings?: Partial<FieldsOf<GasSettings>>,
|
|
226
|
-
): Promise<FeeOptions> {
|
|
226
|
+
protected async completeFeeOptions(config: CompleteFeeOptionsConfig): Promise<FeeOptions> {
|
|
227
|
+
const { from, feePayer, gasSettings, forEstimation } = config;
|
|
227
228
|
const maxFeesPerGas =
|
|
228
229
|
gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
|
|
229
230
|
let accountFeePaymentMethodOptions;
|
|
@@ -242,7 +243,17 @@ export abstract class BaseWallet implements Wallet {
|
|
|
242
243
|
: AccountFeePaymentMethodOptions.EXTERNAL;
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
|
-
const
|
|
246
|
+
const gasSettingsOverrides = {
|
|
247
|
+
gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
|
|
248
|
+
teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
|
|
249
|
+
maxFeesPerGas,
|
|
250
|
+
maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty(),
|
|
251
|
+
};
|
|
252
|
+
// When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
|
|
253
|
+
// When sending for real, use protocol max limits that the network will actually accept.
|
|
254
|
+
const fullGasSettings = forEstimation
|
|
255
|
+
? GasSettings.forEstimation(gasSettingsOverrides)
|
|
256
|
+
: GasSettings.fallback(gasSettingsOverrides);
|
|
246
257
|
this.log.debug(`Using L2 gas settings`, fullGasSettings);
|
|
247
258
|
return {
|
|
248
259
|
gasSettings: fullGasSettings,
|
|
@@ -251,37 +262,6 @@ export abstract class BaseWallet implements Wallet {
|
|
|
251
262
|
};
|
|
252
263
|
}
|
|
253
264
|
|
|
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
265
|
registerSender(address: AztecAddress, _alias: string = ''): Promise<AztecAddress> {
|
|
286
266
|
return this.pxe.registerSender(address);
|
|
287
267
|
}
|
|
@@ -352,9 +332,12 @@ export abstract class BaseWallet implements Wallet {
|
|
|
352
332
|
* @returns The merged simulation result.
|
|
353
333
|
*/
|
|
354
334
|
async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
|
|
355
|
-
const feeOptions =
|
|
356
|
-
|
|
357
|
-
:
|
|
335
|
+
const feeOptions = await this.completeFeeOptions({
|
|
336
|
+
from: opts.from,
|
|
337
|
+
feePayer: executionPayload.feePayer,
|
|
338
|
+
gasSettings: opts.fee?.gasSettings,
|
|
339
|
+
forEstimation: true,
|
|
340
|
+
});
|
|
358
341
|
const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
|
|
359
342
|
const remainingPayload = { ...executionPayload, calls: remainingCalls };
|
|
360
343
|
|
|
@@ -397,7 +380,11 @@ export abstract class BaseWallet implements Wallet {
|
|
|
397
380
|
}
|
|
398
381
|
|
|
399
382
|
async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
|
|
400
|
-
const feeOptions = await this.completeFeeOptions(
|
|
383
|
+
const feeOptions = await this.completeFeeOptions({
|
|
384
|
+
from: opts.from,
|
|
385
|
+
feePayer: executionPayload.feePayer,
|
|
386
|
+
gasSettings: opts.fee?.gasSettings,
|
|
387
|
+
});
|
|
401
388
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
402
389
|
return this.pxe.profileTx(txRequest, {
|
|
403
390
|
profileMode: opts.profileMode,
|
|
@@ -410,7 +397,11 @@ export abstract class BaseWallet implements Wallet {
|
|
|
410
397
|
executionPayload: ExecutionPayload,
|
|
411
398
|
opts: SendOptions<W>,
|
|
412
399
|
): Promise<SendReturn<W>> {
|
|
413
|
-
const feeOptions = await this.completeFeeOptions(
|
|
400
|
+
const feeOptions = await this.completeFeeOptions({
|
|
401
|
+
from: opts.from,
|
|
402
|
+
feePayer: executionPayload.feePayer,
|
|
403
|
+
gasSettings: opts.fee?.gasSettings,
|
|
404
|
+
});
|
|
414
405
|
const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
|
|
415
406
|
const provenTx = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
|
|
416
407
|
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';
|