@tetherto/wdk-wallet-evm 1.0.0-beta.2 → 1.0.0-beta.20

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,27 +1,38 @@
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
- * Creates a new evm wallet account.
4
+ * Creates a new evm wallet account from a raw private key.
5
5
  *
6
- * @param {string | Uint8Array} seed - The wallet's [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
6
+ * @param {string | Uint8Array} privateKey - The raw private key (hex string with or without 0x, or 32 bytes).
7
+ * @param {EvmWalletConfig} [config] - The configuration object.
8
+ * @returns {WalletAccountEvm} The wallet account.
9
+ */
10
+ static fromPrivateKey(privateKey: string | Uint8Array, config?: EvmWalletConfig): WalletAccountEvm;
11
+ /**
12
+ * Creates a new evm wallet account from a BIP-39 seed, deriving the account's key at the
13
+ * given BIP-44 path.
14
+ *
15
+ * @param {string | Uint8Array} seed - A BIP-39 mnemonic seed phrase, or a raw BIP-32 master seed (16-64 bytes).
7
16
  * @param {string} path - The BIP-44 derivation path (e.g. "0'/0/0").
8
17
  * @param {EvmWalletConfig} [config] - The configuration object.
9
18
  */
10
19
  constructor(seed: string | Uint8Array, path: string, config?: EvmWalletConfig);
11
20
  /**
12
- * The wallet account configuration.
21
+ * Creates a new evm wallet account using a signer.
13
22
  *
14
- * @protected
15
- * @type {EvmWalletConfig}
23
+ * @param {ISignerEvm} signer - A signer implementing the EVM signer interface.
24
+ * @param {EvmWalletConfig} [config] - The configuration object.
16
25
  */
17
- protected _config: EvmWalletConfig;
26
+ constructor(signer: ISignerEvm, config?: EvmWalletConfig);
18
27
  /**
19
- * The account.
28
+ * The wallet account configuration.
20
29
  *
21
30
  * @protected
22
- * @type {HDNodeWallet}
31
+ * @type {EvmWalletConfig}
23
32
  */
24
- protected _account: HDNodeWallet;
33
+ protected _config: EvmWalletConfig;
34
+ /** @private */
35
+ private _signer;
25
36
  /**
26
37
  * The derivation path's index of this account.
27
38
  *
@@ -37,9 +48,20 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
37
48
  /**
38
49
  * The account's key pair.
39
50
  *
51
+ * The uint8 arrays are bound to the wallet account, so any external change will reflect to the internal representation. For this reason,
52
+ * it's strongly recommended to treat the key pair as a read-only view of the keys. While it's still technically possible to alter their
53
+ * content, client code should never do so.
54
+ *
40
55
  * @type {KeyPair}
41
56
  */
42
57
  get keyPair(): KeyPair;
58
+ /**
59
+ * Returns the account's address. If it wasn't resolved at construction time (e.g hardware signers), it asks the
60
+ * underlying signer to resolve it, then caches it locally.
61
+ *
62
+ * @returns {Promise<string>} The account's address.
63
+ */
64
+ getAddress(): Promise<string>;
43
65
  /**
44
66
  * Signs a message.
45
67
  *
@@ -48,44 +70,131 @@ export default class WalletAccountEvm extends WalletAccountReadOnlyEvm implement
48
70
  */
49
71
  sign(message: string): Promise<string>;
50
72
  /**
51
- * Verifies a message's signature.
73
+ * Signs typed data according to EIP-712.
52
74
  *
53
- * @param {string} message - The original message.
54
- * @param {string} signature - The signature to verify.
55
- * @returns {Promise<boolean>} True if the signature is valid.
75
+ * @param {TypedData} typedData - The typed data to sign.
76
+ * @returns {Promise<string>} The typed data signature.
56
77
  */
57
- verify(message: string, signature: string): Promise<boolean>;
78
+ signTypedData({ domain, types, message }: TypedData): Promise<string>;
79
+ /**
80
+ * Signs a transaction.
81
+ *
82
+ * If a provider is set, it also estimates the transaction's costs and checks them against the transaction max. fee option.
83
+ *
84
+ * @param {EvmTransaction} tx - The transaction to sign.
85
+ * @returns {Promise<string>} The signed transaction as a hex string.
86
+ * @throws {MaximumFeeExceededError} If a provider is set, and the transaction's cost surpasses the transaction max. fee option.
87
+ */
88
+ signTransaction(tx: EvmTransaction): Promise<string>;
58
89
  /**
59
90
  * Sends a transaction.
60
91
  *
61
- * @param {EvmTransaction} tx - The transaction.
92
+ * @param {EvmTransaction | string} tx - The transaction.
62
93
  * @returns {Promise<TransactionResult>} The transaction's result.
94
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
95
+ * @throws {MaximumFeeExceededError} If the transaction's cost exceeds the maximum transaction fee option.
96
+ * @throws {ValueError} If the transaction mixes fee fields that its type doesn't support, or a type 3 transaction omits `maxFeePerBlobGas`.
97
+ */
98
+ sendTransaction(tx: EvmTransaction | string): Promise<TransactionResult>;
99
+ /**
100
+ * Quotes the costs of a send transaction operation.
101
+ *
102
+ * The transaction is always simulated through gas estimation, so one that would revert is rejected here instead of
103
+ * reaching the signer. A `gasLimit` set on the transaction replaces the estimated gas in the quote, and a `maxFeePerGas`
104
+ * (or `gasPrice`) set on it replaces the fee rate fetched from the provider, so the quote is the transaction's maximum
105
+ * cost as it will be sent.
106
+ * A signed raw transaction is simulated the same way and quoted from its own gas limit and fee cap.
107
+ *
108
+ * @param {EvmTransaction | string} tx - The transaction, or a signed raw transaction as a hex string.
109
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
110
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
111
+ * @throws {Error} If the simulation of the transaction reverts, as an ethers error with code `CALL_EXCEPTION`.
63
112
  */
64
- sendTransaction(tx: EvmTransaction): Promise<TransactionResult>;
113
+ quoteSendTransaction(tx: EvmTransaction | string): Promise<Omit<TransactionResult, "hash">>;
65
114
  /**
66
115
  * Transfers a token to another address.
67
116
  *
68
- * @param {TransferOptions} options - The transfer's options.
117
+ * @param {EvmTransferOptions} options - The transfer's options, including any gas overrides to carry onto the transaction.
69
118
  * @returns {Promise<TransferResult>} The transfer's result.
119
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
120
+ * @throws {MaximumFeeExceededError} If the transfer's cost exceeds the maximum transfer fee option.
121
+ */
122
+ transfer(options: EvmTransferOptions): Promise<TransferResult>;
123
+ /**
124
+ * Approves a specific amount of tokens to a spender.
125
+ *
126
+ * @param {EvmApproveOptions} options - The approve options, including any gas overrides to carry onto the transaction.
127
+ * @returns {Promise<TransactionResult>} The transaction's result.
128
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
129
+ * @throws {ValueError} If trying to approve usdts on ethereum with allowance not equal to zero (due to the usdt allowance reset requirement).
70
130
  */
71
- transfer(options: TransferOptions): Promise<TransferResult>;
131
+ approve(options: EvmApproveOptions): Promise<TransactionResult>;
72
132
  /**
73
133
  * Returns a read-only copy of the account.
74
134
  *
75
135
  * @returns {Promise<WalletAccountReadOnlyEvm>} The read-only account.
76
136
  */
77
137
  toReadOnlyAccount(): Promise<WalletAccountReadOnlyEvm>;
138
+ /**
139
+ * Signs an ERC-7702 authorization tuple.
140
+ *
141
+ * @param {AuthorizationRequest} auth - The authorization request.
142
+ * @returns {Promise<Authorization>} The signed authorization.
143
+ */
144
+ signAuthorization(auth: AuthorizationRequest): Promise<Authorization>;
145
+ /**
146
+ * Delegates this EOA to a smart contract via an ERC-7702 type 4 transaction.
147
+ *
148
+ * The transaction is sent to the EOA itself with zero value and no data.
149
+ * A fixed gas limit is used because `eth_estimateGas` may revert when
150
+ * the delegate contract lacks a `receive`/`fallback` function.
151
+ *
152
+ * @param {string} delegateAddress - The address of the contract to delegate to.
153
+ * @returns {Promise<TransactionResult>} The transaction result.
154
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
155
+ */
156
+ delegate(delegateAddress: string): Promise<TransactionResult>;
157
+ /**
158
+ * Revokes any active ERC-7702 delegation by delegating to the zero address.
159
+ *
160
+ * @returns {Promise<TransactionResult>} The transaction result.
161
+ */
162
+ revokeDelegation(): Promise<TransactionResult>;
78
163
  /**
79
164
  * Disposes the wallet account, erasing the private key from the memory.
80
165
  */
81
166
  dispose(): void;
82
167
  }
168
+ export type ISignerEvm = import("./signers/seed-signer-evm.js").ISignerEvm;
83
169
  export type HDNodeWallet = import("ethers").HDNodeWallet;
84
- export type IWalletAccount = import("@tetherto/wdk-wallet").IWalletAccount;
170
+ export type AuthorizationRequest = import("ethers").AuthorizationRequest;
171
+ export type Authorization = import("ethers").Authorization;
172
+ export type AuthorizationLike = import("ethers").AuthorizationLike;
173
+ export type IWalletAccount<TSignedTransaction> = import("@tetherto/wdk-wallet").IWalletAccount<TSignedTransaction>;
85
174
  export type KeyPair = import("@tetherto/wdk-wallet").KeyPair;
86
175
  export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult;
87
- export type TransferOptions = import("@tetherto/wdk-wallet").TransferOptions;
88
176
  export type TransferResult = import("@tetherto/wdk-wallet").TransferResult;
177
+ export type TypedData = import("./wallet-account-read-only-evm.js").TypedData;
89
178
  export type EvmTransaction = import("./wallet-account-read-only-evm.js").EvmTransaction;
179
+ export type EvmTransferOptions = import("./wallet-account-read-only-evm.js").EvmTransferOptions;
180
+ export type EvmGasOverrides = import("./wallet-account-read-only-evm.js").EvmGasOverrides;
90
181
  export type EvmWalletConfig = import("./wallet-account-read-only-evm.js").EvmWalletConfig;
182
+ export type ApproveOptions = {
183
+ /**
184
+ * - The address of the token to approve.
185
+ */
186
+ token: string;
187
+ /**
188
+ * - The spender's address.
189
+ */
190
+ spender: string;
191
+ /**
192
+ * - The amount of tokens to approve to the spender.
193
+ */
194
+ amount: number | bigint;
195
+ };
196
+ /**
197
+ * The options of a token approval, extended with the optional gas overrides of an evm transaction.
198
+ */
199
+ export type EvmApproveOptions = ApproveOptions & EvmGasOverrides;
91
200
  import WalletAccountReadOnlyEvm from './wallet-account-read-only-evm.js';
@@ -1,26 +1,34 @@
1
1
  export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
2
+ /**
3
+ * Extracts the gas and fee overrides set on transfer or approve options.
4
+ *
5
+ * @protected
6
+ * @param {EvmGasOverrides} options - The options to read the overrides from.
7
+ * @returns {EvmGasOverrides} Only the gas and fee fields that are set on the options.
8
+ */
9
+ protected static _getGasOverrides(options: EvmGasOverrides): EvmGasOverrides;
2
10
  /**
3
11
  * Returns an evm transaction to execute the given token transfer.
4
12
  *
5
13
  * @protected
6
- * @param {TransferOptions} options - The transfer's options.
7
- * @returns {Promise<EvmTransaction>} The evm transaction.
14
+ * @param {EvmTransferOptions} options - The transfer's options, including any gas overrides and ERC-7702 authorizations to carry onto the transaction.
15
+ * @returns {Promise<EvmTransaction>} The ERC-20 transfer call as an evm transaction, with the options' gas overrides and authorizations applied.
8
16
  */
9
- protected static _getTransferTransaction(options: TransferOptions): Promise<EvmTransaction>;
17
+ protected static _getTransferTransaction(options: EvmTransferOptions): Promise<EvmTransaction>;
10
18
  /**
11
19
  * Creates a new evm read-only wallet account.
12
20
  *
13
21
  * @param {string} address - The account's address.
14
- * @param {Omit<EvmWalletConfig, 'transferMaxFee'>} [config] - The configuration object.
22
+ * @param {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>} [config] - The configuration object.
15
23
  */
16
- constructor(address: string, config?: Omit<EvmWalletConfig, "transferMaxFee">);
24
+ constructor(address: string, config?: Omit<EvmWalletConfig, "transferMaxFee" | "transactionMaxFee">);
17
25
  /**
18
26
  * The read-only wallet account configuration.
19
27
  *
20
28
  * @protected
21
- * @type {Omit<EvmWalletConfig, 'transferMaxFee'>}
29
+ * @type {Omit<EvmWalletConfig, 'transferMaxFee' | 'transactionMaxFee'>}
22
30
  */
23
- protected _config: Omit<EvmWalletConfig, "transferMaxFee">;
31
+ protected _config: Omit<EvmWalletConfig, "transferMaxFee" | "transactionMaxFee">;
24
32
  /**
25
33
  * An ethers provider to interact with a node of the blockchain.
26
34
  *
@@ -28,10 +36,17 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
28
36
  * @type {Provider | undefined}
29
37
  */
30
38
  protected _provider: Provider | undefined;
39
+ /**
40
+ * The account's address.
41
+ *
42
+ * @type {string}
43
+ */
44
+ get address(): string;
31
45
  /**
32
46
  * Returns the account's eth balance.
33
47
  *
34
48
  * @returns {Promise<bigint>} The eth balance (in weis).
49
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
35
50
  */
36
51
  getBalance(): Promise<bigint>;
37
52
  /**
@@ -39,41 +54,189 @@ export default class WalletAccountReadOnlyEvm extends WalletAccountReadOnly {
39
54
  *
40
55
  * @param {string} tokenAddress - The smart contract address of the token.
41
56
  * @returns {Promise<bigint>} The token balance (in base unit).
57
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
42
58
  */
43
59
  getTokenBalance(tokenAddress: string): Promise<bigint>;
60
+ /**
61
+ * Returns the account balances for multiple tokens.
62
+ *
63
+ * @param {string[]} tokenAddresses - The smart contract addresses of the tokens.
64
+ * @returns {Promise<Record<string, bigint>>} A mapping of token addresses to their balances (in base units).
65
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
66
+ */
67
+ getTokenBalances(tokenAddresses: string[]): Promise<Record<string, bigint>>;
44
68
  /**
45
69
  * Quotes the costs of a send transaction operation.
46
70
  *
71
+ * The transaction is always simulated through gas estimation, so one that would revert is rejected here instead of
72
+ * reaching the signer. A `gasLimit` set on the transaction replaces the estimated gas in the quote, and a `maxFeePerGas`
73
+ * (or `gasPrice`) set on it replaces the fee rate fetched from the provider, so the quote is the transaction's maximum
74
+ * cost as it will be sent.
75
+ *
47
76
  * @param {EvmTransaction} tx - The transaction.
48
77
  * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
78
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
79
+ * @throws {Error} If the simulation of the transaction reverts, as an ethers error with code `CALL_EXCEPTION`.
49
80
  */
50
81
  quoteSendTransaction(tx: EvmTransaction): Promise<Omit<TransactionResult, "hash">>;
51
82
  /**
52
83
  * Quotes the costs of a transfer operation.
53
84
  *
54
- * @param {TransferOptions} options - The transfer's options.
85
+ * @param {EvmTransferOptions} options - The transfer's options, including any gas overrides to carry onto the transaction.
55
86
  * @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
87
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
56
88
  */
57
- quoteTransfer(options: TransferOptions): Promise<Omit<TransferResult, "hash">>;
89
+ quoteTransfer(options: EvmTransferOptions): Promise<Omit<TransferResult, "hash">>;
58
90
  /**
59
91
  * Returns a transaction's receipt.
60
92
  *
93
+ * @deprecated Use {@link getTransaction} instead, which returns a normalized, finality-based receipt. The raw ethers receipt remains available on its `receipt` property.
61
94
  * @param {string} hash - The transaction's hash.
62
95
  * @returns {Promise<EvmTransactionReceipt | null>} – The receipt, or null if the transaction has not been included in a block yet.
96
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
63
97
  */
64
98
  getTransactionReceipt(hash: string): Promise<EvmTransactionReceipt | null>;
99
+ /**
100
+ * Returns a normalized, finality-based receipt for a transaction.
101
+ *
102
+ * @param {string} hash - The transaction's hash.
103
+ * @returns {Promise<TransactionReceipt & EvmTransactionDetails>} The normalized receipt.
104
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
105
+ * @throws {ValueError} If the hash is not a valid transaction hash.
106
+ * @throws {NoSuchElementError} If no transaction has been found for the given hash.
107
+ */
108
+ getTransaction(hash: string): Promise<TransactionReceipt & EvmTransactionDetails>;
109
+ /**
110
+ * Blocks until a transaction reaches a terminal state (the requested finality target or `dropped`), or times out.
111
+ *
112
+ * @param {string} hash - The transaction's hash.
113
+ * @param {WaitForTransactionOptions} [options] - The wait options.
114
+ * @returns {Promise<TransactionReceipt & EvmTransactionDetails>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
115
+ * @throws {TimeoutError} If the target is not reached before the timeout.
116
+ */
117
+ waitForTransaction(hash: string, options?: WaitForTransactionOptions): Promise<TransactionReceipt & EvmTransactionDetails>;
118
+ /**
119
+ * 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.
120
+ *
121
+ * @protected
122
+ * @param {number} blockNumber - The block number to check.
123
+ * @returns {Promise<boolean>} True if the block is finalized.
124
+ */
125
+ protected _isFinalized(blockNumber: number): Promise<boolean>;
126
+ /**
127
+ * Returns whether an unmined transaction has been replaced, i.e. its sender's mined nonce has already advanced past the transaction's nonce.
128
+ *
129
+ * @protected
130
+ * @param {EvmTransactionResponse} transaction - The unmined transaction.
131
+ * @returns {Promise<boolean>} True if the transaction's nonce slot is already taken.
132
+ */
133
+ protected _isReplaced(transaction: EvmTransactionResponse): Promise<boolean>;
134
+ /**
135
+ * Overrides the base default to allow for slower EVM inclusion and confirmation.
136
+ *
137
+ * @type {number}
138
+ */
139
+ get defaultWaitTimeout(): number;
140
+ /**
141
+ * Returns the current allowance for the given token and spender.
142
+ * @param {string} token The token's address.
143
+ * @param {string} spender The spender's address.
144
+ * @returns {Promise<bigint>} The allowance.
145
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
146
+ */
147
+ getAllowance(token: string, spender: string): Promise<bigint>;
148
+ /**
149
+ * Verifies a message's signature.
150
+ *
151
+ * @param {string} message - The original message.
152
+ * @param {string} signature - The signature to verify.
153
+ * @returns {Promise<boolean>} True if the signature is valid.
154
+ */
155
+ verify(message: string, signature: string): Promise<boolean>;
156
+ /**
157
+ * Verifies a typed data signature.
158
+ *
159
+ * @param {TypedData} typedData - The typed data to verify.
160
+ * @param {string} signature - The signature to verify.
161
+ * @returns {Promise<boolean>} True if the signature is valid.
162
+ */
163
+ verifyTypedData(typedData: TypedData, signature: string): Promise<boolean>;
164
+ /**
165
+ * Checks if this account has an active ERC-7702 delegation.
166
+ *
167
+ * @returns {Promise<DelegationInfo>} The delegation info.
168
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
169
+ */
170
+ getDelegation(): Promise<DelegationInfo>;
171
+ /** @private */
172
+ private _estimateGasWithAuthList;
173
+ /**
174
+ * Estimates the gas of a transaction by simulating it against the connected provider, using the authorization-list
175
+ * aware estimation for ERC-7702 transactions.
176
+ *
177
+ * @protected
178
+ * @param {EvmTransactionRequest} tx - The transaction to simulate, including its `from` address.
179
+ * @returns {Promise<bigint>} The gas units the simulated transaction consumed.
180
+ */
181
+ protected _estimateGas(tx: EvmTransactionRequest): Promise<bigint>;
182
+ private _getFeeRate;
65
183
  }
66
184
  export type Provider = import("ethers").Provider;
67
185
  export type Eip1193Provider = import("ethers").Eip1193Provider;
186
+ export type TypedDataDomain = import("ethers").TypedDataDomain;
187
+ export type TypedDataField = import("ethers").TypedDataField;
188
+ export type BlobLike = import("ethers").BlobLike;
189
+ export type AuthorizationLike = import("ethers").AuthorizationLike;
68
190
  export type EvmTransactionReceipt = import("ethers").TransactionReceipt;
191
+ export type EvmTransactionResponse = import("ethers").TransactionResponse;
192
+ export type EvmTransactionRequest = import("ethers").TransactionRequest;
69
193
  export type TransactionResult = import("@tetherto/wdk-wallet").TransactionResult;
70
- export type TransferOptions = import("@tetherto/wdk-wallet").TransferOptions;
71
194
  export type TransferResult = import("@tetherto/wdk-wallet").TransferResult;
195
+ export type TransactionReceipt = import("@tetherto/wdk-wallet").TransactionReceipt;
196
+ export type WaitForTransactionOptions = import("@tetherto/wdk-wallet").WaitForTransactionOptions;
197
+ export type TransferOptions = import("@tetherto/wdk-wallet").TransferOptions;
198
+ /**
199
+ * The EVM-specific fields added to a normalized transaction receipt.
200
+ */
201
+ export type EvmTransactionDetails = {
202
+ /**
203
+ * - The number of confirmations (0 while pending or dropped).
204
+ */
205
+ confirmations: number;
206
+ /**
207
+ * - The native ethers receipt, or null while the transaction is pending or dropped.
208
+ */
209
+ receipt: EvmTransactionReceipt | null;
210
+ };
211
+ export type TypedData = {
212
+ /**
213
+ * - The domain separator.
214
+ */
215
+ domain: TypedDataDomain;
216
+ /**
217
+ * - The type definitions.
218
+ */
219
+ types: Record<string, TypedDataField[]>;
220
+ /**
221
+ * - The message data.
222
+ */
223
+ message: Record<string, unknown>;
224
+ };
225
+ export type DelegationInfo = {
226
+ /**
227
+ * - Whether the account has an active ERC-7702 delegation.
228
+ */
229
+ isDelegated: boolean;
230
+ /**
231
+ * - The address of the delegate contract, or null if not delegated.
232
+ */
233
+ delegateAddress: string | null;
234
+ };
72
235
  export type EvmTransaction = {
73
236
  /**
74
- * - The transaction's recipient.
237
+ * - The transaction's recipient. Omit or pass null to deploy a contract.
75
238
  */
76
- to: string;
239
+ to?: string | null;
77
240
  /**
78
241
  * - The amount of ethers to send to the recipient (in weis).
79
242
  */
@@ -98,15 +261,64 @@ export type EvmTransaction = {
98
261
  * - 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.
99
262
  */
100
263
  maxPriorityFeePerGas?: number | bigint;
264
+ /**
265
+ * - The transaction type (e.g. 4 for ERC-7702).
266
+ */
267
+ type?: number;
268
+ /**
269
+ * - The transaction nonce.
270
+ */
271
+ nonce?: number;
272
+ /**
273
+ * - The chain ID of the network.
274
+ */
275
+ chainId?: number | bigint;
276
+ /**
277
+ * - 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.
278
+ */
279
+ maxFeePerBlobGas?: number | bigint;
280
+ /**
281
+ * - The blobs of an [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) type 3 transaction.
282
+ */
283
+ blobs?: BlobLike[];
284
+ /**
285
+ * - The versioned hashes of the blobs of an [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) type 3 transaction.
286
+ */
287
+ blobVersionedHashes?: string[];
288
+ /**
289
+ * - An optional list of ERC-7702 signed authorizations for type 4 transactions.
290
+ */
291
+ authorizationList?: AuthorizationLike[];
101
292
  };
293
+ /**
294
+ * The gas and fee fields of an evm transaction that can be set on transfer and approve options.
295
+ */
296
+ export type EvmGasOverrides = Pick<EvmTransaction, "gasLimit" | "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas">;
297
+ /**
298
+ * The options of a token transfer, extended with the optional gas overrides and ERC-7702 authorizations of an evm
299
+ * transaction.
300
+ */
301
+ export type EvmTransferOptions = TransferOptions & EvmGasOverrides & Pick<EvmTransaction, "authorizationList">;
102
302
  export type EvmWalletConfig = {
103
303
  /**
104
- * - The url of the rpc provider, or an instance of a class that implements eip-1193.
304
+ * - The url of the rpc provider, or an instance of a class that implements eip-1193. It's also possible to provide an array of urls or EIP 1193 providers instead. In such case, connection errors will cause the wallet to automatically fallback on the next provider in the list.
305
+ */
306
+ provider?: string | Eip1193Provider | Array<string | Eip1193Provider>;
307
+ /**
308
+ * - 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.
309
+ */
310
+ retries?: number;
311
+ /**
312
+ * - The chain ID of the network. When provided, skips automatic chain ID detection from the provider.
105
313
  */
106
- provider?: string | Eip1193Provider;
314
+ chainId?: number;
107
315
  /**
108
316
  * - The maximum fee amount for transfer operations.
109
317
  */
110
318
  transferMaxFee?: number | bigint;
319
+ /**
320
+ * - The maximum fee amount for sendTransaction and signTransaction operations.
321
+ */
322
+ transactionMaxFee?: number | bigint;
111
323
  };
112
324
  import { WalletAccountReadOnly } from '@tetherto/wdk-wallet';
@@ -1,3 +1,8 @@
1
+ /** @typedef {import('ethers').Provider} Provider */
2
+ /** @typedef {import("@tetherto/wdk-wallet").FeeRates} FeeRates */
3
+ /** @typedef {import("@tetherto/wdk-wallet").ISigner} ISigner */
4
+ /** @typedef {import("@tetherto/wdk-wallet").NoSuchElementError} NoSuchElementError */
5
+ /** @typedef {import('./wallet-account-evm.js').EvmWalletConfig} EvmWalletConfig */
1
6
  export default class WalletManagerEvm extends WalletManager {
2
7
  /**
3
8
  * Multiplier for normal fee rate calculations (in %).
@@ -16,17 +21,16 @@ export default class WalletManagerEvm extends WalletManager {
16
21
  /**
17
22
  * Creates a new wallet manager for evm blockchains.
18
23
  *
19
- * @param {string | Uint8Array} seed - The wallet's [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
20
- * @param {EvmWalletConfig} [config] - The configuration object.
21
- */
22
- constructor(seed: string | Uint8Array, config?: EvmWalletConfig);
23
- /**
24
- * The evm wallet configuration.
24
+ * Accepts either a BIP-39 seed (string/Uint8Array) for backwards compatibility, or a
25
+ * pre-built root signer object. The default signer must be derivable (it must be able to
26
+ * derive child accounts); non-derivable signers (e.g. private-key signers) are not allowed
27
+ * as the default but may be registered by name via {@link addSigner} - If not adding to your global account managment for using just one non derivable signer create a standalone account.
25
28
  *
26
- * @protected
27
- * @type {EvmWalletConfig}
29
+ * @param {string|Uint8Array|ISigner} seedOrSigner - A BIP-39 mnemonic seed phrase, a raw BIP-32 master seed (16-64 bytes), or a root signer. Root signers must be derivable — non-derivable signers (e.g. private-key signers) can only be registered by name via {@link addSigner}.
30
+ * @param {EvmWalletConfig} [config] - The configuration object.
31
+ * @throws {InvalidSignerError} If the default signer doesn't support account derivation.
28
32
  */
29
- protected _config: EvmWalletConfig;
33
+ constructor(seedOrSigner: string | Uint8Array | ISigner, config?: EvmWalletConfig);
30
34
  /**
31
35
  * An ethers provider to interact with a node of the blockchain.
32
36
  *
@@ -35,34 +39,54 @@ export default class WalletManagerEvm extends WalletManager {
35
39
  */
36
40
  protected _provider: Provider | undefined;
37
41
  /**
38
- * Returns the wallet account at a specific index (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)).
42
+ * Returns the wallet account at a specific index.
39
43
  *
40
- * @example
41
- * // Returns the account with derivation path m/44'/60'/0'/0/1
42
- * const account = await wallet.getAccount(1);
43
44
  * @param {number} [index] - The index of the account to get (default: 0).
45
+ * @param {Object} [options] - Account options.
46
+ * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
47
+ * @returns {Promise<WalletAccountEvm>} The account.
48
+ * @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
49
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
50
+ */
51
+ getAccount(index?: number, options?: {
52
+ signerName?: string;
53
+ }): Promise<WalletAccountEvm>;
54
+ /**
55
+ * Returns the wallet account associated with a registered signer. Non-derivable
56
+ * signers (e.g. private-key signers) return the signer's single account; derivable signers
57
+ * derive a detached child at the signer's own account (the root is never handed out).
58
+ *
59
+ * @param {string} signerName - The signer name registered via {@link addSigner}.
44
60
  * @returns {Promise<WalletAccountEvm>} The account.
61
+ * @throws {NoSuchElementError} If no signer exists with the given name.
45
62
  */
46
- getAccount(index?: number): Promise<WalletAccountEvm>;
63
+ getAccount(signerName: string): Promise<WalletAccountEvm>;
47
64
  /**
48
- * Returns the wallet account at a specific BIP-44 derivation path.
65
+ * Returns the wallet account at a specific derivation path.
49
66
  *
50
- * @example
51
- * // Returns the account with derivation path m/44'/60'/0'/0/1
52
- * const account = await wallet.getAccountByPath("0'/0/1");
53
67
  * @param {string} path - The derivation path (e.g. "0'/0/0").
68
+ * @param {Object} [options] - Account options.
69
+ * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
54
70
  * @returns {Promise<WalletAccountEvm>} The account.
71
+ * @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
72
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
55
73
  */
56
- getAccountByPath(path: string): Promise<WalletAccountEvm>;
74
+ getAccountByPath(path: string, options?: {
75
+ signerName?: string;
76
+ }): Promise<WalletAccountEvm>;
57
77
  /**
58
78
  * Returns the current fee rates.
59
79
  *
60
80
  * @returns {Promise<FeeRates>} The fee rates (in weis).
81
+ * @throws {ProviderRequiredError} If the wallet is not connected to a provider.
61
82
  */
62
83
  getFeeRates(): Promise<FeeRates>;
63
84
  }
85
+ export type ISignerEvm = import("./signers/seed-signer-evm.js").ISignerEvm;
64
86
  export type Provider = import("ethers").Provider;
65
87
  export type FeeRates = import("@tetherto/wdk-wallet").FeeRates;
88
+ export type ISigner = import("@tetherto/wdk-wallet").ISigner;
89
+ export type NoSuchElementError = import("@tetherto/wdk-wallet").NoSuchElementError;
66
90
  export type EvmWalletConfig = import("./wallet-account-evm.js").EvmWalletConfig;
67
91
  import WalletManager from '@tetherto/wdk-wallet';
68
92
  import WalletAccountEvm from './wallet-account-evm.js';