@tetherto/wdk-wallet-evm 1.0.0-beta.13 → 1.0.0-beta.14
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetherto/wdk-wallet-evm",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
4
4
|
"description": "A simple package to manage BIP-32 wallets for evm blockchains.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wdk",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@noble/hashes": "1.8.0",
|
|
32
32
|
"@noble/secp256k1": "2.2.3",
|
|
33
33
|
"@tetherto/wdk-failover-provider": "1.0.0-beta.2",
|
|
34
|
-
"@tetherto/wdk-wallet": "1.0.0-beta.
|
|
35
|
-
"bare-node-runtime": "^1.
|
|
34
|
+
"@tetherto/wdk-wallet": "1.0.0-beta.11",
|
|
35
|
+
"bare-node-runtime": "^1.5.0",
|
|
36
36
|
"bip39": "3.1.0",
|
|
37
37
|
"ethers": "6.14.4",
|
|
38
38
|
"sodium-universal": "5.0.1"
|
|
@@ -154,10 +154,21 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
|
|
|
154
154
|
/**
|
|
155
155
|
* Signs a transaction.
|
|
156
156
|
*
|
|
157
|
+
* If a provider is set, it also estimates the transaction's costs and checks them against the transaction max. fee option.
|
|
158
|
+
*
|
|
157
159
|
* @param {EvmTransaction} tx - The transaction to sign.
|
|
158
160
|
* @returns {Promise<string>} The signed transaction as a hex string.
|
|
161
|
+
* @throws {Error} If a provider is set, and the transaction's cost surpasses the transaction max. fee option.
|
|
159
162
|
*/
|
|
160
163
|
async signTransaction (tx) {
|
|
164
|
+
if (this._account.provider && this._config.transactionMaxFee !== undefined) {
|
|
165
|
+
const { fee } = await this.quoteSendTransaction(tx)
|
|
166
|
+
|
|
167
|
+
if (fee > this._config.transactionMaxFee) {
|
|
168
|
+
throw new Error('Exceeded maximum fee cost for transaction operation.')
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
161
172
|
return await this._account.signTransaction({
|
|
162
173
|
from: await this.getAddress(),
|
|
163
174
|
...tx
|
|
@@ -169,6 +180,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
|
|
|
169
180
|
*
|
|
170
181
|
* @param {EvmTransaction} tx - The transaction.
|
|
171
182
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
183
|
+
* @throws {Error} If the transaction's cost exceeds the maximum transaction fee option.
|
|
172
184
|
*/
|
|
173
185
|
async sendTransaction (tx) {
|
|
174
186
|
if (!this._account.provider) {
|
|
@@ -177,6 +189,10 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
|
|
|
177
189
|
|
|
178
190
|
const { fee } = await this.quoteSendTransaction(tx)
|
|
179
191
|
|
|
192
|
+
if (this._config.transactionMaxFee !== undefined && fee > this._config.transactionMaxFee) {
|
|
193
|
+
throw new Error('Exceeded maximum fee cost for transaction operation.')
|
|
194
|
+
}
|
|
195
|
+
|
|
180
196
|
const { hash } = await this._account.sendTransaction({
|
|
181
197
|
from: await this.getAddress(),
|
|
182
198
|
...tx
|
|
@@ -190,6 +206,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
|
|
|
190
206
|
*
|
|
191
207
|
* @param {EvmTransferOptions} options - The transfer's options.
|
|
192
208
|
* @returns {Promise<TransferResult>} The transfer's result.
|
|
209
|
+
* @throws {Error} If the transfer's cost exceeds the maximum transfer fee option.
|
|
193
210
|
*/
|
|
194
211
|
async transfer (options) {
|
|
195
212
|
if (!this._account.provider) {
|
|
@@ -200,7 +217,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm {
|
|
|
200
217
|
|
|
201
218
|
const { fee } = await this.quoteSendTransaction(tx)
|
|
202
219
|
|
|
203
|
-
if (this._config.transferMaxFee !== undefined && fee
|
|
220
|
+
if (this._config.transferMaxFee !== undefined && fee > this._config.transferMaxFee) {
|
|
204
221
|
throw new Error('Exceeded maximum fee cost for transfer operation.')
|
|
205
222
|
}
|
|
206
223
|
|
|
@@ -74,6 +74,7 @@ import FailoverProvider from '@tetherto/wdk-failover-provider'
|
|
|
74
74
|
* @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.
|
|
75
75
|
* @property {number} [chainId] - The chain ID of the network. When provided, skips automatic chain ID detection from the provider.
|
|
76
76
|
* @property {number | bigint} [transferMaxFee] - The maximum fee amount for transfer operations.
|
|
77
|
+
* @property {number | bigint} [transactionMaxFee] - The maximum fee amount for sendTransaction and signTransaction operations.
|
|
77
78
|
*/
|
|
78
79
|
|
|
79
80
|
const DELEGATION_DESIGNATOR_PREFIX = '0xef0100'
|
|
@@ -85,7 +86,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
|
|
|
85
86
|
* Creates a new evm read-only wallet account.
|
|
86
87
|
*
|
|
87
88
|
* @param {string} address - The account's address.
|
|
88
|
-
* @param {Omit<EvmWalletConfig, 'transferMaxFee'>} [config] - The configuration object.
|
|
89
|
+
* @param {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>} [config] - The configuration object.
|
|
89
90
|
*/
|
|
90
91
|
constructor (address, config = { }) {
|
|
91
92
|
super(address)
|
|
@@ -94,7 +95,7 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
|
|
|
94
95
|
* The read-only wallet account configuration.
|
|
95
96
|
*
|
|
96
97
|
* @protected
|
|
97
|
-
* @type {Omit<EvmWalletConfig, 'transferMaxFee'>}
|
|
98
|
+
* @type {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>}
|
|
98
99
|
*/
|
|
99
100
|
this._config = config
|
|
100
101
|
|
|
@@ -61,8 +61,11 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
|
|
|
61
61
|
/**
|
|
62
62
|
* Signs a transaction.
|
|
63
63
|
*
|
|
64
|
+
* If a provider is set, it also estimates the transaction's costs and checks them against the transaction max. fee option.
|
|
65
|
+
*
|
|
64
66
|
* @param {EvmTransaction} tx - The transaction to sign.
|
|
65
67
|
* @returns {Promise<string>} The signed transaction as a hex string.
|
|
68
|
+
* @throws {Error} If a provider is set, and the transaction's cost surpasses the transaction max. fee option.
|
|
66
69
|
*/
|
|
67
70
|
signTransaction(tx: EvmTransaction): Promise<string>;
|
|
68
71
|
/**
|
|
@@ -70,6 +73,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
|
|
|
70
73
|
*
|
|
71
74
|
* @param {EvmTransaction} tx - The transaction.
|
|
72
75
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
76
|
+
* @throws {Error} If the transaction's cost exceeds the maximum transaction fee option.
|
|
73
77
|
*/
|
|
74
78
|
sendTransaction(tx: EvmTransaction): Promise<TransactionResult>;
|
|
75
79
|
/**
|
|
@@ -77,6 +81,7 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
|
|
|
77
81
|
*
|
|
78
82
|
* @param {EvmTransferOptions} options - The transfer's options.
|
|
79
83
|
* @returns {Promise<TransferResult>} The transfer's result.
|
|
84
|
+
* @throws {Error} If the transfer's cost exceeds the maximum transfer fee option.
|
|
80
85
|
*/
|
|
81
86
|
transfer(options: EvmTransferOptions): Promise<TransferResult>;
|
|
82
87
|
/**
|
|
@@ -11,16 +11,16 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
|
|
|
11
11
|
* Creates a new evm read-only wallet account.
|
|
12
12
|
*
|
|
13
13
|
* @param {string} address - The account's address.
|
|
14
|
-
* @param {Omit<EvmWalletConfig, 'transferMaxFee'>} [config] - The configuration object.
|
|
14
|
+
* @param {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>} [config] - The configuration object.
|
|
15
15
|
*/
|
|
16
|
-
constructor(address: string, config?: Omit<EvmWalletConfig, "transferMaxFee">);
|
|
16
|
+
constructor(address: string, config?: Omit<EvmWalletConfig, "transferMaxFee" | "transactionMaxFee">);
|
|
17
17
|
/**
|
|
18
18
|
* The read-only wallet account configuration.
|
|
19
19
|
*
|
|
20
20
|
* @protected
|
|
21
|
-
* @type {Omit<EvmWalletConfig, 'transferMaxFee'>}
|
|
21
|
+
* @type {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>}
|
|
22
22
|
*/
|
|
23
|
-
protected _config: Omit<EvmWalletConfig, "transferMaxFee">;
|
|
23
|
+
protected _config: Omit<EvmWalletConfig, "transferMaxFee" | "transactionMaxFee">;
|
|
24
24
|
/**
|
|
25
25
|
* An ethers provider to interact with a node of the blockchain.
|
|
26
26
|
*
|
|
@@ -220,5 +220,9 @@ export type EvmWalletConfig = {
|
|
|
220
220
|
* - The maximum fee amount for transfer operations.
|
|
221
221
|
*/
|
|
222
222
|
transferMaxFee?: number | bigint;
|
|
223
|
+
/**
|
|
224
|
+
* - The maximum fee amount for sendTransaction and signTransaction operations.
|
|
225
|
+
*/
|
|
226
|
+
transactionMaxFee?: number | bigint;
|
|
223
227
|
};
|
|
224
228
|
import { WalletAccountReadOnly } from '@tetherto/wdk-wallet';
|