@rango-dev/queue-manager-rango-preset 0.1.11-next.2 → 0.1.11-next.4

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,14 +1,43 @@
1
- import { SignerError, isAPIErrorCode, isSignerErrorCode, SignerErrorCode } from 'rango-types';
2
1
  import { WalletType, Network, getBlockChainNameFromId } from '@rango-dev/wallets-shared';
3
- import BigNumber from 'bignumber.js';
4
2
  import { readAccountAddress } from '@rango-dev/wallets-core';
5
3
  import { RangoClient, TransactionType } from 'rango-sdk';
6
4
  import { Status, Persistor, DB_NAME } from '@rango-dev/queue-manager-core';
5
+ import { SignerError, isAPIErrorCode, isSignerErrorCode, SignerErrorCode } from 'rango-types';
6
+ import BigNumber from 'bignumber.js';
7
7
  import { captureException } from '@sentry/browser';
8
8
  import { useManager } from '@rango-dev/queue-manager-react';
9
9
  import { useState, useEffect } from 'react';
10
10
  import { v4 } from 'uuid';
11
11
 
12
+ // this API key is limited and
13
+ // it is only for test purpose
14
+ var RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
15
+ var configs = {
16
+ API_KEY: RANGO_PUBLIC_API_KEY
17
+ };
18
+ function getConfig(name) {
19
+ return configs[name];
20
+ }
21
+ function initConfig(nextConfigs) {
22
+ configs = structuredClone(nextConfigs);
23
+ return configs;
24
+ }
25
+
26
+ var SwapActionTypes;
27
+ (function (SwapActionTypes) {
28
+ SwapActionTypes["START"] = "START";
29
+ SwapActionTypes["SCHEDULE_NEXT_STEP"] = "SCHEDULE_NEXT_STEP";
30
+ SwapActionTypes["CREATE_TRANSACTION"] = "CREATE_TRANSACTION";
31
+ SwapActionTypes["EXECUTE_TRANSACTION"] = "EXECUTE_TRANSACTION";
32
+ SwapActionTypes["CHECK_TRANSACTION_STATUS"] = "CHECK_TRANSACTION_STATUS";
33
+ })(SwapActionTypes || (SwapActionTypes = {}));
34
+ var BlockReason;
35
+ (function (BlockReason) {
36
+ BlockReason["WAIT_FOR_CONNECT_WALLET"] = "waiting_for_connecting_wallet";
37
+ BlockReason["WAIT_FOR_NETWORK_CHANGE"] = "waiting_for_network_change";
38
+ BlockReason["DEPENDS_ON_OTHER_QUEUES"] = "depends_on_other_queues";
39
+ })(BlockReason || (BlockReason = {}));
40
+
12
41
  function _regeneratorRuntime() {
13
42
  _regeneratorRuntime = function () {
14
43
  return exports;
@@ -434,6 +463,17 @@ function _assertThisInitialized(self) {
434
463
  return self;
435
464
  }
436
465
 
466
+ var ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
467
+ var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address) {
468
+ return "Please change your " + (type || 'wallet') + " account to " + (address || 'proper address');
469
+ };
470
+ var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type) {
471
+ return "Please connect to " + (type || 'your wallet') + " by using bellow button or top right button on page.";
472
+ };
473
+ var ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK = function ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(network) {
474
+ return "Please change your network to " + network + ".";
475
+ };
476
+
437
477
  var ERROR_ASSERTION_FAILED = 'Assertion failed (Unexpected behaviour)';
438
478
  var ERROR_CREATE_TRANSACTION = 'Create transaction failed in Rango Server';
439
479
  var ERROR_INPUT_WALLET_NOT_FOUND = 'Input wallet not found';
@@ -739,34 +779,6 @@ function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validat
739
779
  };
740
780
  }
741
781
 
742
- var SwapActionTypes;
743
- (function (SwapActionTypes) {
744
- SwapActionTypes["START"] = "START";
745
- SwapActionTypes["SCHEDULE_NEXT_STEP"] = "SCHEDULE_NEXT_STEP";
746
- SwapActionTypes["CREATE_TRANSACTION"] = "CREATE_TRANSACTION";
747
- SwapActionTypes["EXECUTE_TRANSACTION"] = "EXECUTE_TRANSACTION";
748
- SwapActionTypes["CHECK_TRANSACTION_STATUS"] = "CHECK_TRANSACTION_STATUS";
749
- })(SwapActionTypes || (SwapActionTypes = {}));
750
- var BlockReason;
751
- (function (BlockReason) {
752
- BlockReason["WAIT_FOR_CONNECT_WALLET"] = "waiting_for_connecting_wallet";
753
- BlockReason["WAIT_FOR_NETWORK_CHANGE"] = "waiting_for_network_change";
754
- BlockReason["DEPENDS_ON_OTHER_QUEUES"] = "depends_on_other_queues";
755
- })(BlockReason || (BlockReason = {}));
756
-
757
- var RANGO_DAPP_API_KEY = process.env.REACT_APP_API_KEY;
758
- var RANGO_DAPP_API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
759
- var ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
760
- var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address) {
761
- return "Please change your " + (type || 'wallet') + " account to " + (address || 'proper address');
762
- };
763
- var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type) {
764
- return "Please connect to " + (type || 'your wallet') + " by using bellow button or top right button on page.";
765
- };
766
- var ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK = function ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(network) {
767
- return "Please change your network to " + network + ".";
768
- };
769
-
770
782
  function logRPCError(error, swap, currentStep, walletType) {
771
783
  try {
772
784
  captureException(error, {
@@ -785,7 +797,12 @@ function logRPCError(error, swap, currentStep, walletType) {
785
797
  }
786
798
  }
787
799
 
788
- var httpService = /*#__PURE__*/new RangoClient(RANGO_DAPP_API_KEY || '', RANGO_DAPP_API_BASE_URL);
800
+ var rango = undefined;
801
+ var httpService = function httpService() {
802
+ if (rango) return rango;
803
+ rango = new RangoClient(getConfig('API_KEY'));
804
+ return rango;
805
+ };
789
806
 
790
807
  var swapClaimedBy = null;
791
808
  /**
@@ -869,7 +886,7 @@ function updateSwapStatus(_ref) {
869
886
  var errorReason = details && details.includes('Warning') ? 'Swap canceled by user.' : details;
870
887
  var walletType = (_getRelatedWalletOrNu = getRelatedWalletOrNull(swap, currentStep)) == null ? void 0 : _getRelatedWalletOrNu.walletType;
871
888
  swap.extraMessageSeverity = MessageSeverity.error;
872
- httpService.reportFailure({
889
+ httpService().reportFailure({
873
890
  requestId: swap.requestId,
874
891
  step: (currentStep == null ? void 0 : currentStep.id) || 1,
875
892
  eventType: mapAppErrorCodesToAPIErrorCode(errorCode),
@@ -2164,7 +2181,7 @@ function _checkTransactionStatus() {
2164
2181
  status = null;
2165
2182
  _context.prev = 5;
2166
2183
  _context.next = 8;
2167
- return httpService.checkStatus({
2184
+ return httpService().checkStatus({
2168
2185
  requestId: swap.requestId,
2169
2186
  txId: txId,
2170
2187
  step: currentStep.id
@@ -2296,7 +2313,7 @@ function _checkApprovalStatus() {
2296
2313
  isApproved = false;
2297
2314
  _context2.prev = 4;
2298
2315
  _context2.next = 7;
2299
- return httpService.checkApproval(swap.requestId, currentStep.executedTransactionId || '');
2316
+ return httpService().checkApproval(swap.requestId, currentStep.executedTransactionId || '');
2300
2317
  case 7:
2301
2318
  response = _context2.sent;
2302
2319
  isApproved = response.isApproved;
@@ -2446,7 +2463,7 @@ function _createTransaction() {
2446
2463
  };
2447
2464
  _context.prev = 6;
2448
2465
  _context.next = 9;
2449
- return throwOnOK(httpService.createTransaction(request));
2466
+ return throwOnOK(httpService().createTransaction(request));
2450
2467
  case 9:
2451
2468
  _yield$throwOnOK = _context.sent;
2452
2469
  transaction = _yield$throwOnOK.transaction;
@@ -2895,5 +2912,10 @@ function useQueueManager(params) {
2895
2912
  }, [params.disconnectedWallet]);
2896
2913
  }
2897
2914
 
2898
- export { MessageSeverity, PendingSwapNetworkStatus, PrettyError, calculatePendingSwap, cancelSwap, checkWaitingForNetworkChange, getCurrentBlockchainOfOrNull, getCurrentStep, getEvmProvider, getRelatedWallet, getRelatedWalletOrNull, getRequiredWallet, getRunningSwaps, prettifyErrorMessage, resetRunningSwapNotifsOnPageLoad, splitWalletNetwork, swapQueueDef, updateSwapStatus, useMigration, useQueueManager };
2915
+ function makeQueueDefinition(configs) {
2916
+ initConfig(configs);
2917
+ return swapQueueDef;
2918
+ }
2919
+
2920
+ export { MessageSeverity, PendingSwapNetworkStatus, PrettyError, calculatePendingSwap, cancelSwap, checkWaitingForNetworkChange, getCurrentBlockchainOfOrNull, getCurrentStep, getEvmProvider, getRelatedWallet, getRelatedWalletOrNull, getRequiredWallet, getRunningSwaps, makeQueueDefinition, prettifyErrorMessage, resetRunningSwapNotifsOnPageLoad, splitWalletNetwork, updateSwapStatus, useMigration, useQueueManager };
2899
2921
  //# sourceMappingURL=queue-manager-rango-preset.esm.js.map