@tetherto/wdk-wallet-evm-erc-4337 1.0.0-beta.2 → 1.0.0-beta.21

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.
@@ -1,32 +1,82 @@
1
+ export const SALT_NONCE: "0x69b348339eea4ed93f9d11931c3b894c8f9d8c7663a053024b11cb7eb4e5a1f6";
2
+ export const FEE_TOLERANCE_COEFFICIENT: 120n;
1
3
  export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOnly {
4
+ /**
5
+ * Predicts the address of a safe account.
6
+ *
7
+ * @param {string} owner - The safe owner's address.
8
+ * @param {Pick<EvmErc4337WalletConfig, 'safeModulesVersion' | 'onChainIdentifier'>} config - The safe configuration.
9
+ * @throws {ValueError} If `owner` is not a well-formed evm address.
10
+ * @returns {string} The Safe address.
11
+ */
12
+ static predictSafeAddress(owner: string, config: Pick<EvmErc4337WalletConfig, "safeModulesVersion" | "onChainIdentifier">): string;
13
+ /**
14
+ * Creates a read-only account for a safe whose address is already known.
15
+ *
16
+ * The address is used as the account's own address, so balances, allowances and quotes resolve against that
17
+ * safe. Its owner is unknown to the account: {@link verify} and {@link verifyTypedData} throw, and the safe must
18
+ * already be deployed for {@link quoteSendTransaction} and {@link quoteTransfer}.
19
+ *
20
+ * @param {string} safeAddress - The safe's evm address. Normalized to its checksummed form.
21
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee' | 'transactionMaxFee'>} config - The configuration object.
22
+ * @throws {ValueError} If `safeAddress` is not a well-formed evm address.
23
+ * @throws {ValueError} If the `provider` option is set to an empty array.
24
+ * @throws {ConfigurationError} If `config.safeModulesVersion` is not in the supported set.
25
+ * @returns {WalletAccountReadOnlyEvmErc4337} A read-only account whose address is `safeAddress`.
26
+ */
27
+ static fromSafeAddress(safeAddress: string, config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">): WalletAccountReadOnlyEvmErc4337;
28
+ /**
29
+ * Builds the init code overrides from the wallet configuration.
30
+ *
31
+ * @protected
32
+ * @param {Pick<EvmErc4337WalletConfig, 'safeModulesVersion' | 'onChainIdentifier'>} config - The wallet configuration fields used for init code generation.
33
+ * @returns {InitCodeOverrides} The init code overrides for SafeAccount creation.
34
+ */
35
+ protected static _getInitCodeOverrides(config: Pick<EvmErc4337WalletConfig, "safeModulesVersion" | "onChainIdentifier">): import('abstractionkit').InitCodeOverrides;
2
36
  /**
3
37
  * Creates a new read-only evm [erc-4337](https://www.erc4337.io/docs) wallet account.
4
38
  *
5
- * @param {string} address - The evm account's address.
39
+ * `address` is the safe owner's address; the account's own address is the counterfactual safe address derived
40
+ * from it. To read a safe whose address is already known, use {@link fromSafeAddress}.
41
+ *
42
+ * @param {string} address - The safe owner's evm address.
6
43
  * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The configuration object.
44
+ * @throws {ValueError} If `address` is not a well-formed evm address.
45
+ * @throws {ValueError} If the `provider` option is set to an empty array.
46
+ * @throws {ConfigurationError} If `config.safeModulesVersion` is not in the supported set.
7
47
  */
8
- constructor(address: string, config: Omit<EvmErc4337WalletConfig, "transferMaxFee">);
48
+ constructor(address: string, config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">);
9
49
  /**
10
50
  * The read-only evm erc-4337 wallet account configuration.
11
51
  *
12
52
  * @protected
13
53
  * @type {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>}
14
54
  */
15
- protected _config: Omit<EvmErc4337WalletConfig, "transferMaxFee">;
55
+ protected _config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">;
56
+ /**
57
+ * The shared ethers provider used to interact with the blockchain. A single instance is
58
+ * built here (or reused from the manager) and passed to every nested `WalletAccountReadOnlyEvm`
59
+ * so accounts do not open their own connection.
60
+ *
61
+ * @protected
62
+ * @type {Provider}
63
+ */
64
+ protected _provider: Provider;
16
65
  /**
17
- * The safe's implementation of the erc-4337 standard.
66
+ * An EIP-1193 adapter over {@link _provider}, built once and used only where abstractionkit
67
+ * (Safe4337Pack) requires the EIP-1193 interface. Reuses the same underlying connection.
18
68
  *
19
69
  * @protected
20
- * @type {Safe4337Pack | undefined}
70
+ * @type {Eip1193Provider}
21
71
  */
22
- protected _safe4337Pack: Safe4337Pack | undefined;
72
+ protected _eip1193Provider: Eip1193Provider;
23
73
  /**
24
- * The safe's fee estimator.
74
+ * Cached AbstractionKit bundler.
25
75
  *
26
76
  * @protected
27
- * @type {GenericFeeEstimator | undefined}
77
+ * @type {Bundler | undefined}
28
78
  */
29
- protected _feeEstimator: GenericFeeEstimator | undefined;
79
+ protected _bundler: Bundler | undefined;
30
80
  /**
31
81
  * The chain id.
32
82
  *
@@ -34,8 +84,13 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
34
84
  * @type {bigint | undefined}
35
85
  */
36
86
  protected _chainId: bigint | undefined;
37
- /** @private */
38
- private _ownerAccountAddress;
87
+ /**
88
+ * The safe owner's address, or `undefined` when the account was created from a safe address.
89
+ *
90
+ * @protected
91
+ * @type {string | undefined}
92
+ */
93
+ protected _ownerAccountAddress: string | undefined;
39
94
  /**
40
95
  * Returns the account's eth balance.
41
96
  *
@@ -49,49 +104,155 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
49
104
  * @returns {Promise<bigint>} The token balance (in base unit).
50
105
  */
51
106
  getTokenBalance(tokenAddress: string): Promise<bigint>;
107
+ /**
108
+ * Returns the account balances for multiple tokens.
109
+ *
110
+ * @param {string[]} tokenAddresses - The smart contract addresses of the tokens.
111
+ * @returns {Promise<Record<string, bigint>>} A mapping of token addresses to their balances (in base units).
112
+ */
113
+ getTokenBalances(tokenAddresses: string[]): Promise<Record<string, bigint>>;
52
114
  /**
53
115
  * Returns the account's balance for the paymaster token provided in the wallet account configuration.
54
116
  *
55
117
  * @returns {Promise<bigint>} The paymaster token balance (in base unit).
118
+ * @throws {ConfigurationError} If no paymaster token is configured (sponsored or native-coins mode).
56
119
  */
57
120
  getPaymasterTokenBalance(): Promise<bigint>;
58
121
  /**
59
122
  * Quotes the costs of a send transaction operation.
60
123
  *
61
- * @param {EvmTransaction | EvmTransaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
62
- * @param {Pick<EvmErc4337WalletConfig, 'paymasterToken'>} [config] - If set, overrides the 'paymasterToken' option defined in the wallet account configuration.
124
+ * The result is cached internally for up to 2 minutes. If `sendTransaction` is called with the
125
+ * same transaction within that window, the cached fee is reused without an additional RPC round-trip.
126
+ *
127
+ * In a batched call (`tx` passed as `[tx1, tx2, ...]`), only the gas overrides on `tx1` are
128
+ * honored — a UserOperation has a single set of gas fields regardless of how many calls it batches.
129
+ *
130
+ * @param {EvmErc4337Transaction | EvmErc4337Transaction[]} tx - The transaction, or an array of multiple transactions to send in batch.
131
+ * @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
63
132
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
133
+ * @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
134
+ * @throws {ConfigurationError} If, in token mode, the configured `paymasterAddress` does not match the paymaster address returned by the paymaster RPC. This guards against the auto-generated ERC-20 approval targeting an unexpected paymaster contract.
135
+ * @throws {TransactionError} If the token paymaster reports AA50 (account does not hold the paymaster token).
136
+ * @throws {ConfigurationError} If the account was created from a safe address that is not deployed.
64
137
  */
65
- quoteSendTransaction(tx: EvmTransaction | EvmTransaction[], config?: Pick<EvmErc4337WalletConfig, "paymasterToken">): Promise<Omit<TransactionResult, "hash">>;
138
+ quoteSendTransaction(tx: EvmErc4337Transaction | EvmErc4337Transaction[], config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<Omit<TransactionResult, "hash">>;
66
139
  /**
67
140
  * Quotes the costs of a transfer operation.
68
141
  *
69
- * @param {TransferOptions} options - The transfer's options.
70
- * @param {Pick<EvmErc4337WalletConfig, 'paymasterToken'>} [config] - If set, overrides the 'paymasterToken' option defined in the wallet account configuration.
142
+ * The result is cached internally for up to 2 minutes. If `transfer` is called with the
143
+ * same transaction within that window, the cached fee is reused without an additional RPC round-trip.
144
+ *
145
+ * @param {EvmErc4337TransferOptions} options - The transfer's options, including any UserOperationV7 gas/fee overrides to apply to the underlying transaction.
146
+ * @param {Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>} [config] - If set, overrides the given configuration options.
71
147
  * @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
148
+ * @throws {ConfigurationError} If the override `config` is invalid or has missing required fields.
149
+ * @throws {ConfigurationError} If, in token mode, the configured `paymasterAddress` does not match the paymaster address returned by the paymaster RPC. This guards against the auto-generated ERC-20 approval targeting an unexpected paymaster contract.
150
+ * @throws {TransactionError} If the token paymaster reports AA50 (account does not hold the paymaster token).
151
+ * @throws {ConfigurationError} If the account was created from a safe address that is not deployed.
72
152
  */
73
- quoteTransfer(options: TransferOptions, config?: Pick<EvmErc4337WalletConfig, "paymasterToken">): Promise<Omit<TransferResult, "hash">>;
153
+ quoteTransfer(options: EvmErc4337TransferOptions, config?: Partial<EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig>): Promise<Omit<TransferResult, "hash">>;
74
154
  /**
75
155
  * Returns a transaction's receipt.
76
156
  *
157
+ * @deprecated Use {@link getTransaction} instead, which returns a normalized, finality-based receipt. The raw ethers receipt and the user operation receipt remain available on its `receipt` and `userOperationReceipt` properties.
77
158
  * @param {string} hash - The user operation hash.
78
159
  * @returns {Promise<EvmTransactionReceipt | null>} – The receipt, or null if the transaction has not been included in a block yet.
79
160
  */
80
161
  getTransactionReceipt(hash: string): Promise<EvmTransactionReceipt | null>;
162
+ /**
163
+ * Returns a normalized, finality-based receipt for a user operation. Finality and confirmations come from the bundling transaction; `success` and `fee` come from the user operation.
164
+ *
165
+ * @param {string} hash - The user operation hash.
166
+ * @returns {Promise<TransactionReceipt & EvmErc4337TransactionDetails>} The normalized receipt.
167
+ * @throws {ValueError} If the hash is not a valid user operation hash.
168
+ * @throws {NoSuchElementError} If no user operation has been found for the given hash.
169
+ */
170
+ getTransaction(hash: string): Promise<TransactionReceipt & EvmErc4337TransactionDetails>;
171
+ /**
172
+ * Blocks until a user operation reaches a terminal state (the requested finality target or `dropped`), or times out.
173
+ *
174
+ * @param {string} hash - The user operation hash.
175
+ * @param {WaitForTransactionOptions} [options] - The wait options.
176
+ * @returns {Promise<TransactionReceipt & EvmErc4337TransactionDetails>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
177
+ * @throws {TimeoutError} If the target is not reached before the timeout.
178
+ */
179
+ waitForTransaction(hash: string, options?: WaitForTransactionOptions): Promise<TransactionReceipt & EvmErc4337TransactionDetails>;
180
+ /**
181
+ * Overrides the base default to allow for slower ERC-4337 bundling, inclusion, and confirmation.
182
+ *
183
+ * @type {number}
184
+ */
185
+ get defaultWaitTimeout(): number;
186
+ /**
187
+ * Returns a user operation's receipt.
188
+ *
189
+ * @param {string} hash - The user operation hash.
190
+ * @returns {Promise<UserOperationReceipt | null>} – The receipt, or null if the user operation has not been included in a block yet.
191
+ */
192
+ getUserOperationReceipt(hash: string): Promise<UserOperationReceipt | null>;
81
193
  /**
82
194
  * Returns the current allowance for the given token and spender.
83
- * @param {string} token - The token’s address.
84
- * @param {string} spender - The spender’s address.
85
- * @returns {Promise<bigint>} - The allowance.
195
+ *
196
+ * @param {string} token - The token's address.
197
+ * @param {string} spender - The spender's address.
198
+ * @returns {Promise<bigint>} The allowance.
86
199
  */
87
200
  getAllowance(token: string, spender: string): Promise<bigint>;
88
201
  /**
89
- * Returns the safe's erc-4337 pack of the account.
202
+ * Verifies a message's signature.
203
+ *
204
+ * @param {string} message - The original message.
205
+ * @param {string} signature - The signature to verify.
206
+ * @throws {UnsupportedOperationError} If the account was created from a safe address, whose owner is unknown.
207
+ * @returns {Promise<boolean>} True if the signature is valid.
208
+ */
209
+ verify(message: string, signature: string): Promise<boolean>;
210
+ /**
211
+ * Verifies a typed data signature.
212
+ *
213
+ * @param {TypedData} typedData - The typed data to verify.
214
+ * @param {string} signature - The signature to verify.
215
+ * @throws {UnsupportedOperationError} If the account was created from a safe address, whose owner is unknown.
216
+ * @returns {Promise<boolean>} True if the signature is valid.
217
+ */
218
+ verifyTypedData(typedData: TypedData, signature: string): Promise<boolean>;
219
+ /**
220
+ * Validates the configuration to ensure all required fields are present.
90
221
  *
91
222
  * @protected
92
- * @returns {Promise<Safe4337Pack>} The safe's erc-4337 pack.
223
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The configuration to validate.
224
+ * @throws {ConfigurationError} If the configuration is invalid or has missing required fields.
225
+ * @returns {void}
93
226
  */
94
- protected _getSafe4337Pack(): Promise<Safe4337Pack>;
227
+ protected _validateConfig(config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">): void;
228
+ /**
229
+ * Builds a safe account instance for the current owner.
230
+ *
231
+ * @protected
232
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} [config] - The wallet configuration. Defaults to the instance configuration.
233
+ * @throws {ConfigurationError} If the account was created from a safe address that is not deployed.
234
+ * @returns {Promise<SafeAccountV0_3_0>} The safe account instance.
235
+ */
236
+ protected _getSmartAccount(config?: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">): Promise<import('abstractionkit').SafeAccountV0_3_0>;
237
+ /**
238
+ * Builds the RPC transport for an AbstractionKit client (Bundler / Erc7677Paymaster).
239
+ *
240
+ * When `headers` are provided, the transport injects them on every request (e.g.
241
+ * `{ Authorization: 'Bearer <key>' }` for authenticated bundlers/paymasters).
242
+ *
243
+ * @protected
244
+ * @param {string} url - The bundler or paymaster RPC url.
245
+ * @param {Record<string, string>} [headers] - Optional HTTP headers to inject on every request.
246
+ * @returns {HttpTransport} An HttpTransport for the url, carrying the headers when set.
247
+ */
248
+ protected static _rpcTarget(url: string, headers?: Record<string, string>): HttpTransport;
249
+ /**
250
+ * Returns an AbstractionKit Bundler for querying UserOperations.
251
+ *
252
+ * @protected
253
+ * @returns {Bundler} The bundler.
254
+ */
255
+ protected _getBundler(): Bundler;
95
256
  /**
96
257
  * Returns the chain id.
97
258
  *
@@ -99,48 +260,289 @@ export default class WalletAccountReadOnlyEvmErc4337 extends WalletAccountReadOn
99
260
  * @returns {Promise<bigint>} - The chain id.
100
261
  */
101
262
  protected _getChainId(): Promise<bigint>;
263
+ /**
264
+ * Adapts an ethers provider (or failover aggregate) to the EIP-1193 interface required by
265
+ * abstractionkit (Safe4337Pack). Already-EIP-1193 objects are returned as-is.
266
+ *
267
+ * @protected
268
+ * @param {Provider | Eip1193Provider} provider - The ethers provider (or EIP-1193 provider) to adapt.
269
+ * @returns {Eip1193Provider} An EIP-1193-compatible provider that reuses the given client.
270
+ */
271
+ protected static _asEip1193 (provider: Provider | Eip1193Provider): Eip1193Provider
272
+ /**
273
+ * Builds the EIP-1193 view that abstractionkit needs. A caller-supplied EIP-1193 provider is
274
+ * reused directly; otherwise the shared ethers provider is adapted so `request` forwards to `send`.
275
+ *
276
+ * @protected
277
+ * @param {Provider} provider - The shared ethers provider built from `config`.
278
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The configuration object.
279
+ * @returns {Eip1193Provider} The EIP-1193 provider that reuses the given connection.
280
+ */
281
+ protected static _buildEip1193Provider (provider: Provider, config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">): Eip1193Provider
282
+ /**
283
+ * Builds the single shared ethers provider from the configuration, reusing an already-built
284
+ * provider as-is and delegating construction to wdk-wallet-evm.
285
+ *
286
+ * @protected
287
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} [config] - The configuration object.
288
+ * @returns {Provider} The shared provider.
289
+ * @throws {ValueError} If the `provider` option is set to an empty array.
290
+ */
291
+ protected _buildProvider (config?: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">): Provider
102
292
  /** @private */
103
293
  private _getEvmReadOnlyAccount;
104
- /** @private */
105
- private _getFeeEstimator;
106
- /** @private */
107
- private _getUserOperationGasCost;
294
+ /**
295
+ * Builds a UserOperation with paymaster fields applied.
296
+ *
297
+ * @protected
298
+ * @param {MetaTransaction[]} calls - The meta-transactions to include in the UserOperation.
299
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration.
300
+ * @param {EvmErc4337GasOverrides & Nonce} [txOverrides] - Optional UserOperationV7 gas overrides extracted from the input transaction(s), plus an optional explicit lane `nonce`.
301
+ * @returns {Promise<BuiltUserOperation>} The built operation, signing context, and (in token mode) the paymaster quote.
302
+ * @throws {ConfigurationError} If the account was created from a safe address that is not deployed.
303
+ */
304
+ protected _buildUserOperation(calls: import('abstractionkit').MetaTransaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">, txOverrides?: EvmErc4337GasOverrides & Nonce): Promise<BuiltUserOperation>;
305
+ /**
306
+ * Returns an evm transaction to execute the given token transfer, carrying any UserOperationV7
307
+ * gas overrides set on the options.
308
+ *
309
+ * @protected
310
+ * @param {EvmErc4337TransferOptions} options - The transfer's options, including any gas/fee overrides to carry onto the transaction.
311
+ * @returns {Promise<EvmErc4337Transaction>} The ERC-20 transfer call as an evm transaction, with the options' gas overrides applied.
312
+ */
313
+ protected static _getTransferTransaction(options: EvmErc4337TransferOptions): Promise<EvmErc4337Transaction>;
314
+ /**
315
+ * Extracts the optional UserOperationV7 gas overrides from a transaction or an options object.
316
+ *
317
+ * Only the fields actually consumed by AbstractionKit's `CreateUserOperationOverrides`
318
+ * are picked. Numeric values are coerced to bigint.
319
+ *
320
+ * @protected
321
+ * @param {EvmErc4337GasOverrides} [source] - The transaction or options object to read overrides from.
322
+ * @returns {EvmErc4337GasOverrides} The overrides object (empty if `source` is falsy or has no override fields).
323
+ */
324
+ protected static _extractGasOverrides(source?: EvmErc4337GasOverrides): EvmErc4337GasOverrides;
325
+ /**
326
+ * Builds a UserOperation and returns its estimated gas cost.
327
+ *
328
+ * Returns the cost in the paymaster token when a token quote is available, otherwise in
329
+ * native wei. Used by `quoteSendTransaction` and reused by `sendTransaction` via the cache.
330
+ *
331
+ * In a batched call, only `txs[0]`'s gas overrides are honored — a UserOperation
332
+ * carries a single set of gas fields regardless of how many calls it batches.
333
+ *
334
+ * @protected
335
+ * @param {EvmErc4337Transaction[]} txs - The EVM transactions to include in the UserOperation.
336
+ * @param {Omit<EvmErc4337WalletConfig, 'transferMaxFee'>} config - The wallet configuration to use for the build.
337
+ * @returns {Promise<BuiltUserOperation & Omit<TransactionResult, 'hash'>>} The built operation plus its raw fee (no tolerance buffer applied).
338
+ * @throws {TransactionError} If the token paymaster reports AA50 (account does not hold the paymaster token).
339
+ */
340
+ protected _getUserOperationGasCost(txs: EvmErc4337Transaction[], config: Omit<EvmErc4337WalletConfig, "transferMaxFee" | "transactionMaxFee">): Promise<BuiltUserOperation & Omit<TransactionResult, "hash">>;
108
341
  }
342
+ export type Provider = import("ethers").Provider;
109
343
  export type Eip1193Provider = import("ethers").Eip1193Provider;
110
- export type EvmTransaction = import("@tetherto/wdk-wallet-evm").EvmTransaction;
111
344
  export type TransactionResult = import("@tetherto/wdk-wallet-evm").TransactionResult;
112
345
  export type TransferOptions = import("@tetherto/wdk-wallet-evm").TransferOptions;
113
346
  export type TransferResult = import("@tetherto/wdk-wallet-evm").TransferResult;
114
347
  export type EvmTransactionReceipt = import("@tetherto/wdk-wallet-evm").EvmTransactionReceipt;
115
- export type EvmErc4337WalletConfig = {
348
+ export type TypedData = import("@tetherto/wdk-wallet-evm").TypedData;
349
+ export type UserOperationReceipt = import('abstractionkit').UserOperationReceiptResult;
350
+ export type TransactionReceipt = import("@tetherto/wdk-wallet").TransactionReceipt;
351
+ export type WaitForTransactionOptions = import("@tetherto/wdk-wallet").WaitForTransactionOptions;
352
+ /**
353
+ * The ERC-4337-specific fields added to a normalized transaction receipt.
354
+ */
355
+ export type EvmErc4337TransactionDetails = {
356
+ /**
357
+ * - The number of confirmations (0 while pending or dropped).
358
+ */
359
+ confirmations: number;
360
+ /**
361
+ * - The native ethers receipt, or null while the user operation is pending or dropped.
362
+ */
363
+ receipt: EvmTransactionReceipt | null;
364
+ /**
365
+ * - The user operation receipt, or null while pending or unavailable.
366
+ */
367
+ userOperationReceipt: UserOperationReceipt | null;
368
+ };
369
+ export type EvmErc4337Transaction = {
370
+ /**
371
+ * - The call's recipient.
372
+ */
373
+ to: string;
374
+ /**
375
+ * - The amount of native coin to send to the recipient (in wei).
376
+ */
377
+ value: number | bigint;
378
+ /**
379
+ * - The call's data in hex format.
380
+ */
381
+ data?: string;
382
+ /**
383
+ * - If set, overrides the user operations' call gas limit.
384
+ */
385
+ callGasLimit?: number | bigint;
386
+ /**
387
+ * - If set, overrides the user operations' verification gas limit.
388
+ */
389
+ verificationGasLimit?: number | bigint;
390
+ /**
391
+ * - If set, overrides the user operations' pre-verification gas.
392
+ */
393
+ preVerificationGas?: number | bigint;
394
+ /**
395
+ * - 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.
396
+ */
397
+ maxFeePerGas?: number | bigint;
398
+ /**
399
+ * - 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.
400
+ */
401
+ maxPriorityFeePerGas?: number | bigint;
402
+ };
403
+ /**
404
+ * Gas-related UserOperationV7 overrides. Numeric fields accept `number` or `bigint`; numbers are
405
+ * coerced to `bigint` by `_extractGasOverrides` before the operation is built. All fields are
406
+ * optional; absent fields fall back to the bundler-fetched gas price (fee pair) or the bundler's
407
+ * gas estimation (gas limits).
408
+ */
409
+ export type EvmErc4337GasOverrides = {
410
+ /**
411
+ * - Override for the UserOperation's call gas limit.
412
+ */
413
+ callGasLimit?: number | bigint;
414
+ /**
415
+ * - Override for the UserOperation's verification gas limit.
416
+ */
417
+ verificationGasLimit?: number | bigint;
418
+ /**
419
+ * - Override for the UserOperation's pre-verification gas.
420
+ */
421
+ preVerificationGas?: number | bigint;
422
+ /**
423
+ * - Override for the UserOperation's max fee per gas (EIP-1559 cap).
424
+ */
425
+ maxFeePerGas?: number | bigint;
426
+ /**
427
+ * - Override for the UserOperation's max priority fee per gas.
428
+ */
429
+ maxPriorityFeePerGas?: number | bigint;
430
+ };
431
+ /**
432
+ * The options of a token transfer, extended with the optional UserOperationV7 gas overrides.
433
+ */
434
+ export type EvmErc4337TransferOptions = TransferOptions & EvmErc4337GasOverrides;
435
+ /**
436
+ * A single explicit UserOperationV7 `nonce`, combined with `EvmErc4337GasOverrides` for the build
437
+ * step to place the operation in a specific two-dimensional nonce lane. The `nonce` is derived
438
+ * internally from the account's `parallel`/`nonceKey` configuration, never from user-supplied
439
+ * transaction fields.
440
+ */
441
+ export type Nonce = {
442
+ /**
443
+ * - Full 256-bit UserOperation nonce (`key << 64 | sequence`) placing the op in a specific lane. Omitted for default (key-0) sends, in which case the account fetches the current on-chain nonce.
444
+ */
445
+ nonce?: number | bigint;
446
+ };
447
+ export type BuiltUserOperation = {
448
+ /**
449
+ * - The fully-populated UserOperation ready to sign.
450
+ */
451
+ userOp: import('abstractionkit').UserOperationV7;
452
+ /**
453
+ * - The Safe account that will execute the operation.
454
+ */
455
+ smartAccount: import('abstractionkit').SafeAccountV0_3_0;
456
+ /**
457
+ * - The paymaster mode used to build the operation.
458
+ */
459
+ mode: 'native' | 'sponsored' | 'token';
460
+ /**
461
+ * - The chain id captured at build time.
462
+ */
463
+ chainId: bigint;
464
+ /**
465
+ * - The paymaster token quote, present only in token mode.
466
+ */
467
+ tokenQuote?: import('abstractionkit').TokenQuote;
468
+ };
469
+ export type OnChainIdentifier = {
470
+ /**
471
+ * - The project name included in the 50-byte on-chain marker.
472
+ */
473
+ project: string;
474
+ /**
475
+ * - The platform type (default: 'Web').
476
+ */
477
+ platform?: "Web" | "Mobile" | "Safe App" | "Widget";
478
+ /**
479
+ * - The tool name used to create the UserOperation.
480
+ */
481
+ tool?: string;
482
+ /**
483
+ * - Semver-style tool version string included in the on-chain marker (e.g. "1.0.0").
484
+ */
485
+ toolVersion?: string;
486
+ };
487
+ export type EvmErc4337WalletCommonConfig = {
116
488
  /**
117
489
  * - The blockchain's id (e.g., 1 for ethereum).
118
490
  */
119
491
  chainId: number;
120
492
  /**
121
- * - The url of the rpc provider, or an instance of a class that implements eip-1193.
493
+ * - The url of the rpc provider, an already-built ethers `Provider` (reused as-is), or an instance of a class that implements eip-1193. It's also possible to provide an array of these instead. In such case, connection errors will cause the wallet to automatically fallback on the next provider in the list.
122
494
  */
123
- provider: string | Eip1193Provider;
495
+ provider: string | Provider | Eip1193Provider | Array<string | Provider | Eip1193Provider>;
496
+ /**
497
+ * - If set and if 'provider' is a list of urls or EIP 1193 providers, the number of additional retry attempts after the initial call fails. Total attempts = `1 + retries`. For example, `retries: 3` with 4 providers will try each provider once before throwing. If `retries` exceeds the number of providers, the failover will loop back and retry already-failed providers in round-robin order. Default: 3.
498
+ */
499
+ retries?: number;
124
500
  /**
125
501
  * - The url of the bundler service.
126
502
  */
127
503
  bundlerUrl: string;
128
504
  /**
129
- * - The url of the paymaster service.
505
+ * - Optional HTTP headers sent on every request to the bundler (e.g. `{ Authorization: 'Bearer <key>' }`). Use for bundlers that require authentication.
130
506
  */
131
- paymasterUrl: string;
507
+ bundlerHeaders?: Record<string, string>;
132
508
  /**
133
- * - The address of the paymaster smart contract.
509
+ * - Version of the Safe 4337 module set to deploy with the account (e.g. "0.3.0"). Determines the module addresses used in init code.
134
510
  */
135
- paymasterAddress: string;
511
+ safeModulesVersion: string;
136
512
  /**
137
- * - The address of the entry point smart contract.
513
+ * - Optional on-chain identifier. Appends a 50-byte project marker to every UserOperation callData. Pass a string to reuse it as the project name, or a full object for more control.
138
514
  */
139
- entryPointAddress: string;
515
+ onChainIdentifier?: OnChainIdentifier | string;
140
516
  /**
141
- * - The safe modules version.
517
+ * - When true, each send is placed in a fresh, independent nonce lane (a random 192-bit key at sequence 0) so concurrent or back-to-back sends don't collide on the nonce. Ordering between such sends is not guaranteed and each consumes a new EntryPoint nonce slot. Ignored when `nonceKey` is set. Overridable per call.
142
518
  */
143
- safeModulesVersion: string;
519
+ parallel?: boolean;
520
+ /**
521
+ * - Send in an explicit nonce lane. A string is hashed to a deterministic key — a reusable named lane that resumes the same sequence across sessions; a number or bigint is used as the raw uint192 key and must be within the uint192 range (0 to 2^192 - 1), otherwise the send throws (pass a bigint or string for keys above 2^53). Sends sharing a key are ordered sequentially; different keys run in parallel. Overridable per call.
522
+ */
523
+ nonceKey?: number | bigint | string;
524
+ };
525
+ export type EvmErc4337WalletPaymasterTokenConfig = {
526
+ /**
527
+ * - Whether the paymaster is sponsoring the account.
528
+ */
529
+ isSponsored?: false;
530
+ /**
531
+ * - Whether to use native coins instead of a paymaster to pay for gas fees.
532
+ */
533
+ useNativeCoins?: false;
534
+ /**
535
+ * - The url of the paymaster service.
536
+ */
537
+ paymasterUrl: string;
538
+ /**
539
+ * - Optional HTTP headers sent on every request to the paymaster (e.g. `{ Authorization: 'Bearer <key>' }`). Use for paymasters that require authentication.
540
+ */
541
+ paymasterHeaders?: Record<string, string>;
542
+ /**
543
+ * - The address of the paymaster smart contract.
544
+ */
545
+ paymasterAddress: string;
144
546
  /**
145
547
  * - The paymaster token configuration.
146
548
  */
@@ -151,6 +553,52 @@ export type EvmErc4337WalletConfig = {
151
553
  * - The maximum fee amount for transfer operations.
152
554
  */
153
555
  transferMaxFee?: number | bigint;
556
+ /**
557
+ * - The maximum fee amount for sendTransaction and signTransaction operations.
558
+ */
559
+ transactionMaxFee?: number | bigint;
560
+ };
561
+ export type EvmErc4337WalletSponsorshipPolicyConfig = {
562
+ /**
563
+ * - Whether the paymaster is sponsoring the account.
564
+ */
565
+ isSponsored: true;
566
+ /**
567
+ * - Whether to use native coins instead of a paymaster to pay for gas fees.
568
+ */
569
+ useNativeCoins?: false;
570
+ /**
571
+ * - The url of the paymaster service.
572
+ */
573
+ paymasterUrl: string;
574
+ /**
575
+ * - Optional HTTP headers sent on every request to the paymaster (e.g. `{ Authorization: 'Bearer <key>' }`). Use for paymasters that require authentication.
576
+ */
577
+ paymasterHeaders?: Record<string, string>;
578
+ /**
579
+ * - Identifier of the paymaster sponsorship policy to apply (provider-specific). Optional; some paymasters infer the policy from the project key.
580
+ */
581
+ sponsorshipPolicyId?: string;
582
+ };
583
+ export type EvmErc4337WalletNativeCoinsConfig = {
584
+ /**
585
+ * - Whether the paymaster is sponsoring the account.
586
+ */
587
+ isSponsored?: false;
588
+ /**
589
+ * - Whether to use native coins instead of a paymaster to pay for gas fees.
590
+ */
591
+ useNativeCoins: true;
592
+ /**
593
+ * - The maximum fee amount for transfer operations.
594
+ */
595
+ transferMaxFee?: number | bigint;
596
+ /**
597
+ * - The maximum fee amount for sendTransaction and signTransaction operations.
598
+ */
599
+ transactionMaxFee?: number | bigint;
154
600
  };
601
+ export type EvmErc4337WalletConfig = EvmErc4337WalletCommonConfig & (EvmErc4337WalletPaymasterTokenConfig | EvmErc4337WalletSponsorshipPolicyConfig | EvmErc4337WalletNativeCoinsConfig);
155
602
  import { WalletAccountReadOnly } from '@tetherto/wdk-wallet';
156
- import { GenericFeeEstimator, Safe4337Pack } from '@wdk-safe-global/relay-kit';
603
+ import { Bundler } from 'abstractionkit';
604
+ import { HttpTransport } from 'abstractionkit';