@tetherto/wdk-wallet 1.0.0-beta.21 → 1.0.0-beta.23
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 +1 -1
- package/package.json +1 -1
- package/src/disposable.js +9 -0
- package/src/errors.js +16 -0
- package/src/protocols/bridge-protocol.js +3 -0
- package/src/protocols/errors.js +2 -2
- package/src/protocols/fiat-protocol.js +5 -0
- package/src/protocols/index.js +1 -1
- package/src/protocols/lending-protocol.js +9 -0
- package/src/protocols/sda-protocol.js +11 -0
- package/src/protocols/swap-protocol.js +3 -0
- package/src/protocols/swidge-protocol.js +5 -0
- package/src/signer.js +3 -0
- package/src/wallet-account.js +7 -3
- package/src/wallet-manager.js +25 -1
- package/types/index.d.ts +1 -1
- package/types/src/disposable.d.ts +6 -0
- package/types/src/errors.d.ts +11 -0
- package/types/src/protocols/bridge-protocol.d.ts +3 -0
- package/types/src/protocols/errors.d.ts +2 -1
- package/types/src/protocols/fiat-protocol.d.ts +5 -0
- package/types/src/protocols/index.d.ts +1 -1
- package/types/src/protocols/lending-protocol.d.ts +9 -0
- package/types/src/protocols/sda-protocol.d.ts +11 -0
- package/types/src/protocols/swap-protocol.d.ts +3 -0
- package/types/src/protocols/swidge-protocol.d.ts +5 -0
- package/types/src/signer.d.ts +3 -0
- package/types/src/wallet-account.d.ts +5 -0
- package/types/src/wallet-manager.d.ts +13 -0
package/index.js
CHANGED
|
@@ -41,4 +41,4 @@ export { ISigner } from './src/signer.js'
|
|
|
41
41
|
|
|
42
42
|
export { IDisposable } from './src/disposable.js'
|
|
43
43
|
|
|
44
|
-
export { AssertionError, InvalidTokenError, InvalidSignerError, InvalidSignerError as SignerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderErrorReason, ProviderRequiredError, TimeoutError, TransactionError, TransactionErrorReason, TransferError, TransferErrorReason, UnsupportedOperationError, ValueError, WdkError } from './src/errors.js'
|
|
44
|
+
export { AssertionError, DisposalError, InvalidTokenError, InvalidSignerError, InvalidSignerError as SignerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderErrorReason, ProviderRequiredError, TimeoutError, TransactionError, TransactionErrorReason, TransferError, TransferErrorReason, UnsupportedOperationError, ValueError, WdkError } from './src/errors.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetherto/wdk-wallet",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.23",
|
|
4
4
|
"description": "Base wallet and protocol classes for WDK (Wallet Development Kit) by Tether. For internal use only.",
|
|
5
5
|
"homepage": "https://docs.wdk.tether.io/",
|
|
6
6
|
"keywords": [
|
package/src/disposable.js
CHANGED
|
@@ -17,6 +17,15 @@ import { NotImplementedError } from './errors.js'
|
|
|
17
17
|
|
|
18
18
|
/** @interface */
|
|
19
19
|
export class IDisposable {
|
|
20
|
+
/**
|
|
21
|
+
* True if the object has been disposed.
|
|
22
|
+
*
|
|
23
|
+
* @type {boolean}
|
|
24
|
+
*/
|
|
25
|
+
get disposed () {
|
|
26
|
+
throw new NotImplementedError('disposed')
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
/**
|
|
21
30
|
* Disposes the object along with all its data (cleaning up any sensitive field from memory).
|
|
22
31
|
*/
|
package/src/errors.js
CHANGED
|
@@ -340,3 +340,19 @@ export class TimeoutError extends WdkError {
|
|
|
340
340
|
this.name = 'TimeoutError'
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Thrown when an operation is attempted on an object that has been disposed.
|
|
346
|
+
*/
|
|
347
|
+
export class DisposalError extends WdkError {
|
|
348
|
+
/**
|
|
349
|
+
* Creates a new disposal error.
|
|
350
|
+
*
|
|
351
|
+
* @param {string} message - The error's message.
|
|
352
|
+
*/
|
|
353
|
+
constructor (message) {
|
|
354
|
+
super(message)
|
|
355
|
+
|
|
356
|
+
this.name = 'DisposalError'
|
|
357
|
+
}
|
|
358
|
+
}
|
|
@@ -20,6 +20,7 @@ import { NotImplementedError } from './errors.js'
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
22
|
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
23
24
|
/** @typedef {import('./errors.js').BridgeError} BridgeError */
|
|
24
25
|
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
25
26
|
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
@@ -56,6 +57,7 @@ export class IBridgeProtocol {
|
|
|
56
57
|
* @param {BridgeOptions} options - The bridge's options.
|
|
57
58
|
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
58
59
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
|
|
60
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
59
61
|
* @throws {ValueError} If the bridge options are not valid.
|
|
60
62
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
61
63
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -129,6 +131,7 @@ export default class BridgeProtocol {
|
|
|
129
131
|
* @param {BridgeOptions} options - The bridge's options.
|
|
130
132
|
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
131
133
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
|
|
134
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
132
135
|
* @throws {ValueError} If the bridge options are not valid.
|
|
133
136
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
134
137
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
package/src/protocols/errors.js
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
import { InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, UnsupportedOperationError, ValueError, WdkError } from '../errors.js'
|
|
16
|
+
import { DisposalError, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, UnsupportedOperationError, ValueError, WdkError } from '../errors.js'
|
|
17
17
|
|
|
18
|
-
export { InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, UnsupportedOperationError, ValueError, WdkError }
|
|
18
|
+
export { DisposalError, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, UnsupportedOperationError, ValueError, WdkError }
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @typedef {Object} SwapErrorOptions
|
|
@@ -20,6 +20,7 @@ import { NotImplementedError } from './errors.js'
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
22
|
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
23
24
|
/** @typedef {import('./errors.js').BuyError} BuyError */
|
|
24
25
|
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
25
26
|
/** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
|
|
@@ -160,6 +161,7 @@ export class IFiatProtocol {
|
|
|
160
161
|
* @param {BuyOptions} options - The options for the buy operation.
|
|
161
162
|
* @returns {Promise<BuyResult>} The operation's result.
|
|
162
163
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
|
|
164
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
163
165
|
* @throws {ValueError} If the buy options are not valid.
|
|
164
166
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
165
167
|
* @throws {ProviderError} If the provider fails to perform the purchase.
|
|
@@ -191,6 +193,7 @@ export class IFiatProtocol {
|
|
|
191
193
|
* @param {SellOptions} options - The options for the sell operation.
|
|
192
194
|
* @returns {Promise<SellResult>} The operation's result.
|
|
193
195
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
|
|
196
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
194
197
|
* @throws {ValueError} If the buy options are not valid.
|
|
195
198
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
196
199
|
* @throws {ProviderError} If the provider fails to perform the sale.
|
|
@@ -305,6 +308,7 @@ export default class FiatProtocol {
|
|
|
305
308
|
* @param {BuyOptions} options - The options for the buy operation.
|
|
306
309
|
* @returns {Promise<BuyResult>} The URL for the user to complete the purchase.
|
|
307
310
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
|
|
311
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
308
312
|
* @throws {ValueError} If the buy options are not valid.
|
|
309
313
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
310
314
|
* @throws {ProviderError} If the provider fails to perform the purchase.
|
|
@@ -338,6 +342,7 @@ export default class FiatProtocol {
|
|
|
338
342
|
* @param {SellOptions} options - The options for the sell operation.
|
|
339
343
|
* @returns {Promise<SellResult>} The URL for the user to complete the sale.
|
|
340
344
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
|
|
345
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
341
346
|
* @throws {ValueError} If the buy options are not valid.
|
|
342
347
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
343
348
|
* @throws {ProviderError} If the provider fails to perform the sale.
|
package/src/protocols/index.js
CHANGED
|
@@ -110,4 +110,4 @@ export { default as SwidgeProtocol, ISwidgeProtocol } from './swidge-protocol.js
|
|
|
110
110
|
|
|
111
111
|
export { default as SdaProtocol, ISdaProtocol } from './sda-protocol.js'
|
|
112
112
|
|
|
113
|
-
export { AccountRequiredError, BorrowError, BorrowErrorReason, BridgeError, BridgeErrorReason, BuyError, BuyErrorReason, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, ReadOnlyAccountRequiredError, RepayError, RepayErrorReason, SdaError, SdaErrorReason, SellError, SellErrorReason, SupplyError, SupplyErrorReason, SwapError, SwapErrorReason, SwidgeError, SwidgeErrorReason, UnsupportedOperationError, ValueError, WdkError, WithdrawError, WithdrawErrorReason } from './errors.js'
|
|
113
|
+
export { AccountRequiredError, BorrowError, BorrowErrorReason, BridgeError, BridgeErrorReason, BuyError, BuyErrorReason, DisposalError, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, ReadOnlyAccountRequiredError, RepayError, RepayErrorReason, SdaError, SdaErrorReason, SellError, SellErrorReason, SupplyError, SupplyErrorReason, SwapError, SwapErrorReason, SwidgeError, SwidgeErrorReason, UnsupportedOperationError, ValueError, WdkError, WithdrawError, WithdrawErrorReason } from './errors.js'
|
|
@@ -20,6 +20,7 @@ import { NotImplementedError } from './errors.js'
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
22
|
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
23
24
|
/** @typedef {import('./errors.js').BorrowError} BorrowError */
|
|
24
25
|
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
25
26
|
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
@@ -91,6 +92,7 @@ export class ILendingProtocol {
|
|
|
91
92
|
* @param {SupplyOptions} options - The supply's options.
|
|
92
93
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
93
94
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
95
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
94
96
|
* @throws {ValueError} If the supply options are not valid.
|
|
95
97
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
96
98
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -124,6 +126,7 @@ export class ILendingProtocol {
|
|
|
124
126
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
125
127
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
126
128
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
129
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
127
130
|
* @throws {ValueError} If the withdraw options are not valid.
|
|
128
131
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
129
132
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -157,6 +160,7 @@ export class ILendingProtocol {
|
|
|
157
160
|
* @param {BorrowOptions} options - The borrow's options.
|
|
158
161
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
159
162
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
163
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
160
164
|
* @throws {ValueError} If the borrow options are not valid.
|
|
161
165
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
162
166
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -190,6 +194,7 @@ export class ILendingProtocol {
|
|
|
190
194
|
* @param {RepayOptions} options - The repay's options.
|
|
191
195
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
192
196
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
197
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
193
198
|
* @throws {ValueError} If the repay options are not valid.
|
|
194
199
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
195
200
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -253,6 +258,7 @@ export default class LendingProtocol {
|
|
|
253
258
|
* @param {SupplyOptions} options - The supply's options.
|
|
254
259
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
255
260
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
261
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
256
262
|
* @throws {ValueError} If the supply options are not valid.
|
|
257
263
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
258
264
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -287,6 +293,7 @@ export default class LendingProtocol {
|
|
|
287
293
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
288
294
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
289
295
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
296
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
290
297
|
* @throws {ValueError} If the withdraw options are not valid.
|
|
291
298
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
292
299
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -321,6 +328,7 @@ export default class LendingProtocol {
|
|
|
321
328
|
* @param {BorrowOptions} options - The borrow's options.
|
|
322
329
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
323
330
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
331
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
324
332
|
* @throws {ValueError} If the borrow options are not valid.
|
|
325
333
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
326
334
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -355,6 +363,7 @@ export default class LendingProtocol {
|
|
|
355
363
|
* @param {RepayOptions} options - The borrow's options.
|
|
356
364
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
357
365
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
366
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
358
367
|
* @throws {ValueError} If the repay options are not valid.
|
|
359
368
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
360
369
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -20,6 +20,7 @@ import { NotImplementedError, UnsupportedOperationError } from './errors.js'
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
22
|
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
23
24
|
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
24
25
|
/** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
|
|
25
26
|
/** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
|
|
@@ -273,6 +274,7 @@ export class ISdaProtocol {
|
|
|
273
274
|
* @param {SdaCreateDepositAddressOptions} options - The address creation options.
|
|
274
275
|
* @returns {Promise<SdaDepositAddress[]>} The created deposit addresses, one per distinct address.
|
|
275
276
|
* @throws {AccountRequiredError} If the protocol requires a full account to create a new deposit address.
|
|
277
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
276
278
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
277
279
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
278
280
|
* @throws {ProviderError} If the provider fails to create a new deposit address.
|
|
@@ -292,6 +294,7 @@ export class ISdaProtocol {
|
|
|
292
294
|
* @returns {Promise<string>} The derived deposit address.
|
|
293
295
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
294
296
|
* @throws {AccountRequiredError} If the protocol requires a full account to derive a deposit address.
|
|
297
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
295
298
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
296
299
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
297
300
|
* @throws {ProviderError} If the provider fails to derive the deposit address.
|
|
@@ -325,6 +328,7 @@ export class ISdaProtocol {
|
|
|
325
328
|
* @returns {Promise<SdaDepositAddress>} The refreshed deposit address descriptor (with the new `expiry`).
|
|
326
329
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
327
330
|
* @throws {AccountRequiredError} If the protocol requires a full account to renew a deposit address.
|
|
331
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
328
332
|
* @throws {ValueError} If the id is not valid.
|
|
329
333
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
330
334
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -388,6 +392,7 @@ export class ISdaProtocol {
|
|
|
388
392
|
* @returns {Promise<SdaRecoveryResult>} The recovery outcome.
|
|
389
393
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
390
394
|
* @throws {AccountRequiredError} If the protocol requires a full account to recover a deposit address.
|
|
395
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
391
396
|
* @throws {ValueError} If the id is not valid.
|
|
392
397
|
* @throws {NoSuchElementError} If no deposit address exists for the given id or address.
|
|
393
398
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -406,6 +411,7 @@ export class ISdaProtocol {
|
|
|
406
411
|
* @returns {Promise<void>} Resolves once the address has been disabled.
|
|
407
412
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
408
413
|
* @throws {AccountRequiredError} If the protocol requires a full account to disable a deposit address.
|
|
414
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
409
415
|
* @throws {ValueError} If the id is not valid.
|
|
410
416
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
411
417
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -498,6 +504,7 @@ export default class SdaProtocol {
|
|
|
498
504
|
* @param {SdaCreateDepositAddressOptions} options - The address creation options.
|
|
499
505
|
* @returns {Promise<SdaDepositAddress[]>} The created deposit addresses, one per distinct address.
|
|
500
506
|
* @throws {AccountRequiredError} If the protocol requires a full account to create a new deposit address.
|
|
507
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
501
508
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
502
509
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
503
510
|
* @throws {ProviderError} If the provider fails to create a new deposit address.
|
|
@@ -517,6 +524,7 @@ export default class SdaProtocol {
|
|
|
517
524
|
* @returns {Promise<string>} The derived deposit address.
|
|
518
525
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
519
526
|
* @throws {AccountRequiredError} If the protocol requires a full account to derive a deposit address.
|
|
527
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
520
528
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
521
529
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
522
530
|
* @throws {ProviderError} If the provider fails to derive the deposit address.
|
|
@@ -550,6 +558,7 @@ export default class SdaProtocol {
|
|
|
550
558
|
* @returns {Promise<SdaDepositAddress>} The refreshed deposit address descriptor (with the new `expiry`).
|
|
551
559
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
552
560
|
* @throws {AccountRequiredError} If the protocol requires a full account to renew a deposit address.
|
|
561
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
553
562
|
* @throws {ValueError} If the id is not valid.
|
|
554
563
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
555
564
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -613,6 +622,7 @@ export default class SdaProtocol {
|
|
|
613
622
|
* @returns {Promise<SdaRecoveryResult>} The recovery outcome.
|
|
614
623
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
615
624
|
* @throws {AccountRequiredError} If the protocol requires a full account to recover a deposit address.
|
|
625
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
616
626
|
* @throws {ValueError} If the id is not valid.
|
|
617
627
|
* @throws {NoSuchElementError} If no deposit address exists for the given id or address.
|
|
618
628
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -631,6 +641,7 @@ export default class SdaProtocol {
|
|
|
631
641
|
* @returns {Promise<void>} Resolves once the address has been disabled.
|
|
632
642
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
633
643
|
* @throws {AccountRequiredError} If the protocol requires a full account to disable a deposit address.
|
|
644
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
634
645
|
* @throws {ValueError} If the id is not valid.
|
|
635
646
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
636
647
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -20,6 +20,7 @@ import { NotImplementedError } from './errors.js'
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
22
|
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
23
24
|
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
24
25
|
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
25
26
|
/** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
|
|
@@ -73,6 +74,7 @@ export class ISwapProtocol {
|
|
|
73
74
|
* @param {SwapOptions} options - The swap's options.
|
|
74
75
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
75
76
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
77
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
76
78
|
* @throws {ValueError} If the swap options are not valid.
|
|
77
79
|
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
78
80
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -146,6 +148,7 @@ export default class SwapProtocol {
|
|
|
146
148
|
* @param {SwapOptions} options - The swap's options.
|
|
147
149
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
148
150
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
151
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
149
152
|
* @throws {ValueError} If the swap options are not valid.
|
|
150
153
|
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
151
154
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -28,6 +28,7 @@ import { BridgeError, NotImplementedError, SwapError, SwidgeError } from './erro
|
|
|
28
28
|
/** @typedef {import('./bridge-protocol.js').BridgeResult} BridgeResult */
|
|
29
29
|
|
|
30
30
|
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
31
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
31
32
|
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
32
33
|
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
33
34
|
/** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
|
|
@@ -189,6 +190,7 @@ export class ISwidgeProtocol {
|
|
|
189
190
|
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
190
191
|
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
191
192
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
|
|
193
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
192
194
|
* @throws {ValueError} If the swidge options are not valid.
|
|
193
195
|
* @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
|
|
194
196
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -293,6 +295,7 @@ export default class SwidgeProtocol {
|
|
|
293
295
|
* @param {SwapOptions} options - The swap's options.
|
|
294
296
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
295
297
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
298
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
296
299
|
* @throws {ValueError} If the swap options are not valid.
|
|
297
300
|
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
298
301
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -364,6 +367,7 @@ export default class SwidgeProtocol {
|
|
|
364
367
|
* @param {BridgeOptions} options - The bridge's options.
|
|
365
368
|
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
366
369
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
|
|
370
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
367
371
|
* @throws {ValueError} If the bridge options are not valid.
|
|
368
372
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
369
373
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -462,6 +466,7 @@ export default class SwidgeProtocol {
|
|
|
462
466
|
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
463
467
|
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
464
468
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
|
|
469
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
465
470
|
* @throws {ValueError} If the swidge options are not valid.
|
|
466
471
|
* @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
|
|
467
472
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
package/src/signer.js
CHANGED
|
@@ -18,6 +18,7 @@ import { NotImplementedError } from './errors.js'
|
|
|
18
18
|
import { IDisposable } from './disposable.js'
|
|
19
19
|
|
|
20
20
|
/** @typedef {import('./wallet-account.js').KeyPair} KeyPair */
|
|
21
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
21
22
|
/** @typedef {import('./errors.js').UnsupportedOperationError} UnsupportedOperationError */
|
|
22
23
|
/** @typedef {import('./errors.js').ValueError} ValueError */
|
|
23
24
|
|
|
@@ -63,6 +64,7 @@ export class ISigner extends IDisposable {
|
|
|
63
64
|
* @returns {Promise<ISigner>} The derived signer.
|
|
64
65
|
* @throws {UnsupportedOperationError} If the signer does not support account derivation.
|
|
65
66
|
* @throws {ValueError} If the path is not valid.
|
|
67
|
+
* @throws {DisposalError} If the signer has been disposed.
|
|
66
68
|
*/
|
|
67
69
|
async derive (path) {
|
|
68
70
|
throw new NotImplementedError('derive(path)')
|
|
@@ -82,6 +84,7 @@ export class ISigner extends IDisposable {
|
|
|
82
84
|
*
|
|
83
85
|
* @param {string} message - The message to sign.
|
|
84
86
|
* @returns {Promise<string>} The message's signature.
|
|
87
|
+
* @throws {DisposalError} If the signer has been disposed.
|
|
85
88
|
*/
|
|
86
89
|
async sign (message) {
|
|
87
90
|
throw new NotImplementedError('sign(message)')
|
package/src/wallet-account.js
CHANGED
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
import { IWalletAccountReadOnly } from './wallet-account-read-only.js'
|
|
17
|
-
|
|
18
16
|
import { NotImplementedError } from './errors.js'
|
|
19
17
|
|
|
18
|
+
/** @typedef {import('./wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
|
|
20
19
|
/** @typedef {import('./wallet-account-read-only.js').Transaction} Transaction */
|
|
21
20
|
/** @typedef {import('./wallet-account-read-only.js').TransactionResult} TransactionResult */
|
|
22
21
|
|
|
23
22
|
/** @typedef {import('./wallet-account-read-only.js').TransferOptions} TransferOptions */
|
|
24
23
|
/** @typedef {import('./wallet-account-read-only.js').TransferResult} TransferResult */
|
|
25
24
|
|
|
25
|
+
/** @typedef {import('./errors.js').DisposalError} DisposalError */
|
|
26
26
|
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
27
27
|
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
28
28
|
/** @typedef {import('./errors.js').ProviderError} ProviderError */
|
|
@@ -45,7 +45,7 @@ import { NotImplementedError } from './errors.js'
|
|
|
45
45
|
* @extends {IDisposable}
|
|
46
46
|
* @template [TSignedTransaction=unknown]
|
|
47
47
|
*/
|
|
48
|
-
export class IWalletAccount
|
|
48
|
+
export class IWalletAccount {
|
|
49
49
|
/**
|
|
50
50
|
* The derivation path of this account (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)),
|
|
51
51
|
* or null if the account's signer is not bound to a BIP-44 position (e.g. private-key signers).
|
|
@@ -71,6 +71,7 @@ export class IWalletAccount extends IWalletAccountReadOnly {
|
|
|
71
71
|
*
|
|
72
72
|
* @param {string} message - The message to sign.
|
|
73
73
|
* @returns {Promise<string>} The message's signature.
|
|
74
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
74
75
|
*/
|
|
75
76
|
async sign (message) {
|
|
76
77
|
throw new NotImplementedError('sign(message)')
|
|
@@ -82,6 +83,7 @@ export class IWalletAccount extends IWalletAccountReadOnly {
|
|
|
82
83
|
* @param {Transaction} tx - The transaction to sign.
|
|
83
84
|
* @returns {Promise<TSignedTransaction>} The signed transaction.
|
|
84
85
|
* @throws {ValueError} If the transaction is not valid.
|
|
86
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
85
87
|
*/
|
|
86
88
|
async signTransaction (tx) {
|
|
87
89
|
throw new NotImplementedError('signTransaction(tx)')
|
|
@@ -108,6 +110,7 @@ export class IWalletAccount extends IWalletAccountReadOnly {
|
|
|
108
110
|
* @throws {ProviderError} If the provider fails to perform the transaction.
|
|
109
111
|
* @throws {TransactionError} If the transaction fails with an error.
|
|
110
112
|
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the transaction max. fee option.
|
|
113
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
111
114
|
*/
|
|
112
115
|
async sendTransaction (tx) {
|
|
113
116
|
throw new NotImplementedError('sendTransaction(tx)')
|
|
@@ -138,6 +141,7 @@ export class IWalletAccount extends IWalletAccountReadOnly {
|
|
|
138
141
|
* @throws {ProviderError} If the provider fails to perform the transfer.
|
|
139
142
|
* @throws {TransferError} If the transfer fails with an error.
|
|
140
143
|
* @throws {MaximumFeeExceededError} If the the costs of the transfer exceeds the transfer max. fee option.
|
|
144
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
141
145
|
*/
|
|
142
146
|
async transfer (options) {
|
|
143
147
|
throw new NotImplementedError('transfer(options)')
|
package/src/wallet-manager.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import * as bip39 from 'bip39'
|
|
17
17
|
|
|
18
|
-
import { InvalidSignerError, NoSuchElementError, NotImplementedError, ValueError } from './errors.js'
|
|
18
|
+
import { DisposalError, InvalidSignerError, NoSuchElementError, NotImplementedError, ValueError } from './errors.js'
|
|
19
19
|
|
|
20
20
|
/** @typedef {import('./wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
@@ -111,6 +111,18 @@ export default class WalletManager {
|
|
|
111
111
|
* @type {WalletConfig}
|
|
112
112
|
*/
|
|
113
113
|
this._config = config
|
|
114
|
+
|
|
115
|
+
/** @private */
|
|
116
|
+
this._disposed = false
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* True if the wallet manager has been disposed.
|
|
121
|
+
*
|
|
122
|
+
* @type {boolean}
|
|
123
|
+
*/
|
|
124
|
+
get disposed () {
|
|
125
|
+
return this._disposed
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
/**
|
|
@@ -151,8 +163,13 @@ export default class WalletManager {
|
|
|
151
163
|
* @param {TSigner} signer - The signer.
|
|
152
164
|
* @returns {this} The wallet manager.
|
|
153
165
|
* @throws {ValueError} If the signer name is an empty or blank string.
|
|
166
|
+
* @throws {DisposalError} If the wallet manager has been disposed.
|
|
154
167
|
*/
|
|
155
168
|
addSigner (signerName, signer) {
|
|
169
|
+
if (this.disposed) {
|
|
170
|
+
throw new DisposalError('The wallet manager has been disposed.')
|
|
171
|
+
}
|
|
172
|
+
|
|
156
173
|
if (!signerName.trim()) {
|
|
157
174
|
throw new ValueError('The signer name cannot be an empty or blank string.')
|
|
158
175
|
}
|
|
@@ -209,6 +226,7 @@ export default class WalletManager {
|
|
|
209
226
|
* @throws {ValueError} If the index is not valid.
|
|
210
227
|
* @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
|
|
211
228
|
* @throws {InvalidSignerError} If the signer doesn't support account derivation.
|
|
229
|
+
* @throws {DisposalError} If the wallet manager or the given signer has been disposed.
|
|
212
230
|
*/
|
|
213
231
|
|
|
214
232
|
/**
|
|
@@ -221,6 +239,7 @@ export default class WalletManager {
|
|
|
221
239
|
* @param {string} signerName - The signer name registered via {@link addSigner}.
|
|
222
240
|
* @returns {Promise<IWalletAccount>} The account.
|
|
223
241
|
* @throws {NoSuchElementError} If no signer exists with the given name.
|
|
242
|
+
* @throws {DisposalError} If the wallet manager or the given signer has been disposed.
|
|
224
243
|
*/
|
|
225
244
|
|
|
226
245
|
/** @abstract */
|
|
@@ -239,6 +258,7 @@ export default class WalletManager {
|
|
|
239
258
|
* @throws {ValueError} If the path is not valid.
|
|
240
259
|
* @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
|
|
241
260
|
* @throws {InvalidSignerError} If the signer doesn't support account derivation.
|
|
261
|
+
* @throws {DisposalError} If the wallet manager or the given signer has been disposed.
|
|
242
262
|
*/
|
|
243
263
|
async getAccountByPath (path, options = {}) {
|
|
244
264
|
throw new NotImplementedError('getAccountByPath(path, options?)')
|
|
@@ -260,6 +280,8 @@ export default class WalletManager {
|
|
|
260
280
|
* Disposes all wallet accounts, clearing secret material from memory.
|
|
261
281
|
*/
|
|
262
282
|
dispose () {
|
|
283
|
+
if (this._disposed) return
|
|
284
|
+
|
|
263
285
|
for (const account of Object.values(this._accounts)) {
|
|
264
286
|
if (account.keyPair?.privateKey) {
|
|
265
287
|
account.dispose()
|
|
@@ -267,5 +289,7 @@ export default class WalletManager {
|
|
|
267
289
|
}
|
|
268
290
|
|
|
269
291
|
this._accounts = {}
|
|
292
|
+
|
|
293
|
+
this._disposed = true
|
|
270
294
|
}
|
|
271
295
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ export type ProviderErrorOptions = import("./src/errors.js").ProviderErrorOption
|
|
|
17
17
|
export type TransactionErrorOptions = import("./src/errors.js").TransactionErrorOptions;
|
|
18
18
|
export type TransferErrorOptions = import("./src/errors.js").TransferErrorOptions;
|
|
19
19
|
export { default as WalletAccountReadOnly, IWalletAccountReadOnly, FINALITY } from "./src/wallet-account-read-only.js";
|
|
20
|
-
export { AssertionError, InvalidTokenError, InvalidSignerError, InvalidSignerError as SignerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderErrorReason, ProviderRequiredError, TimeoutError, TransactionError, TransactionErrorReason, TransferError, TransferErrorReason, UnsupportedOperationError, ValueError, WdkError } from "./src/errors.js";
|
|
20
|
+
export { AssertionError, DisposalError, InvalidTokenError, InvalidSignerError, InvalidSignerError as SignerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderErrorReason, ProviderRequiredError, TimeoutError, TransactionError, TransactionErrorReason, TransferError, TransferErrorReason, UnsupportedOperationError, ValueError, WdkError } from "./src/errors.js";
|
package/types/src/errors.d.ts
CHANGED
|
@@ -206,6 +206,17 @@ export class TimeoutError extends WdkError {
|
|
|
206
206
|
*/
|
|
207
207
|
constructor(message: string);
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Thrown when an operation is attempted on an object that has been disposed.
|
|
211
|
+
*/
|
|
212
|
+
export class DisposalError extends WdkError {
|
|
213
|
+
/**
|
|
214
|
+
* Creates a new disposal error.
|
|
215
|
+
*
|
|
216
|
+
* @param {string} message - The error's message.
|
|
217
|
+
*/
|
|
218
|
+
constructor(message: string);
|
|
219
|
+
}
|
|
209
220
|
export type ProviderErrorOptions = {
|
|
210
221
|
/**
|
|
211
222
|
* - The error's reason.
|
|
@@ -6,6 +6,7 @@ export interface IBridgeProtocol {
|
|
|
6
6
|
* @param {BridgeOptions} options - The bridge's options.
|
|
7
7
|
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
8
8
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
|
|
9
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
9
10
|
* @throws {ValueError} If the bridge options are not valid.
|
|
10
11
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
11
12
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -70,6 +71,7 @@ export default abstract class BridgeProtocol implements IBridgeProtocol {
|
|
|
70
71
|
* @param {BridgeOptions} options - The bridge's options.
|
|
71
72
|
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
72
73
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
|
|
74
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
73
75
|
* @throws {ValueError} If the bridge options are not valid.
|
|
74
76
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
75
77
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -95,6 +97,7 @@ export default abstract class BridgeProtocol implements IBridgeProtocol {
|
|
|
95
97
|
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
96
98
|
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
97
99
|
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
100
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
98
101
|
export type BridgeError = import("./errors.js").BridgeError;
|
|
99
102
|
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
100
103
|
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
@@ -354,6 +354,7 @@ export type SdaErrorOptions = {
|
|
|
354
354
|
*/
|
|
355
355
|
reason: SdaErrorReason;
|
|
356
356
|
};
|
|
357
|
+
import { DisposalError } from '../errors.js';
|
|
357
358
|
import { InvalidTokenError } from '../errors.js';
|
|
358
359
|
import { MaximumFeeExceededError } from '../errors.js';
|
|
359
360
|
import { NoSuchElementError } from '../errors.js';
|
|
@@ -363,4 +364,4 @@ import { ProviderRequiredError } from '../errors.js';
|
|
|
363
364
|
import { UnsupportedOperationError } from '../errors.js';
|
|
364
365
|
import { ValueError } from '../errors.js';
|
|
365
366
|
import { WdkError } from '../errors.js';
|
|
366
|
-
export { InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, UnsupportedOperationError, ValueError, WdkError };
|
|
367
|
+
export { DisposalError, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, UnsupportedOperationError, ValueError, WdkError };
|
|
@@ -18,6 +18,7 @@ export interface IFiatProtocol {
|
|
|
18
18
|
* @param {BuyOptions} options - The options for the buy operation.
|
|
19
19
|
* @returns {Promise<BuyResult>} The operation's result.
|
|
20
20
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
|
|
21
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
21
22
|
* @throws {ValueError} If the buy options are not valid.
|
|
22
23
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
23
24
|
* @throws {ProviderError} If the provider fails to perform the purchase.
|
|
@@ -43,6 +44,7 @@ export interface IFiatProtocol {
|
|
|
43
44
|
* @param {SellOptions} options - The options for the sell operation.
|
|
44
45
|
* @returns {Promise<SellResult>} The operation's result.
|
|
45
46
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
|
|
47
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
46
48
|
* @throws {ValueError} If the buy options are not valid.
|
|
47
49
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
48
50
|
* @throws {ProviderError} If the provider fails to perform the sale.
|
|
@@ -139,6 +141,7 @@ export default abstract class FiatProtocol implements IFiatProtocol {
|
|
|
139
141
|
* @param {BuyOptions} options - The options for the buy operation.
|
|
140
142
|
* @returns {Promise<BuyResult>} The URL for the user to complete the purchase.
|
|
141
143
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a purchase.
|
|
144
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
142
145
|
* @throws {ValueError} If the buy options are not valid.
|
|
143
146
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
144
147
|
* @throws {ProviderError} If the provider fails to perform the purchase.
|
|
@@ -166,6 +169,7 @@ export default abstract class FiatProtocol implements IFiatProtocol {
|
|
|
166
169
|
* @param {SellOptions} options - The options for the sell operation.
|
|
167
170
|
* @returns {Promise<SellResult>} The URL for the user to complete the sale.
|
|
168
171
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a sale.
|
|
172
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
169
173
|
* @throws {ValueError} If the buy options are not valid.
|
|
170
174
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
171
175
|
* @throws {ProviderError} If the provider fails to perform the sale.
|
|
@@ -216,6 +220,7 @@ export default abstract class FiatProtocol implements IFiatProtocol {
|
|
|
216
220
|
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
217
221
|
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
218
222
|
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
223
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
219
224
|
export type BuyError = import("./errors.js").BuyError;
|
|
220
225
|
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
221
226
|
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
|
@@ -78,4 +78,4 @@ export { default as LendingProtocol, ILendingProtocol } from "./lending-protocol
|
|
|
78
78
|
export { default as FiatProtocol, IFiatProtocol } from "./fiat-protocol.js";
|
|
79
79
|
export { default as SwidgeProtocol, ISwidgeProtocol } from "./swidge-protocol.js";
|
|
80
80
|
export { default as SdaProtocol, ISdaProtocol } from "./sda-protocol.js";
|
|
81
|
-
export { AccountRequiredError, BorrowError, BorrowErrorReason, BridgeError, BridgeErrorReason, BuyError, BuyErrorReason, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, ReadOnlyAccountRequiredError, RepayError, RepayErrorReason, SdaError, SdaErrorReason, SellError, SellErrorReason, SupplyError, SupplyErrorReason, SwapError, SwapErrorReason, SwidgeError, SwidgeErrorReason, UnsupportedOperationError, ValueError, WdkError, WithdrawError, WithdrawErrorReason } from "./errors.js";
|
|
81
|
+
export { AccountRequiredError, BorrowError, BorrowErrorReason, BridgeError, BridgeErrorReason, BuyError, BuyErrorReason, DisposalError, InvalidTokenError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, ReadOnlyAccountRequiredError, RepayError, RepayErrorReason, SdaError, SdaErrorReason, SellError, SellErrorReason, SupplyError, SupplyErrorReason, SwapError, SwapErrorReason, SwidgeError, SwidgeErrorReason, UnsupportedOperationError, ValueError, WdkError, WithdrawError, WithdrawErrorReason } from "./errors.js";
|
|
@@ -6,6 +6,7 @@ export interface ILendingProtocol {
|
|
|
6
6
|
* @param {SupplyOptions} options - The supply's options.
|
|
7
7
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
8
8
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
9
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
9
10
|
* @throws {ValueError} If the supply options are not valid.
|
|
10
11
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
11
12
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -33,6 +34,7 @@ export interface ILendingProtocol {
|
|
|
33
34
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
34
35
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
35
36
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
37
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
36
38
|
* @throws {ValueError} If the withdraw options are not valid.
|
|
37
39
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
38
40
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -60,6 +62,7 @@ export interface ILendingProtocol {
|
|
|
60
62
|
* @param {BorrowOptions} options - The borrow's options.
|
|
61
63
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
62
64
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
65
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
63
66
|
* @throws {ValueError} If the borrow options are not valid.
|
|
64
67
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
65
68
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -87,6 +90,7 @@ export interface ILendingProtocol {
|
|
|
87
90
|
* @param {RepayOptions} options - The repay's options.
|
|
88
91
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
89
92
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
93
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
90
94
|
* @throws {ValueError} If the repay options are not valid.
|
|
91
95
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
92
96
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -142,6 +146,7 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
142
146
|
* @param {SupplyOptions} options - The supply's options.
|
|
143
147
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
144
148
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
149
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
145
150
|
* @throws {ValueError} If the supply options are not valid.
|
|
146
151
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
147
152
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -170,6 +175,7 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
170
175
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
171
176
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
172
177
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
178
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
173
179
|
* @throws {ValueError} If the withdraw options are not valid.
|
|
174
180
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
175
181
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -198,6 +204,7 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
198
204
|
* @param {BorrowOptions} options - The borrow's options.
|
|
199
205
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
200
206
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
207
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
201
208
|
* @throws {ValueError} If the borrow options are not valid.
|
|
202
209
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
203
210
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -226,6 +233,7 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
226
233
|
* @param {RepayOptions} options - The borrow's options.
|
|
227
234
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
228
235
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
236
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
229
237
|
* @throws {ValueError} If the repay options are not valid.
|
|
230
238
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
231
239
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -251,6 +259,7 @@ export default abstract class LendingProtocol implements ILendingProtocol {
|
|
|
251
259
|
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
252
260
|
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
253
261
|
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
262
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
254
263
|
export type BorrowError = import("./errors.js").BorrowError;
|
|
255
264
|
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
256
265
|
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
@@ -44,6 +44,7 @@ export interface ISdaProtocol {
|
|
|
44
44
|
* @param {SdaCreateDepositAddressOptions} options - The address creation options.
|
|
45
45
|
* @returns {Promise<SdaDepositAddress[]>} The created deposit addresses, one per distinct address.
|
|
46
46
|
* @throws {AccountRequiredError} If the protocol requires a full account to create a new deposit address.
|
|
47
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
47
48
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
48
49
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
49
50
|
* @throws {ProviderError} If the provider fails to create a new deposit address.
|
|
@@ -60,6 +61,7 @@ export interface ISdaProtocol {
|
|
|
60
61
|
* @returns {Promise<string>} The derived deposit address.
|
|
61
62
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
62
63
|
* @throws {AccountRequiredError} If the protocol requires a full account to derive a deposit address.
|
|
64
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
63
65
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
64
66
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
65
67
|
* @throws {ProviderError} If the provider fails to derive the deposit address.
|
|
@@ -87,6 +89,7 @@ export interface ISdaProtocol {
|
|
|
87
89
|
* @returns {Promise<SdaDepositAddress>} The refreshed deposit address descriptor (with the new `expiry`).
|
|
88
90
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
89
91
|
* @throws {AccountRequiredError} If the protocol requires a full account to renew a deposit address.
|
|
92
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
90
93
|
* @throws {ValueError} If the id is not valid.
|
|
91
94
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
92
95
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -138,6 +141,7 @@ export interface ISdaProtocol {
|
|
|
138
141
|
* @returns {Promise<SdaRecoveryResult>} The recovery outcome.
|
|
139
142
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
140
143
|
* @throws {AccountRequiredError} If the protocol requires a full account to recover a deposit address.
|
|
144
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
141
145
|
* @throws {ValueError} If the id is not valid.
|
|
142
146
|
* @throws {NoSuchElementError} If no deposit address exists for the given id or address.
|
|
143
147
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -153,6 +157,7 @@ export interface ISdaProtocol {
|
|
|
153
157
|
* @returns {Promise<void>} Resolves once the address has been disabled.
|
|
154
158
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
155
159
|
* @throws {AccountRequiredError} If the protocol requires a full account to disable a deposit address.
|
|
160
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
156
161
|
* @throws {ValueError} If the id is not valid.
|
|
157
162
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
158
163
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -234,6 +239,7 @@ export default abstract class SdaProtocol implements ISdaProtocol {
|
|
|
234
239
|
* @param {SdaCreateDepositAddressOptions} options - The address creation options.
|
|
235
240
|
* @returns {Promise<SdaDepositAddress[]>} The created deposit addresses, one per distinct address.
|
|
236
241
|
* @throws {AccountRequiredError} If the protocol requires a full account to create a new deposit address.
|
|
242
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
237
243
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
238
244
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
239
245
|
* @throws {ProviderError} If the provider fails to create a new deposit address.
|
|
@@ -250,6 +256,7 @@ export default abstract class SdaProtocol implements ISdaProtocol {
|
|
|
250
256
|
* @returns {Promise<string>} The derived deposit address.
|
|
251
257
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
252
258
|
* @throws {AccountRequiredError} If the protocol requires a full account to derive a deposit address.
|
|
259
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
253
260
|
* @throws {ValueError} If the create deposit address options are not valid.
|
|
254
261
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
255
262
|
* @throws {ProviderError} If the provider fails to derive the deposit address.
|
|
@@ -277,6 +284,7 @@ export default abstract class SdaProtocol implements ISdaProtocol {
|
|
|
277
284
|
* @returns {Promise<SdaDepositAddress>} The refreshed deposit address descriptor (with the new `expiry`).
|
|
278
285
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
279
286
|
* @throws {AccountRequiredError} If the protocol requires a full account to renew a deposit address.
|
|
287
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
280
288
|
* @throws {ValueError} If the id is not valid.
|
|
281
289
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
282
290
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -328,6 +336,7 @@ export default abstract class SdaProtocol implements ISdaProtocol {
|
|
|
328
336
|
* @returns {Promise<SdaRecoveryResult>} The recovery outcome.
|
|
329
337
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
330
338
|
* @throws {AccountRequiredError} If the protocol requires a full account to recover a deposit address.
|
|
339
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
331
340
|
* @throws {ValueError} If the id is not valid.
|
|
332
341
|
* @throws {NoSuchElementError} If no deposit address exists for the given id or address.
|
|
333
342
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -343,6 +352,7 @@ export default abstract class SdaProtocol implements ISdaProtocol {
|
|
|
343
352
|
* @returns {Promise<void>} Resolves once the address has been disabled.
|
|
344
353
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
345
354
|
* @throws {AccountRequiredError} If the protocol requires a full account to disable a deposit address.
|
|
355
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
346
356
|
* @throws {ValueError} If the id is not valid.
|
|
347
357
|
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
348
358
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -354,6 +364,7 @@ export default abstract class SdaProtocol implements ISdaProtocol {
|
|
|
354
364
|
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
355
365
|
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
356
366
|
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
367
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
357
368
|
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
358
369
|
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
|
359
370
|
export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
|
|
@@ -6,6 +6,7 @@ export interface ISwapProtocol {
|
|
|
6
6
|
* @param {SwapOptions} options - The swap's options.
|
|
7
7
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
8
8
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
9
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
9
10
|
* @throws {ValueError} If the swap options are not valid.
|
|
10
11
|
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
11
12
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -70,6 +71,7 @@ export default abstract class SwapProtocol implements ISwapProtocol {
|
|
|
70
71
|
* @param {SwapOptions} options - The swap's options.
|
|
71
72
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
72
73
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
74
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
73
75
|
* @throws {ValueError} If the swap options are not valid.
|
|
74
76
|
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
75
77
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -95,6 +97,7 @@ export default abstract class SwapProtocol implements ISwapProtocol {
|
|
|
95
97
|
export type IWalletAccountReadOnly = import("../wallet-account-read-only.js").IWalletAccountReadOnly;
|
|
96
98
|
export type IWalletAccount = import("../wallet-account.js").IWalletAccount;
|
|
97
99
|
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
100
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
98
101
|
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
99
102
|
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
100
103
|
export type ReadOnlyAccountRequiredError = import("./errors.js").ReadOnlyAccountRequiredError;
|
|
@@ -22,6 +22,7 @@ export interface ISwidgeProtocol extends ISwapProtocol, IBridgeProtocol {
|
|
|
22
22
|
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
23
23
|
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
24
24
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
|
|
25
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
25
26
|
* @throws {ValueError} If the swidge options are not valid.
|
|
26
27
|
* @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
|
|
27
28
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -106,6 +107,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
|
|
|
106
107
|
* @param {SwapOptions} options - The swap's options.
|
|
107
108
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
108
109
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
110
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
109
111
|
* @throws {ValueError} If the swap options are not valid.
|
|
110
112
|
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
111
113
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -133,6 +135,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
|
|
|
133
135
|
* @param {BridgeOptions} options - The bridge's options.
|
|
134
136
|
* @returns {Promise<BridgeResult>} The bridge's result.
|
|
135
137
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
|
|
138
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
136
139
|
* @throws {ValueError} If the bridge options are not valid.
|
|
137
140
|
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
138
141
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -178,6 +181,7 @@ export default abstract class SwidgeProtocol implements ISwidgeProtocol, ISwapPr
|
|
|
178
181
|
* @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
|
|
179
182
|
* @returns {Promise<SwidgeResult>} The swidge execution result.
|
|
180
183
|
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
|
|
184
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
181
185
|
* @throws {ValueError} If the swidge options are not valid.
|
|
182
186
|
* @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
|
|
183
187
|
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
@@ -228,6 +232,7 @@ export type IBridgeProtocol = import("./bridge-protocol.js").IBridgeProtocol;
|
|
|
228
232
|
export type BridgeOptions = import("./bridge-protocol.js").BridgeOptions;
|
|
229
233
|
export type BridgeResult = import("./bridge-protocol.js").BridgeResult;
|
|
230
234
|
export type AccountRequiredError = import("./errors.js").AccountRequiredError;
|
|
235
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
231
236
|
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
232
237
|
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
233
238
|
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
package/types/src/signer.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export class ISigner extends IDisposable {
|
|
|
31
31
|
* @returns {Promise<ISigner>} The derived signer.
|
|
32
32
|
* @throws {UnsupportedOperationError} If the signer does not support account derivation.
|
|
33
33
|
* @throws {ValueError} If the path is not valid.
|
|
34
|
+
* @throws {DisposalError} If the signer has been disposed.
|
|
34
35
|
*/
|
|
35
36
|
derive(path: string): Promise<ISigner>;
|
|
36
37
|
/**
|
|
@@ -44,10 +45,12 @@ export class ISigner extends IDisposable {
|
|
|
44
45
|
*
|
|
45
46
|
* @param {string} message - The message to sign.
|
|
46
47
|
* @returns {Promise<string>} The message's signature.
|
|
48
|
+
* @throws {DisposalError} If the signer has been disposed.
|
|
47
49
|
*/
|
|
48
50
|
sign(message: string): Promise<string>;
|
|
49
51
|
}
|
|
50
52
|
export type KeyPair = import("./wallet-account.js").KeyPair;
|
|
53
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
51
54
|
import { IDisposable } from "./disposable.js";
|
|
52
55
|
export type UnsupportedOperationError = import("./errors.js").UnsupportedOperationError;
|
|
53
56
|
export type ValueError = import("./errors.js").ValueError;
|
|
@@ -24,6 +24,7 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
24
24
|
*
|
|
25
25
|
* @param {string} message - The message to sign.
|
|
26
26
|
* @returns {Promise<string>} The message's signature.
|
|
27
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
27
28
|
*/
|
|
28
29
|
sign(message: string): Promise<string>;
|
|
29
30
|
/**
|
|
@@ -32,6 +33,7 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
32
33
|
* @param {Transaction} tx - The transaction to sign.
|
|
33
34
|
* @returns {Promise<TSignedTransaction>} The signed transaction.
|
|
34
35
|
* @throws {ValueError} If the transaction is not valid.
|
|
36
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
35
37
|
*/
|
|
36
38
|
signTransaction(tx: Transaction): Promise<TSignedTransaction>;
|
|
37
39
|
/**
|
|
@@ -52,6 +54,7 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
52
54
|
* @throws {ProviderError} If the provider fails to perform the transaction.
|
|
53
55
|
* @throws {TransactionError} If the transaction fails with an error.
|
|
54
56
|
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the transaction max. fee option.
|
|
57
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
55
58
|
*/
|
|
56
59
|
sendTransaction(tx: Transaction | TSignedTransaction): Promise<TransactionResult>;
|
|
57
60
|
/**
|
|
@@ -76,6 +79,7 @@ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAcc
|
|
|
76
79
|
* @throws {ProviderError} If the provider fails to perform the transfer.
|
|
77
80
|
* @throws {TransferError} If the transfer fails with an error.
|
|
78
81
|
* @throws {MaximumFeeExceededError} If the the costs of the transfer exceeds the transfer max. fee option.
|
|
82
|
+
* @throws {DisposalError} If the account has been disposed.
|
|
79
83
|
*/
|
|
80
84
|
transfer(options: TransferOptions): Promise<TransferResult>;
|
|
81
85
|
/**
|
|
@@ -89,6 +93,7 @@ export type Transaction = import("./wallet-account-read-only.js").Transaction;
|
|
|
89
93
|
export type TransactionResult = import("./wallet-account-read-only.js").TransactionResult;
|
|
90
94
|
export type TransferOptions = import("./wallet-account-read-only.js").TransferOptions;
|
|
91
95
|
export type TransferResult = import("./wallet-account-read-only.js").TransferResult;
|
|
96
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
92
97
|
export type InvalidTokenError = import("./errors.js").InvalidTokenError;
|
|
93
98
|
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
94
99
|
export type ProviderError = import("./errors.js").ProviderError;
|
|
@@ -68,6 +68,14 @@ export default abstract class WalletManager<TSigner extends ISigner = ISigner> i
|
|
|
68
68
|
* @type {WalletConfig}
|
|
69
69
|
*/
|
|
70
70
|
protected _config: WalletConfig;
|
|
71
|
+
/** @private */
|
|
72
|
+
private _disposed;
|
|
73
|
+
/**
|
|
74
|
+
* True if the wallet manager has been disposed.
|
|
75
|
+
*
|
|
76
|
+
* @type {boolean}
|
|
77
|
+
*/
|
|
78
|
+
get disposed(): boolean;
|
|
71
79
|
/**
|
|
72
80
|
* The seed of the wallet.
|
|
73
81
|
*
|
|
@@ -81,6 +89,7 @@ export default abstract class WalletManager<TSigner extends ISigner = ISigner> i
|
|
|
81
89
|
* @param {TSigner} signer - The signer.
|
|
82
90
|
* @returns {this} The wallet manager.
|
|
83
91
|
* @throws {ValueError} If the signer name is an empty or blank string.
|
|
92
|
+
* @throws {DisposalError} If the wallet manager has been disposed.
|
|
84
93
|
*/
|
|
85
94
|
addSigner(signerName: string, signer: TSigner): this;
|
|
86
95
|
/**
|
|
@@ -110,6 +119,7 @@ export default abstract class WalletManager<TSigner extends ISigner = ISigner> i
|
|
|
110
119
|
* @throws {ValueError} If the index is not valid.
|
|
111
120
|
* @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
|
|
112
121
|
* @throws {InvalidSignerError} If the signer doesn't support account derivation.
|
|
122
|
+
* @throws {DisposalError} If the wallet manager or the given signer has been disposed.
|
|
113
123
|
*/
|
|
114
124
|
abstract getAccount(index?: number, options?: {
|
|
115
125
|
signerName?: string;
|
|
@@ -124,6 +134,7 @@ export default abstract class WalletManager<TSigner extends ISigner = ISigner> i
|
|
|
124
134
|
* @param {string} signerName - The signer name registered via {@link addSigner}.
|
|
125
135
|
* @returns {Promise<IWalletAccount>} The account.
|
|
126
136
|
* @throws {NoSuchElementError} If no signer exists with the given name.
|
|
137
|
+
* @throws {DisposalError} If the wallet manager or the given signer has been disposed.
|
|
127
138
|
*/
|
|
128
139
|
abstract getAccount(signerName: string): Promise<IWalletAccount>;
|
|
129
140
|
/**
|
|
@@ -137,6 +148,7 @@ export default abstract class WalletManager<TSigner extends ISigner = ISigner> i
|
|
|
137
148
|
* @throws {ValueError} If the path is not valid.
|
|
138
149
|
* @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
|
|
139
150
|
* @throws {InvalidSignerError} If the signer doesn't support account derivation.
|
|
151
|
+
* @throws {DisposalError} If the wallet manager or the given signer has been disposed.
|
|
140
152
|
*/
|
|
141
153
|
abstract getAccountByPath(path: string, options?: {
|
|
142
154
|
signerName?: string;
|
|
@@ -157,6 +169,7 @@ export default abstract class WalletManager<TSigner extends ISigner = ISigner> i
|
|
|
157
169
|
}
|
|
158
170
|
export type IWalletAccount = import("./wallet-account.js").IWalletAccount;
|
|
159
171
|
export type ISigner = import("./signer.js").ISigner;
|
|
172
|
+
export type DisposalError = import("./errors.js").DisposalError;
|
|
160
173
|
export type InvalidSignerError = import("./errors.js").InvalidSignerError;
|
|
161
174
|
export type ProviderError = import("./errors.js").ProviderError;
|
|
162
175
|
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|