@tetherto/wdk-wallet-evm 1.0.0-beta.15 → 1.0.0-beta.17

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,9 +1,8 @@
1
- require('@nomicfoundation/hardhat-ethers')
2
-
3
1
  /** @type {import('hardhat/config').HardhatUserConfig} */
4
- module.exports = {
2
+ export default {
5
3
  networks: {
6
4
  hardhat: {
5
+ type: 'edr-simulated',
7
6
  chainId: 1,
8
7
  hardfork: 'prague',
9
8
  accounts: {
package/index.js CHANGED
@@ -19,17 +19,23 @@
19
19
  /** @typedef {import('ethers').Authorization} Authorization */
20
20
  /** @typedef {import('ethers').AuthorizationLike} AuthorizationLike */
21
21
  /** @typedef {import('ethers').TransactionReceipt} EvmTransactionReceipt */
22
+ /** @typedef {import('ethers').TransactionResponse} EvmTransactionResponse */
22
23
 
23
24
  /** @typedef {import('@tetherto/wdk-wallet').FeeRates} FeeRates */
24
25
  /** @typedef {import('@tetherto/wdk-wallet').KeyPair} KeyPair */
25
26
  /** @typedef {import('@tetherto/wdk-wallet').TransactionResult} TransactionResult */
26
27
  /** @typedef {import('@tetherto/wdk-wallet').TransferResult} TransferResult */
28
+ /** @typedef {import('@tetherto/wdk-wallet').Finality} Finality */
29
+ /** @typedef {import('@tetherto/wdk-wallet').TransactionReceipt} TransactionReceipt */
30
+ /** @typedef {import('@tetherto/wdk-wallet').WaitForTransactionTarget} WaitForTransactionTarget */
31
+ /** @typedef {import('@tetherto/wdk-wallet').WaitForTransactionOptions} WaitForTransactionOptions */
27
32
 
28
33
  /** @typedef {import('./src/wallet-account-read-only-evm.js').TypedData} TypedData */
29
34
  /** @typedef {import('./src/wallet-account-read-only-evm.js').DelegationInfo} DelegationInfo */
30
35
  /** @typedef {import('./src/wallet-account-read-only-evm.js').EvmTransaction} EvmTransaction */
31
36
  /** @typedef {import('./src/wallet-account-read-only-evm.js').EvmTransferOptions} EvmTransferOptions */
32
37
  /** @typedef {import('./src/wallet-account-read-only-evm.js').EvmWalletConfig} EvmWalletConfig */
38
+ /** @typedef {import('./src/wallet-account-read-only-evm.js').EvmTransactionDetails} EvmTransactionDetails */
33
39
 
34
40
  /** @typedef {import('./src/wallet-account-evm.js').ApproveOptions} ApproveOptions */
35
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet-evm",
3
- "version": "1.0.0-beta.15",
3
+ "version": "1.0.0-beta.17",
4
4
  "description": "A simple package to manage BIP-32 wallets for evm blockchains.",
5
5
  "keywords": [
6
6
  "wdk",
@@ -21,38 +21,38 @@
21
21
  "build:types": "tsc",
22
22
  "lint": "standard",
23
23
  "lint:fix": "standard --fix",
24
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
25
- "test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
26
- "test:integration": "cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/integration",
27
- "test:integration:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/integration --coverage"
24
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=/tests/integration/",
25
+ "test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage --testPathIgnorePatterns=/tests/integration/",
26
+ "test:integration-wait": "wait-on tcp:127.0.0.1:8545 && cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/integration --runInBand",
27
+ "test:integration-wait:coverage": "wait-on tcp:127.0.0.1:8545 && cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/integration --coverage --runInBand",
28
+ "test:integration": "concurrently -k -s first -n \"NODE,TEST\" -c \"black,green\" --hide NODE \"npx hardhat node --network hardhat\" \"npm run test:integration-wait\"",
29
+ "test:integration:coverage": "concurrently -k -s first -n \"NODE,TEST\" -c \"black,green\" --hide NODE \"npx hardhat node --network hardhat\" \"npm run test:integration-wait:coverage\""
28
30
  },
29
31
  "dependencies": {
30
32
  "@noble/hashes": "1.8.0",
31
33
  "@noble/secp256k1": "2.2.3",
32
- "@tetherto/wdk-wallet": "1.0.0-beta.13",
33
34
  "@tetherto/wdk-failover-provider": "1.0.0-beta.2",
35
+ "@tetherto/wdk-wallet": "1.0.0-beta.17",
34
36
  "bare-node-runtime": "^1.5.0",
35
37
  "bip39": "3.1.0",
36
38
  "ethers": "6.17.0",
37
39
  "sodium-universal": "5.0.1"
38
40
  },
39
41
  "devDependencies": {
40
- "@nomicfoundation/hardhat-ethers": "3.0.9",
42
+ "concurrently": "9.2.0",
41
43
  "cross-env": "7.0.3",
42
- "hardhat": "2.24.2",
44
+ "hardhat": "3.12.0",
43
45
  "jest": "29.7.0",
44
46
  "standard": "17.1.2",
45
- "typescript": "5.8.3"
47
+ "typescript": "5.8.3",
48
+ "wait-on": "8.0.4"
46
49
  },
47
- "overrides": {
48
- "brace-expansion": "1.1.15",
49
- "cookie": "1.1.1",
50
- "immutable": "4.3.8",
51
- "picomatch@2": "2.3.2",
52
- "serialize-javascript": ">=7.0.5",
53
- "tmp": "0.2.6",
54
- "undici": "8.3.0",
55
- "uuid": "14.0.0"
50
+ "devEngines": {
51
+ "runtime": {
52
+ "name": "node",
53
+ "version": ">=22.13.0",
54
+ "onFail": "error"
55
+ }
56
56
  },
57
57
  "exports": {
58
58
  ".": {
@@ -15,7 +15,7 @@
15
15
 
16
16
  import { BaseWallet } from 'ethers'
17
17
 
18
- import { SignerError } from '@tetherto/wdk-wallet'
18
+ import { InvalidSignerError } from '@tetherto/wdk-wallet'
19
19
 
20
20
  import MemorySafeSigningKey from '../memory-safe/signing-key.js'
21
21
  import { ISignerEvm } from './seed-signer-evm.js'
@@ -97,10 +97,10 @@ export default class PrivateKeySignerEvm extends ISignerEvm {
97
97
  /**
98
98
  * PrivateKeySignerEvm is not a hierarchical signer and cannot derive.
99
99
  * @returns {Promise<never>}
100
- * @throws {SignerError} Always — private-key signers do not support derivation.
100
+ * @throws {InvalidSignerError} Always — private-key signers do not support derivation.
101
101
  */
102
102
  async derive () {
103
- throw new SignerError('PrivateKeySignerEvm does not support derivation.')
103
+ throw new InvalidSignerError('PrivateKeySignerEvm does not support derivation.')
104
104
  }
105
105
 
106
106
  /** @returns {Promise<string>} */
@@ -25,7 +25,7 @@ const DEFAULT_ACCOUNT_PATH = "0'/0/0"
25
25
 
26
26
  /** @typedef {import('../utils/tx-populator-evm.js').UnsignedEvmTransaction} UnsignedEvmTransaction */
27
27
  /** @typedef {import('@tetherto/wdk-wallet').ISigner} ISigner */
28
- /** @typedef {import('@tetherto/wdk-wallet').SignerError} SignerError */
28
+ /** @typedef {import('@tetherto/wdk-wallet').InvalidSignerError} InvalidSignerError */
29
29
  /** @typedef {import('@tetherto/wdk-wallet').KeyPair} KeyPair */
30
30
  /** @typedef {import('ethers').AuthorizationRequest} AuthorizationRequest */
31
31
  /** @typedef {import('ethers').Authorization} Authorization */
@@ -93,7 +93,7 @@ export class ISignerEvm extends ISigner {
93
93
  *
94
94
  * @param {string} relPath - The relative BIP-44 path segment.
95
95
  * @returns {Promise<ISignerEvm>} The derived child signer.
96
- * @throws {SignerError} If the signer does not support derivation (e.g. private-key signers).
96
+ * @throws {InvalidSignerError} If the signer does not support derivation (e.g. private-key signers).
97
97
  */
98
98
  async derive (relPath) {
99
99
  throw new NotImplementedError('derive(relPath)')
@@ -14,7 +14,7 @@
14
14
 
15
15
  'use strict'
16
16
 
17
- import { Contract, ZeroAddress } from 'ethers'
17
+ import { Contract, Transaction, ZeroAddress } from 'ethers'
18
18
 
19
19
  import WalletAccountReadOnlyEvm from './wallet-account-read-only-evm.js'
20
20
 
@@ -50,7 +50,7 @@ const USDT_MAINNET_ADDRESS = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
50
50
 
51
51
  const DELEGATION_TX_GAS_LIMIT = 100_000
52
52
 
53
- /** @implements {IWalletAccount} */
53
+ /** @implements {IWalletAccount<string>} */
54
54
  export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
55
55
  /**
56
56
  * Creates a new evm wallet account from a BIP-39 seed, deriving the account's key at the
@@ -191,7 +191,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
191
191
  /**
192
192
  * Sends a transaction.
193
193
  *
194
- * @param {EvmTransaction} tx - The transaction.
194
+ * @param {EvmTransaction | string} tx - The transaction.
195
195
  * @returns {Promise<TransactionResult>} The transaction's result.
196
196
  * @throws {Error} If the transaction's cost exceeds the maximum transaction fee option.
197
197
  */
@@ -211,6 +211,36 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
211
211
  return { hash, fee }
212
212
  }
213
213
 
214
+ /**
215
+ * Quotes the costs of a send transaction operation.
216
+ *
217
+ * @param {EvmTransaction | string} tx - The transaction.
218
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
219
+ */
220
+ async quoteSendTransaction (tx) {
221
+ if (typeof tx === 'string') {
222
+ if (!this._provider) {
223
+ throw new Error('The wallet must be connected to a provider to quote send transaction operations.')
224
+ }
225
+
226
+ const { from, to, value, data, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, type, nonce, chainId, authorizationList } = Transaction.from(tx)
227
+
228
+ const transaction = { from, to, value, data, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, type, nonce, chainId, authorizationList }
229
+
230
+ const gas = transaction.authorizationList
231
+ ? await this._estimateGasWithAuthList(transaction)
232
+ : await this._provider.estimateGas(transaction)
233
+
234
+ const fees = await this._provider.getFeeData()
235
+
236
+ const feeRate = fees.maxFeePerGas || fees.gasPrice
237
+
238
+ return { fee: gas * feeRate }
239
+ }
240
+
241
+ return await super.quoteSendTransaction(tx)
242
+ }
243
+
214
244
  /**
215
245
  * Transfers a token to another address.
216
246
  *
@@ -14,9 +14,9 @@
14
14
 
15
15
  'use strict'
16
16
 
17
- import { WalletAccountReadOnly } from '@tetherto/wdk-wallet'
17
+ import { WalletAccountReadOnly, NoSuchElementError, ValueError } from '@tetherto/wdk-wallet'
18
18
 
19
- import { BrowserProvider, Contract, Interface, JsonRpcProvider, Network, Signature, toQuantity, verifyMessage, verifyTypedData } from 'ethers'
19
+ import { BrowserProvider, Contract, Interface, isError, isHexString, JsonRpcProvider, Network, Signature, toQuantity, verifyMessage, verifyTypedData } from 'ethers'
20
20
 
21
21
  import { multicall } from './multicall.js'
22
22
 
@@ -28,9 +28,20 @@ import FailoverProvider from '@tetherto/wdk-failover-provider'
28
28
  /** @typedef {import('ethers').TypedDataField} TypedDataField */
29
29
  /** @typedef {import('ethers').AuthorizationLike} AuthorizationLike */
30
30
  /** @typedef {import('ethers').TransactionReceipt} EvmTransactionReceipt */
31
+ /** @typedef {import('ethers').TransactionResponse} EvmTransactionResponse */
31
32
 
32
33
  /** @typedef {import('@tetherto/wdk-wallet').TransactionResult} TransactionResult */
33
34
  /** @typedef {import('@tetherto/wdk-wallet').TransferResult} TransferResult */
35
+ /** @typedef {import('@tetherto/wdk-wallet').TransactionReceipt} TransactionReceipt */
36
+ /** @typedef {import('@tetherto/wdk-wallet').WaitForTransactionOptions} WaitForTransactionOptions */
37
+
38
+ /**
39
+ * The EVM-specific fields added to a normalized transaction receipt.
40
+ *
41
+ * @typedef {Object} EvmTransactionDetails
42
+ * @property {number} confirmations - The number of confirmations (0 while pending or dropped).
43
+ * @property {EvmTransactionReceipt | null} receipt - The native ethers receipt, or null while the transaction is pending or dropped.
44
+ */
34
45
 
35
46
  /**
36
47
  * @typedef {Object} TypedData
@@ -260,6 +271,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
260
271
  /**
261
272
  * Returns a transaction's receipt.
262
273
  *
274
+ * @deprecated Use {@link getTransaction} instead, which returns a normalized, finality-based receipt. The raw ethers receipt remains available on its `receipt` property.
263
275
  * @param {string} hash - The transaction's hash.
264
276
  * @returns {Promise<EvmTransactionReceipt | null>} – The receipt, or null if the transaction has not been included in a block yet.
265
277
  */
@@ -271,6 +283,115 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
271
283
  return await this._provider.getTransactionReceipt(hash)
272
284
  }
273
285
 
286
+ /**
287
+ * Returns a normalized, finality-based receipt for a transaction.
288
+ *
289
+ * @param {string} hash - The transaction's hash.
290
+ * @returns {Promise<TransactionReceipt & EvmTransactionDetails>} The normalized receipt.
291
+ * @throws {ValueError} If the hash is not a valid transaction hash.
292
+ * @throws {NoSuchElementError} If no transaction has been found for the given hash.
293
+ */
294
+ async getTransaction (hash) {
295
+ if (!this._provider) {
296
+ throw new Error('The wallet must be connected to a provider to fetch transactions.')
297
+ }
298
+
299
+ if (!isHexString(hash, 32)) {
300
+ throw new ValueError(`Invalid transaction hash: '${hash}'.`)
301
+ }
302
+
303
+ const [transaction, receipt] = await Promise.all([
304
+ this._provider.getTransaction(hash),
305
+ this._provider.getTransactionReceipt(hash)
306
+ ])
307
+
308
+ if (!transaction && !receipt) {
309
+ throw new NoSuchElementError(`No transaction found for '${hash}'.`)
310
+ }
311
+
312
+ if (!receipt) {
313
+ const dropped = transaction
314
+ ? await this._isReplaced(transaction)
315
+ : false
316
+
317
+ return {
318
+ hash,
319
+ finality: dropped ? 'dropped' : 'pending',
320
+ confirmations: 0,
321
+ receipt: null
322
+ }
323
+ }
324
+
325
+ const confirmations = await receipt.confirmations()
326
+ const finalized = await this._isFinalized(receipt.blockNumber)
327
+
328
+ return {
329
+ hash,
330
+ finality: finalized ? 'final' : 'confirmed',
331
+ success: receipt.status === 1,
332
+ block: receipt.blockNumber,
333
+ fee: receipt.fee,
334
+ confirmations,
335
+ receipt
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Blocks until a transaction reaches a terminal state (the requested finality target or `dropped`), or times out.
341
+ *
342
+ * @param {string} hash - The transaction's hash.
343
+ * @param {WaitForTransactionOptions} [options] - The wait options.
344
+ * @returns {Promise<TransactionReceipt & EvmTransactionDetails>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
345
+ * @throws {TimeoutError} If the target is not reached before the timeout.
346
+ */
347
+ async waitForTransaction (hash, options = {}) {
348
+ return await super.waitForTransaction(hash, options)
349
+ }
350
+
351
+ /**
352
+ * Returns whether a block is at or below the chain's `finalized` block. Chains that don't support the tag are treated as not finalized.
353
+ *
354
+ * @protected
355
+ * @param {number} blockNumber - The block number to check.
356
+ * @returns {Promise<boolean>} True if the block is finalized.
357
+ */
358
+ async _isFinalized (blockNumber) {
359
+ try {
360
+ const finalizedBlock = await this._provider.getBlock('finalized')
361
+ return !!finalizedBlock && blockNumber <= finalizedBlock.number
362
+ } catch (error) {
363
+ // Treat an unsupported 'finalized' block tag as not-finalized; let real failures propagate.
364
+ const rpcCode = error?.info?.error?.code
365
+
366
+ if (isError(error, 'UNSUPPORTED_OPERATION') || rpcCode === -32601 || rpcCode === -32602) {
367
+ return false
368
+ }
369
+
370
+ throw error
371
+ }
372
+ }
373
+
374
+ /**
375
+ * Returns whether an unmined transaction has been replaced, i.e. its sender's mined nonce has already advanced past the transaction's nonce.
376
+ *
377
+ * @protected
378
+ * @param {EvmTransactionResponse} transaction - The unmined transaction.
379
+ * @returns {Promise<boolean>} True if the transaction's nonce slot is already taken.
380
+ */
381
+ async _isReplaced (transaction) {
382
+ const accountNonce = await this._provider.getTransactionCount(transaction.from, 'latest')
383
+ return accountNonce > transaction.nonce
384
+ }
385
+
386
+ /**
387
+ * Overrides the base default to allow for slower EVM inclusion and confirmation.
388
+ *
389
+ * @type {number}
390
+ */
391
+ get defaultWaitTimeout () {
392
+ return 120000
393
+ }
394
+
274
395
  /**
275
396
  * Returns the current allowance for the given token and spender.
276
397
  * @param {string} token The token's address.
@@ -28,7 +28,7 @@ import SeedSignerEvm from './signers/seed-signer-evm.js'
28
28
 
29
29
  /** @typedef {import("@tetherto/wdk-wallet").FeeRates} FeeRates */
30
30
  /** @typedef {import("@tetherto/wdk-wallet").ISigner} ISigner */
31
- /** @typedef {import("@tetherto/wdk-wallet").SignerError} SignerError */
31
+ /** @typedef {import("@tetherto/wdk-wallet").InvalidSignerError} InvalidSignerError */
32
32
 
33
33
  /** @typedef {import('./wallet-account-evm.js').EvmWalletConfig} EvmWalletConfig */
34
34
 
@@ -118,7 +118,7 @@ export default class WalletManagerEvm extends WalletManager {
118
118
  * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
119
119
  * @returns {Promise<WalletAccountEvm>} The account.
120
120
  * @throws {Error} If a signer name is given but no signer exists with that name.
121
- * @throws {SignerError} If the signer doesn't support account derivation.
121
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
122
122
  */
123
123
 
124
124
  /**
@@ -159,7 +159,7 @@ export default class WalletManagerEvm extends WalletManager {
159
159
  * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
160
160
  * @returns {Promise<WalletAccountEvm>} The account.
161
161
  * @throws {Error} If a signer name is given but no signer exists with that name.
162
- * @throws {SignerError} If the signer doesn't support account derivation.
162
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
163
163
  */
164
164
  async getAccountByPath (path, options = {}) {
165
165
  const { signerName } = options
package/types/index.d.ts CHANGED
@@ -7,14 +7,20 @@ export type AuthorizationRequest = import("ethers").AuthorizationRequest;
7
7
  export type Authorization = import("ethers").Authorization;
8
8
  export type AuthorizationLike = import("ethers").AuthorizationLike;
9
9
  export type EvmTransactionReceipt = import("ethers").TransactionReceipt;
10
+ export type EvmTransactionResponse = import("ethers").TransactionResponse;
10
11
  export type FeeRates = import("@tetherto/wdk-wallet").FeeRates;
11
12
  export type KeyPair = import("@tetherto/wdk-wallet").KeyPair;
12
13
  export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult;
13
14
  export type TransferResult = import("@tetherto/wdk-wallet").TransferResult;
15
+ export type Finality = import("@tetherto/wdk-wallet").Finality;
16
+ export type TransactionReceipt = import("@tetherto/wdk-wallet").TransactionReceipt;
17
+ export type WaitForTransactionTarget = import("@tetherto/wdk-wallet").WaitForTransactionTarget;
18
+ export type WaitForTransactionOptions = import("@tetherto/wdk-wallet").WaitForTransactionOptions;
14
19
  export type TypedData = import("./src/wallet-account-read-only-evm.js").TypedData;
15
20
  export type DelegationInfo = import("./src/wallet-account-read-only-evm.js").DelegationInfo;
16
21
  export type EvmTransaction = import("./src/wallet-account-read-only-evm.js").EvmTransaction;
17
22
  export type EvmTransferOptions = import("./src/wallet-account-read-only-evm.js").EvmTransferOptions;
18
23
  export type EvmWalletConfig = import("./src/wallet-account-read-only-evm.js").EvmWalletConfig;
24
+ export type EvmTransactionDetails = import("./src/wallet-account-read-only-evm.js").EvmTransactionDetails;
19
25
  export type ApproveOptions = import("./src/wallet-account-evm.js").ApproveOptions;
20
26
  export type UnsignedEvmTransaction = import("./src/utils/tx-populator-evm.js").UnsignedEvmTransaction;
@@ -39,7 +39,7 @@ export default class PrivateKeySignerEvm extends ISignerEvm {
39
39
  /**
40
40
  * PrivateKeySignerEvm is not a hierarchical signer and cannot derive.
41
41
  * @returns {Promise<never>}
42
- * @throws {SignerError} Always — private-key signers do not support derivation.
42
+ * @throws {InvalidSignerError} Always — private-key signers do not support derivation.
43
43
  */
44
44
  derive(): Promise<never>;
45
45
  /** @returns {Promise<string>} */
@@ -79,7 +79,7 @@ export class ISignerEvm extends ISigner {
79
79
  *
80
80
  * @param {string} relPath - The relative BIP-44 path segment.
81
81
  * @returns {Promise<ISignerEvm>} The derived child signer.
82
- * @throws {SignerError} If the signer does not support derivation (e.g. private-key signers).
82
+ * @throws {InvalidSignerError} If the signer does not support derivation (e.g. private-key signers).
83
83
  */
84
84
  derive(relPath: string): Promise<ISignerEvm>;
85
85
  /**
@@ -1,5 +1,5 @@
1
- /** @implements {IWalletAccount} */
2
- export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implements IWalletAccount {
1
+ /** @implements {IWalletAccount<string>} */
2
+ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implements IWalletAccount<string> {
3
3
  /**
4
4
  * Creates a new evm wallet account from a raw private key.
5
5
  *
@@ -89,11 +89,18 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
89
89
  /**
90
90
  * Sends a transaction.
91
91
  *
92
- * @param {EvmTransaction} tx - The transaction.
92
+ * @param {EvmTransaction | string} tx - The transaction.
93
93
  * @returns {Promise<TransactionResult>} The transaction's result.
94
94
  * @throws {Error} If the transaction's cost exceeds the maximum transaction fee option.
95
95
  */
96
- sendTransaction(tx: EvmTransaction): Promise<TransactionResult>;
96
+ sendTransaction(tx: EvmTransaction | string): Promise<TransactionResult>;
97
+ /**
98
+ * Quotes the costs of a send transaction operation.
99
+ *
100
+ * @param {EvmTransaction | string} tx - The transaction.
101
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
102
+ */
103
+ quoteSendTransaction(tx: EvmTransaction | string): Promise<Omit<TransactionResult, "hash">>;
97
104
  /**
98
105
  * Transfers a token to another address.
99
106
  *
@@ -150,7 +157,7 @@ export type HDNodeWallet = import("ethers").HDNodeWallet;
150
157
  export type AuthorizationRequest = import("ethers").AuthorizationRequest;
151
158
  export type Authorization = import("ethers").Authorization;
152
159
  export type AuthorizationLike = import("ethers").AuthorizationLike;
153
- export type IWalletAccount = import("@tetherto/wdk-wallet").IWalletAccount;
160
+ export type IWalletAccount<TSignedTransaction> = import("@tetherto/wdk-wallet").IWalletAccount<TSignedTransaction>;
154
161
  export type KeyPair = import("@tetherto/wdk-wallet").KeyPair;
155
162
  export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult;
156
163
  export type TransferResult = import("@tetherto/wdk-wallet").TransferResult;
@@ -71,10 +71,51 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
71
71
  /**
72
72
  * Returns a transaction's receipt.
73
73
  *
74
+ * @deprecated Use {@link getTransaction} instead, which returns a normalized, finality-based receipt. The raw ethers receipt remains available on its `receipt` property.
74
75
  * @param {string} hash - The transaction's hash.
75
76
  * @returns {Promise<EvmTransactionReceipt | null>} – The receipt, or null if the transaction has not been included in a block yet.
76
77
  */
77
78
  getTransactionReceipt(hash: string): Promise<EvmTransactionReceipt | null>;
79
+ /**
80
+ * Returns a normalized, finality-based receipt for a transaction.
81
+ *
82
+ * @param {string} hash - The transaction's hash.
83
+ * @returns {Promise<TransactionReceipt & EvmTransactionDetails>} The normalized receipt.
84
+ * @throws {ValueError} If the hash is not a valid transaction hash.
85
+ * @throws {NoSuchElementError} If no transaction has been found for the given hash.
86
+ */
87
+ getTransaction(hash: string): Promise<TransactionReceipt & EvmTransactionDetails>;
88
+ /**
89
+ * Blocks until a transaction reaches a terminal state (the requested finality target or `dropped`), or times out.
90
+ *
91
+ * @param {string} hash - The transaction's hash.
92
+ * @param {WaitForTransactionOptions} [options] - The wait options.
93
+ * @returns {Promise<TransactionReceipt & EvmTransactionDetails>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
94
+ * @throws {TimeoutError} If the target is not reached before the timeout.
95
+ */
96
+ waitForTransaction(hash: string, options?: WaitForTransactionOptions): Promise<TransactionReceipt & EvmTransactionDetails>;
97
+ /**
98
+ * Returns whether a block is at or below the chain's `finalized` block. Chains that don't support the tag are treated as not finalized.
99
+ *
100
+ * @protected
101
+ * @param {number} blockNumber - The block number to check.
102
+ * @returns {Promise<boolean>} True if the block is finalized.
103
+ */
104
+ protected _isFinalized(blockNumber: number): Promise<boolean>;
105
+ /**
106
+ * Returns whether an unmined transaction has been replaced, i.e. its sender's mined nonce has already advanced past the transaction's nonce.
107
+ *
108
+ * @protected
109
+ * @param {EvmTransactionResponse} transaction - The unmined transaction.
110
+ * @returns {Promise<boolean>} True if the transaction's nonce slot is already taken.
111
+ */
112
+ protected _isReplaced(transaction: EvmTransactionResponse): Promise<boolean>;
113
+ /**
114
+ * Overrides the base default to allow for slower EVM inclusion and confirmation.
115
+ *
116
+ * @type {number}
117
+ */
118
+ get defaultWaitTimeout(): number;
78
119
  /**
79
120
  * Returns the current allowance for the given token and spender.
80
121
  * @param {string} token The token's address.
@@ -113,8 +154,24 @@ export type TypedDataDomain = import("ethers").TypedDataDomain;
113
154
  export type TypedDataField = import("ethers").TypedDataField;
114
155
  export type AuthorizationLike = import("ethers").AuthorizationLike;
115
156
  export type EvmTransactionReceipt = import("ethers").TransactionReceipt;
157
+ export type EvmTransactionResponse = import("ethers").TransactionResponse;
116
158
  export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult;
117
159
  export type TransferResult = import("@tetherto/wdk-wallet").TransferResult;
160
+ export type TransactionReceipt = import("@tetherto/wdk-wallet").TransactionReceipt;
161
+ export type WaitForTransactionOptions = import("@tetherto/wdk-wallet").WaitForTransactionOptions;
162
+ /**
163
+ * The EVM-specific fields added to a normalized transaction receipt.
164
+ */
165
+ export type EvmTransactionDetails = {
166
+ /**
167
+ * - The number of confirmations (0 while pending or dropped).
168
+ */
169
+ confirmations: number;
170
+ /**
171
+ * - The native ethers receipt, or null while the transaction is pending or dropped.
172
+ */
173
+ receipt: EvmTransactionReceipt | null;
174
+ };
118
175
  export type TypedData = {
119
176
  /**
120
177
  * - The domain separator.
@@ -44,7 +44,7 @@ export default class WalletManagerEvm extends WalletManager {
44
44
  * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
45
45
  * @returns {Promise<WalletAccountEvm>} The account.
46
46
  * @throws {Error} If a signer name is given but no signer exists with that name.
47
- * @throws {SignerError} If the signer doesn't support account derivation.
47
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
48
48
  */
49
49
  getAccount(index?: number, options?: {
50
50
  signerName?: string;
@@ -67,7 +67,7 @@ export default class WalletManagerEvm extends WalletManager {
67
67
  * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
68
68
  * @returns {Promise<WalletAccountEvm>} The account.
69
69
  * @throws {Error} If a signer name is given but no signer exists with that name.
70
- * @throws {SignerError} If the signer doesn't support account derivation.
70
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
71
71
  */
72
72
  getAccountByPath(path: string, options?: {
73
73
  signerName?: string;