@tetherto/wdk-wallet 1.0.0-beta.16 → 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.
- package/index.js +11 -12
- package/package.json +1 -1
- package/src/errors.js +280 -19
- package/src/multisig/errors.js +54 -0
- package/src/multisig/index.js +15 -3
- package/src/multisig/multisig-message-signing-read-only.js +63 -0
- package/src/multisig/multisig-message-signing.js +64 -0
- package/src/multisig/multisig-owner-management.js +22 -5
- package/src/multisig/wallet-account-multisig.js +28 -39
- package/src/multisig/wallet-account-read-only-multisig.js +20 -34
- package/src/protocols/bridge-protocol.js +35 -1
- package/src/protocols/errors.js +510 -0
- package/src/protocols/fiat-protocol.js +104 -4
- package/src/protocols/index.js +13 -0
- package/src/protocols/lending-protocol.js +114 -2
- package/src/protocols/sda-protocol.js +103 -16
- package/src/protocols/swap-protocol.js +35 -1
- package/src/protocols/swidge-protocol.js +166 -55
- package/src/signer.js +8 -4
- package/src/wallet-account-read-only-simple.js +86 -1
- package/src/wallet-account-read-only.js +175 -6
- package/src/wallet-account.js +25 -1
- package/src/wallet-manager.js +38 -22
- package/types/index.d.ts +9 -2
- package/types/src/errors.d.ts +198 -14
- package/types/src/multisig/errors.d.ts +33 -0
- package/types/src/multisig/index.d.ts +7 -3
- package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
- package/types/src/multisig/multisig-message-signing.d.ts +40 -0
- package/types/src/multisig/multisig-owner-management.d.ts +20 -4
- package/types/src/multisig/wallet-account-multisig.d.ts +29 -35
- package/types/src/multisig/wallet-account-read-only-multisig.d.ts +20 -40
- package/types/src/protocols/bridge-protocol.d.ts +39 -3
- package/types/src/protocols/errors.d.ts +366 -0
- package/types/src/protocols/fiat-protocol.d.ts +103 -9
- package/types/src/protocols/index.d.ts +11 -0
- package/types/src/protocols/lending-protocol.d.ts +118 -4
- package/types/src/protocols/sda-protocol.d.ts +120 -23
- package/types/src/protocols/swap-protocol.d.ts +40 -4
- package/types/src/protocols/swidge-protocol.d.ts +106 -38
- package/types/src/signer.d.ts +6 -4
- package/types/src/wallet-account-read-only-simple.d.ts +99 -1
- package/types/src/wallet-account-read-only.d.ts +95 -3
- package/types/src/wallet-account.d.ts +27 -3
- package/types/src/wallet-manager.d.ts +37 -35
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum that assigns a comparable ordinal to each finality level, used to check
|
|
3
|
+
* whether an observed finality satisfies a requested target.
|
|
4
|
+
*/
|
|
5
|
+
export type FINALITY = number;
|
|
6
|
+
export namespace FINALITY {
|
|
7
|
+
let pending: number;
|
|
8
|
+
let dropped: number;
|
|
9
|
+
let confirmed: number;
|
|
10
|
+
let final: number;
|
|
11
|
+
}
|
|
1
12
|
/** @interface */
|
|
2
13
|
export interface IWalletAccountReadOnly extends IWalletAccountReadOnlySimple {
|
|
3
14
|
/**
|
|
@@ -5,6 +16,10 @@ export interface IWalletAccountReadOnly extends IWalletAccountReadOnlySimple {
|
|
|
5
16
|
*
|
|
6
17
|
* @param {Transaction} tx - The transaction.
|
|
7
18
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
19
|
+
* @throws {ValueError} If the transaction is not valid.
|
|
20
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
21
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the transaction.
|
|
22
|
+
* @throws {TransactionError} If the transaction fails with an error.
|
|
8
23
|
*/
|
|
9
24
|
quoteSendTransaction(tx: Transaction): Promise<Omit<TransactionResult, "hash">>;
|
|
10
25
|
/**
|
|
@@ -12,6 +27,11 @@ export interface IWalletAccountReadOnly extends IWalletAccountReadOnlySimple {
|
|
|
12
27
|
*
|
|
13
28
|
* @param {TransferOptions} options - The transfer's options.
|
|
14
29
|
* @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
|
|
30
|
+
* @throws {ValueError} If the transfer options are not valid.
|
|
31
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
32
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
33
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the transfer.
|
|
34
|
+
* @throws {TransferError} If the transfer fails with an error.
|
|
15
35
|
*/
|
|
16
36
|
quoteTransfer(options: TransferOptions): Promise<Omit<TransferResult, "hash">>;
|
|
17
37
|
}
|
|
@@ -26,6 +46,22 @@ export default abstract class WalletAccountReadOnly implements IWalletAccountRea
|
|
|
26
46
|
* @param {string} [address] - The account's address.
|
|
27
47
|
*/
|
|
28
48
|
constructor(address?: string);
|
|
49
|
+
/**
|
|
50
|
+
* The default poll cadence for {@link waitForTransaction}, in milliseconds,
|
|
51
|
+
* applied when the caller doesn't provide an `interval`. Subclasses override
|
|
52
|
+
* it to match their chain's block time.
|
|
53
|
+
*
|
|
54
|
+
* @type {number}
|
|
55
|
+
*/
|
|
56
|
+
get defaultWaitInterval(): number;
|
|
57
|
+
/**
|
|
58
|
+
* The default time budget for {@link waitForTransaction}, in milliseconds,
|
|
59
|
+
* applied when the caller doesn't provide a `timeout`. Subclasses override it
|
|
60
|
+
* to match their chain's finality expectations.
|
|
61
|
+
*
|
|
62
|
+
* @type {number}
|
|
63
|
+
*/
|
|
64
|
+
get defaultWaitTimeout(): number;
|
|
29
65
|
/** @private */
|
|
30
66
|
private __address;
|
|
31
67
|
/**
|
|
@@ -44,18 +80,19 @@ export default abstract class WalletAccountReadOnly implements IWalletAccountRea
|
|
|
44
80
|
/**
|
|
45
81
|
* Verifies a message's signature.
|
|
46
82
|
*
|
|
47
|
-
* @abstract
|
|
48
83
|
* @param {string} message - The original message.
|
|
49
84
|
* @param {string} signature - The signature to verify.
|
|
50
85
|
* @returns {Promise<boolean>} True if the signature is valid.
|
|
51
|
-
* @throws {
|
|
86
|
+
* @throws {UnsupportedOperationError} If the read-only wallet account class is not able to provide an implementation for the method.
|
|
52
87
|
*/
|
|
53
|
-
|
|
88
|
+
verify(message: string, signature: string): Promise<boolean>;
|
|
54
89
|
/**
|
|
55
90
|
* Returns the account's native token balance.
|
|
56
91
|
*
|
|
57
92
|
* @abstract
|
|
58
93
|
* @returns {Promise<bigint>} The native token balance.
|
|
94
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
95
|
+
* @throws {ProviderError} If the provider fails to fetch the account's balance.
|
|
59
96
|
*/
|
|
60
97
|
abstract getBalance(): Promise<bigint>;
|
|
61
98
|
/**
|
|
@@ -64,6 +101,10 @@ export default abstract class WalletAccountReadOnly implements IWalletAccountRea
|
|
|
64
101
|
* @abstract
|
|
65
102
|
* @param {string} tokenAddress - The smart contract address of the token.
|
|
66
103
|
* @returns {Promise<bigint>} The token balance.
|
|
104
|
+
* @throws {ValueError} If the token's address is not valid.
|
|
105
|
+
* @throws {InvalidTokenError} If the token's address doesn't match an existing ERC 20 token.
|
|
106
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
107
|
+
* @throws {ProviderError} If the provider fails to fetch the account's token balance.
|
|
67
108
|
*/
|
|
68
109
|
abstract getTokenBalance(tokenAddress: string): Promise<bigint>;
|
|
69
110
|
/**
|
|
@@ -72,6 +113,10 @@ export default abstract class WalletAccountReadOnly implements IWalletAccountRea
|
|
|
72
113
|
* @abstract
|
|
73
114
|
* @param {Transaction} tx - The transaction.
|
|
74
115
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
116
|
+
* @throws {ValueError} If the transaction is not valid.
|
|
117
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
118
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the transaction.
|
|
119
|
+
* @throws {TransactionError} If the transaction fails with an error.
|
|
75
120
|
*/
|
|
76
121
|
abstract quoteSendTransaction(tx: Transaction): Promise<Omit<TransactionResult, "hash">>;
|
|
77
122
|
/**
|
|
@@ -80,17 +125,64 @@ export default abstract class WalletAccountReadOnly implements IWalletAccountRea
|
|
|
80
125
|
* @abstract
|
|
81
126
|
* @param {TransferOptions} options - The transfer's options.
|
|
82
127
|
* @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
|
|
128
|
+
* @throws {ValueError} If the transfer options are not valid.
|
|
129
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
130
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
131
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the transfer.
|
|
132
|
+
* @throws {TransferError} If the transfer fails with an error.
|
|
83
133
|
*/
|
|
84
134
|
abstract quoteTransfer(options: TransferOptions): Promise<Omit<TransferResult, "hash">>;
|
|
85
135
|
/**
|
|
86
136
|
* Returns a transaction's receipt.
|
|
87
137
|
*
|
|
138
|
+
* @deprecated Use {@link getTransaction} instead, which returns a normalized, finality-based receipt. The native receipt fields remain available on each module's extended return type.
|
|
88
139
|
* @abstract
|
|
89
140
|
* @param {string} hash - The transaction's hash.
|
|
90
141
|
* @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
|
|
142
|
+
* @throws {ValueError} If the hash is not valid.
|
|
143
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
144
|
+
* @throws {ProviderError} If the provider fails to fetch the transaction's receipt.
|
|
91
145
|
*/
|
|
92
146
|
abstract getTransactionReceipt(hash: string): Promise<unknown | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Returns a normalized, finality-based receipt for a transaction.
|
|
149
|
+
*
|
|
150
|
+
* @abstract
|
|
151
|
+
* @param {string} hash - The transaction's identifier (hash / signature / lt:hash).
|
|
152
|
+
* @returns {Promise<TransactionReceipt>} The normalized receipt.
|
|
153
|
+
* @throws {ValueError} If the hash is not a valid identifier.
|
|
154
|
+
* @throws {NoSuchElementError} If no transaction has been found for the given hash.
|
|
155
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
156
|
+
* @throws {ProviderError} If the provider fails to fetch the transaction.
|
|
157
|
+
*/
|
|
158
|
+
abstract getTransaction(hash: string): Promise<TransactionReceipt>;
|
|
159
|
+
/**
|
|
160
|
+
* Blocks until a transaction reaches a terminal state (the requested finality
|
|
161
|
+
* target or `dropped`), or times out.
|
|
162
|
+
*
|
|
163
|
+
* The polling loop and target resolution are chain-agnostic: this method only
|
|
164
|
+
* interprets the normalized receipt returned by {@link getTransaction}. A
|
|
165
|
+
* {@link NoSuchElementError} is treated as a transient not-found, so the loop
|
|
166
|
+
* keeps polling until the timeout.
|
|
167
|
+
*
|
|
168
|
+
* @param {string} hash - The transaction's identifier.
|
|
169
|
+
* @param {WaitForTransactionOptions} [options] - The wait options.
|
|
170
|
+
* @returns {Promise<TransactionReceipt>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
|
|
171
|
+
* @throws {ValueError} If the hash is not a valid identifier.
|
|
172
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
173
|
+
* @throws {ProviderError} If the provider fails to fetch the transaction.
|
|
174
|
+
* @throws {TimeoutError} If the operation times out.
|
|
175
|
+
*/
|
|
176
|
+
waitForTransaction(hash: string, options?: WaitForTransactionOptions): Promise<TransactionReceipt>;
|
|
93
177
|
}
|
|
178
|
+
export type Finality = import("./wallet-account-read-only-simple.js").Finality;
|
|
179
|
+
export type TransactionReceipt = import("./wallet-account-read-only-simple.js").TransactionReceipt;
|
|
180
|
+
export type WaitForTransactionOptions = import("./wallet-account-read-only-simple.js").WaitForTransactionOptions;
|
|
181
|
+
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
182
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
183
|
+
export type TransactionError = import("./errors.js").TransactionError;
|
|
184
|
+
export type TransferError = import("./errors.js").TransferError;
|
|
185
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
94
186
|
export type Transaction = {
|
|
95
187
|
/**
|
|
96
188
|
* - The transaction's recipient.
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @interface
|
|
3
|
+
* @template [TSignedTransaction=unknown]
|
|
4
|
+
*/
|
|
2
5
|
export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAccountReadOnly {
|
|
3
6
|
/**
|
|
4
7
|
* The derivation path's index of this account.
|
|
@@ -30,6 +33,7 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
30
33
|
*
|
|
31
34
|
* @param {Transaction} tx - The transaction to sign.
|
|
32
35
|
* @returns {Promise<TSignedTransaction>} The signed transaction.
|
|
36
|
+
* @throws {ValueError} If the transaction is not valid.
|
|
33
37
|
*/
|
|
34
38
|
signTransaction(tx: Transaction): Promise<TSignedTransaction>;
|
|
35
39
|
/**
|
|
@@ -43,17 +47,24 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
43
47
|
/**
|
|
44
48
|
* Sends a transaction.
|
|
45
49
|
*
|
|
46
|
-
* @overload
|
|
47
50
|
* @param {Transaction | TSignedTransaction} tx - The transaction.
|
|
48
51
|
* @returns {Promise<TransactionResult>} The transaction's result.
|
|
52
|
+
* @throws {ValueError} If the transaction is not valid.
|
|
53
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
54
|
+
* @throws {ProviderError} If the provider fails to perform the transaction.
|
|
55
|
+
* @throws {TransactionError} If the transaction fails with an error.
|
|
56
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the transaction max. fee option.
|
|
49
57
|
*/
|
|
50
58
|
sendTransaction(tx: Transaction | TSignedTransaction): Promise<TransactionResult>;
|
|
51
59
|
/**
|
|
52
60
|
* Quotes the costs of a send transaction operation.
|
|
53
61
|
*
|
|
54
|
-
* @overload
|
|
55
62
|
* @param {Transaction | TSignedTransaction} tx - The transaction.
|
|
56
63
|
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
|
|
64
|
+
* @throws {ValueError} If the transaction is not valid.
|
|
65
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
66
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the transaction.
|
|
67
|
+
* @throws {TransactionError} If the transaction fails with an error.
|
|
57
68
|
*/
|
|
58
69
|
quoteSendTransaction(tx: Transaction | TSignedTransaction): Promise<Omit<TransactionResult, "hash">>;
|
|
59
70
|
/**
|
|
@@ -61,6 +72,12 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
61
72
|
*
|
|
62
73
|
* @param {TransferOptions} options - The transfer's options.
|
|
63
74
|
* @returns {Promise<TransferResult>} The transfer's result.
|
|
75
|
+
* @throws {ValueError} If the transfer options are not valid.
|
|
76
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
77
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
78
|
+
* @throws {ProviderError} If the provider fails to perform the transfer.
|
|
79
|
+
* @throws {TransferError} If the transfer fails with an error.
|
|
80
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transfer exceeds the transfer max. fee option.
|
|
64
81
|
*/
|
|
65
82
|
transfer(options: TransferOptions): Promise<TransferResult>;
|
|
66
83
|
/**
|
|
@@ -78,6 +95,13 @@ export type Transaction = import("./wallet-account-read-only.js").Transaction;
|
|
|
78
95
|
export type TransactionResult = import("./wallet-account-read-only.js").TransactionResult;
|
|
79
96
|
export type TransferOptions = import("./wallet-account-read-only.js").TransferOptions;
|
|
80
97
|
export type TransferResult = import("./wallet-account-read-only.js").TransferResult;
|
|
98
|
+
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
99
|
+
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
100
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
101
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
102
|
+
export type TransactionError = import("./errors.js").TransactionError;
|
|
103
|
+
export type TransferError = import("./errors.js").TransferError;
|
|
104
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
81
105
|
export type KeyPair = {
|
|
82
106
|
/**
|
|
83
107
|
* - The public key.
|
|
@@ -3,7 +3,7 @@ export default abstract class WalletManager {
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a random [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
|
|
5
5
|
*
|
|
6
|
-
* @param {12 | 24} [wordCount
|
|
6
|
+
* @param {12 | 24} [wordCount] - The number of words in the seed phrase (default: 12).
|
|
7
7
|
* @returns {string} The seed phrase.
|
|
8
8
|
*/
|
|
9
9
|
static getRandomSeedPhrase(wordCount?: 12 | 24): string;
|
|
@@ -17,22 +17,25 @@ export default abstract class WalletManager {
|
|
|
17
17
|
/**
|
|
18
18
|
* Creates a new wallet manager from a BIP-39 seed.
|
|
19
19
|
*
|
|
20
|
+
* @overload
|
|
20
21
|
* @param {string | Uint8Array} seed - The BIP-39 seed phrase or raw seed bytes.
|
|
21
22
|
* @param {WalletConfig} [config] - The wallet configuration.
|
|
23
|
+
* @throws {ValueError} If the seed is not a valid seed or BIP-39 seed phrase.
|
|
22
24
|
*/
|
|
23
25
|
constructor(seed: string | Uint8Array, config?: WalletConfig);
|
|
24
26
|
/**
|
|
25
27
|
* Creates a new wallet manager from a default signer.
|
|
26
28
|
*
|
|
29
|
+
* @overload
|
|
27
30
|
* @param {ISigner} signer - The default signer.
|
|
28
31
|
* @param {WalletConfig} [config] - The wallet configuration.
|
|
32
|
+
* @throws {InvalidSignerError} If the given signer doesn't support account derivation.
|
|
29
33
|
*/
|
|
30
34
|
constructor(signer: ISigner, config?: WalletConfig);
|
|
31
35
|
/** @private */
|
|
32
|
-
private _seed
|
|
36
|
+
private _seed;
|
|
33
37
|
/**
|
|
34
|
-
* The default signer
|
|
35
|
-
* with no arguments.
|
|
38
|
+
* The default signer.
|
|
36
39
|
*
|
|
37
40
|
* @protected
|
|
38
41
|
* @type {ISigner | undefined}
|
|
@@ -68,23 +71,20 @@ export default abstract class WalletManager {
|
|
|
68
71
|
*/
|
|
69
72
|
get seed(): Uint8Array | undefined;
|
|
70
73
|
/**
|
|
71
|
-
* Registers a signer
|
|
74
|
+
* Registers a signer with the given name.
|
|
72
75
|
*
|
|
73
76
|
* @param {string} signerName - The signer name.
|
|
74
77
|
* @param {ISigner} signer - The signer.
|
|
75
78
|
* @returns {WalletManager} The wallet manager.
|
|
76
|
-
* @throws {
|
|
79
|
+
* @throws {ValueError} If the signer name is an empty or blank string.
|
|
77
80
|
*/
|
|
78
81
|
addSigner(signerName: string, signer: ISigner): WalletManager;
|
|
79
82
|
/**
|
|
80
|
-
* Returns
|
|
81
|
-
* at construction. With a name, returns the signer registered under that
|
|
82
|
-
* name via {@link addSigner}.
|
|
83
|
+
* Returns the default signer, or the signer with the given name.
|
|
83
84
|
*
|
|
84
|
-
* @param {string} [signerName] -
|
|
85
|
+
* @param {string} [signerName] - If set, returns the signer with the given name.
|
|
85
86
|
* @returns {ISigner} The signer.
|
|
86
|
-
* @throws {
|
|
87
|
-
* provided at construction, or if called with a name that is not registered.
|
|
87
|
+
* @throws {NoSuchElementError} If the default signer is not set, or no signers are found for the given name.
|
|
88
88
|
*/
|
|
89
89
|
getSigner(signerName?: string): ISigner;
|
|
90
90
|
/**
|
|
@@ -98,28 +98,28 @@ export default abstract class WalletManager {
|
|
|
98
98
|
/**
|
|
99
99
|
* Returns the wallet account at a specific index (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)).
|
|
100
100
|
*
|
|
101
|
+
* @overload
|
|
101
102
|
* @param {number} [index] - The index of the account to get (default: 0).
|
|
102
103
|
* @param {Object} [options] - Account options.
|
|
103
|
-
* @param {string} [options.signerName] - The signer name.
|
|
104
|
+
* @param {string} [options.signerName] - The signer name.
|
|
104
105
|
* @returns {Promise<IWalletAccount>} The account.
|
|
105
|
-
* @throws {
|
|
106
|
-
* @throws {
|
|
106
|
+
* @throws {ValueError} If the index is not valid.
|
|
107
|
+
* @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
|
|
108
|
+
* @throws {InvalidSignerError} If the signer doesn't support account derivation.
|
|
107
109
|
*/
|
|
108
|
-
abstract getAccount(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
signerName?: string;
|
|
112
|
-
},
|
|
113
|
-
): Promise<IWalletAccount>;
|
|
110
|
+
abstract getAccount(index?: number, options?: {
|
|
111
|
+
signerName?: string;
|
|
112
|
+
}): Promise<IWalletAccount>;
|
|
114
113
|
/**
|
|
115
114
|
* Returns the wallet account associated with a registered signer. For
|
|
116
115
|
* non-derivable signers (e.g., private-key signers), returns the signer's
|
|
117
116
|
* single account. For derivable signers, returns the wallet account at the
|
|
118
117
|
* signer's root, with no further derivation.
|
|
119
118
|
*
|
|
119
|
+
* @overload
|
|
120
120
|
* @param {string} signerName - The signer name registered via {@link addSigner}.
|
|
121
121
|
* @returns {Promise<IWalletAccount>} The account.
|
|
122
|
-
* @throws {
|
|
122
|
+
* @throws {NoSuchElementError} If no signer exists with the given name.
|
|
123
123
|
*/
|
|
124
124
|
abstract getAccount(signerName: string): Promise<IWalletAccount>;
|
|
125
125
|
/**
|
|
@@ -130,20 +130,20 @@ export default abstract class WalletManager {
|
|
|
130
130
|
* @param {Object} [options] - Account options.
|
|
131
131
|
* @param {string} [options.signerName] - The signer name. Omit to use the default signer.
|
|
132
132
|
* @returns {Promise<IWalletAccount>} The account.
|
|
133
|
-
* @throws {
|
|
134
|
-
* @throws {
|
|
133
|
+
* @throws {ValueError} If the path is not valid.
|
|
134
|
+
* @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
|
|
135
|
+
* @throws {InvalidSignerError} If the signer doesn't support account derivation.
|
|
135
136
|
*/
|
|
136
|
-
abstract getAccountByPath(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
signerName?: string;
|
|
140
|
-
},
|
|
141
|
-
): Promise<IWalletAccount>;
|
|
137
|
+
abstract getAccountByPath(path: string, options?: {
|
|
138
|
+
signerName?: string;
|
|
139
|
+
}): Promise<IWalletAccount>;
|
|
142
140
|
/**
|
|
143
141
|
* Returns the current fee rates.
|
|
144
142
|
*
|
|
145
143
|
* @abstract
|
|
146
144
|
* @returns {Promise<FeeRates>} The fee rates (in base unit).
|
|
145
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
146
|
+
* @throws {ProviderError} If the provider fails to fetch fee rates.
|
|
147
147
|
*/
|
|
148
148
|
abstract getFeeRates(): Promise<FeeRates>;
|
|
149
149
|
/**
|
|
@@ -153,16 +153,18 @@ export default abstract class WalletManager {
|
|
|
153
153
|
}
|
|
154
154
|
export type IWalletAccount = import("./wallet-account.js").IWalletAccount;
|
|
155
155
|
export type ISigner = import("./signer.js").ISigner;
|
|
156
|
-
export type
|
|
156
|
+
export type InvalidSignerError = import("./errors.js").InvalidSignerError;
|
|
157
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
158
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
157
159
|
export type WalletConfig = {
|
|
158
160
|
/**
|
|
159
|
-
* - The maximum fee amount for
|
|
161
|
+
* - The maximum fee amount for sending transactions.
|
|
160
162
|
*/
|
|
161
|
-
|
|
163
|
+
transactionMaxFee?: number | bigint;
|
|
162
164
|
/**
|
|
163
|
-
* - The maximum fee amount for
|
|
165
|
+
* - The maximum fee amount for transfer operations.
|
|
164
166
|
*/
|
|
165
|
-
|
|
167
|
+
transferMaxFee?: number | bigint;
|
|
166
168
|
};
|
|
167
169
|
export type FeeRates = {
|
|
168
170
|
/**
|