@tetherto/wdk-wallet-evm-erc-4337 1.0.0-beta.7 → 1.0.0-beta.9
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/index.js +2 -1
- package/package.json +11 -11
- package/src/wallet-account-evm-erc-4337.js +43 -58
- package/src/wallet-account-read-only-evm-erc-4337.js +83 -13
- package/types/index.d.ts +2 -1
- package/types/src/wallet-account-evm-erc-4337.d.ts +22 -12
- package/types/src/wallet-account-read-only-evm-erc-4337.d.ts +88 -7
package/index.js
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
/** @typedef {import('@tetherto/wdk-wallet-evm').FeeRates} FeeRates */
|
|
21
21
|
|
|
22
22
|
/** @typedef {import('@tetherto/wdk-wallet-evm').KeyPair} KeyPair */
|
|
23
|
-
/** @typedef {import('
|
|
23
|
+
/** @typedef {import('./src/wallet-account-read-only-evm-erc-4337.js').EvmErc4337Transaction} EvmErc4337Transaction */
|
|
24
|
+
/** @typedef {import('./src/wallet-account-read-only-evm-erc-4337.js').EvmErc4337GasOverrides} EvmErc4337GasOverrides */
|
|
24
25
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransactionResult} TransactionResult */
|
|
25
26
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransferOptions} TransferOptions */
|
|
26
27
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransferResult} TransferResult */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetherto/wdk-wallet-evm-erc-4337",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "A simple package to manage BIP-32 wallets for evm blockchains, which implement the erc-4337 standard and its account abstraction features",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wdk",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@tetherto/wdk-failover-provider": "1.0.0-beta.2",
|
|
33
33
|
"@tetherto/wdk-wallet": "1.0.0-beta.9",
|
|
34
|
-
"@tetherto/wdk-wallet-evm": "1.0.0-beta.
|
|
35
|
-
"abstractionkit": "0.
|
|
36
|
-
"bare-node-runtime": "^1.
|
|
37
|
-
"ethers": "6.
|
|
34
|
+
"@tetherto/wdk-wallet-evm": "1.0.0-beta.13",
|
|
35
|
+
"abstractionkit": "0.4.0",
|
|
36
|
+
"bare-node-runtime": "^1.4.0",
|
|
37
|
+
"ethers": "6.16.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@nomicfoundation/hardhat-ethers": "3.1.0",
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"wait-on": "8.0.4"
|
|
51
51
|
},
|
|
52
52
|
"overrides": {
|
|
53
|
-
"axios": "1.
|
|
54
|
-
"cookie": "1.
|
|
53
|
+
"axios": "1.17.0",
|
|
54
|
+
"cookie": "1.1.1",
|
|
55
55
|
"fast-uri": "3.1.2",
|
|
56
56
|
"@protobufjs/utf8": "1.1.1",
|
|
57
|
-
"protobufjs": "7.
|
|
57
|
+
"protobufjs": "7.6.3",
|
|
58
58
|
"serialize-javascript": "7.0.5",
|
|
59
|
-
"tar": "7.5.
|
|
60
|
-
"tmp": "0.2.
|
|
61
|
-
"undici": "7.
|
|
59
|
+
"tar": "7.5.16",
|
|
60
|
+
"tmp": "0.2.7",
|
|
61
|
+
"undici": "7.26.0"
|
|
62
62
|
},
|
|
63
63
|
"exports": {
|
|
64
64
|
".": {
|
|
@@ -39,12 +39,12 @@ import WalletAccountReadOnlyEvmErc4337, { FEE_TOLERANCE_COEFFICIENT } from './wa
|
|
|
39
39
|
|
|
40
40
|
/** @typedef {import('@tetherto/wdk-wallet-evm').KeyPair} KeyPair */
|
|
41
41
|
|
|
42
|
-
/** @typedef {import('@tetherto/wdk-wallet-evm').EvmTransaction} EvmTransaction */
|
|
43
42
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransactionResult} TransactionResult */
|
|
44
43
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransferOptions} TransferOptions */
|
|
45
44
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransferResult} TransferResult */
|
|
46
45
|
/** @typedef {import('@tetherto/wdk-wallet-evm').ApproveOptions} ApproveOptions */
|
|
47
46
|
|
|
47
|
+
/** @typedef {import('./wallet-account-read-only-evm-erc-4337.js').EvmErc4337Transaction} EvmErc4337Transaction */
|
|
48
48
|
/** @typedef {import('./wallet-account-read-only-evm-erc-4337.js').EvmErc4337WalletConfig} EvmErc4337WalletConfig */
|
|
49
49
|
/** @typedef {import('./wallet-account-read-only-evm-erc-4337.js').EvmErc4337WalletPaymasterTokenConfig} EvmErc4337WalletPaymasterTokenConfig */
|
|
50
50
|
/** @typedef {import('./wallet-account-read-only-evm-erc-4337.js').EvmErc4337WalletSponsorshipPolicyConfig} EvmErc4337WalletSponsorshipPolicyConfig */
|
|
@@ -143,7 +143,7 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
143
143
|
/**
|
|
144
144
|
* Signs a user operation built from the given transaction.
|
|
145
145
|
*
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {EvmErc4337Transaction} tx - The transaction to include in the user operation.
|
|
147
147
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
148
148
|
* @returns {Promise<UserOperationV7>} The signed user operation.
|
|
149
149
|
*/
|
|
@@ -154,11 +154,7 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
154
154
|
this._validateConfig(mergedConfig)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
if (!cached) {
|
|
159
|
-
await this.quoteSendTransaction(tx, config)
|
|
160
|
-
cached = this._consumeCachedQuote(tx)
|
|
161
|
-
}
|
|
157
|
+
const cached = await this._resolveQuote(tx, config)
|
|
162
158
|
|
|
163
159
|
const { userOp } = await this._signUserOperation([tx], { config: mergedConfig, cachedBuild: cached })
|
|
164
160
|
|
|
@@ -171,10 +167,11 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
171
167
|
* Approves a specific amount of tokens to a spender.
|
|
172
168
|
*
|
|
173
169
|
* @param {ApproveOptions} options - The approve options.
|
|
170
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
|
|
174
171
|
* @returns {Promise<TransactionResult>} - The transaction's result.
|
|
175
172
|
* @throws {Error} - If trying to approve usdts on ethereum with allowance not equal to zero (due to the usdt allowance reset requirement).
|
|
176
173
|
*/
|
|
177
|
-
async approve (options) {
|
|
174
|
+
async approve (options, txOverrides) {
|
|
178
175
|
if (!this._ownerAccount._provider) {
|
|
179
176
|
throw new Error('The wallet must be connected to a provider to approve funds.')
|
|
180
177
|
}
|
|
@@ -197,7 +194,8 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
197
194
|
const tx = {
|
|
198
195
|
to: token,
|
|
199
196
|
value: 0,
|
|
200
|
-
data: contract.interface.encodeFunctionData('approve', [spender, amount])
|
|
197
|
+
data: contract.interface.encodeFunctionData('approve', [spender, amount]),
|
|
198
|
+
...txOverrides
|
|
201
199
|
}
|
|
202
200
|
|
|
203
201
|
return await this.sendTransaction(tx)
|
|
@@ -206,10 +204,14 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
206
204
|
/**
|
|
207
205
|
* Quotes the costs of a send transaction operation.
|
|
208
206
|
*
|
|
209
|
-
* The result is cached internally for up to 2 minutes.
|
|
210
|
-
* same transaction
|
|
207
|
+
* The result is cached internally for up to 2 minutes. A subsequent `sendTransaction` with the
|
|
208
|
+
* same transaction reuses the cached operation — skipping the gas-estimation and paymaster
|
|
209
|
+
* round-trips — after a lightweight on-chain nonce check, re-quoting only if the nonce has moved.
|
|
210
|
+
*
|
|
211
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
212
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
211
213
|
*
|
|
212
|
-
* @param {
|
|
214
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
213
215
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
214
216
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
215
217
|
*/
|
|
@@ -245,7 +247,10 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
245
247
|
/**
|
|
246
248
|
* Sends a transaction.
|
|
247
249
|
*
|
|
248
|
-
*
|
|
250
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
251
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
252
|
+
*
|
|
253
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
249
254
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
250
255
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
251
256
|
*/
|
|
@@ -256,18 +261,12 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
256
261
|
this._validateConfig(mergedConfig)
|
|
257
262
|
}
|
|
258
263
|
|
|
259
|
-
|
|
260
|
-
if (!cached) {
|
|
261
|
-
await this.quoteSendTransaction(tx, config)
|
|
262
|
-
cached = this._consumeCachedQuote(tx)
|
|
263
|
-
}
|
|
264
|
+
const cached = await this._resolveQuote(tx, config)
|
|
264
265
|
|
|
265
266
|
const fee = cached.fee
|
|
266
267
|
|
|
267
268
|
const hash = await this._sendUserOperation([tx].flat(), { config: mergedConfig, cachedBuild: cached })
|
|
268
269
|
|
|
269
|
-
await this._bumpCachedNonces()
|
|
270
|
-
|
|
271
270
|
return { hash, fee }
|
|
272
271
|
}
|
|
273
272
|
|
|
@@ -276,9 +275,10 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
276
275
|
*
|
|
277
276
|
* @param {TransferOptions} options - The transfer's options.
|
|
278
277
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
278
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
|
|
279
279
|
* @returns {Promise<TransferResult>} The transfer's result.
|
|
280
280
|
*/
|
|
281
|
-
async transfer (options, config) {
|
|
281
|
+
async transfer (options, config, txOverrides) {
|
|
282
282
|
const mergedConfig = { ...this._config, ...config }
|
|
283
283
|
|
|
284
284
|
if (config) {
|
|
@@ -287,13 +287,10 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
287
287
|
|
|
288
288
|
const { isSponsored, transferMaxFee } = mergedConfig
|
|
289
289
|
|
|
290
|
-
const
|
|
290
|
+
const baseTx = await WalletAccountEvm._getTransferTransaction(options)
|
|
291
|
+
const tx = { ...baseTx, ...txOverrides }
|
|
291
292
|
|
|
292
|
-
|
|
293
|
-
if (!cached) {
|
|
294
|
-
await this.quoteSendTransaction(tx, config)
|
|
295
|
-
cached = this._consumeCachedQuote(tx)
|
|
296
|
-
}
|
|
293
|
+
const cached = await this._resolveQuote(tx, config)
|
|
297
294
|
|
|
298
295
|
const fee = cached.fee
|
|
299
296
|
|
|
@@ -303,8 +300,6 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
303
300
|
|
|
304
301
|
const hash = await this._sendUserOperation([tx], { config: mergedConfig, cachedBuild: cached })
|
|
305
302
|
|
|
306
|
-
await this._bumpCachedNonces()
|
|
307
|
-
|
|
308
303
|
return { hash, fee }
|
|
309
304
|
}
|
|
310
305
|
|
|
@@ -329,34 +324,20 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
329
324
|
}
|
|
330
325
|
|
|
331
326
|
/** @private */
|
|
332
|
-
async
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
try {
|
|
347
|
-
const { userOp } = await this._applyPaymasterToUserOp({
|
|
348
|
-
mode,
|
|
349
|
-
smartAccount: quote.smartAccount,
|
|
350
|
-
userOp: quote.userOp,
|
|
351
|
-
config: this._config,
|
|
352
|
-
chainId: quote.chainId
|
|
353
|
-
})
|
|
354
|
-
quote.userOp = userOp
|
|
355
|
-
} catch {
|
|
356
|
-
this._quoteCache.delete(txKey)
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}))
|
|
327
|
+
async _resolveQuote (tx, config) {
|
|
328
|
+
let cached = this._consumeCachedQuote(tx)
|
|
329
|
+
|
|
330
|
+
if (cached?.userOp) {
|
|
331
|
+
const onChainNonce = await fetchAccountNonce(this._provider, cached.smartAccount.entrypointAddress, cached.smartAccount.accountAddress)
|
|
332
|
+
if (cached.userOp.nonce !== onChainNonce) cached = undefined
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (!cached) {
|
|
336
|
+
await this.quoteSendTransaction(tx, config)
|
|
337
|
+
cached = this._consumeCachedQuote(tx)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return cached
|
|
360
341
|
}
|
|
361
342
|
|
|
362
343
|
/** @private */
|
|
@@ -386,7 +367,11 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
386
367
|
async _signUserOperation (txs, { config, cachedBuild }) {
|
|
387
368
|
const { userOp, smartAccount, chainId } = cachedBuild?.userOp
|
|
388
369
|
? cachedBuild
|
|
389
|
-
: await this._buildUserOperation(
|
|
370
|
+
: await this._buildUserOperation(
|
|
371
|
+
WalletAccountReadOnlyEvmErc4337._toMetaTransactions(txs),
|
|
372
|
+
config,
|
|
373
|
+
WalletAccountReadOnlyEvmErc4337._extractGasOverrides(txs[0])
|
|
374
|
+
)
|
|
390
375
|
|
|
391
376
|
const signer = {
|
|
392
377
|
address: this._ownerAccountAddress,
|
|
@@ -48,7 +48,6 @@ export const FEE_TOLERANCE_COEFFICIENT = 120n
|
|
|
48
48
|
|
|
49
49
|
/** @typedef {import('ethers').Eip1193Provider} Eip1193Provider */
|
|
50
50
|
|
|
51
|
-
/** @typedef {import('@tetherto/wdk-wallet-evm').EvmTransaction} EvmTransaction */
|
|
52
51
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransactionResult} TransactionResult */
|
|
53
52
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransferOptions} TransferOptions */
|
|
54
53
|
/** @typedef {import('@tetherto/wdk-wallet-evm').TransferResult} TransferResult */
|
|
@@ -70,6 +69,35 @@ export const FEE_TOLERANCE_COEFFICIENT = 120n
|
|
|
70
69
|
* @property {TokenQuote} [tokenQuote] - The paymaster token quote, present only in token mode.
|
|
71
70
|
*/
|
|
72
71
|
|
|
72
|
+
/**
|
|
73
|
+
* An EVM transaction shape used to build an ERC-4337 UserOperation.
|
|
74
|
+
*
|
|
75
|
+
* @typedef {Object} EvmErc4337Transaction
|
|
76
|
+
* @property {string} to - The call's recipient.
|
|
77
|
+
* @property {number | bigint} value - The amount of native coin to send to the recipient (in wei).
|
|
78
|
+
* @property {string} [data] - The call's data in hex format.
|
|
79
|
+
* @property {number | bigint} [callGasLimit] - If set, overrides the user operations' call gas limit.
|
|
80
|
+
* @property {number | bigint} [verificationGasLimit] - If set, overrides the user operations' verification gas limit.
|
|
81
|
+
* @property {number | bigint} [preVerificationGas] - If set, overrides the user operations' pre-verification gas.
|
|
82
|
+
* @property {number | bigint} [maxFeePerGas] - If set, overrides the user operations' max fee per gas (EIP-1559 cap). Treated as a pair with `maxPriorityFeePerGas`: setting either disables the bundler-fetched fee fallback for both.
|
|
83
|
+
* @property {number | bigint} [maxPriorityFeePerGas] - If set, overrides the user operations' max priority fee per gas. Treated as a pair with `maxFeePerGas`: setting either disables the bundler-fetched fee fallback for both.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Gas-related UserOperationV7 overrides, coerced to `bigint`.
|
|
88
|
+
*
|
|
89
|
+
* Produced by `_extractGasOverrides` from an `EvmErc4337Transaction` and threaded into
|
|
90
|
+
* `_buildUserOperation`. All fields are optional; absent fields fall back to the bundler-fetched
|
|
91
|
+
* gas price (fee pair) or AbstractionKit's gas estimation (gas limits).
|
|
92
|
+
*
|
|
93
|
+
* @typedef {Object} EvmErc4337GasOverrides
|
|
94
|
+
* @property {bigint} [callGasLimit] - Override for the UserOperation's call gas limit.
|
|
95
|
+
* @property {bigint} [verificationGasLimit] - Override for the UserOperation's verification gas limit.
|
|
96
|
+
* @property {bigint} [preVerificationGas] - Override for the UserOperation's pre-verification gas.
|
|
97
|
+
* @property {bigint} [maxFeePerGas] - Override for the UserOperation's max fee per gas (EIP-1559 cap).
|
|
98
|
+
* @property {bigint} [maxPriorityFeePerGas] - Override for the UserOperation's max priority fee per gas.
|
|
99
|
+
*/
|
|
100
|
+
|
|
73
101
|
/**
|
|
74
102
|
* @typedef {Object} OnChainIdentifier
|
|
75
103
|
* @property {string} project - The project name included in the 50-byte on-chain marker.
|
|
@@ -268,7 +296,10 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
268
296
|
* The result is cached internally for up to 2 minutes. If `sendTransaction` is called with the
|
|
269
297
|
* same transaction within that window, the cached fee is reused without an additional RPC round-trip.
|
|
270
298
|
*
|
|
271
|
-
*
|
|
299
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
300
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
301
|
+
*
|
|
302
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
272
303
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
273
304
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
274
305
|
* @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
|
|
@@ -302,12 +333,14 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
302
333
|
*
|
|
303
334
|
* @param {TransferOptions} options - The transfer's options.
|
|
304
335
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
336
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
|
|
305
337
|
* @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
|
|
306
338
|
* @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
|
|
307
339
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
308
340
|
*/
|
|
309
|
-
async quoteTransfer (options, config) {
|
|
310
|
-
const
|
|
341
|
+
async quoteTransfer (options, config, txOverrides) {
|
|
342
|
+
const baseTx = await WalletAccountReadOnlyEvm._getTransferTransaction(options)
|
|
343
|
+
const tx = { ...baseTx, ...txOverrides }
|
|
311
344
|
|
|
312
345
|
const result = await this.quoteSendTransaction(tx, config)
|
|
313
346
|
|
|
@@ -541,7 +574,7 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
541
574
|
* Converts EVM transactions to AbstractionKit MetaTransaction calls.
|
|
542
575
|
*
|
|
543
576
|
* @protected
|
|
544
|
-
* @param {
|
|
577
|
+
* @param {EvmErc4337Transaction[]} txs - The transactions to convert.
|
|
545
578
|
* @returns {MetaTransaction[]} The calls array for createUserOperation.
|
|
546
579
|
*/
|
|
547
580
|
static _toMetaTransactions (txs) {
|
|
@@ -585,9 +618,10 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
585
618
|
* @protected
|
|
586
619
|
* @param {MetaTransaction[]} calls - The meta-transactions to include in the UserOperation.
|
|
587
620
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration.
|
|
621
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - Optional UserOperationV7 gas overrides extracted from the input transaction(s).
|
|
588
622
|
* @returns {Promise<BuiltUserOperation>} The built operation, signing context, and (in token mode) the paymaster quote.
|
|
589
623
|
*/
|
|
590
|
-
async _buildUserOperation (calls, config) {
|
|
624
|
+
async _buildUserOperation (calls, config, txOverrides = {}) {
|
|
591
625
|
const smartAccount = await this._getSmartAccount(config)
|
|
592
626
|
const chainId = await this._getChainId()
|
|
593
627
|
|
|
@@ -598,37 +632,68 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
598
632
|
|
|
599
633
|
const gasPrice = await this._fetchBundlerGasPrice(config.bundlerUrl)
|
|
600
634
|
|
|
635
|
+
const feePairOverridden = txOverrides.maxFeePerGas !== undefined || txOverrides.maxPriorityFeePerGas !== undefined
|
|
636
|
+
const overrides = feePairOverridden
|
|
637
|
+
? { ...txOverrides }
|
|
638
|
+
: { ...gasPrice, ...txOverrides }
|
|
639
|
+
|
|
601
640
|
const baseUserOp = (mode === PaymasterMode.NATIVE || provider === 'candide')
|
|
602
|
-
? await smartAccount.createUserOperation(calls, this._provider, config.bundlerUrl,
|
|
603
|
-
: await smartAccount.createUserOperation(calls, this._provider, undefined, { skipGasEstimation: true, ...
|
|
641
|
+
? await smartAccount.createUserOperation(calls, this._provider, config.bundlerUrl, overrides)
|
|
642
|
+
: await smartAccount.createUserOperation(calls, this._provider, undefined, { skipGasEstimation: true, ...overrides })
|
|
604
643
|
|
|
605
644
|
if (mode === PaymasterMode.NATIVE) {
|
|
606
645
|
return { userOp: baseUserOp, smartAccount, mode, chainId }
|
|
607
646
|
}
|
|
608
647
|
|
|
609
648
|
const { userOp, tokenQuote } = await this._applyPaymasterToUserOp({
|
|
610
|
-
mode, smartAccount, userOp: baseUserOp, config, chainId
|
|
649
|
+
mode, smartAccount, userOp: baseUserOp, config, chainId, txOverrides
|
|
611
650
|
})
|
|
612
651
|
return { userOp, smartAccount, mode, chainId, tokenQuote }
|
|
613
652
|
}
|
|
614
653
|
|
|
654
|
+
/**
|
|
655
|
+
* Extracts the optional UserOperationV7 gas overrides from a single transaction.
|
|
656
|
+
*
|
|
657
|
+
* Only the fields actually consumed by AbstractionKit's `CreateUserOperationOverrides`
|
|
658
|
+
* are picked. Numeric values are coerced to bigint.
|
|
659
|
+
*
|
|
660
|
+
* @protected
|
|
661
|
+
* @param {EvmErc4337Transaction} [tx] - The transaction to read overrides from.
|
|
662
|
+
* @returns {EvmErc4337GasOverrides} The overrides object (empty if `tx` is falsy or has no override fields).
|
|
663
|
+
*/
|
|
664
|
+
static _extractGasOverrides (tx) {
|
|
665
|
+
const overrides = {}
|
|
666
|
+
if (!tx) return overrides
|
|
667
|
+
|
|
668
|
+
const fields = ['callGasLimit', 'verificationGasLimit', 'preVerificationGas', 'maxFeePerGas', 'maxPriorityFeePerGas']
|
|
669
|
+
for (const field of fields) {
|
|
670
|
+
if (tx[field] !== undefined) overrides[field] = BigInt(tx[field])
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return overrides
|
|
674
|
+
}
|
|
675
|
+
|
|
615
676
|
/**
|
|
616
677
|
* Builds a UserOperation and returns its estimated gas cost.
|
|
617
678
|
*
|
|
618
679
|
* Returns the cost in the paymaster token when a token quote is available, otherwise in
|
|
619
680
|
* native wei. Used by `quoteSendTransaction` and reused by `sendTransaction` via the cache.
|
|
620
681
|
*
|
|
682
|
+
* In a batched call, only `txs[0]`'s gas overrides are honored — a UserOperation
|
|
683
|
+
* carries a single set of gas fields regardless of how many calls it batches.
|
|
684
|
+
*
|
|
621
685
|
* @protected
|
|
622
|
-
* @param {
|
|
686
|
+
* @param {EvmErc4337Transaction[]} txs - The EVM transactions to include in the UserOperation.
|
|
623
687
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration to use for the build.
|
|
624
688
|
* @returns {Promise<BuiltUserOperation & Omit<TransactionResult, 'hash'>>} The built operation plus its raw fee (no tolerance buffer applied).
|
|
625
689
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
626
690
|
*/
|
|
627
691
|
async _getUserOperationGasCost (txs, config) {
|
|
628
692
|
const calls = WalletAccountReadOnlyEvmErc4337._toMetaTransactions(txs)
|
|
693
|
+
const txOverrides = WalletAccountReadOnlyEvmErc4337._extractGasOverrides(txs[0])
|
|
629
694
|
|
|
630
695
|
try {
|
|
631
|
-
const buildResult = await this._buildUserOperation(calls, config)
|
|
696
|
+
const buildResult = await this._buildUserOperation(calls, config, txOverrides)
|
|
632
697
|
|
|
633
698
|
const fee = buildResult.tokenQuote
|
|
634
699
|
? buildResult.tokenQuote.tokenCost
|
|
@@ -677,19 +742,24 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
677
742
|
}
|
|
678
743
|
|
|
679
744
|
/** @private */
|
|
680
|
-
async _applyPaymasterToUserOp ({ mode, smartAccount, userOp, config, chainId }) {
|
|
745
|
+
async _applyPaymasterToUserOp ({ mode, smartAccount, userOp, config, chainId, txOverrides = {} }) {
|
|
681
746
|
const erc7677 = this._getPaymaster(config.paymasterUrl, { chainId: BigInt(chainId) })
|
|
682
747
|
|
|
683
748
|
const context = mode === PaymasterMode.TOKEN
|
|
684
749
|
? { token: config.paymasterToken.address }
|
|
685
750
|
: { sponsorshipPolicyId: config.sponsorshipPolicyId }
|
|
686
751
|
|
|
752
|
+
const paymasterOverrides = { entrypoint: ENTRYPOINT_V7 }
|
|
753
|
+
if (txOverrides.callGasLimit !== undefined) paymasterOverrides.callGasLimit = txOverrides.callGasLimit
|
|
754
|
+
if (txOverrides.verificationGasLimit !== undefined) paymasterOverrides.verificationGasLimit = txOverrides.verificationGasLimit
|
|
755
|
+
if (txOverrides.preVerificationGas !== undefined) paymasterOverrides.preVerificationGas = txOverrides.preVerificationGas
|
|
756
|
+
|
|
687
757
|
const result = await erc7677.createPaymasterUserOperation(
|
|
688
758
|
smartAccount,
|
|
689
759
|
userOp,
|
|
690
760
|
config.bundlerUrl,
|
|
691
761
|
context,
|
|
692
|
-
|
|
762
|
+
paymasterOverrides
|
|
693
763
|
)
|
|
694
764
|
|
|
695
765
|
return { userOp: result.userOperation, tokenQuote: result.tokenQuote }
|
package/types/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export type UserOperationReceipt = import("./src/wallet-account-read-only-evm-er
|
|
|
6
6
|
export type BuiltUserOperation = import("./src/wallet-account-read-only-evm-erc-4337.js").BuiltUserOperation;
|
|
7
7
|
export type FeeRates = import("@tetherto/wdk-wallet-evm").FeeRates;
|
|
8
8
|
export type KeyPair = import("@tetherto/wdk-wallet-evm").KeyPair;
|
|
9
|
-
export type
|
|
9
|
+
export type EvmErc4337Transaction = import("./src/wallet-account-read-only-evm-erc-4337.js").EvmErc4337Transaction;
|
|
10
|
+
export type EvmErc4337GasOverrides = import("./src/wallet-account-read-only-evm-erc-4337.js").EvmErc4337GasOverrides;
|
|
10
11
|
export type TransactionResult = import("@tetherto/wdk-wallet-evm").TransactionResult;
|
|
11
12
|
export type TransferOptions = import("@tetherto/wdk-wallet-evm").TransferOptions;
|
|
12
13
|
export type TransferResult = import("@tetherto/wdk-wallet-evm").TransferResult;
|
|
@@ -58,46 +58,55 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
58
58
|
/**
|
|
59
59
|
* Signs a user operation built from the given transaction.
|
|
60
60
|
*
|
|
61
|
-
* @param {
|
|
61
|
+
* @param {EvmErc4337Transaction} tx - The transaction to include in the user operation.
|
|
62
62
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
63
63
|
* @returns {Promise<UserOperationV7>} The signed user operation.
|
|
64
64
|
*/
|
|
65
|
-
signTransaction(tx:
|
|
65
|
+
signTransaction(tx: EvmErc4337Transaction, config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<UserOperationV7>;
|
|
66
66
|
/**
|
|
67
67
|
* Approves a specific amount of tokens to a spender.
|
|
68
68
|
*
|
|
69
69
|
* @param {ApproveOptions} options - The approve options.
|
|
70
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
|
|
70
71
|
* @returns {Promise<TransactionResult>} - The transaction's result.
|
|
71
72
|
* @throws {Error} - If trying to approve usdts on ethereum with allowance not equal to zero (due to the usdt allowance reset requirement).
|
|
72
73
|
*/
|
|
73
|
-
approve(options: ApproveOptions): Promise<TransactionResult>;
|
|
74
|
+
approve(options: ApproveOptions, txOverrides?: EvmErc4337GasOverrides): Promise<TransactionResult>;
|
|
74
75
|
/**
|
|
75
76
|
* Quotes the costs of a send transaction operation.
|
|
76
77
|
*
|
|
77
|
-
* The result is cached internally for up to 2 minutes.
|
|
78
|
-
* same transaction
|
|
78
|
+
* The result is cached internally for up to 2 minutes. A subsequent `sendTransaction` with the
|
|
79
|
+
* same transaction reuses the cached operation — skipping the gas-estimation and paymaster
|
|
80
|
+
* round-trips — after a lightweight on-chain nonce check, re-quoting only if the nonce has moved.
|
|
79
81
|
*
|
|
80
|
-
*
|
|
82
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
83
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
84
|
+
*
|
|
85
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
81
86
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
82
87
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
83
88
|
*/
|
|
84
|
-
quoteSendTransaction(tx:
|
|
89
|
+
quoteSendTransaction(tx: EvmErc4337Transaction | EvmErc4337Transaction[], config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<Omit<TransactionResult, "hash">>;
|
|
85
90
|
/**
|
|
86
91
|
* Sends a transaction.
|
|
87
92
|
*
|
|
88
|
-
*
|
|
93
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
94
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
95
|
+
*
|
|
96
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
89
97
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
90
98
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
91
99
|
*/
|
|
92
|
-
sendTransaction(tx:
|
|
100
|
+
sendTransaction(tx: EvmErc4337Transaction | EvmErc4337Transaction[], config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<TransactionResult>;
|
|
93
101
|
/**
|
|
94
102
|
* Transfers a token to another address.
|
|
95
103
|
*
|
|
96
104
|
* @param {TransferOptions} options - The transfer's options.
|
|
97
105
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
106
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
|
|
98
107
|
* @returns {Promise<TransferResult>} The transfer's result.
|
|
99
108
|
*/
|
|
100
|
-
transfer(options: TransferOptions, config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig
|
|
109
|
+
transfer(options: TransferOptions, config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>, txOverrides?: EvmErc4337GasOverrides): Promise<TransferResult>;
|
|
101
110
|
/**
|
|
102
111
|
* Returns a read-only copy of the account.
|
|
103
112
|
*
|
|
@@ -109,7 +118,7 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
109
118
|
*/
|
|
110
119
|
dispose(): void;
|
|
111
120
|
/** @private */
|
|
112
|
-
private
|
|
121
|
+
private _resolveQuote;
|
|
113
122
|
/** @private */
|
|
114
123
|
private static _getTxKey;
|
|
115
124
|
/** @private */
|
|
@@ -122,7 +131,8 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
122
131
|
export type Eip1193Provider = import("ethers").Eip1193Provider;
|
|
123
132
|
export type IWalletAccount = import("@tetherto/wdk-wallet").IWalletAccount;
|
|
124
133
|
export type KeyPair = import("@tetherto/wdk-wallet-evm").KeyPair;
|
|
125
|
-
export type
|
|
134
|
+
export type EvmErc4337Transaction = import("./wallet-account-read-only-evm-erc-4337.js").EvmErc4337Transaction;
|
|
135
|
+
export type EvmErc4337GasOverrides = import("./wallet-account-read-only-evm-erc-4337.js").EvmErc4337GasOverrides;
|
|
126
136
|
export type TransactionResult = import("@tetherto/wdk-wallet-evm").TransactionResult;
|
|
127
137
|
export type TransferOptions = import("@tetherto/wdk-wallet-evm").TransferOptions;
|
|
128
138
|
export type TransferResult = import("@tetherto/wdk-wallet-evm").TransferResult;
|
|
@@ -93,13 +93,16 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
93
93
|
* The result is cached internally for up to 2 minutes. If `sendTransaction` is called with the
|
|
94
94
|
* same transaction within that window, the cached fee is reused without an additional RPC round-trip.
|
|
95
95
|
*
|
|
96
|
-
*
|
|
96
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
97
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
98
|
+
*
|
|
99
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
97
100
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
98
101
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
99
102
|
* @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
|
|
100
103
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
101
104
|
*/
|
|
102
|
-
quoteSendTransaction(tx:
|
|
105
|
+
quoteSendTransaction(tx: EvmErc4337Transaction | EvmErc4337Transaction[], config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<Omit<TransactionResult, "hash">>;
|
|
103
106
|
/**
|
|
104
107
|
* Quotes the costs of a transfer operation.
|
|
105
108
|
*
|
|
@@ -108,11 +111,12 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
108
111
|
*
|
|
109
112
|
* @param {TransferOptions} options - The transfer's options.
|
|
110
113
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
114
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - If set, applies these UserOperationV7 gas/fee overrides to the underlying transaction.
|
|
111
115
|
* @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
|
|
112
116
|
* @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
|
|
113
117
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
114
118
|
*/
|
|
115
|
-
quoteTransfer(options: TransferOptions, config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig
|
|
119
|
+
quoteTransfer(options: TransferOptions, config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>, txOverrides?: EvmErc4337GasOverrides): Promise<Omit<TransferResult, "hash">>;
|
|
116
120
|
/**
|
|
117
121
|
* Returns a transaction's receipt.
|
|
118
122
|
*
|
|
@@ -207,31 +211,108 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
207
211
|
* @protected
|
|
208
212
|
* @param {MetaTransaction[]} calls - The meta-transactions to include in the UserOperation.
|
|
209
213
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration.
|
|
214
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - Optional UserOperationV7 gas overrides extracted from the input transaction(s).
|
|
210
215
|
* @returns {Promise<BuiltUserOperation>} The built operation, signing context, and (in token mode) the paymaster quote.
|
|
211
216
|
*/
|
|
212
|
-
protected _buildUserOperation(calls: import('abstractionkit').MetaTransaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee"
|
|
217
|
+
protected _buildUserOperation(calls: import('abstractionkit').MetaTransaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee">, txOverrides?: EvmErc4337GasOverrides): Promise<BuiltUserOperation>;
|
|
218
|
+
/**
|
|
219
|
+
* Extracts the optional UserOperationV7 gas overrides from a single transaction.
|
|
220
|
+
*
|
|
221
|
+
* Only the fields actually consumed by AbstractionKit's `CreateUserOperationOverrides`
|
|
222
|
+
* are picked. Numeric values are coerced to bigint.
|
|
223
|
+
*
|
|
224
|
+
* @protected
|
|
225
|
+
* @param {EvmErc4337Transaction} [tx] - The transaction to read overrides from.
|
|
226
|
+
* @returns {EvmErc4337GasOverrides} The overrides object (empty if `tx` is falsy or has no override fields).
|
|
227
|
+
*/
|
|
228
|
+
protected static _extractGasOverrides(tx?: EvmErc4337Transaction): EvmErc4337GasOverrides;
|
|
213
229
|
/**
|
|
214
230
|
* Builds a UserOperation and returns its estimated gas cost.
|
|
215
231
|
*
|
|
216
232
|
* Returns the cost in the paymaster token when a token quote is available, otherwise in
|
|
217
233
|
* native wei. Used by `quoteSendTransaction` and reused by `sendTransaction` via the cache.
|
|
218
234
|
*
|
|
235
|
+
* In a batched call, only `txs[0]`'s gas overrides are honored — a UserOperation
|
|
236
|
+
* carries a single set of gas fields regardless of how many calls it batches.
|
|
237
|
+
*
|
|
219
238
|
* @protected
|
|
220
|
-
* @param {
|
|
239
|
+
* @param {EvmErc4337Transaction[]} txs - The EVM transactions to include in the UserOperation.
|
|
221
240
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration to use for the build.
|
|
222
241
|
* @returns {Promise<BuiltUserOperation & Omit<TransactionResult, 'hash'>>} The built operation plus its raw fee (no tolerance buffer applied).
|
|
223
242
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
224
243
|
*/
|
|
225
|
-
protected _getUserOperationGasCost(txs:
|
|
244
|
+
protected _getUserOperationGasCost(txs: EvmErc4337Transaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee">): Promise<BuiltUserOperation & Omit<TransactionResult, "hash">>;
|
|
226
245
|
}
|
|
227
246
|
export type Eip1193Provider = import("ethers").Eip1193Provider;
|
|
228
|
-
export type EvmTransaction = import("@tetherto/wdk-wallet-evm").EvmTransaction;
|
|
229
247
|
export type TransactionResult = import("@tetherto/wdk-wallet-evm").TransactionResult;
|
|
230
248
|
export type TransferOptions = import("@tetherto/wdk-wallet-evm").TransferOptions;
|
|
231
249
|
export type TransferResult = import("@tetherto/wdk-wallet-evm").TransferResult;
|
|
232
250
|
export type EvmTransactionReceipt = import("@tetherto/wdk-wallet-evm").EvmTransactionReceipt;
|
|
233
251
|
export type TypedData = import("@tetherto/wdk-wallet-evm").TypedData;
|
|
234
252
|
export type UserOperationReceipt = import('abstractionkit').UserOperationReceiptResult;
|
|
253
|
+
export type EvmErc4337Transaction = {
|
|
254
|
+
/**
|
|
255
|
+
* - The call's recipient.
|
|
256
|
+
*/
|
|
257
|
+
to: string;
|
|
258
|
+
/**
|
|
259
|
+
* - The amount of native coin to send to the recipient (in wei).
|
|
260
|
+
*/
|
|
261
|
+
value: number | bigint;
|
|
262
|
+
/**
|
|
263
|
+
* - The call's data in hex format.
|
|
264
|
+
*/
|
|
265
|
+
data?: string;
|
|
266
|
+
/**
|
|
267
|
+
* - If set, overrides the user operations' call gas limit.
|
|
268
|
+
*/
|
|
269
|
+
callGasLimit?: number | bigint;
|
|
270
|
+
/**
|
|
271
|
+
* - If set, overrides the user operations' verification gas limit.
|
|
272
|
+
*/
|
|
273
|
+
verificationGasLimit?: number | bigint;
|
|
274
|
+
/**
|
|
275
|
+
* - If set, overrides the user operations' pre-verification gas.
|
|
276
|
+
*/
|
|
277
|
+
preVerificationGas?: number | bigint;
|
|
278
|
+
/**
|
|
279
|
+
* - If set, overrides the user operations' max fee per gas (EIP-1559 cap). Treated as a pair with `maxPriorityFeePerGas`: setting either disables the bundler-fetched fee fallback for both.
|
|
280
|
+
*/
|
|
281
|
+
maxFeePerGas?: number | bigint;
|
|
282
|
+
/**
|
|
283
|
+
* - If set, overrides the user operations' max priority fee per gas. Treated as a pair with `maxFeePerGas`: setting either disables the bundler-fetched fee fallback for both.
|
|
284
|
+
*/
|
|
285
|
+
maxPriorityFeePerGas?: number | bigint;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Gas-related UserOperationV7 overrides, coerced to `bigint`.
|
|
289
|
+
*
|
|
290
|
+
* Produced by `_extractGasOverrides` from an `EvmErc4337Transaction` and threaded into
|
|
291
|
+
* `_buildUserOperation`. All fields are optional; absent fields fall back to the bundler-fetched
|
|
292
|
+
* gas price (fee pair) or AbstractionKit's gas estimation (gas limits).
|
|
293
|
+
*/
|
|
294
|
+
export type EvmErc4337GasOverrides = {
|
|
295
|
+
/**
|
|
296
|
+
* - Override for the UserOperation's call gas limit.
|
|
297
|
+
*/
|
|
298
|
+
callGasLimit?: bigint;
|
|
299
|
+
/**
|
|
300
|
+
* - Override for the UserOperation's verification gas limit.
|
|
301
|
+
*/
|
|
302
|
+
verificationGasLimit?: bigint;
|
|
303
|
+
/**
|
|
304
|
+
* - Override for the UserOperation's pre-verification gas.
|
|
305
|
+
*/
|
|
306
|
+
preVerificationGas?: bigint;
|
|
307
|
+
/**
|
|
308
|
+
* - Override for the UserOperation's max fee per gas (EIP-1559 cap).
|
|
309
|
+
*/
|
|
310
|
+
maxFeePerGas?: bigint;
|
|
311
|
+
/**
|
|
312
|
+
* - Override for the UserOperation's max priority fee per gas.
|
|
313
|
+
*/
|
|
314
|
+
maxPriorityFeePerGas?: bigint;
|
|
315
|
+
};
|
|
235
316
|
export type BuiltUserOperation = {
|
|
236
317
|
/**
|
|
237
318
|
* - The fully-populated UserOperation ready to sign.
|