rango-sdk-basic 0.1.51 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  import uuid from 'uuid-random';
2
- import { getMessageFromCode } from 'eth-rpc-errors';
3
2
  import axios from 'axios';
4
3
 
5
4
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
@@ -395,6 +394,7 @@ var RoutingResultType;
395
394
  RoutingResultType["HIGH_IMPACT"] = "HIGH_IMPACT";
396
395
  RoutingResultType["NO_ROUTE"] = "NO_ROUTE";
397
396
  RoutingResultType["INPUT_LIMIT_ISSUE"] = "INPUT_LIMIT_ISSUE";
397
+ RoutingResultType["HIGH_IMPACT_FOR_CREATE_TX"] = "HIGH_IMPACT_FOR_CREATE_TX";
398
398
  })(RoutingResultType || (RoutingResultType = {}));
399
399
 
400
400
  /**
@@ -453,286 +453,6 @@ var isEvmTransaction = function isEvmTransaction(transaction) {
453
453
  return transaction.type === TransactionType.EVM;
454
454
  };
455
455
 
456
- var MetamaskErrorCodes = {
457
- rpc: {
458
- invalidInput: -32000,
459
- resourceNotFound: -32001,
460
- resourceUnavailable: -32002,
461
- transactionRejected: -32003,
462
- methodNotSupported: -32004,
463
- limitExceeded: -32005,
464
- parse: -32700,
465
- invalidRequest: -32600,
466
- methodNotFound: -32601,
467
- invalidParams: -32602,
468
- internal: -32603
469
- },
470
- provider: {
471
- userRejectedRequest: 4001,
472
- unauthorized: 4100,
473
- unsupportedMethod: 4200,
474
- disconnected: 4900,
475
- chainDisconnected: 4901
476
- }
477
- };
478
-
479
- function sleep(ms) {
480
- return new Promise(function (resolve) {
481
- return setTimeout(resolve, ms);
482
- });
483
- }
484
-
485
- function prepareEvmTransaction(evmTx, isApprove) {
486
- var gasPrice = !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x') ? '0x' + parseInt(evmTx.gasPrice).toString(16) : null;
487
- var manipulatedTx = _extends({}, evmTx, {
488
- gasPrice: gasPrice
489
- });
490
- var tx = {};
491
- if (!!manipulatedTx.from) tx = _extends({}, tx, {
492
- from: manipulatedTx.from
493
- });
494
- if (isApprove) {
495
- if (!!manipulatedTx.approveTo) tx = _extends({}, tx, {
496
- to: manipulatedTx.approveTo
497
- });
498
- if (!!manipulatedTx.approveData) tx = _extends({}, tx, {
499
- data: manipulatedTx.approveData
500
- });
501
- } else {
502
- if (!!manipulatedTx.txTo) tx = _extends({}, tx, {
503
- to: manipulatedTx.txTo
504
- });
505
- if (!!manipulatedTx.txData) tx = _extends({}, tx, {
506
- data: manipulatedTx.txData
507
- });
508
- if (!!manipulatedTx.value) tx = _extends({}, tx, {
509
- value: manipulatedTx.value
510
- });
511
- if (!!manipulatedTx.gasLimit) tx = _extends({}, tx, {
512
- gasLimit: manipulatedTx.gasLimit
513
- });
514
- if (!!manipulatedTx.gasPrice) tx = _extends({}, tx, {
515
- gasPrice: manipulatedTx.gasPrice
516
- });
517
- }
518
- return tx;
519
- }
520
- function checkApprovalSync(_x, _x2, _x3) {
521
- return _checkApprovalSync.apply(this, arguments);
522
- }
523
- function _checkApprovalSync() {
524
- _checkApprovalSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(requestId, txId, rangoClient) {
525
- var approvalResponse;
526
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
527
- while (1) switch (_context3.prev = _context3.next) {
528
- case 0:
529
- _context3.prev = 1;
530
- _context3.next = 4;
531
- return rangoClient.isApproved(requestId, txId);
532
- case 4:
533
- approvalResponse = _context3.sent;
534
- if (!(approvalResponse != null && approvalResponse.isApproved)) {
535
- _context3.next = 7;
536
- break;
537
- }
538
- return _context3.abrupt("return", true);
539
- case 7:
540
- if (!(!(approvalResponse != null && approvalResponse.isApproved) && (approvalResponse == null ? void 0 : approvalResponse.txStatus) === TransactionStatus.FAILED)) {
541
- _context3.next = 9;
542
- break;
543
- }
544
- return _context3.abrupt("return", false);
545
- case 9:
546
- _context3.next = 14;
547
- break;
548
- case 11:
549
- _context3.prev = 11;
550
- _context3.t0 = _context3["catch"](1);
551
- console.log('ignorinig error', {
552
- err: _context3.t0
553
- });
554
- case 14:
555
- _context3.next = 16;
556
- return sleep(3000);
557
- case 16:
558
- _context3.next = 0;
559
- break;
560
- case 18:
561
- case "end":
562
- return _context3.stop();
563
- }
564
- }, _callee3, null, [[1, 11]]);
565
- }));
566
- return _checkApprovalSync.apply(this, arguments);
567
- }
568
- var checkTransactionStatusSync = /*#__PURE__*/function () {
569
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(requestId, txId, rangoClient) {
570
- var txStatus;
571
- return _regeneratorRuntime().wrap(function _callee$(_context) {
572
- while (1) switch (_context.prev = _context.next) {
573
- case 0:
574
- _context.prev = 1;
575
- _context.next = 4;
576
- return rangoClient.status({
577
- requestId: requestId,
578
- txId: txId
579
- });
580
- case 4:
581
- txStatus = _context.sent;
582
- _context.next = 10;
583
- break;
584
- case 7:
585
- _context.prev = 7;
586
- _context.t0 = _context["catch"](1);
587
- console.log('ignorinig error', {
588
- err: _context.t0
589
- });
590
- case 10:
591
- if (!txStatus) {
592
- _context.next = 13;
593
- break;
594
- }
595
- if (!(!!txStatus.status && [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(txStatus.status))) {
596
- _context.next = 13;
597
- break;
598
- }
599
- return _context.abrupt("return", txStatus);
600
- case 13:
601
- _context.next = 15;
602
- return sleep(3000);
603
- case 15:
604
- _context.next = 0;
605
- break;
606
- case 17:
607
- case "end":
608
- return _context.stop();
609
- }
610
- }, _callee, null, [[1, 7]]);
611
- }));
612
- return function checkTransactionStatusSync(_x4, _x5, _x6) {
613
- return _ref.apply(this, arguments);
614
- };
615
- }();
616
- var executeEvmRoute = /*#__PURE__*/function () {
617
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(client, signer, route) {
618
- var tx, requestId, error, resultType, evmTransaction, txChainId, signerChainId, approveTxData, approveTx, isApproved, mainTxData, mainTx, status;
619
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
620
- while (1) switch (_context2.prev = _context2.next) {
621
- case 0:
622
- tx = route.tx, requestId = route.requestId, error = route.error, resultType = route.resultType;
623
- if (!(resultType != 'OK')) {
624
- _context2.next = 3;
625
- break;
626
- }
627
- throw new Error(resultType);
628
- case 3:
629
- if (!(!!error || !tx)) {
630
- _context2.next = 5;
631
- break;
632
- }
633
- throw new Error(error || 'Error creating the transaction.');
634
- case 5:
635
- if (!((tx == null ? void 0 : tx.type) !== TransactionType.EVM)) {
636
- _context2.next = 7;
637
- break;
638
- }
639
- throw new Error('Non Evm transactions are not supported yet.');
640
- case 7:
641
- evmTransaction = tx;
642
- if (evmTransaction) {
643
- _context2.next = 10;
644
- break;
645
- }
646
- throw new Error('Transaction is null. Please try again!');
647
- case 10:
648
- txChainId = parseInt(evmTransaction.blockChain.chainId || '-1');
649
- _context2.next = 13;
650
- return signer.getChainId();
651
- case 13:
652
- signerChainId = _context2.sent;
653
- if (!(signerChainId !== txChainId)) {
654
- _context2.next = 16;
655
- break;
656
- }
657
- throw new Error("Signer chainId " + signerChainId + " doesn't match required chainId " + txChainId + ".");
658
- case 16:
659
- if (!(!!evmTransaction.approveTo && !!evmTransaction.approveData)) {
660
- _context2.next = 27;
661
- break;
662
- }
663
- approveTxData = prepareEvmTransaction(evmTransaction, true);
664
- _context2.next = 20;
665
- return signer.sendTransaction(approveTxData);
666
- case 20:
667
- approveTx = _context2.sent;
668
- approveTx.wait();
669
- _context2.next = 24;
670
- return checkApprovalSync(requestId, approveTx.hash, client);
671
- case 24:
672
- isApproved = _context2.sent;
673
- if (isApproved) {
674
- _context2.next = 27;
675
- break;
676
- }
677
- throw new Error('Error in approve transaction.');
678
- case 27:
679
- _context2.next = 29;
680
- return signer.getChainId();
681
- case 29:
682
- signerChainId = _context2.sent;
683
- if (!(signerChainId !== txChainId)) {
684
- _context2.next = 32;
685
- break;
686
- }
687
- throw new Error("Signer chainId " + signerChainId + " doesn't match required chainId " + txChainId + ".");
688
- case 32:
689
- mainTxData = prepareEvmTransaction(evmTransaction, false);
690
- _context2.next = 35;
691
- return signer.sendTransaction(mainTxData);
692
- case 35:
693
- mainTx = _context2.sent;
694
- mainTx.wait();
695
- _context2.next = 39;
696
- return checkTransactionStatusSync(requestId, mainTx.hash, client);
697
- case 39:
698
- status = _context2.sent;
699
- if (!(status.status !== TransactionStatus.SUCCESS)) {
700
- _context2.next = 42;
701
- break;
702
- }
703
- throw new Error("Cross-chain swap failed. " + (status.error || ''));
704
- case 42:
705
- return _context2.abrupt("return", status);
706
- case 43:
707
- case "end":
708
- return _context2.stop();
709
- }
710
- }, _callee2);
711
- }));
712
- return function executeEvmRoute(_x7, _x8, _x9) {
713
- return _ref2.apply(this, arguments);
714
- };
715
- }();
716
-
717
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
718
- var prettifyError = function prettifyError(error) {
719
- if (!error) return error;
720
- if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001)) return new Error('Transaction Rejected');
721
- if (error && typeof error.code === 'number') {
722
- if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {
723
- return new Error(getMessageFromCode(error.code));
724
- }
725
- if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {
726
- var _error$message, _error$message2, _error$message3;
727
- if (error.code === MetamaskErrorCodes.rpc.internal && (_error$message = error.message) != null && _error$message.includes('underpriced')) return new Error('Transaction underpriced');
728
- if ((_error$message2 = error.message) != null && _error$message2.includes('intrinsic gas too low') || (_error$message3 = error.message) != null && _error$message3.includes('out of gas')) return new Error('This Gas limit is low.');
729
- return new Error(getMessageFromCode(error.code));
730
- }
731
- }
732
- if (error.message) return new Error(error.message);
733
- return error;
734
- };
735
-
736
456
  var RangoClient = /*#__PURE__*/function () {
737
457
  function RangoClient(apiKey, debug, apiUrl) {
738
458
  if (debug === void 0) {
@@ -868,11 +588,35 @@ var RangoClient = /*#__PURE__*/function () {
868
588
  }
869
589
  return messagingProtocols;
870
590
  }();
871
- _proto.quote = /*#__PURE__*/function () {
872
- var _quote = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(quoteRequest, options) {
873
- var body, axiosResponse;
591
+ _proto.token = /*#__PURE__*/function () {
592
+ var _token = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(customTokenRequest, options) {
593
+ var axiosResponse;
874
594
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
875
595
  while (1) switch (_context5.prev = _context5.next) {
596
+ case 0:
597
+ _context5.next = 2;
598
+ return this.httpService.get("/basic/meta/custom-token?apiKey=" + this.apiKey, _extends({
599
+ params: customTokenRequest
600
+ }, options));
601
+ case 2:
602
+ axiosResponse = _context5.sent;
603
+ return _context5.abrupt("return", axiosResponse.data);
604
+ case 4:
605
+ case "end":
606
+ return _context5.stop();
607
+ }
608
+ }, _callee5, this);
609
+ }));
610
+ function token(_x6, _x7) {
611
+ return _token.apply(this, arguments);
612
+ }
613
+ return token;
614
+ }();
615
+ _proto.quote = /*#__PURE__*/function () {
616
+ var _quote = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(quoteRequest, options) {
617
+ var body, axiosResponse;
618
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
619
+ while (1) switch (_context6.prev = _context6.next) {
876
620
  case 0:
877
621
  body = _extends({}, quoteRequest, {
878
622
  from: assetToString(quoteRequest.from),
@@ -881,7 +625,7 @@ var RangoClient = /*#__PURE__*/function () {
881
625
  swapperGroups: !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0 ? quoteRequest.swapperGroups.join(',') : undefined,
882
626
  messagingProtocols: !!quoteRequest.messagingProtocols && quoteRequest.messagingProtocols.length > 0 ? quoteRequest.messagingProtocols.join(',') : undefined
883
627
  });
884
- _context5.next = 3;
628
+ _context6.next = 3;
885
629
  return this.httpService.get("/basic/quote?apiKey=" + this.apiKey, _extends({
886
630
  params: body,
887
631
  headers: {
@@ -889,26 +633,26 @@ var RangoClient = /*#__PURE__*/function () {
889
633
  }
890
634
  }, options));
891
635
  case 3:
892
- axiosResponse = _context5.sent;
893
- return _context5.abrupt("return", axiosResponse.data);
636
+ axiosResponse = _context6.sent;
637
+ return _context6.abrupt("return", axiosResponse.data);
894
638
  case 5:
895
639
  case "end":
896
- return _context5.stop();
640
+ return _context6.stop();
897
641
  }
898
- }, _callee5, this);
642
+ }, _callee6, this);
899
643
  }));
900
- function quote(_x6, _x7) {
644
+ function quote(_x8, _x9) {
901
645
  return _quote.apply(this, arguments);
902
646
  }
903
647
  return quote;
904
648
  }();
905
649
  _proto.isApproved = /*#__PURE__*/function () {
906
- var _isApproved = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(requestId, txId, options) {
650
+ var _isApproved = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(requestId, txId, options) {
907
651
  var axiosResponse;
908
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
909
- while (1) switch (_context6.prev = _context6.next) {
652
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
653
+ while (1) switch (_context7.prev = _context7.next) {
910
654
  case 0:
911
- _context6.next = 2;
655
+ _context7.next = 2;
912
656
  return this.httpService.get("/basic/is-approved?apiKey=" + this.apiKey, _extends({
913
657
  params: {
914
658
  requestId: requestId,
@@ -919,26 +663,26 @@ var RangoClient = /*#__PURE__*/function () {
919
663
  }
920
664
  }, options));
921
665
  case 2:
922
- axiosResponse = _context6.sent;
923
- return _context6.abrupt("return", axiosResponse.data);
666
+ axiosResponse = _context7.sent;
667
+ return _context7.abrupt("return", axiosResponse.data);
924
668
  case 4:
925
669
  case "end":
926
- return _context6.stop();
670
+ return _context7.stop();
927
671
  }
928
- }, _callee6, this);
672
+ }, _callee7, this);
929
673
  }));
930
- function isApproved(_x8, _x9, _x10) {
674
+ function isApproved(_x10, _x11, _x12) {
931
675
  return _isApproved.apply(this, arguments);
932
676
  }
933
677
  return isApproved;
934
678
  }();
935
679
  _proto.status = /*#__PURE__*/function () {
936
- var _status = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(statusRequest, options) {
680
+ var _status = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(statusRequest, options) {
937
681
  var axiosResponse;
938
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
939
- while (1) switch (_context7.prev = _context7.next) {
682
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
683
+ while (1) switch (_context8.prev = _context8.next) {
940
684
  case 0:
941
- _context7.next = 2;
685
+ _context8.next = 2;
942
686
  return this.httpService.get("/basic/status?apiKey=" + this.apiKey, _extends({
943
687
  params: statusRequest,
944
688
  headers: {
@@ -946,24 +690,24 @@ var RangoClient = /*#__PURE__*/function () {
946
690
  }
947
691
  }, options));
948
692
  case 2:
949
- axiosResponse = _context7.sent;
950
- return _context7.abrupt("return", axiosResponse.data);
693
+ axiosResponse = _context8.sent;
694
+ return _context8.abrupt("return", axiosResponse.data);
951
695
  case 4:
952
696
  case "end":
953
- return _context7.stop();
697
+ return _context8.stop();
954
698
  }
955
- }, _callee7, this);
699
+ }, _callee8, this);
956
700
  }));
957
- function status(_x11, _x12) {
701
+ function status(_x13, _x14) {
958
702
  return _status.apply(this, arguments);
959
703
  }
960
704
  return status;
961
705
  }();
962
706
  _proto.swap = /*#__PURE__*/function () {
963
- var _swap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(swapRequest, options) {
707
+ var _swap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(swapRequest, options) {
964
708
  var body, axiosResponse;
965
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
966
- while (1) switch (_context8.prev = _context8.next) {
709
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
710
+ while (1) switch (_context9.prev = _context9.next) {
967
711
  case 0:
968
712
  body = _extends({}, swapRequest, {
969
713
  from: assetToString(swapRequest.from),
@@ -975,7 +719,7 @@ var RangoClient = /*#__PURE__*/function () {
975
719
  swapperGroups: !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0 ? swapRequest.swapperGroups.join(',') : undefined,
976
720
  messagingProtocols: !!swapRequest.messagingProtocols && swapRequest.messagingProtocols.length > 0 ? swapRequest.messagingProtocols.join(',') : undefined
977
721
  });
978
- _context8.next = 3;
722
+ _context9.next = 3;
979
723
  return this.httpService.get("/basic/swap?apiKey=" + this.apiKey, _extends({
980
724
  params: body,
981
725
  headers: {
@@ -983,25 +727,25 @@ var RangoClient = /*#__PURE__*/function () {
983
727
  }
984
728
  }, options));
985
729
  case 3:
986
- axiosResponse = _context8.sent;
987
- return _context8.abrupt("return", axiosResponse.data);
730
+ axiosResponse = _context9.sent;
731
+ return _context9.abrupt("return", axiosResponse.data);
988
732
  case 5:
989
733
  case "end":
990
- return _context8.stop();
734
+ return _context9.stop();
991
735
  }
992
- }, _callee8, this);
736
+ }, _callee9, this);
993
737
  }));
994
- function swap(_x13, _x14) {
738
+ function swap(_x15, _x16) {
995
739
  return _swap.apply(this, arguments);
996
740
  }
997
741
  return swap;
998
742
  }();
999
743
  _proto.reportFailure = /*#__PURE__*/function () {
1000
- var _reportFailure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(requestBody, options) {
1001
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1002
- while (1) switch (_context9.prev = _context9.next) {
744
+ var _reportFailure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(requestBody, options) {
745
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
746
+ while (1) switch (_context10.prev = _context10.next) {
1003
747
  case 0:
1004
- _context9.next = 2;
748
+ _context10.next = 2;
1005
749
  return this.httpService.post("/basic/report-tx?apiKey=" + this.apiKey, requestBody, _extends({
1006
750
  headers: {
1007
751
  'X-Rango-Id': this.deviceId
@@ -1009,22 +753,22 @@ var RangoClient = /*#__PURE__*/function () {
1009
753
  }, options));
1010
754
  case 2:
1011
755
  case "end":
1012
- return _context9.stop();
756
+ return _context10.stop();
1013
757
  }
1014
- }, _callee9, this);
758
+ }, _callee10, this);
1015
759
  }));
1016
- function reportFailure(_x15, _x16) {
760
+ function reportFailure(_x17, _x18) {
1017
761
  return _reportFailure.apply(this, arguments);
1018
762
  }
1019
763
  return reportFailure;
1020
764
  }();
1021
765
  _proto.balance = /*#__PURE__*/function () {
1022
- var _balance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(walletAddress, options) {
766
+ var _balance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(walletAddress, options) {
1023
767
  var axiosResponse;
1024
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1025
- while (1) switch (_context10.prev = _context10.next) {
768
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
769
+ while (1) switch (_context11.prev = _context11.next) {
1026
770
  case 0:
1027
- _context10.next = 2;
771
+ _context11.next = 2;
1028
772
  return this.httpService.get("/basic/balance?apiKey=" + this.apiKey, _extends({
1029
773
  params: walletAddress,
1030
774
  headers: {
@@ -1032,70 +776,53 @@ var RangoClient = /*#__PURE__*/function () {
1032
776
  }
1033
777
  }, options));
1034
778
  case 2:
1035
- axiosResponse = _context10.sent;
1036
- return _context10.abrupt("return", axiosResponse.data);
779
+ axiosResponse = _context11.sent;
780
+ return _context11.abrupt("return", axiosResponse.data);
1037
781
  case 4:
1038
782
  case "end":
1039
- return _context10.stop();
783
+ return _context11.stop();
1040
784
  }
1041
- }, _callee10, this);
785
+ }, _callee11, this);
1042
786
  }));
1043
- function balance(_x17, _x18) {
787
+ function balance(_x19, _x20) {
1044
788
  return _balance.apply(this, arguments);
1045
789
  }
1046
790
  return balance;
1047
791
  }();
1048
- _proto.executeEvmRoute = /*#__PURE__*/function () {
1049
- var _executeEvmRoute2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(
1050
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1051
- signer, route) {
1052
- var prettifiedError, message;
1053
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1054
- while (1) switch (_context11.prev = _context11.next) {
792
+ _proto.tokenBalance = /*#__PURE__*/function () {
793
+ var _tokenBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(tokenBalanceRequest, options) {
794
+ var axiosResponse;
795
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
796
+ while (1) switch (_context12.prev = _context12.next) {
1055
797
  case 0:
1056
- _context11.prev = 0;
1057
- _context11.next = 3;
1058
- return executeEvmRoute(this, signer, route);
1059
- case 3:
1060
- return _context11.abrupt("return", _context11.sent);
1061
- case 6:
1062
- _context11.prev = 6;
1063
- _context11.t0 = _context11["catch"](0);
1064
- prettifiedError = prettifyError(_context11.t0);
1065
- try {
1066
- message = (prettifiedError == null ? void 0 : prettifiedError.message) || 'Error executing the route';
1067
- this.reportFailure({
1068
- requestId: route.requestId,
1069
- eventType: 'TX_FAIL',
1070
- reason: message
1071
- });
1072
- } catch (err) {
1073
- console.log({
1074
- err: err
1075
- });
1076
- }
1077
- throw prettifiedError;
1078
- case 11:
798
+ _context12.next = 2;
799
+ return this.httpService.get("/basic/token-balance?apiKey=" + this.apiKey, _extends({
800
+ params: tokenBalanceRequest
801
+ }, options));
802
+ case 2:
803
+ axiosResponse = _context12.sent;
804
+ return _context12.abrupt("return", axiosResponse.data);
805
+ case 4:
1079
806
  case "end":
1080
- return _context11.stop();
807
+ return _context12.stop();
1081
808
  }
1082
- }, _callee11, this, [[0, 6]]);
809
+ }, _callee12, this);
1083
810
  }));
1084
- function executeEvmRoute$1(_x19, _x20) {
1085
- return _executeEvmRoute2.apply(this, arguments);
811
+ function tokenBalance(_x21, _x22) {
812
+ return _tokenBalance.apply(this, arguments);
1086
813
  }
1087
- return executeEvmRoute$1;
814
+ return tokenBalance;
1088
815
  }();
1089
816
  _proto.connectedAssets = /*#__PURE__*/function () {
1090
- var _connectedAssets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(connectedAssetsRequest, options) {
817
+ var _connectedAssets = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(connectedAssetsRequest, options) {
1091
818
  var body, axiosResponse;
1092
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1093
- while (1) switch (_context12.prev = _context12.next) {
819
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
820
+ while (1) switch (_context13.prev = _context13.next) {
1094
821
  case 0:
1095
822
  body = {
1096
823
  from: assetToString(connectedAssetsRequest.from)
1097
824
  };
1098
- _context12.next = 3;
825
+ _context13.next = 3;
1099
826
  return this.httpService.get("/basic/connected-assets?apiKey=" + this.apiKey, _extends({
1100
827
  params: body,
1101
828
  headers: {
@@ -1103,15 +830,15 @@ var RangoClient = /*#__PURE__*/function () {
1103
830
  }
1104
831
  }, options));
1105
832
  case 3:
1106
- axiosResponse = _context12.sent;
1107
- return _context12.abrupt("return", axiosResponse.data);
833
+ axiosResponse = _context13.sent;
834
+ return _context13.abrupt("return", axiosResponse.data);
1108
835
  case 5:
1109
836
  case "end":
1110
- return _context12.stop();
837
+ return _context13.stop();
1111
838
  }
1112
- }, _callee12, this);
839
+ }, _callee13, this);
1113
840
  }));
1114
- function connectedAssets(_x21, _x22) {
841
+ function connectedAssets(_x23, _x24) {
1115
842
  return _connectedAssets.apply(this, arguments);
1116
843
  }
1117
844
  return connectedAssets;
@@ -1119,5 +846,5 @@ var RangoClient = /*#__PURE__*/function () {
1119
846
  return RangoClient;
1120
847
  }();
1121
848
 
1122
- export { GenericTransactionType, MetamaskErrorCodes, RangoClient, RoutingResultType, TransactionStatus, TransactionType, assetToString, cosmosBlockchains, evmBlockchains, isCosmosBlockchain, isCosmosTransaction, isEvmBlockchain, isEvmTransaction, isSolanaBlockchain, isSolanaTransaction, isStarknetBlockchain, isTonBlockchain, isTransferBlockchain, isTransferTransaction, isTronBlockchain, solanaBlockchain, starknetBlockchain, tonBlockchain, transferBlockchains, tronBlockchain };
849
+ export { GenericTransactionType, RangoClient, RoutingResultType, TransactionStatus, TransactionType, assetToString, cosmosBlockchains, evmBlockchains, isCosmosBlockchain, isCosmosTransaction, isEvmBlockchain, isEvmTransaction, isSolanaBlockchain, isSolanaTransaction, isStarknetBlockchain, isTonBlockchain, isTransferBlockchain, isTransferTransaction, isTronBlockchain, solanaBlockchain, starknetBlockchain, tonBlockchain, transferBlockchains, tronBlockchain };
1123
850
  //# sourceMappingURL=rango-sdk-basic.esm.js.map