@tetherto/wdk-wallet-evm-erc-4337 1.0.0-beta.7 → 1.0.0-beta.8
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 +5 -5
- package/src/wallet-account-evm-erc-4337.js +15 -5
- package/src/wallet-account-read-only-evm-erc-4337.js +79 -11
- package/types/index.d.ts +2 -1
- package/types/src/wallet-account-evm-erc-4337.d.ts +13 -7
- package/types/src/wallet-account-read-only-evm-erc-4337.d.ts +86 -6
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.8",
|
|
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.
|
|
34
|
+
"@tetherto/wdk-wallet-evm": "1.0.0-beta.13",
|
|
35
35
|
"abstractionkit": "0.3.8",
|
|
36
36
|
"bare-node-runtime": "^1.1.4",
|
|
37
|
-
"ethers": "6.
|
|
37
|
+
"ethers": "6.16.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@nomicfoundation/hardhat-ethers": "3.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"wait-on": "8.0.4"
|
|
51
51
|
},
|
|
52
52
|
"overrides": {
|
|
53
|
-
"axios": "1.
|
|
53
|
+
"axios": "1.16.1",
|
|
54
54
|
"cookie": "1.0.2",
|
|
55
55
|
"fast-uri": "3.1.2",
|
|
56
56
|
"@protobufjs/utf8": "1.1.1",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"serialize-javascript": "7.0.5",
|
|
59
59
|
"tar": "7.5.7",
|
|
60
60
|
"tmp": "0.2.5",
|
|
61
|
-
"undici": "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
|
*/
|
|
@@ -209,7 +209,10 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
209
209
|
* The result is cached internally for up to 2 minutes. If `sendTransaction` is called with the
|
|
210
210
|
* same transaction within that window, the cached fee is reused without an additional RPC round-trip.
|
|
211
211
|
*
|
|
212
|
-
*
|
|
212
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
213
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
214
|
+
*
|
|
215
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
213
216
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
214
217
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
215
218
|
*/
|
|
@@ -245,7 +248,10 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
245
248
|
/**
|
|
246
249
|
* Sends a transaction.
|
|
247
250
|
*
|
|
248
|
-
*
|
|
251
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
252
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
253
|
+
*
|
|
254
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
249
255
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
250
256
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
251
257
|
*/
|
|
@@ -386,7 +392,11 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
386
392
|
async _signUserOperation (txs, { config, cachedBuild }) {
|
|
387
393
|
const { userOp, smartAccount, chainId } = cachedBuild?.userOp
|
|
388
394
|
? cachedBuild
|
|
389
|
-
: await this._buildUserOperation(
|
|
395
|
+
: await this._buildUserOperation(
|
|
396
|
+
WalletAccountReadOnlyEvmErc4337._toMetaTransactions(txs),
|
|
397
|
+
config,
|
|
398
|
+
WalletAccountReadOnlyEvmErc4337._extractGasOverrides(txs[0])
|
|
399
|
+
)
|
|
390
400
|
|
|
391
401
|
const signer = {
|
|
392
402
|
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.
|
|
@@ -541,7 +572,7 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
541
572
|
* Converts EVM transactions to AbstractionKit MetaTransaction calls.
|
|
542
573
|
*
|
|
543
574
|
* @protected
|
|
544
|
-
* @param {
|
|
575
|
+
* @param {EvmErc4337Transaction[]} txs - The transactions to convert.
|
|
545
576
|
* @returns {MetaTransaction[]} The calls array for createUserOperation.
|
|
546
577
|
*/
|
|
547
578
|
static _toMetaTransactions (txs) {
|
|
@@ -585,9 +616,10 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
585
616
|
* @protected
|
|
586
617
|
* @param {MetaTransaction[]} calls - The meta-transactions to include in the UserOperation.
|
|
587
618
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration.
|
|
619
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - Optional UserOperationV7 gas overrides extracted from the input transaction(s).
|
|
588
620
|
* @returns {Promise<BuiltUserOperation>} The built operation, signing context, and (in token mode) the paymaster quote.
|
|
589
621
|
*/
|
|
590
|
-
async _buildUserOperation (calls, config) {
|
|
622
|
+
async _buildUserOperation (calls, config, txOverrides = {}) {
|
|
591
623
|
const smartAccount = await this._getSmartAccount(config)
|
|
592
624
|
const chainId = await this._getChainId()
|
|
593
625
|
|
|
@@ -598,37 +630,68 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
598
630
|
|
|
599
631
|
const gasPrice = await this._fetchBundlerGasPrice(config.bundlerUrl)
|
|
600
632
|
|
|
633
|
+
const feePairOverridden = txOverrides.maxFeePerGas !== undefined || txOverrides.maxPriorityFeePerGas !== undefined
|
|
634
|
+
const overrides = feePairOverridden
|
|
635
|
+
? { ...txOverrides }
|
|
636
|
+
: { ...gasPrice, ...txOverrides }
|
|
637
|
+
|
|
601
638
|
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, ...
|
|
639
|
+
? await smartAccount.createUserOperation(calls, this._provider, config.bundlerUrl, overrides)
|
|
640
|
+
: await smartAccount.createUserOperation(calls, this._provider, undefined, { skipGasEstimation: true, ...overrides })
|
|
604
641
|
|
|
605
642
|
if (mode === PaymasterMode.NATIVE) {
|
|
606
643
|
return { userOp: baseUserOp, smartAccount, mode, chainId }
|
|
607
644
|
}
|
|
608
645
|
|
|
609
646
|
const { userOp, tokenQuote } = await this._applyPaymasterToUserOp({
|
|
610
|
-
mode, smartAccount, userOp: baseUserOp, config, chainId
|
|
647
|
+
mode, smartAccount, userOp: baseUserOp, config, chainId, txOverrides
|
|
611
648
|
})
|
|
612
649
|
return { userOp, smartAccount, mode, chainId, tokenQuote }
|
|
613
650
|
}
|
|
614
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Extracts the optional UserOperationV7 gas overrides from a single transaction.
|
|
654
|
+
*
|
|
655
|
+
* Only the fields actually consumed by AbstractionKit's `CreateUserOperationOverrides`
|
|
656
|
+
* are picked. Numeric values are coerced to bigint.
|
|
657
|
+
*
|
|
658
|
+
* @protected
|
|
659
|
+
* @param {EvmErc4337Transaction} [tx] - The transaction to read overrides from.
|
|
660
|
+
* @returns {EvmErc4337GasOverrides} The overrides object (empty if `tx` is falsy or has no override fields).
|
|
661
|
+
*/
|
|
662
|
+
static _extractGasOverrides (tx) {
|
|
663
|
+
const overrides = {}
|
|
664
|
+
if (!tx) return overrides
|
|
665
|
+
|
|
666
|
+
const fields = ['callGasLimit', 'verificationGasLimit', 'preVerificationGas', 'maxFeePerGas', 'maxPriorityFeePerGas']
|
|
667
|
+
for (const field of fields) {
|
|
668
|
+
if (tx[field] !== undefined) overrides[field] = BigInt(tx[field])
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
return overrides
|
|
672
|
+
}
|
|
673
|
+
|
|
615
674
|
/**
|
|
616
675
|
* Builds a UserOperation and returns its estimated gas cost.
|
|
617
676
|
*
|
|
618
677
|
* Returns the cost in the paymaster token when a token quote is available, otherwise in
|
|
619
678
|
* native wei. Used by `quoteSendTransaction` and reused by `sendTransaction` via the cache.
|
|
620
679
|
*
|
|
680
|
+
* In a batched call, only `txs[0]`'s gas overrides are honored — a UserOperation
|
|
681
|
+
* carries a single set of gas fields regardless of how many calls it batches.
|
|
682
|
+
*
|
|
621
683
|
* @protected
|
|
622
|
-
* @param {
|
|
684
|
+
* @param {EvmErc4337Transaction[]} txs - The EVM transactions to include in the UserOperation.
|
|
623
685
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration to use for the build.
|
|
624
686
|
* @returns {Promise<BuiltUserOperation & Omit<TransactionResult, 'hash'>>} The built operation plus its raw fee (no tolerance buffer applied).
|
|
625
687
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
626
688
|
*/
|
|
627
689
|
async _getUserOperationGasCost (txs, config) {
|
|
628
690
|
const calls = WalletAccountReadOnlyEvmErc4337._toMetaTransactions(txs)
|
|
691
|
+
const txOverrides = WalletAccountReadOnlyEvmErc4337._extractGasOverrides(txs[0])
|
|
629
692
|
|
|
630
693
|
try {
|
|
631
|
-
const buildResult = await this._buildUserOperation(calls, config)
|
|
694
|
+
const buildResult = await this._buildUserOperation(calls, config, txOverrides)
|
|
632
695
|
|
|
633
696
|
const fee = buildResult.tokenQuote
|
|
634
697
|
? buildResult.tokenQuote.tokenCost
|
|
@@ -677,19 +740,24 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
677
740
|
}
|
|
678
741
|
|
|
679
742
|
/** @private */
|
|
680
|
-
async _applyPaymasterToUserOp ({ mode, smartAccount, userOp, config, chainId }) {
|
|
743
|
+
async _applyPaymasterToUserOp ({ mode, smartAccount, userOp, config, chainId, txOverrides = {} }) {
|
|
681
744
|
const erc7677 = this._getPaymaster(config.paymasterUrl, { chainId: BigInt(chainId) })
|
|
682
745
|
|
|
683
746
|
const context = mode === PaymasterMode.TOKEN
|
|
684
747
|
? { token: config.paymasterToken.address }
|
|
685
748
|
: { sponsorshipPolicyId: config.sponsorshipPolicyId }
|
|
686
749
|
|
|
750
|
+
const paymasterOverrides = { entrypoint: ENTRYPOINT_V7 }
|
|
751
|
+
if (txOverrides.callGasLimit !== undefined) paymasterOverrides.callGasLimit = txOverrides.callGasLimit
|
|
752
|
+
if (txOverrides.verificationGasLimit !== undefined) paymasterOverrides.verificationGasLimit = txOverrides.verificationGasLimit
|
|
753
|
+
if (txOverrides.preVerificationGas !== undefined) paymasterOverrides.preVerificationGas = txOverrides.preVerificationGas
|
|
754
|
+
|
|
687
755
|
const result = await erc7677.createPaymasterUserOperation(
|
|
688
756
|
smartAccount,
|
|
689
757
|
userOp,
|
|
690
758
|
config.bundlerUrl,
|
|
691
759
|
context,
|
|
692
|
-
|
|
760
|
+
paymasterOverrides
|
|
693
761
|
)
|
|
694
762
|
|
|
695
763
|
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,11 +58,11 @@ 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
|
*
|
|
@@ -77,19 +77,25 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
77
77
|
* The result is cached internally for up to 2 minutes. If `sendTransaction` is called with the
|
|
78
78
|
* same transaction within that window, the cached fee is reused without an additional RPC round-trip.
|
|
79
79
|
*
|
|
80
|
-
*
|
|
80
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
81
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
82
|
+
*
|
|
83
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
81
84
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
82
85
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
83
86
|
*/
|
|
84
|
-
quoteSendTransaction(tx:
|
|
87
|
+
quoteSendTransaction(tx: EvmErc4337Transaction | EvmErc4337Transaction[], config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<Omit<TransactionResult, "hash">>;
|
|
85
88
|
/**
|
|
86
89
|
* Sends a transaction.
|
|
87
90
|
*
|
|
88
|
-
*
|
|
91
|
+
* In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
|
|
92
|
+
* honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
|
|
93
|
+
*
|
|
94
|
+
* @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
|
|
89
95
|
* @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
|
|
90
96
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
91
97
|
*/
|
|
92
|
-
sendTransaction(tx:
|
|
98
|
+
sendTransaction(tx: EvmErc4337Transaction | EvmErc4337Transaction[], config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<TransactionResult>;
|
|
93
99
|
/**
|
|
94
100
|
* Transfers a token to another address.
|
|
95
101
|
*
|
|
@@ -122,7 +128,7 @@ export default class WalletAccountEvmErc4337 extends WalletAccountReadOnlyEvmErc
|
|
|
122
128
|
export type Eip1193Provider = import("ethers").Eip1193Provider;
|
|
123
129
|
export type IWalletAccount = import("@tetherto/wdk-wallet").IWalletAccount;
|
|
124
130
|
export type KeyPair = import("@tetherto/wdk-wallet-evm").KeyPair;
|
|
125
|
-
export type
|
|
131
|
+
export type EvmErc4337Transaction = import("./wallet-account-read-only-evm-erc-4337.js").EvmErc4337Transaction;
|
|
126
132
|
export type TransactionResult = import("@tetherto/wdk-wallet-evm").TransactionResult;
|
|
127
133
|
export type TransferOptions = import("@tetherto/wdk-wallet-evm").TransferOptions;
|
|
128
134
|
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
|
*
|
|
@@ -207,31 +210,108 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
|
|
|
207
210
|
* @protected
|
|
208
211
|
* @param {MetaTransaction[]} calls - The meta-transactions to include in the UserOperation.
|
|
209
212
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration.
|
|
213
|
+
* @param {EvmErc4337GasOverrides} [txOverrides] - Optional UserOperationV7 gas overrides extracted from the input transaction(s).
|
|
210
214
|
* @returns {Promise<BuiltUserOperation>} The built operation, signing context, and (in token mode) the paymaster quote.
|
|
211
215
|
*/
|
|
212
|
-
protected _buildUserOperation(calls: import('abstractionkit').MetaTransaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee"
|
|
216
|
+
protected _buildUserOperation(calls: import('abstractionkit').MetaTransaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee">, txOverrides?: EvmErc4337GasOverrides): Promise<BuiltUserOperation>;
|
|
217
|
+
/**
|
|
218
|
+
* Extracts the optional UserOperationV7 gas overrides from a single transaction.
|
|
219
|
+
*
|
|
220
|
+
* Only the fields actually consumed by AbstractionKit's `CreateUserOperationOverrides`
|
|
221
|
+
* are picked. Numeric values are coerced to bigint.
|
|
222
|
+
*
|
|
223
|
+
* @protected
|
|
224
|
+
* @param {EvmErc4337Transaction} [tx] - The transaction to read overrides from.
|
|
225
|
+
* @returns {EvmErc4337GasOverrides} The overrides object (empty if `tx` is falsy or has no override fields).
|
|
226
|
+
*/
|
|
227
|
+
protected static _extractGasOverrides(tx?: EvmErc4337Transaction): EvmErc4337GasOverrides;
|
|
213
228
|
/**
|
|
214
229
|
* Builds a UserOperation and returns its estimated gas cost.
|
|
215
230
|
*
|
|
216
231
|
* Returns the cost in the paymaster token when a token quote is available, otherwise in
|
|
217
232
|
* native wei. Used by `quoteSendTransaction` and reused by `sendTransaction` via the cache.
|
|
218
233
|
*
|
|
234
|
+
* In a batched call, only `txs[0]`'s gas overrides are honored — a UserOperation
|
|
235
|
+
* carries a single set of gas fields regardless of how many calls it batches.
|
|
236
|
+
*
|
|
219
237
|
* @protected
|
|
220
|
-
* @param {
|
|
238
|
+
* @param {EvmErc4337Transaction[]} txs - The EVM transactions to include in the UserOperation.
|
|
221
239
|
* @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration to use for the build.
|
|
222
240
|
* @returns {Promise<BuiltUserOperation & Omit<TransactionResult, 'hash'>>} The built operation plus its raw fee (no tolerance buffer applied).
|
|
223
241
|
* @throws {Error} If the token paymaster reports AA50 (account does not hold the paymaster token).
|
|
224
242
|
*/
|
|
225
|
-
protected _getUserOperationGasCost(txs:
|
|
243
|
+
protected _getUserOperationGasCost(txs: EvmErc4337Transaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee">): Promise<BuiltUserOperation & Omit<TransactionResult, "hash">>;
|
|
226
244
|
}
|
|
227
245
|
export type Eip1193Provider = import("ethers").Eip1193Provider;
|
|
228
|
-
export type EvmTransaction = import("@tetherto/wdk-wallet-evm").EvmTransaction;
|
|
229
246
|
export type TransactionResult = import("@tetherto/wdk-wallet-evm").TransactionResult;
|
|
230
247
|
export type TransferOptions = import("@tetherto/wdk-wallet-evm").TransferOptions;
|
|
231
248
|
export type TransferResult = import("@tetherto/wdk-wallet-evm").TransferResult;
|
|
232
249
|
export type EvmTransactionReceipt = import("@tetherto/wdk-wallet-evm").EvmTransactionReceipt;
|
|
233
250
|
export type TypedData = import("@tetherto/wdk-wallet-evm").TypedData;
|
|
234
251
|
export type UserOperationReceipt = import('abstractionkit').UserOperationReceiptResult;
|
|
252
|
+
export type EvmErc4337Transaction = {
|
|
253
|
+
/**
|
|
254
|
+
* - The call's recipient.
|
|
255
|
+
*/
|
|
256
|
+
to: string;
|
|
257
|
+
/**
|
|
258
|
+
* - The amount of native coin to send to the recipient (in wei).
|
|
259
|
+
*/
|
|
260
|
+
value: number | bigint;
|
|
261
|
+
/**
|
|
262
|
+
* - The call's data in hex format.
|
|
263
|
+
*/
|
|
264
|
+
data?: string;
|
|
265
|
+
/**
|
|
266
|
+
* - If set, overrides the user operations' call gas limit.
|
|
267
|
+
*/
|
|
268
|
+
callGasLimit?: number | bigint;
|
|
269
|
+
/**
|
|
270
|
+
* - If set, overrides the user operations' verification gas limit.
|
|
271
|
+
*/
|
|
272
|
+
verificationGasLimit?: number | bigint;
|
|
273
|
+
/**
|
|
274
|
+
* - If set, overrides the user operations' pre-verification gas.
|
|
275
|
+
*/
|
|
276
|
+
preVerificationGas?: number | bigint;
|
|
277
|
+
/**
|
|
278
|
+
* - 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.
|
|
279
|
+
*/
|
|
280
|
+
maxFeePerGas?: number | bigint;
|
|
281
|
+
/**
|
|
282
|
+
* - 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.
|
|
283
|
+
*/
|
|
284
|
+
maxPriorityFeePerGas?: number | bigint;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Gas-related UserOperationV7 overrides, coerced to `bigint`.
|
|
288
|
+
*
|
|
289
|
+
* Produced by `_extractGasOverrides` from an `EvmErc4337Transaction` and threaded into
|
|
290
|
+
* `_buildUserOperation`. All fields are optional; absent fields fall back to the bundler-fetched
|
|
291
|
+
* gas price (fee pair) or AbstractionKit's gas estimation (gas limits).
|
|
292
|
+
*/
|
|
293
|
+
export type EvmErc4337GasOverrides = {
|
|
294
|
+
/**
|
|
295
|
+
* - Override for the UserOperation's call gas limit.
|
|
296
|
+
*/
|
|
297
|
+
callGasLimit?: bigint;
|
|
298
|
+
/**
|
|
299
|
+
* - Override for the UserOperation's verification gas limit.
|
|
300
|
+
*/
|
|
301
|
+
verificationGasLimit?: bigint;
|
|
302
|
+
/**
|
|
303
|
+
* - Override for the UserOperation's pre-verification gas.
|
|
304
|
+
*/
|
|
305
|
+
preVerificationGas?: bigint;
|
|
306
|
+
/**
|
|
307
|
+
* - Override for the UserOperation's max fee per gas (EIP-1559 cap).
|
|
308
|
+
*/
|
|
309
|
+
maxFeePerGas?: bigint;
|
|
310
|
+
/**
|
|
311
|
+
* - Override for the UserOperation's max priority fee per gas.
|
|
312
|
+
*/
|
|
313
|
+
maxPriorityFeePerGas?: bigint;
|
|
314
|
+
};
|
|
235
315
|
export type BuiltUserOperation = {
|
|
236
316
|
/**
|
|
237
317
|
* - The fully-populated UserOperation ready to sign.
|