@tetherto/wdk-wallet 1.0.0-beta.15 → 1.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +11 -12
- package/package.json +5 -1
- package/src/errors.js +280 -19
- package/src/multisig/errors.js +54 -0
- package/src/multisig/index.js +42 -0
- package/src/multisig/multisig-message-signing-read-only.js +63 -0
- package/src/multisig/multisig-message-signing.js +64 -0
- package/src/multisig/multisig-owner-management.js +94 -0
- package/src/multisig/wallet-account-multisig.js +144 -0
- package/src/multisig/wallet-account-read-only-multisig.js +98 -0
- package/src/protocols/bridge-protocol.js +35 -1
- package/src/protocols/errors.js +510 -0
- package/src/protocols/fiat-protocol.js +104 -4
- package/src/protocols/index.js +13 -0
- package/src/protocols/lending-protocol.js +114 -2
- package/src/protocols/sda-protocol.js +103 -16
- package/src/protocols/swap-protocol.js +35 -1
- package/src/protocols/swidge-protocol.js +166 -55
- package/src/signer.js +8 -4
- package/src/wallet-account-read-only-simple.js +162 -0
- package/src/wallet-account-read-only.js +176 -55
- package/src/wallet-account.js +25 -1
- package/src/wallet-manager.js +38 -22
- package/types/index.d.ts +9 -2
- package/types/src/errors.d.ts +198 -14
- package/types/src/multisig/errors.d.ts +33 -0
- package/types/src/multisig/index.d.ts +15 -0
- package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
- package/types/src/multisig/multisig-message-signing.d.ts +40 -0
- package/types/src/multisig/multisig-owner-management.d.ts +65 -0
- package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
- package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
- package/types/src/protocols/bridge-protocol.d.ts +39 -3
- package/types/src/protocols/errors.d.ts +366 -0
- package/types/src/protocols/fiat-protocol.d.ts +103 -9
- package/types/src/protocols/index.d.ts +11 -0
- package/types/src/protocols/lending-protocol.d.ts +118 -4
- package/types/src/protocols/sda-protocol.d.ts +120 -23
- package/types/src/protocols/swap-protocol.d.ts +40 -4
- package/types/src/protocols/swidge-protocol.d.ts +106 -38
- package/types/src/signer.d.ts +6 -4
- package/types/src/wallet-account-read-only-simple.d.ts +144 -0
- package/types/src/wallet-account-read-only.d.ts +97 -39
- package/types/src/wallet-account.d.ts +27 -3
- package/types/src/wallet-manager.d.ts +37 -35
|
@@ -13,15 +13,20 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
import { NotImplementedError, UnsupportedOperationError } from '
|
|
16
|
+
import { NotImplementedError, UnsupportedOperationError } from './errors.js'
|
|
17
17
|
|
|
18
18
|
/** @typedef {import('../wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
|
|
19
19
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
|
-
/** @typedef {import('
|
|
23
|
-
|
|
24
|
-
/** @typedef {import('
|
|
22
|
+
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
24
|
+
/** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
|
|
25
|
+
/** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
|
|
26
|
+
/** @typedef {import('./errors.js').ProviderError} ProviderError */
|
|
27
|
+
/** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
|
|
28
|
+
/** @typedef {import('./errors.js').SdaError} SdaError */
|
|
29
|
+
/** @typedef {import('./errors.js').ValueError} ValueError */
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* A blockchain identifier: a numeric chain id (e.g. `1`) or a protocol-specific chain name (e.g. `'ethereum'`).
|
|
@@ -236,6 +241,8 @@ export class ISdaProtocol {
|
|
|
236
241
|
* @returns {Promise<SdaRoute[]>} The supported routes.
|
|
237
242
|
* @throws {ValueError} If the protocol discovers routes by blockchain pairs and the source or destination blockchain
|
|
238
243
|
* is not set.
|
|
244
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
245
|
+
* @throws {ProviderError} If the provider fails to fetch the available routes.
|
|
239
246
|
*/
|
|
240
247
|
async getSupportedRoutes (options) {
|
|
241
248
|
throw new NotImplementedError('getSupportedRoutes(options)')
|
|
@@ -247,7 +254,11 @@ export class ISdaProtocol {
|
|
|
247
254
|
* @param {SdaDepositOptions} options - The quote options.
|
|
248
255
|
* @returns {Promise<SdaDepositQuote>} The quoted deposit details.
|
|
249
256
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
250
|
-
* @throws {
|
|
257
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a deposit.
|
|
258
|
+
* @throws {ValueError} If the deposit options are not valid.
|
|
259
|
+
* @throws {InvalidTokenError} If the input token is not a valid ERC 20 token's address.
|
|
260
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
261
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the deposit.
|
|
251
262
|
*/
|
|
252
263
|
async quoteDeposit (options) {
|
|
253
264
|
throw new NotImplementedError('quoteDeposit(options)')
|
|
@@ -261,8 +272,11 @@ export class ISdaProtocol {
|
|
|
261
272
|
*
|
|
262
273
|
* @param {SdaCreateDepositAddressOptions} options - The address creation options.
|
|
263
274
|
* @returns {Promise<SdaDepositAddress[]>} The created deposit addresses, one per distinct address.
|
|
264
|
-
* @throws {
|
|
265
|
-
* @throws {ValueError} If the
|
|
275
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to create a new deposit address.
|
|
276
|
+
* @throws {ValueError} If the create deposit address options are not valid.
|
|
277
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
278
|
+
* @throws {ProviderError} If the provider fails to create a new deposit address.
|
|
279
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
266
280
|
*/
|
|
267
281
|
async createDepositAddress (options) {
|
|
268
282
|
throw new NotImplementedError('createDepositAddress(options)')
|
|
@@ -277,7 +291,11 @@ export class ISdaProtocol {
|
|
|
277
291
|
* options type (which extends `SdaCreateDepositAddressOptions`).
|
|
278
292
|
* @returns {Promise<string>} The derived deposit address.
|
|
279
293
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
280
|
-
* @throws {
|
|
294
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to derive a deposit address.
|
|
295
|
+
* @throws {ValueError} If the create deposit address options are not valid.
|
|
296
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
297
|
+
* @throws {ProviderError} If the provider fails to derive the deposit address.
|
|
298
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
281
299
|
*/
|
|
282
300
|
async deriveDepositAddress (options) {
|
|
283
301
|
throw new NotImplementedError('deriveDepositAddress(options)')
|
|
@@ -291,7 +309,10 @@ export class ISdaProtocol {
|
|
|
291
309
|
* context the protocol needs).
|
|
292
310
|
* @returns {Promise<SdaDepositAddress>} The deposit address descriptor.
|
|
293
311
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
294
|
-
* @throws {
|
|
312
|
+
* @throws {ValueError} If the id is not valid.
|
|
313
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
314
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
315
|
+
* @throws {ProviderError} If the provider fails to fetch the deposit's address.
|
|
295
316
|
*/
|
|
296
317
|
async getDepositAddress (id) {
|
|
297
318
|
throw new NotImplementedError('getDepositAddress(id)')
|
|
@@ -303,6 +324,12 @@ export class ISdaProtocol {
|
|
|
303
324
|
* @param {string} id - The deposit-address identifier returned in `SdaDepositAddress.id`.
|
|
304
325
|
* @returns {Promise<SdaDepositAddress>} The refreshed deposit address descriptor (with the new `expiry`).
|
|
305
326
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
327
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to renew a deposit address.
|
|
328
|
+
* @throws {ValueError} If the id is not valid.
|
|
329
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
330
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
331
|
+
* @throws {ProviderError} If the provider fails to renew the deposit address.
|
|
332
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
306
333
|
*/
|
|
307
334
|
async renewDepositAddress (id) {
|
|
308
335
|
throw new NotImplementedError('renewDepositAddress(id)')
|
|
@@ -316,6 +343,8 @@ export class ISdaProtocol {
|
|
|
316
343
|
* addresses by (address, chain).
|
|
317
344
|
* @returns {Promise<SdaTransfer[]>} The transfers for the address.
|
|
318
345
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
346
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
347
|
+
* @throws {ProviderError} If the provider fails to fetch transfers.
|
|
319
348
|
*/
|
|
320
349
|
async getTransfers (address, options) {
|
|
321
350
|
throw new NotImplementedError('getTransfers(address, options)')
|
|
@@ -330,6 +359,8 @@ export class ISdaProtocol {
|
|
|
330
359
|
* @param {SdaTransfersOptions} [options] - Optional pagination/filtering.
|
|
331
360
|
* @returns {Promise<SdaTransfer[]>} The transfers routed to the recipient.
|
|
332
361
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
362
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
363
|
+
* @throws {ProviderError} If the provider fails to fetch transfers.
|
|
333
364
|
*/
|
|
334
365
|
async getTransfersByRecipient (destinationChain, recipient, options) {
|
|
335
366
|
throw new NotImplementedError('getTransfersByRecipient(destinationChain, recipient, options)')
|
|
@@ -341,7 +372,10 @@ export class ISdaProtocol {
|
|
|
341
372
|
* @param {string} id - The transfer identifier.
|
|
342
373
|
* @returns {Promise<SdaTransfer>} The transfer's current status.
|
|
343
374
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
344
|
-
* @throws {
|
|
375
|
+
* @throws {ValueError} If the id is not valid.
|
|
376
|
+
* @throws {NoSuchElementError} If no transfer exists for the given id.
|
|
377
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
378
|
+
* @throws {ProviderError} If the provider fails to fetch the transfer.
|
|
345
379
|
*/
|
|
346
380
|
async getTransfer (id) {
|
|
347
381
|
throw new NotImplementedError('getTransfer(id)')
|
|
@@ -353,6 +387,12 @@ export class ISdaProtocol {
|
|
|
353
387
|
* @param {SdaRecoveryOptions} options - The recovery options.
|
|
354
388
|
* @returns {Promise<SdaRecoveryResult>} The recovery outcome.
|
|
355
389
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
390
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to recover a deposit address.
|
|
391
|
+
* @throws {ValueError} If the id is not valid.
|
|
392
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id or address.
|
|
393
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
394
|
+
* @throws {ProviderError} If the provider fails to recover the deposit address.
|
|
395
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
356
396
|
*/
|
|
357
397
|
async recoverDepositAddress (options) {
|
|
358
398
|
throw new NotImplementedError('recoverDepositAddress(options)')
|
|
@@ -365,6 +405,12 @@ export class ISdaProtocol {
|
|
|
365
405
|
* context the protocol needs).
|
|
366
406
|
* @returns {Promise<void>} Resolves once the address has been disabled.
|
|
367
407
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
408
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to disable a deposit address.
|
|
409
|
+
* @throws {ValueError} If the id is not valid.
|
|
410
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
411
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
412
|
+
* @throws {ProviderError} If the provider fails to disable the deposit address.
|
|
413
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
368
414
|
*/
|
|
369
415
|
async disableDepositAddress (id) {
|
|
370
416
|
throw new NotImplementedError('disableDepositAddress(id)')
|
|
@@ -419,6 +465,8 @@ export default class SdaProtocol {
|
|
|
419
465
|
* @returns {Promise<SdaRoute[]>} The supported routes.
|
|
420
466
|
* @throws {ValueError} If the protocol discovers routes by blockchain pairs and the source or destination blockchain
|
|
421
467
|
* is not set.
|
|
468
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
469
|
+
* @throws {ProviderError} If the provider fails to fetch the available routes.
|
|
422
470
|
*/
|
|
423
471
|
async getSupportedRoutes (options) {
|
|
424
472
|
throw new NotImplementedError('getSupportedRoutes(options)')
|
|
@@ -430,7 +478,11 @@ export default class SdaProtocol {
|
|
|
430
478
|
* @param {SdaDepositOptions} options - The quote options.
|
|
431
479
|
* @returns {Promise<SdaDepositQuote>} The quoted deposit details.
|
|
432
480
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
433
|
-
* @throws {
|
|
481
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a deposit.
|
|
482
|
+
* @throws {ValueError} If the deposit options are not valid.
|
|
483
|
+
* @throws {InvalidTokenError} If the input token is not a valid ERC 20 token's address.
|
|
484
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
485
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the deposit.
|
|
434
486
|
*/
|
|
435
487
|
async quoteDeposit (options) {
|
|
436
488
|
throw new UnsupportedOperationError('quoteDeposit(options)')
|
|
@@ -445,8 +497,11 @@ export default class SdaProtocol {
|
|
|
445
497
|
* @abstract
|
|
446
498
|
* @param {SdaCreateDepositAddressOptions} options - The address creation options.
|
|
447
499
|
* @returns {Promise<SdaDepositAddress[]>} The created deposit addresses, one per distinct address.
|
|
448
|
-
* @throws {
|
|
449
|
-
* @throws {ValueError} If the
|
|
500
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to create a new deposit address.
|
|
501
|
+
* @throws {ValueError} If the create deposit address options are not valid.
|
|
502
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
503
|
+
* @throws {ProviderError} If the provider fails to create a new deposit address.
|
|
504
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
450
505
|
*/
|
|
451
506
|
async createDepositAddress (options) {
|
|
452
507
|
throw new NotImplementedError('createDepositAddress(options)')
|
|
@@ -461,7 +516,11 @@ export default class SdaProtocol {
|
|
|
461
516
|
* options type (which extends `SdaCreateDepositAddressOptions`).
|
|
462
517
|
* @returns {Promise<string>} The derived deposit address.
|
|
463
518
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
464
|
-
* @throws {
|
|
519
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to derive a deposit address.
|
|
520
|
+
* @throws {ValueError} If the create deposit address options are not valid.
|
|
521
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
522
|
+
* @throws {ProviderError} If the provider fails to derive the deposit address.
|
|
523
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
465
524
|
*/
|
|
466
525
|
async deriveDepositAddress (options) {
|
|
467
526
|
throw new UnsupportedOperationError('deriveDepositAddress(options)')
|
|
@@ -475,7 +534,10 @@ export default class SdaProtocol {
|
|
|
475
534
|
* context the protocol needs).
|
|
476
535
|
* @returns {Promise<SdaDepositAddress>} The deposit address descriptor.
|
|
477
536
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
478
|
-
* @throws {
|
|
537
|
+
* @throws {ValueError} If the id is not valid.
|
|
538
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
539
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
540
|
+
* @throws {ProviderError} If the provider fails to fetch the deposit's address.
|
|
479
541
|
*/
|
|
480
542
|
async getDepositAddress (id) {
|
|
481
543
|
throw new UnsupportedOperationError('getDepositAddress(id)')
|
|
@@ -487,6 +549,12 @@ export default class SdaProtocol {
|
|
|
487
549
|
* @param {string} id - The deposit-address identifier returned in `SdaDepositAddress.id`.
|
|
488
550
|
* @returns {Promise<SdaDepositAddress>} The refreshed deposit address descriptor (with the new `expiry`).
|
|
489
551
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
552
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to renew a deposit address.
|
|
553
|
+
* @throws {ValueError} If the id is not valid.
|
|
554
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
555
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
556
|
+
* @throws {ProviderError} If the provider fails to renew the deposit address.
|
|
557
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
490
558
|
*/
|
|
491
559
|
async renewDepositAddress (id) {
|
|
492
560
|
throw new UnsupportedOperationError('renewDepositAddress(id)')
|
|
@@ -500,6 +568,8 @@ export default class SdaProtocol {
|
|
|
500
568
|
* addresses by (address, chain).
|
|
501
569
|
* @returns {Promise<SdaTransfer[]>} The transfers for the address.
|
|
502
570
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
571
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
572
|
+
* @throws {ProviderError} If the provider fails to fetch transfers.
|
|
503
573
|
*/
|
|
504
574
|
async getTransfers (address, options) {
|
|
505
575
|
throw new UnsupportedOperationError('getTransfers(address, options)')
|
|
@@ -514,6 +584,8 @@ export default class SdaProtocol {
|
|
|
514
584
|
* @param {SdaTransfersOptions} [options] - Optional pagination/filtering.
|
|
515
585
|
* @returns {Promise<SdaTransfer[]>} The transfers routed to the recipient.
|
|
516
586
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
587
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
588
|
+
* @throws {ProviderError} If the provider fails to fetch transfers.
|
|
517
589
|
*/
|
|
518
590
|
async getTransfersByRecipient (destinationChain, recipient, options) {
|
|
519
591
|
throw new UnsupportedOperationError('getTransfersByRecipient(destinationChain, recipient, options)')
|
|
@@ -525,7 +597,10 @@ export default class SdaProtocol {
|
|
|
525
597
|
* @param {string} id - The transfer identifier.
|
|
526
598
|
* @returns {Promise<SdaTransfer>} The transfer's current status.
|
|
527
599
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
528
|
-
* @throws {
|
|
600
|
+
* @throws {ValueError} If the id is not valid.
|
|
601
|
+
* @throws {NoSuchElementError} If no transfer exists for the given id.
|
|
602
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
603
|
+
* @throws {ProviderError} If the provider fails to fetch the transfer.
|
|
529
604
|
*/
|
|
530
605
|
async getTransfer (id) {
|
|
531
606
|
throw new UnsupportedOperationError('getTransfer(id)')
|
|
@@ -537,6 +612,12 @@ export default class SdaProtocol {
|
|
|
537
612
|
* @param {SdaRecoveryOptions} options - The recovery options.
|
|
538
613
|
* @returns {Promise<SdaRecoveryResult>} The recovery outcome.
|
|
539
614
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
615
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to recover a deposit address.
|
|
616
|
+
* @throws {ValueError} If the id is not valid.
|
|
617
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id or address.
|
|
618
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
619
|
+
* @throws {ProviderError} If the provider fails to recover the deposit address.
|
|
620
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
540
621
|
*/
|
|
541
622
|
async recoverDepositAddress (options) {
|
|
542
623
|
throw new UnsupportedOperationError('recoverDepositAddress(options)')
|
|
@@ -549,6 +630,12 @@ export default class SdaProtocol {
|
|
|
549
630
|
* context the protocol needs).
|
|
550
631
|
* @returns {Promise<void>} Resolves once the address has been disabled.
|
|
551
632
|
* @throws {UnsupportedOperationError} If the protocol does not support this operation.
|
|
633
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to disable a deposit address.
|
|
634
|
+
* @throws {ValueError} If the id is not valid.
|
|
635
|
+
* @throws {NoSuchElementError} If no deposit address exists for the given id.
|
|
636
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
637
|
+
* @throws {ProviderError} If the provider fails to disable the deposit address.
|
|
638
|
+
* @throws {SdaError} If the operation fails with an error.
|
|
552
639
|
*/
|
|
553
640
|
async disableDepositAddress (id) {
|
|
554
641
|
throw new UnsupportedOperationError('disableDepositAddress(id)')
|
|
@@ -13,12 +13,21 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
import { NotImplementedError } from '
|
|
16
|
+
import { NotImplementedError } from './errors.js'
|
|
17
17
|
|
|
18
18
|
/** @typedef {import('../wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
|
|
19
19
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
|
+
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
24
|
+
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
25
|
+
/** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
|
|
26
|
+
/** @typedef {import('./errors.js').ProviderError} ProviderError */
|
|
27
|
+
/** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
|
|
28
|
+
/** @typedef {import('./errors.js').SwapError} SwapError */
|
|
29
|
+
/** @typedef {import('./errors.js').ValueError} ValueError */
|
|
30
|
+
|
|
22
31
|
/**
|
|
23
32
|
* @typedef {Object} SwapProtocolConfig
|
|
24
33
|
* @property {number | bigint} [swapMaxFee] - The maximum fee amount for swap operations.
|
|
@@ -63,6 +72,13 @@ export class ISwapProtocol {
|
|
|
63
72
|
*
|
|
64
73
|
* @param {SwapOptions} options - The swap's options.
|
|
65
74
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
75
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
76
|
+
* @throws {ValueError} If the swap options are not valid.
|
|
77
|
+
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
78
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
79
|
+
* @throws {ProviderError} If the provider fails to perform the swap.
|
|
80
|
+
* @throws {SwapError} If the swap fails with an error.
|
|
81
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the swap max. fee option.
|
|
66
82
|
*/
|
|
67
83
|
async swap (options) {
|
|
68
84
|
throw new NotImplementedError('swap(options)')
|
|
@@ -73,6 +89,12 @@ export class ISwapProtocol {
|
|
|
73
89
|
*
|
|
74
90
|
* @param {SwapOptions} options - The swap's options.
|
|
75
91
|
* @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
|
|
92
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
|
|
93
|
+
* @throws {ValueError} If the swap options are not valid.
|
|
94
|
+
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
95
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
96
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the swap.
|
|
97
|
+
* @throws {SwapError} If the swap fails with an error.
|
|
76
98
|
*/
|
|
77
99
|
async quoteSwap (options) {
|
|
78
100
|
throw new NotImplementedError('quoteSwap(options)')
|
|
@@ -123,6 +145,13 @@ export default class SwapProtocol {
|
|
|
123
145
|
* @abstract
|
|
124
146
|
* @param {SwapOptions} options - The swap's options.
|
|
125
147
|
* @returns {Promise<SwapResult>} The swap's result.
|
|
148
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
|
|
149
|
+
* @throws {ValueError} If the swap options are not valid.
|
|
150
|
+
* @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
|
|
151
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
152
|
+
* @throws {ProviderError} If the provider fails to perform the swap.
|
|
153
|
+
* @throws {SwapError} If the swap fails with an error.
|
|
154
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the swap max. fee option.
|
|
126
155
|
*/
|
|
127
156
|
async swap (options) {
|
|
128
157
|
throw new NotImplementedError('swap(options)')
|
|
@@ -134,6 +163,11 @@ export default class SwapProtocol {
|
|
|
134
163
|
* @abstract
|
|
135
164
|
* @param {SwapOptions} options - The swap's options.
|
|
136
165
|
* @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
|
|
166
|
+
* @throws {ValueError} If the swap options are not valid.
|
|
167
|
+
* @throws {InvalidTokenError} If the input or output 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 estimate the costs of the swap.
|
|
170
|
+
* @throws {SwapError} If the swap fails with an error.
|
|
137
171
|
*/
|
|
138
172
|
async quoteSwap (options) {
|
|
139
173
|
throw new NotImplementedError('quoteSwap(options)')
|