@tetherto/wdk-wallet 1.0.0-beta.16 → 1.0.0-beta.18

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.
Files changed (45) hide show
  1. package/index.js +11 -12
  2. package/package.json +1 -1
  3. package/src/errors.js +280 -19
  4. package/src/multisig/errors.js +54 -0
  5. package/src/multisig/index.js +15 -3
  6. package/src/multisig/multisig-message-signing-read-only.js +63 -0
  7. package/src/multisig/multisig-message-signing.js +64 -0
  8. package/src/multisig/multisig-owner-management.js +22 -5
  9. package/src/multisig/wallet-account-multisig.js +26 -37
  10. package/src/multisig/wallet-account-read-only-multisig.js +20 -34
  11. package/src/protocols/bridge-protocol.js +35 -1
  12. package/src/protocols/errors.js +510 -0
  13. package/src/protocols/fiat-protocol.js +104 -4
  14. package/src/protocols/index.js +13 -0
  15. package/src/protocols/lending-protocol.js +114 -2
  16. package/src/protocols/sda-protocol.js +103 -16
  17. package/src/protocols/swap-protocol.js +35 -1
  18. package/src/protocols/swidge-protocol.js +166 -55
  19. package/src/signer.js +8 -4
  20. package/src/wallet-account-read-only-simple.js +86 -1
  21. package/src/wallet-account-read-only.js +175 -6
  22. package/src/wallet-account.js +25 -1
  23. package/src/wallet-manager.js +38 -22
  24. package/types/index.d.ts +9 -2
  25. package/types/src/errors.d.ts +198 -14
  26. package/types/src/multisig/errors.d.ts +33 -0
  27. package/types/src/multisig/index.d.ts +7 -3
  28. package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
  29. package/types/src/multisig/multisig-message-signing.d.ts +40 -0
  30. package/types/src/multisig/multisig-owner-management.d.ts +20 -4
  31. package/types/src/multisig/wallet-account-multisig.d.ts +27 -33
  32. package/types/src/multisig/wallet-account-read-only-multisig.d.ts +20 -40
  33. package/types/src/protocols/bridge-protocol.d.ts +39 -3
  34. package/types/src/protocols/errors.d.ts +366 -0
  35. package/types/src/protocols/fiat-protocol.d.ts +103 -9
  36. package/types/src/protocols/index.d.ts +11 -0
  37. package/types/src/protocols/lending-protocol.d.ts +118 -4
  38. package/types/src/protocols/sda-protocol.d.ts +120 -23
  39. package/types/src/protocols/swap-protocol.d.ts +40 -4
  40. package/types/src/protocols/swidge-protocol.d.ts +106 -38
  41. package/types/src/signer.d.ts +6 -4
  42. package/types/src/wallet-account-read-only-simple.d.ts +99 -1
  43. package/types/src/wallet-account-read-only.d.ts +95 -3
  44. package/types/src/wallet-account.d.ts +27 -3
  45. package/types/src/wallet-manager.d.ts +37 -35
@@ -5,6 +5,13 @@ export interface ISwapProtocol {
5
5
  *
6
6
  * @param {SwapOptions} options - The swap's options.
7
7
  * @returns {Promise<SwapResult>} The swap's result.
8
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
9
+ * @throws {ValueError} If the swap options are not valid.
10
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
11
+ * @throws {ProviderRequiredError} If the method requires a provider.
12
+ * @throws {ProviderError} If the provider fails to perform the swap.
13
+ * @throws {SwapError} If the swap fails with an error.
14
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the swap max. fee option.
8
15
  */
9
16
  swap(options: SwapOptions): Promise<SwapResult>;
10
17
  /**
@@ -12,10 +19,19 @@ export interface ISwapProtocol {
12
19
  *
13
20
  * @param {SwapOptions} options - The swap's options.
14
21
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
22
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
23
+ * @throws {ValueError} If the swap options are not valid.
24
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
25
+ * @throws {ProviderRequiredError} If the method requires a provider.
26
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
27
+ * @throws {SwapError} If the swap fails with an error.
15
28
  */
16
29
  quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
17
30
  }
18
- /** @abstract */
31
+ /**
32
+ * @abstract
33
+ * @implements {ISwapProtocol}
34
+ */
19
35
  export default abstract class SwapProtocol implements ISwapProtocol {
20
36
  /**
21
37
  * Creates a new read-only swap protocol.
@@ -53,6 +69,13 @@ export default abstract class SwapProtocol implements ISwapProtocol {
53
69
  * @abstract
54
70
  * @param {SwapOptions} options - The swap's options.
55
71
  * @returns {Promise<SwapResult>} The swap's result.
72
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
73
+ * @throws {ValueError} If the swap options are not valid.
74
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
75
+ * @throws {ProviderRequiredError} If the method requires a provider.
76
+ * @throws {ProviderError} If the provider fails to perform the swap.
77
+ * @throws {SwapError} If the swap fails with an error.
78
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the swap max. fee option.
56
79
  */
57
80
  abstract swap(options: SwapOptions): Promise<SwapResult>;
58
81
  /**
@@ -61,11 +84,24 @@ export default abstract class SwapProtocol implements ISwapProtocol {
61
84
  * @abstract
62
85
  * @param {SwapOptions} options - The swap's options.
63
86
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
87
+ * @throws {ValueError} If the swap options are not valid.
88
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
89
+ * @throws {ProviderRequiredError} If the method requires a provider.
90
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
91
+ * @throws {SwapError} If the swap fails with an error.
64
92
  */
65
93
  abstract quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
66
94
  }
67
95
  export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
68
96
  export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
97
+ export type AccountRequiredError = import("./errors.js").AccountRequiredError;
98
+ export type InvalidTokenError = import("./errors.js").InvalidTokenError;
99
+ export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
100
+ export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
101
+ export type ProviderError = import("./errors.js").ProviderError;
102
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
103
+ export type SwapError = import("./errors.js").SwapError;
104
+ export type ValueError = import("./errors.js").ValueError;
69
105
  export type SwapProtocolConfig = {
70
106
  /**
71
107
  * - The maximum fee amount for swap operations.
@@ -73,7 +109,7 @@ export type SwapProtocolConfig = {
73
109
  swapMaxFee?: number | bigint;
74
110
  };
75
111
  export type SwapOptions = SwapCommonOptions & (SwapBuyOptions | SwapSellOptions);
76
- type SwapCommonOptions = {
112
+ export type SwapCommonOptions = {
77
113
  /**
78
114
  * - The address of the token to sell.
79
115
  */
@@ -91,7 +127,7 @@ type SwapCommonOptions = {
91
127
  */
92
128
  minAmountOut?: number | bigint;
93
129
  };
94
- type SwapBuyOptions = {
130
+ export type SwapBuyOptions = {
95
131
  /**
96
132
  * - The amount of input tokens to sell (in base unit).
97
133
  */
@@ -101,7 +137,7 @@ type SwapBuyOptions = {
101
137
  */
102
138
  tokenOutAmount: number | bigint;
103
139
  };
104
- type SwapSellOptions = {
140
+ export type SwapSellOptions = {
105
141
  /**
106
142
  * - The amount of input tokens to sell (in base unit).
107
143
  */
@@ -7,6 +7,12 @@ export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
7
7
  *
8
8
  * @param {SwidgeOptions} options - The swidge options.
9
9
  * @returns {Promise<SwidgeQuote>} The quoted swidge details.
10
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swidge.
11
+ * @throws {ValueError} If the swidge options are not valid.
12
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
13
+ * @throws {ProviderRequiredError} If the method requires a provider.
14
+ * @throws {ProviderError} If the provider fails to perform the swidge.
15
+ * @throws {SwidgeError} If the swidge fails with an error.
10
16
  */
11
17
  quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
12
18
  /**
@@ -15,6 +21,13 @@ export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
15
21
  * @param {SwidgeOptions} options - The swidge options.
16
22
  * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
17
23
  * @returns {Promise<SwidgeResult>} The swidge execution result.
24
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
25
+ * @throws {ValueError} If the swidge options are not valid.
26
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
27
+ * @throws {ProviderRequiredError} If the method requires a provider.
28
+ * @throws {ProviderError} If the provider fails to perform the swidge.
29
+ * @throws {SwidgeError} If the swidge fails with an error.
30
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
18
31
  */
19
32
  swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
20
33
  /**
@@ -23,13 +36,18 @@ export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
23
36
  * @param {string} id - The swidge execution identifier returned by swidge.
24
37
  * @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
25
38
  * @returns {Promise<SwidgeStatusResult>} The current swidge status.
26
- * @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
39
+ * @throws {ValueError} If the id is not valid.
40
+ * @throws {NoSuchElementError} If no swidge exists for the given id.
41
+ * @throws {ProviderRequiredError} If the method requires a provider.
42
+ * @throws {ProviderError} If the provider fails to fetch the swidge's status.
27
43
  */
28
44
  getSwidgeStatus(id: string, options?: SwidgeStatusOptions): Promise<SwidgeStatusResult>;
29
45
  /**
30
46
  * Retrieves the chains supported by the provider for swidge operations.
31
47
  *
32
48
  * @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
49
+ * @throws {ProviderRequiredError} If the method requires a provider.
50
+ * @throws {ProviderError} If the provider fails to fetch the available blockchains.
33
51
  */
34
52
  getSupportedChains(): Promise<SwidgeSupportedChain[]>;
35
53
  /**
@@ -37,6 +55,8 @@ export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
37
55
  *
38
56
  * @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
39
57
  * @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
58
+ * @throws {ProviderRequiredError} If the method requires a provider.
59
+ * @throws {ProviderError} If the provider fails to fetch the available tokens.
40
60
  */
41
61
  getSupportedTokens(options?: SwidgeSupportedTokensOptions): Promise<SwidgeSupportedToken[]>;
42
62
  }
@@ -49,7 +69,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
49
69
  * @param {undefined} [account] - The wallet account to use to interact with the protocol.
50
70
  * @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
51
71
  */
52
- constructor(account?: undefined, config?: SwidgeProtocolConfig | undefined);
72
+ constructor(account?: undefined, config?: SwidgeProtocolConfig);
53
73
  /**
54
74
  * Creates a new read-only swidge protocol.
55
75
  *
@@ -57,7 +77,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
57
77
  * @param {IWalletAccountReadOnly} account - The wallet account to use to interact with the protocol.
58
78
  * @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
59
79
  */
60
- constructor(account: IWalletAccountReadOnly, config?: SwidgeProtocolConfig | undefined);
80
+ constructor(account: IWalletAccountReadOnly, config?: SwidgeProtocolConfig);
61
81
  /**
62
82
  * Creates a new swidge protocol.
63
83
  *
@@ -65,7 +85,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
65
85
  * @param {IWalletAccount} account - The wallet account to use to interact with the protocol.
66
86
  * @param {SwidgeProtocolConfig} [config] - The swidge protocol configuration.
67
87
  */
68
- constructor(account: IWalletAccount, config?: SwidgeProtocolConfig | undefined);
88
+ constructor(account: IWalletAccount, config?: SwidgeProtocolConfig);
69
89
  /**
70
90
  * The wallet account to use to interact with the protocol.
71
91
  *
@@ -85,7 +105,13 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
85
105
  *
86
106
  * @param {SwapOptions} options - The swap's options.
87
107
  * @returns {Promise<SwapResult>} The swap's result.
88
- * @throws {Error} If no account, or a read-only account was given at construction.
108
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
109
+ * @throws {ValueError} If the swap options are not valid.
110
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
111
+ * @throws {ProviderRequiredError} If the method requires a provider.
112
+ * @throws {ProviderError} If the provider fails to perform the swap.
113
+ * @throws {SwapError} If the swap fails with an error.
114
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
89
115
  */
90
116
  swap(options: SwapOptions): Promise<SwapResult>;
91
117
  /**
@@ -93,7 +119,12 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
93
119
  *
94
120
  * @param {SwapOptions} options - The swap's options.
95
121
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
96
- * @throws {Error} If no account was given at construction.
122
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
123
+ * @throws {ValueError} If the swap options are not valid.
124
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
125
+ * @throws {ProviderRequiredError} If the method requires a provider.
126
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
127
+ * @throws {SwapError} If the swap fails with an error.
97
128
  */
98
129
  quoteSwap(options: SwapOptions): Promise<Omit<SwapResult, "hash">>;
99
130
  /**
@@ -101,7 +132,13 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
101
132
  *
102
133
  * @param {BridgeOptions} options - The bridge's options.
103
134
  * @returns {Promise<BridgeResult>} The bridge's result.
104
- * @throws {Error} If no account, or a read-only account was given at construction.
135
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
136
+ * @throws {ValueError} If the bridge options are not valid.
137
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
138
+ * @throws {ProviderRequiredError} If the method requires a provider.
139
+ * @throws {ProviderError} If the provider fails to perform the bridge.
140
+ * @throws {BridgeError} If the bridge fails with an error.
141
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
105
142
  */
106
143
  bridge(options: BridgeOptions): Promise<BridgeResult>;
107
144
  /**
@@ -109,7 +146,12 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
109
146
  *
110
147
  * @param {BridgeOptions} options - The bridge's options.
111
148
  * @returns {Promise<Omit<BridgeResult, 'hash'>>} The bridge's quotes.
112
- * @throws {Error} If no account was given at construction.
149
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
150
+ * @throws {ValueError} If the bridge options are not valid.
151
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
152
+ * @throws {ProviderRequiredError} If the method requires a provider.
153
+ * @throws {ProviderError} If the provider fails to perform the bridge.
154
+ * @throws {BridgeError} If the bridge fails with an error.
113
155
  */
114
156
  quoteBridge(options: BridgeOptions): Promise<Omit<BridgeResult, "hash">>;
115
157
  /**
@@ -120,7 +162,12 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
120
162
  * @abstract
121
163
  * @param {SwidgeOptions} options - The swidge options.
122
164
  * @returns {Promise<SwidgeQuote>} The quoted swidge details.
123
- * @throws {Error} If no account was given at construction.
165
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swidge.
166
+ * @throws {ValueError} If the swidge options are not valid.
167
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
168
+ * @throws {ProviderRequiredError} If the method requires a provider.
169
+ * @throws {ProviderError} If the provider fails to perform the swidge.
170
+ * @throws {SwidgeError} If the swidge fails with an error.
124
171
  */
125
172
  abstract quoteSwidge(options: SwidgeOptions): Promise<SwidgeQuote>;
126
173
  /**
@@ -130,7 +177,13 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
130
177
  * @param {SwidgeOptions} options - The swidge options.
131
178
  * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
132
179
  * @returns {Promise<SwidgeResult>} The swidge execution result.
133
- * @throws {Error} If no account, or a read-only account was given at construction.
180
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
181
+ * @throws {ValueError} If the swidge options are not valid.
182
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
183
+ * @throws {ProviderRequiredError} If the method requires a provider.
184
+ * @throws {ProviderError} If the provider fails to perform the swidge.
185
+ * @throws {SwidgeError} If the swidge fails with an error.
186
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
134
187
  */
135
188
  abstract swidge(options: SwidgeOptions, config?: SwidgeProtocolConfig): Promise<SwidgeResult>;
136
189
  /**
@@ -140,7 +193,10 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
140
193
  * @param {string} id - The swidge execution identifier returned by swidge.
141
194
  * @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
142
195
  * @returns {Promise<SwidgeStatusResult>} The current swidge status.
143
- * @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
196
+ * @throws {ValueError} If the id is not valid.
197
+ * @throws {NoSuchElementError} If no swidge exists for the given id.
198
+ * @throws {ProviderRequiredError} If the method requires a provider.
199
+ * @throws {ProviderError} If the provider fails to fetch the swidge's status.
144
200
  */
145
201
  abstract getSwidgeStatus(id: string, options?: SwidgeStatusOptions): Promise<SwidgeStatusResult>;
146
202
  /**
@@ -148,6 +204,8 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
148
204
  *
149
205
  * @abstract
150
206
  * @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
207
+ * @throws {ProviderRequiredError} If the method requires a provider.
208
+ * @throws {ProviderError} If the provider fails to fetch the available blockchains.
151
209
  */
152
210
  abstract getSupportedChains(): Promise<SwidgeSupportedChain[]>;
153
211
  /**
@@ -156,6 +214,8 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
156
214
  * @abstract
157
215
  * @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
158
216
  * @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
217
+ * @throws {ProviderRequiredError} If the method requires a provider.
218
+ * @throws {ProviderError} If the provider fails to fetch the available tokens.
159
219
  */
160
220
  abstract getSupportedTokens(options?: SwidgeSupportedTokensOptions): Promise<SwidgeSupportedToken[]>;
161
221
  }
@@ -167,17 +227,25 @@ export type SwapResult = import("./swap-protocol.js").SwapResult;
167
227
  export type IBridgeProtocol = import("./bridge-protocol.js").IBridgeProtocol;
168
228
  export type BridgeOptions = import("./bridge-protocol.js").BridgeOptions;
169
229
  export type BridgeResult = import("./bridge-protocol.js").BridgeResult;
230
+ export type AccountRequiredError = import("./errors.js").AccountRequiredError;
231
+ export type InvalidTokenError = import("./errors.js").InvalidTokenError;
232
+ export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
233
+ export type NoSuchElementError = import("./errors.js").NoSuchElementError;
234
+ export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
235
+ export type ProviderError = import("./errors.js").ProviderError;
236
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
237
+ export type ValueError = import("./errors.js").ValueError;
170
238
  export type SwidgeStatus = "pending" | "action-required" | "completed" | "failed" | "refund-pending" | "refunded" | "cancelled" | "expired" | "partial";
171
239
  export type SwidgeFeeType = "network" | "protocol" | "affiliate" | "other";
172
240
  export type SwidgeProtocolConfig = {
173
241
  /**
174
242
  * - Maximum acceptable network fee in basis points of the input amount.
175
243
  */
176
- maxNetworkFeeBps?: number | bigint | undefined;
244
+ maxNetworkFeeBps?: number | bigint;
177
245
  /**
178
246
  * - Maximum acceptable protocol fee in basis points of the input amount.
179
247
  */
180
- maxProtocolFeeBps?: number | bigint | undefined;
248
+ maxProtocolFeeBps?: number | bigint;
181
249
  };
182
250
  export type SwidgeOptions = SwidgeCommonOptions & (SwidgeExactInOptions | SwidgeExactOutOptions);
183
251
  export type SwidgeCommonOptions = {
@@ -192,19 +260,19 @@ export type SwidgeCommonOptions = {
192
260
  /**
193
261
  * - The identifier of the destination chain. If omitted, defaults to the source chain (same-chain swap).
194
262
  */
195
- toChain?: string | number | undefined;
263
+ toChain?: string | number;
196
264
  /**
197
265
  * - The address that will receive the output tokens.
198
266
  */
199
- recipient?: string | undefined;
267
+ recipient?: string;
200
268
  /**
201
269
  * - The address that will receive refunds if the tx cannot complete.
202
270
  */
203
- refundAddress?: string | undefined;
271
+ refundAddress?: string;
204
272
  /**
205
273
  * - The maximum acceptable slippage as a decimal (e.g., 0.01 for 1%).
206
274
  */
207
- slippage?: number | undefined;
275
+ slippage?: number;
208
276
  /**
209
277
  * - The minimum acceptable amount of destination tokens to receive (in base unit).
210
278
  */
@@ -218,13 +286,13 @@ export type SwidgeExactInOptions = {
218
286
  /**
219
287
  * - Not applicable for exact-in operations.
220
288
  */
221
- toTokenAmount?: undefined;
289
+ toTokenAmount?: never;
222
290
  };
223
291
  export type SwidgeExactOutOptions = {
224
292
  /**
225
293
  * - Not applicable for exact-out operations.
226
294
  */
227
- fromTokenAmount?: undefined;
295
+ fromTokenAmount?: never;
228
296
  /**
229
297
  * - The exact amount of destination tokens to receive (in base unit).
230
298
  */
@@ -246,15 +314,15 @@ export type SwidgeFee = {
246
314
  /**
247
315
  * - The chain on which the fee is charged.
248
316
  */
249
- chain?: string | number | undefined;
317
+ chain?: string | number;
250
318
  /**
251
319
  * - Whether the fee is already included in the quoted amounts.
252
320
  */
253
- included?: boolean | undefined;
321
+ included?: boolean;
254
322
  /**
255
323
  * - A human-readable description of the fee.
256
324
  */
257
- description?: string | undefined;
325
+ description?: string;
258
326
  };
259
327
  export type SwidgeTransaction = {
260
328
  /**
@@ -264,11 +332,11 @@ export type SwidgeTransaction = {
264
332
  /**
265
333
  * - The chain on which the transaction occurred.
266
334
  */
267
- chain?: string | number | undefined;
335
+ chain?: string | number;
268
336
  /**
269
337
  * - The role of the transaction within the swidge.
270
338
  */
271
- type?: "other" | "source" | "destination" | "approval" | "refund" | undefined;
339
+ type?: "source" | "destination" | "approval" | "refund" | "other";
272
340
  };
273
341
  /**
274
342
  * Non-binding quote for a swidge operation.
@@ -295,15 +363,15 @@ export type SwidgeQuote = {
295
363
  /**
296
364
  * - Estimated duration in seconds.
297
365
  */
298
- estimatedDuration?: number | undefined;
366
+ estimatedDuration?: number;
299
367
  /**
300
368
  * - Unix timestamp (seconds) at which the quote expires.
301
369
  */
302
- expiry?: number | undefined;
370
+ expiry?: number;
303
371
  /**
304
372
  * - Provider-reported estimated price impact as a decimal (e.g., 0.01 for 1%).
305
373
  */
306
- priceImpact?: number | undefined;
374
+ priceImpact?: number;
307
375
  };
308
376
  export type SwidgeResult = {
309
377
  /**
@@ -313,7 +381,7 @@ export type SwidgeResult = {
313
381
  /**
314
382
  * - The primary transaction hash (if available immediately).
315
383
  */
316
- hash?: string | undefined;
384
+ hash?: string;
317
385
  /**
318
386
  * - Itemised fee breakdown.
319
387
  */
@@ -321,7 +389,7 @@ export type SwidgeResult = {
321
389
  /**
322
390
  * - Transactions produced by the swidge execution.
323
391
  */
324
- transactions?: SwidgeTransaction[] | undefined;
392
+ transactions?: SwidgeTransaction[];
325
393
  /**
326
394
  * - The actual amount of source tokens spent.
327
395
  */
@@ -333,17 +401,17 @@ export type SwidgeResult = {
333
401
  /**
334
402
  * - The minimum guaranteed amount after slippage.
335
403
  */
336
- toTokenAmountMin?: bigint | undefined;
404
+ toTokenAmountMin?: bigint;
337
405
  };
338
406
  export type SwidgeStatusOptions = {
339
407
  /**
340
408
  * - The source chain identifier.
341
409
  */
342
- fromChain?: string | number | undefined;
410
+ fromChain?: string | number;
343
411
  /**
344
412
  * - The destination chain identifier.
345
413
  */
346
- toChain?: string | number | undefined;
414
+ toChain?: string | number;
347
415
  };
348
416
  export type SwidgeStatusResult = {
349
417
  /**
@@ -353,7 +421,7 @@ export type SwidgeStatusResult = {
353
421
  /**
354
422
  * - Transactions associated with the swidge.
355
423
  */
356
- transactions?: SwidgeTransaction[] | undefined;
424
+ transactions?: SwidgeTransaction[];
357
425
  };
358
426
  export type SwidgeSupportedChain = {
359
427
  /**
@@ -393,23 +461,23 @@ export type SwidgeSupportedToken = {
393
461
  /**
394
462
  * - The token contract address, if applicable.
395
463
  */
396
- address?: string | undefined;
464
+ address?: string;
397
465
  /**
398
466
  * - The token's full name.
399
467
  */
400
- name?: string | undefined;
468
+ name?: string;
401
469
  };
402
470
  export type SwidgeSupportedTokensOptions = {
403
471
  /**
404
472
  * - The optional source chain for route-scoped discovery.
405
473
  */
406
- fromChain?: string | number | undefined;
474
+ fromChain?: string | number;
407
475
  /**
408
476
  * - The optional source token for route-scoped discovery.
409
477
  */
410
- fromToken?: string | undefined;
478
+ fromToken?: string;
411
479
  /**
412
480
  * - The optional destination chain for route-scoped discovery.
413
481
  */
414
- toChain?: string | number | undefined;
482
+ toChain?: string | number;
415
483
  };
@@ -7,11 +7,12 @@ export class ISigner {
7
7
  /**
8
8
  * Derive a child signer using a relative path (e.g., "0'/0/0").
9
9
  *
10
- * @param {string} relPath - The relative derivation path.
10
+ * @param {string} path - The relative derivation path.
11
11
  * @returns {Promise<ISigner>} The derived signer.
12
- * @throws {SignerError} If the signer does not support derivation.
12
+ * @throws {UnsupportedOperationError} If the signer does not support account derivation.
13
+ * @throws {ValueError} If the path is not valid.
13
14
  */
14
- derive(relPath: string): Promise<ISigner>;
15
+ derive(path: string): Promise<ISigner>;
15
16
  /**
16
17
  * Returns the signer's address.
17
18
  *
@@ -23,4 +24,5 @@ export class ISigner {
23
24
  */
24
25
  dispose(): void;
25
26
  }
26
- export type SignerError = import("./errors.js").SignerError;
27
+ export type UnsupportedOperationError = import("./errors.js").UnsupportedOperationError;
28
+ export type ValueError = import("./errors.js").ValueError;
@@ -20,13 +20,15 @@ export interface IWalletAccountReadOnlySimple {
20
20
  * @param {string} message - The original message.
21
21
  * @param {string} signature - The signature to verify.
22
22
  * @returns {Promise<boolean>} True if the signature is valid.
23
- * @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
23
+ * @throws {UnsupportedOperationError} If the read-only wallet account class is not able to provide an implementation for the method.
24
24
  */
25
25
  verify(message: string, signature: string): Promise<boolean>;
26
26
  /**
27
27
  * Returns the account's native token balance.
28
28
  *
29
29
  * @returns {Promise<bigint>} The native token balance.
30
+ * @throws {ProviderRequiredError} If the method requires a provider.
31
+ * @throws {ProviderError} If the provider fails to fetch the account's balance.
30
32
  */
31
33
  getBalance(): Promise<bigint>;
32
34
  /**
@@ -34,13 +36,109 @@ export interface IWalletAccountReadOnlySimple {
34
36
  *
35
37
  * @param {string} tokenAddress - The smart contract address of the token.
36
38
  * @returns {Promise<bigint>} The token balance.
39
+ * @throws {ValueError} If the token's address is not valid.
40
+ * @throws {InvalidTokenError} If the token's address doesn't match an existing ERC 20 token.
41
+ * @throws {ProviderRequiredError} If the method requires a provider.
42
+ * @throws {ProviderError} If the provider fails to fetch the account's token balance.
37
43
  */
38
44
  getTokenBalance(tokenAddress: string): Promise<bigint>;
39
45
  /**
40
46
  * Returns a transaction's receipt.
41
47
  *
48
+ * @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.
42
49
  * @param {string} hash - The transaction's hash.
43
50
  * @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
51
+ * @throws {ValueError} If the hash is not valid.
52
+ * @throws {ProviderRequiredError} If the method requires a provider.
53
+ * @throws {ProviderError} If the provider fails to fetch the transaction's receipt.
44
54
  */
45
55
  getTransactionReceipt(hash: string): Promise<unknown | null>;
56
+ /**
57
+ * Returns a normalized, finality-based receipt for a transaction.
58
+ *
59
+ * @param {string} hash - The transaction's identifier (hash / signature / lt:hash).
60
+ * @returns {Promise<TransactionReceipt>} The normalized receipt.
61
+ * @throws {ValueError} If the hash is not a valid identifier.
62
+ * @throws {NoSuchElementError} If no transaction has been found for the given hash.
63
+ * @throws {ProviderRequiredError} If the method requires a provider.
64
+ * @throws {ProviderError} If the provider fails to fetch the transaction.
65
+ */
66
+ getTransaction(hash: string): Promise<TransactionReceipt>;
67
+ /**
68
+ * Blocks until a transaction reaches a terminal state (the requested finality target or `dropped`), or times out.
69
+ *
70
+ * @param {string} hash - The transaction's identifier.
71
+ * @param {WaitForTransactionOptions} [options] - The wait options.
72
+ * @returns {Promise<TransactionReceipt>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
73
+ * @throws {ValueError} If the hash is not a valid identifier.
74
+ * @throws {ProviderRequiredError} If the method requires a provider.
75
+ * @throws {ProviderError} If the provider fails to fetch the transaction.
76
+ * @throws {TimeoutError} If the operation times out.
77
+ */
78
+ waitForTransaction(hash: string, options?: WaitForTransactionOptions): Promise<TransactionReceipt>;
46
79
  }
80
+ export type InvalidTokenError = import("./errors.js").InvalidTokenError;
81
+ export type NoSuchElementError = import("./errors.js").NoSuchElementError;
82
+ export type ProviderError = import("./errors.js").ProviderError;
83
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
84
+ export type TimeoutError = import("./errors.js").TimeoutError;
85
+ export type ValueError = import("./errors.js").ValueError;
86
+ export type UnsupportedOperationError = import("./errors.js").UnsupportedOperationError;
87
+ /**
88
+ * A normalized, cross-chain transaction finality level.
89
+ *
90
+ * - `pending`: seen, not settled (mempool / processed / in-flight).
91
+ * - `confirmed`: settled, reversible only under extreme conditions.
92
+ * - `final`: irreversible per the chain's own guarantees.
93
+ * - `dropped`: evicted / replaced, never landed.
94
+ */
95
+ export type Finality = "pending" | "confirmed" | "final" | "dropped";
96
+ /**
97
+ * A normalized, cross-chain transaction receipt. Blockchain modules extend this
98
+ * type with their own native receipt fields (e.g. `confirmations`, the raw
99
+ * transaction and receipt objects, etc.).
100
+ */
101
+ export type TransactionReceipt = {
102
+ /**
103
+ * - The transaction's identifier (hash / signature / lt:hash).
104
+ */
105
+ hash: string;
106
+ /**
107
+ * - The transaction's finality level.
108
+ */
109
+ finality: Finality;
110
+ /**
111
+ * - The execution's result (not set if the transaction is still pending or it has been dropped).
112
+ */
113
+ success?: boolean;
114
+ /**
115
+ * - A reference to the including block (block number / height / slot / masterchain seqno).
116
+ */
117
+ block?: number;
118
+ /**
119
+ * - The fee paid, when known.
120
+ */
121
+ fee?: bigint;
122
+ };
123
+ /**
124
+ * The finality level to wait for.
125
+ */
126
+ export type WaitForTransactionTarget = "confirmed" | "final";
127
+ export type WaitForTransactionOptions = {
128
+ /**
129
+ * - The finality target to wait for (default: 'confirmed').
130
+ */
131
+ target?: WaitForTransactionTarget;
132
+ /**
133
+ * - The total time budget in milliseconds before giving up. If omitted, the account's `defaultWaitTimeout` is used.
134
+ */
135
+ timeout?: number;
136
+ /**
137
+ * - The poll cadence in milliseconds. If omitted, the account's `defaultWaitInterval` is used.
138
+ */
139
+ interval?: number;
140
+ /**
141
+ * - How many consecutive getTransaction() failures to tolerate before rethrowing (default: 3).
142
+ */
143
+ maxPollErrors?: number;
144
+ };