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

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/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.16",
4
4
  "description": "A simple package to manage BIP-32 wallets for evm blockchains.",
5
5
  "keywords": [
6
6
  "wdk",
@@ -21,10 +21,12 @@
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",
@@ -37,22 +39,20 @@
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.9.1",
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
  ".": {
@@ -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
  *
@@ -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;