@tetherto/wdk-wallet-evm 1.0.0-beta.21 → 1.0.0-beta.23

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 CHANGED
@@ -21,7 +21,6 @@
21
21
  /** @typedef {import('ethers').TransactionReceipt} EvmTransactionReceipt */
22
22
  /** @typedef {import('ethers').TransactionResponse} EvmTransactionResponse */
23
23
  /** @typedef {import('ethers').TransactionRequest} EvmTransactionRequest */
24
- /** @typedef {import('ethers').BlobLike} BlobLike */
25
24
 
26
25
  /** @typedef {import('@tetherto/wdk-wallet').FeeRates} FeeRates */
27
26
  /** @typedef {import('@tetherto/wdk-wallet').KeyPair} KeyPair */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet-evm",
3
- "version": "1.0.0-beta.21",
3
+ "version": "1.0.0-beta.23",
4
4
  "description": "EVM wallet module for WDK (Wallet Development Kit) by Tether.",
5
5
  "homepage": "https://docs.wdk.tether.io/sdk/wallet-modules/wallet-evm/",
6
6
  "keywords": [
@@ -21,6 +21,9 @@ import {
21
21
 
22
22
  import * as secp256k1 from '@noble/secp256k1'
23
23
 
24
+ // eslint-disable-next-line camelcase
25
+ import { sodium_memzero } from 'sodium-universal'
26
+
24
27
  import MemorySafeSigningKey from './signing-key.js'
25
28
 
26
29
  const MasterSecret = new Uint8Array([66, 105, 116, 99, 111, 105, 110, 32, 115, 101, 101, 100])
@@ -191,7 +194,11 @@ export default class MemorySafeHDNodeWallet extends BaseWallet {
191
194
  const I = getBytes(computeHmac('sha512', MasterSecret, seed))
192
195
  const signingKey = new MemorySafeSigningKey(I.slice(0, 32))
193
196
 
194
- return new MemorySafeHDNodeWallet(_guard, signingKey, '0x00000000', hexlify(I.slice(32)),
197
+ const root = new MemorySafeHDNodeWallet(_guard, signingKey, '0x00000000', hexlify(I.slice(32)),
195
198
  'm', 0, 0, mnemonic, null)
199
+
200
+ sodium_memzero(I)
201
+
202
+ return root
196
203
  }
197
204
  }
@@ -17,6 +17,9 @@ import * as bip39 from 'bip39'
17
17
 
18
18
  import { ValueError } from '@tetherto/wdk-wallet'
19
19
 
20
+ // eslint-disable-next-line camelcase
21
+ import { sodium_memzero } from 'sodium-universal'
22
+
20
23
  import MemorySafeHDNodeWallet from '../memory-safe/hd-node-wallet.js'
21
24
 
22
25
  /** @typedef {import('./signer-evm.js').ISignerEvm} ISignerEvm */
@@ -54,7 +57,8 @@ export default class SeedSignerEvm {
54
57
  * @throws {ValueError} If the given seed phrase is invalid.
55
58
  */
56
59
  constructor (seed, path = BIP_44_ETH_DERIVATION_PATH_PREFIX) {
57
- if (typeof seed === 'string') {
60
+ const ownsSeed = typeof seed === 'string'
61
+ if (ownsSeed) {
58
62
  if (!bip39.validateMnemonic(seed)) {
59
63
  throw new ValueError('The seed phrase is invalid.')
60
64
  }
@@ -63,8 +67,14 @@ export default class SeedSignerEvm {
63
67
  }
64
68
 
65
69
  const root = MemorySafeHDNodeWallet.fromSeed(seed)
66
- const account = root.derivePath(path)
67
- if (account !== root) root.dispose()
70
+ if (ownsSeed) sodium_memzero(seed)
71
+
72
+ let account
73
+ try {
74
+ account = root.derivePath(path)
75
+ } finally {
76
+ if (account !== root) root.dispose()
77
+ }
68
78
 
69
79
  /** @private */
70
80
  this._account = account
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { Contract, VoidSigner, Transaction, ZeroAddress } from 'ethers'
18
18
 
19
- import { MaximumFeeExceededError, ProviderRequiredError, ValueError } from '@tetherto/wdk-wallet'
19
+ import { AssertionError, MaximumFeeExceededError, ProviderRequiredError, ValueError } from '@tetherto/wdk-wallet'
20
20
 
21
21
  import WalletAccountReadOnlyEvm from './wallet-account-read-only-evm.js'
22
22
 
@@ -200,9 +200,14 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
200
200
  *
201
201
  * @param {EvmTransaction} tx - The transaction to sign.
202
202
  * @returns {Promise<string>} The signed transaction as a hex string.
203
+ * @throws {ValueError} If the transaction is an EIP-4844 (type 3) blob transaction.
203
204
  * @throws {MaximumFeeExceededError} If a provider is set, and the transaction's cost surpasses the transaction max. fee option.
204
205
  */
205
206
  async signTransaction (tx) {
207
+ if (WalletAccountReadOnlyEvm._isBlobTransaction(tx)) {
208
+ throw new ValueError('eip-4844 blob transactions are not supported')
209
+ }
210
+
206
211
  if (this._provider && this._config.transactionMaxFee !== undefined) {
207
212
  const { fee } = await this.quoteSendTransaction(tx)
208
213
 
@@ -223,7 +228,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
223
228
  * @returns {Promise<TransactionResult>} The transaction's result.
224
229
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
225
230
  * @throws {MaximumFeeExceededError} If the transaction's cost exceeds the maximum transaction fee option.
226
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
231
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
227
232
  */
228
233
  async sendTransaction (tx) {
229
234
  if (!this._provider) {
@@ -261,7 +266,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
261
266
  * @param {EvmTransaction | string} tx - The transaction, or a signed raw transaction as a hex string.
262
267
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
263
268
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
264
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
269
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
265
270
  * @throws {Error} If the simulation of the transaction reverts, as an ethers error with code `CALL_EXCEPTION`.
266
271
  */
267
272
  async quoteSendTransaction (tx) {
@@ -270,7 +275,13 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
270
275
  throw new ProviderRequiredError('The wallet must be connected to a provider to quote send transaction operations.')
271
276
  }
272
277
 
273
- const { from, to, value, data, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, type, nonce, chainId, authorizationList } = Transaction.from(tx)
278
+ const parsedTx = Transaction.from(tx)
279
+
280
+ if (WalletAccountReadOnlyEvm._isBlobTransaction(parsedTx)) {
281
+ throw new ValueError('eip-4844 blob transactions are not supported')
282
+ }
283
+
284
+ const { from, to, value, data, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, type, nonce, chainId, authorizationList } = parsedTx
274
285
 
275
286
  await this._estimateGas({ from, to, value, data, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, type, nonce, chainId, authorizationList })
276
287
 
@@ -362,18 +373,26 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
362
373
  *
363
374
  * The chainId and nonce are populated from the provider when not explicitly provided.
364
375
  *
376
+ * A chainId of 0 makes the authorization valid on every chain, so it is only signed when given explicitly, never
377
+ * when reported by the provider.
378
+ *
379
+ * @see https://eips.ethereum.org/EIPS/eip-7702
365
380
  * @param {AuthorizationRequest} auth - The authorization request.
366
381
  * @returns {Promise<Authorization>} The signed authorization.
367
382
  * @throws {ProviderRequiredError} If the chainId or nonce are not provided and the wallet is not connected to a provider.
383
+ * @throws {AssertionError} If the chainId is not provided and the provider reports a chain id of 0.
368
384
  */
369
385
  async signAuthorization (auth) {
370
386
  const populated = { ...auth }
371
- if (populated.chainId === undefined || populated.nonce === undefined) {
387
+ if (populated.chainId == null || populated.nonce == null) {
372
388
  if (!this._provider) {
373
389
  throw new ProviderRequiredError('The wallet must be connected to a provider to populate the authorization chainId and nonce. Provide them explicitly to sign offline.')
374
390
  }
375
391
  if (populated.chainId == null) {
376
392
  const { chainId } = await this._provider.getNetwork()
393
+ if (chainId === 0n) {
394
+ throw new AssertionError('The provider reported chain id 0, which would make the authorization valid on every chain.')
395
+ }
377
396
  populated.chainId = chainId
378
397
  }
379
398
  if (populated.nonce == null) {
@@ -394,6 +413,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
394
413
  * @param {string} delegateAddress - The address of the contract to delegate to.
395
414
  * @returns {Promise<TransactionResult>} The transaction result.
396
415
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
416
+ * @throws {AssertionError} If the provider reports a chain id of 0.
397
417
  */
398
418
  async delegate (delegateAddress) {
399
419
  if (!this._provider) {
@@ -423,6 +443,8 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
423
443
  * Revokes any active ERC-7702 delegation by delegating to the zero address.
424
444
  *
425
445
  * @returns {Promise<TransactionResult>} The transaction result.
446
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
447
+ * @throws {AssertionError} If the provider reports a chain id of 0.
426
448
  */
427
449
  async revokeDelegation () {
428
450
  return await this.delegate(ZeroAddress)
@@ -27,10 +27,10 @@ import FailoverProvider from '@tetherto/wdk-failover-provider'
27
27
  /** @typedef {import('ethers').TypedDataDomain} TypedDataDomain */
28
28
  /** @typedef {import('ethers').TypedDataField} TypedDataField */
29
29
  /** @typedef {import('ethers').AuthorizationLike} AuthorizationLike */
30
- /** @typedef {import('ethers').BlobLike} BlobLike */
31
30
  /** @typedef {import('ethers').TransactionReceipt} EvmTransactionReceipt */
32
31
  /** @typedef {import('ethers').TransactionResponse} EvmTransactionResponse */
33
32
  /** @typedef {import('ethers').TransactionRequest} EvmTransactionRequest */
33
+ /** @typedef {import('ethers').Transaction} Transaction */
34
34
 
35
35
  /** @typedef {import('@tetherto/wdk-wallet').TransactionResult} TransactionResult */
36
36
  /** @typedef {import('@tetherto/wdk-wallet').TransferResult} TransferResult */
@@ -68,12 +68,9 @@ import FailoverProvider from '@tetherto/wdk-failover-provider'
68
68
  * @property {number | bigint} [gasPrice] - The price (in wei) per unit of gas this transaction will pay.
69
69
  * @property {number | bigint} [maxFeePerGas] - The maximum price (in wei) per unit of gas this transaction will pay for the combined [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee and this transaction's priority fee.
70
70
  * @property {number | bigint} [maxPriorityFeePerGas] - The price (in wei) per unit of gas this transaction will allow in addition to the [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) block's base fee to bribe miners into giving this transaction priority. This is included in the maxFeePerGas, so this will not affect the total maximum cost set with maxFeePerGas.
71
- * @property {number} [type] - The transaction type (e.g. 4 for ERC-7702).
71
+ * @property {number} [type] - The [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) transaction type: 0 for legacy, 1 for [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) access-list, 2 for [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559), 4 for ERC-7702. Type 3 ([EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob transactions) is not supported and is rejected. Omit to have the type inferred from the transaction's fields and the network's fee data.
72
72
  * @property {number} [nonce] - The transaction nonce.
73
73
  * @property {number | bigint} [chainId] - The chain ID of the network.
74
- * @property {number | bigint} [maxFeePerBlobGas] - The maximum price (in wei) per unit of blob gas this transaction will pay for [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob data. Required for type 3 (blob) transactions.
75
- * @property {BlobLike[]} [blobs] - The blobs of an [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) type 3 transaction.
76
- * @property {string[]} [blobVersionedHashes] - The versioned hashes of the blobs of an [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) type 3 transaction.
77
74
  * @property {AuthorizationLike[]} [authorizationList] - An optional list of ERC-7702 signed authorizations for type 4 transactions.
78
75
  */
79
76
 
@@ -94,7 +91,7 @@ import FailoverProvider from '@tetherto/wdk-failover-provider'
94
91
  * @typedef {Object} EvmWalletConfig
95
92
  * @property {string | Provider | Eip1193Provider | Array<string | Provider | Eip1193Provider>} [provider] - The url of the rpc provider, an already-built ethers provider (e.g. a `JsonRpcProvider` or a failover wrapper), 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. An already-built provider is reused as-is, which lets a manager share a single provider across all the accounts it creates.
96
93
  * @property {number} [retries] - 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.
97
- * @property {number} [chainId] - The chain ID of the network. When provided, skips automatic chain ID detection from the provider.
94
+ * @property {number} [chainId] - The chain ID of the network. When provided, skips automatic chain ID detection from the provider, except for an already-built provider passed in `provider`, which is reused with its own network configuration.
98
95
  * @property {number | bigint} [transferMaxFee] - The maximum fee amount for transfer operations.
99
96
  * @property {number | bigint} [transactionMaxFee] - The maximum fee amount for sendTransaction and signTransaction operations.
100
97
  */
@@ -142,9 +139,10 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
142
139
  }
143
140
 
144
141
  /**
145
- * Builds an ethers provider from the wallet configuration:
142
+ * Builds an ethers provider from the wallet configuration. When `chainId` is set, the providers built here are
143
+ * pinned to that chain and never ask the rpc for it:
146
144
  * - a url string -> a new `JsonRpcProvider`
147
- * - an already-built ethers provider (or failover wrapper) -> reused as-is
145
+ * - an already-built ethers provider (or failover wrapper) -> reused as-is, with its own network configuration
148
146
  * - anything else (EIP-1193 / browser wallet) -> wrapped in a `BrowserProvider`
149
147
  * - an array of the above -> a `FailoverProvider` across each entry
150
148
  *
@@ -163,7 +161,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
163
161
  }
164
162
 
165
163
  if (WalletAccountReadOnlyEvm._isEip1193Provider(entry)) {
166
- return new BrowserProvider(entry)
164
+ return new BrowserProvider(entry, network, providerOpts)
167
165
  }
168
166
 
169
167
  return entry
@@ -279,17 +277,37 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
279
277
  }, {})
280
278
  }
281
279
 
280
+ /**
281
+ * Whether the given transaction is an EIP-4844 (type 3) blob transaction.
282
+ *
283
+ * @protected
284
+ * @param {EvmTransaction | Transaction} tx - The transaction to inspect.
285
+ * @returns {boolean} True if the transaction explicitly targets type 3, or carries any blob field.
286
+ */
287
+ static _isBlobTransaction (tx) {
288
+ const hasBlobs = (
289
+ ('blobs' in tx && tx.blobs != null) ||
290
+ ('blobVersionedHashes' in tx && tx.blobVersionedHashes != null) ||
291
+ ('maxFeePerBlobGas' in tx && tx.maxFeePerBlobGas != null)
292
+ )
293
+
294
+ return Number(tx.type) === 3 || hasBlobs
295
+ }
296
+
282
297
  /**
283
298
  * Validates that a transaction does not mix fee fields its type doesn't support.
284
299
  *
285
300
  * @protected
286
301
  * @param {EvmTransaction} tx - The transaction to validate.
287
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
302
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
288
303
  */
289
304
  static _validateFeeFields (tx) {
305
+ if (WalletAccountReadOnlyEvm._isBlobTransaction(tx)) {
306
+ throw new ValueError('eip-4844 blob transactions are not supported')
307
+ }
308
+
290
309
  const has1559 = tx.maxFeePerGas !== undefined || tx.maxPriorityFeePerGas !== undefined
291
310
  const hasLegacy = tx.gasPrice !== undefined
292
- const hasBlobs = tx.blobs !== undefined || tx.blobVersionedHashes !== undefined || tx.maxFeePerBlobGas !== undefined
293
311
  const hasAuthList = tx.authorizationList !== undefined
294
312
  const explicitType = (tx.type !== undefined) ? Number(tx.type) : null
295
313
 
@@ -299,12 +317,6 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
299
317
  if ((explicitType === 0 || explicitType === 1) && has1559) {
300
318
  throw new ValueError('pre-eip-1559 transaction does not support maxFeePerGas/maxPriorityFeePerGas')
301
319
  }
302
- if ((explicitType === 3 || hasBlobs) && hasLegacy) {
303
- throw new ValueError('blob transaction does not support gasPrice')
304
- }
305
- if ((explicitType === 3 || hasBlobs) && tx.maxFeePerBlobGas === undefined) {
306
- throw new ValueError('maxFeePerBlobGas is required for type 3 transactions')
307
- }
308
320
  if ((explicitType === 4 || (explicitType === null && hasAuthList)) && hasLegacy) {
309
321
  throw new ValueError('eip-7702 transaction does not support gasPrice')
310
322
  }
@@ -321,7 +333,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
321
333
  * @param {EvmTransaction} tx - The transaction.
322
334
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
323
335
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
324
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
336
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
325
337
  * @throws {Error} If the simulation of the transaction reverts, as an ethers error with code `CALL_EXCEPTION`.
326
338
  */
327
339
  async quoteSendTransaction (tx) {
@@ -94,6 +94,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
94
94
  *
95
95
  * @param {EvmTransaction} tx - The transaction to sign.
96
96
  * @returns {Promise<string>} The signed transaction as a hex string.
97
+ * @throws {ValueError} If the transaction is an EIP-4844 (type 3) blob transaction.
97
98
  * @throws {MaximumFeeExceededError} If a provider is set, and the transaction's cost surpasses the transaction max. fee option.
98
99
  */
99
100
  signTransaction(tx: EvmTransaction): Promise<string>;
@@ -104,7 +105,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
104
105
  * @returns {Promise<TransactionResult>} The transaction's result.
105
106
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
106
107
  * @throws {MaximumFeeExceededError} If the transaction's cost exceeds the maximum transaction fee option.
107
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
108
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
108
109
  */
109
110
  sendTransaction(tx: EvmTransaction | string): Promise<TransactionResult>;
110
111
  /**
@@ -119,7 +120,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
119
120
  * @param {EvmTransaction | string} tx - The transaction, or a signed raw transaction as a hex string.
120
121
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
121
122
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
122
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
123
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
123
124
  * @throws {Error} If the simulation of the transaction reverts, as an ethers error with code `CALL_EXCEPTION`.
124
125
  */
125
126
  quoteSendTransaction(tx: EvmTransaction | string): Promise<Omit<TransactionResult, "hash">>;
@@ -152,9 +153,14 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
152
153
  *
153
154
  * The chainId and nonce are populated from the provider when not explicitly provided.
154
155
  *
156
+ * A chainId of 0 makes the authorization valid on every chain, so it is only signed when given explicitly, never
157
+ * when reported by the provider.
158
+ *
159
+ * @see https://eips.ethereum.org/EIPS/eip-7702
155
160
  * @param {AuthorizationRequest} auth - The authorization request.
156
161
  * @returns {Promise<Authorization>} The signed authorization.
157
162
  * @throws {ProviderRequiredError} If the chainId or nonce are not provided and the wallet is not connected to a provider.
163
+ * @throws {AssertionError} If the chainId is not provided and the provider reports a chain id of 0.
158
164
  */
159
165
  signAuthorization(auth: AuthorizationRequest): Promise<Authorization>;
160
166
  /**
@@ -167,12 +173,15 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
167
173
  * @param {string} delegateAddress - The address of the contract to delegate to.
168
174
  * @returns {Promise<TransactionResult>} The transaction result.
169
175
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
176
+ * @throws {AssertionError} If the provider reports a chain id of 0.
170
177
  */
171
178
  delegate(delegateAddress: string): Promise<TransactionResult>;
172
179
  /**
173
180
  * Revokes any active ERC-7702 delegation by delegating to the zero address.
174
181
  *
175
182
  * @returns {Promise<TransactionResult>} The transaction result.
183
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
184
+ * @throws {AssertionError} If the provider reports a chain id of 0.
176
185
  */
177
186
  revokeDelegation(): Promise<TransactionResult>;
178
187
  /**
@@ -16,9 +16,10 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
16
16
  */
17
17
  protected static _isEip1193Provider(value: string | Eip1193Provider | Provider): boolean;
18
18
  /**
19
- * Builds an ethers provider from the wallet configuration:
19
+ * Builds an ethers provider from the wallet configuration. When `chainId` is set, the providers built here are
20
+ * pinned to that chain and never ask the rpc for it:
20
21
  * - a url string -> a new `JsonRpcProvider`
21
- * - an already-built ethers provider (or failover wrapper) -> reused as-is
22
+ * - an already-built ethers provider (or failover wrapper) -> reused as-is, with its own network configuration
22
23
  * - anything else (EIP-1193 / browser wallet) -> wrapped in a `BrowserProvider`
23
24
  * - an array of the above -> a `FailoverProvider` across each entry
24
25
  *
@@ -27,12 +28,20 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
27
28
  * @returns {Provider | undefined} The provider, or undefined if none is configured.
28
29
  */
29
30
  protected static _buildProvider(config?: Omit<EvmWalletConfig, "transferMaxFee" | "transactionMaxFee">): Provider | undefined;
31
+ /**
32
+ * Whether the given transaction is an EIP-4844 (type 3) blob transaction.
33
+ *
34
+ * @protected
35
+ * @param {EvmTransaction | Transaction} tx - The transaction to inspect.
36
+ * @returns {boolean} True if the transaction explicitly targets type 3, or carries any blob field.
37
+ */
38
+ protected static _isBlobTransaction(tx: EvmTransaction | Transaction): boolean;
30
39
  /**
31
40
  * Validates that a transaction does not mix fee fields its type doesn't support.
32
41
  *
33
42
  * @protected
34
43
  * @param {EvmTransaction} tx - The transaction to validate.
35
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
44
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
36
45
  */
37
46
  protected static _validateFeeFields(tx: EvmTransaction): void;
38
47
  /**
@@ -107,7 +116,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
107
116
  * @param {EvmTransaction} tx - The transaction.
108
117
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
109
118
  * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
110
- * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
119
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or if it is an EIP-4844 (type 3) blob transaction.
111
120
  * @throws {Error} If the simulation of the transaction reverts, as an ethers error with code `CALL_EXCEPTION`.
112
121
  */
113
122
  quoteSendTransaction(tx: EvmTransaction): Promise<Omit<TransactionResult, "hash">>;
@@ -219,11 +228,11 @@ export type Provider = import("ethers").Provider;
219
228
  export type Eip1193Provider = import("ethers").Eip1193Provider;
220
229
  export type TypedDataDomain = import("ethers").TypedDataDomain;
221
230
  export type TypedDataField = import("ethers").TypedDataField;
222
- export type BlobLike = import("ethers").BlobLike;
223
231
  export type AuthorizationLike = import("ethers").AuthorizationLike;
224
232
  export type EvmTransactionReceipt = import("ethers").TransactionReceipt;
225
233
  export type EvmTransactionResponse = import("ethers").TransactionResponse;
226
234
  export type EvmTransactionRequest = import("ethers").TransactionRequest;
235
+ export type Transaction = import("ethers").Transaction;
227
236
  export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult;
228
237
  export type TransferResult = import("@tetherto/wdk-wallet").TransferResult;
229
238
  export type TransactionReceipt = import("@tetherto/wdk-wallet").TransactionReceipt;
@@ -296,7 +305,7 @@ export type EvmTransaction = {
296
305
  */
297
306
  maxPriorityFeePerGas?: number | bigint;
298
307
  /**
299
- * - The transaction type (e.g. 4 for ERC-7702).
308
+ * - The [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) transaction type: 0 for legacy, 1 for [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) access-list, 2 for [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559), 4 for ERC-7702. Type 3 ([EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob transactions) is not supported and is rejected. Omit to have the type inferred from the transaction's fields and the network's fee data.
300
309
  */
301
310
  type?: number;
302
311
  /**
@@ -307,18 +316,6 @@ export type EvmTransaction = {
307
316
  * - The chain ID of the network.
308
317
  */
309
318
  chainId?: number | bigint;
310
- /**
311
- * - The maximum price (in wei) per unit of blob gas this transaction will pay for [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob data. Required for type 3 (blob) transactions.
312
- */
313
- maxFeePerBlobGas?: number | bigint;
314
- /**
315
- * - The blobs of an [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) type 3 transaction.
316
- */
317
- blobs?: BlobLike[];
318
- /**
319
- * - The versioned hashes of the blobs of an [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) type 3 transaction.
320
- */
321
- blobVersionedHashes?: string[];
322
319
  /**
323
320
  * - An optional list of ERC-7702 signed authorizations for type 4 transactions.
324
321
  */
@@ -343,7 +340,7 @@ export type EvmWalletConfig = {
343
340
  */
344
341
  retries?: number;
345
342
  /**
346
- * - The chain ID of the network. When provided, skips automatic chain ID detection from the provider.
343
+ * - The chain ID of the network. When provided, skips automatic chain ID detection from the provider, except for an already-built provider passed in `provider`, which is reused with its own network configuration.
347
344
  */
348
345
  chainId?: number;
349
346
  /**