@rango-dev/queue-manager-rango-preset 0.1.13-next.0 → 0.1.13-next.2

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.
@@ -469,6 +469,7 @@ function _assertThisInitialized(self) {
469
469
  return self;
470
470
  }
471
471
 
472
+ var ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES = 'Waiting for other swaps to complete';
472
473
  var ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
473
474
  var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address) {
474
475
  return "Please change your " + (type || 'wallet') + " account to " + (address || 'proper address');
@@ -1186,7 +1187,7 @@ function _isNetworkMatchedForTransaction() {
1186
1187
  _context2.next = 23;
1187
1188
  break;
1188
1189
  }
1189
- if (![WalletType.META_MASK, WalletType.BINANCE_CHAIN, WalletType.XDEFI, WalletType.WALLET_CONNECT, WalletType.TRUST_WALLET, WalletType.COIN98, WalletType.EXODUS, WalletType.OKX, WalletType.COINBASE, WalletType.TOKEN_POCKET, WalletType.MATH, WalletType.SAFEPAL, WalletType.COSMOSTATION, WalletType.CLOVER, WalletType.BRAVE, WalletType.FRONTIER, WalletType.KUCOIN].includes(sourceWallet.walletType)) {
1190
+ if (![WalletType.META_MASK, WalletType.BINANCE_CHAIN, WalletType.XDEFI, WalletType.WALLET_CONNECT, WalletType.TRUST_WALLET, WalletType.COIN98, WalletType.EXODUS, WalletType.OKX, WalletType.COINBASE, WalletType.TOKEN_POCKET, WalletType.MATH, WalletType.SAFEPAL, WalletType.COSMOSTATION, WalletType.CLOVER, WalletType.BRAVE, WalletType.FRONTIER, WalletType.KUCOIN, WalletType.ENKRYPT].includes(sourceWallet.walletType)) {
1190
1191
  _context2.next = 22;
1191
1192
  break;
1192
1193
  }
@@ -2553,12 +2554,13 @@ function executeTransaction(_x) {
2553
2554
  function _executeTransaction() {
2554
2555
  _executeTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(actions) {
2555
2556
  var _context$_queue;
2556
- var getStorage, context, meta, wallets, providers, isClaimed, requestBlock, swap, currentStep, isWrongAddress, _wallets$blockchains, _getRequiredWallet, type, address, isWalletInCompatible, description, blockedFor, needsToBlockQueue, _blockedFor, networkMatched, fromBlockchain, details, _blockedFor2;
2557
+ var getStorage, context, meta, wallets, providers, _claimQueue, claimedBy, isClaimed, requestBlock, swap, currentStep, isWrongAddress, _wallets$blockchains, _getRequiredWallet, type, address, isWalletInCompatible, description, blockedFor, networkMatched, claimerId, isClaimedByAnyQueue, details, _blockedFor, fromBlockchain, _details, _blockedFor2, needsToBlockQueue, _blockedFor3;
2557
2558
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2558
2559
  while (1) switch (_context.prev = _context.next) {
2559
2560
  case 0:
2560
2561
  getStorage = actions.getStorage, context = actions.context;
2561
2562
  meta = context.meta, wallets = context.wallets, providers = context.providers;
2563
+ _claimQueue = claimQueue(), claimedBy = _claimQueue.claimedBy;
2562
2564
  isClaimed = context.claimedBy === ((_context$_queue = context._queue) == null ? void 0 : _context$_queue.id);
2563
2565
  requestBlock = function requestBlock(blockedFor) {
2564
2566
  actions.block(blockedFor);
@@ -2572,7 +2574,7 @@ function _executeTransaction() {
2572
2574
  /* Make sure wallet is connected and also the connected wallet is matched with tx by checking address. */
2573
2575
  isWrongAddress = !isRequiredWalletConnected(swap, context.state).ok;
2574
2576
  if (!isWrongAddress) {
2575
- _context.next = 15;
2577
+ _context.next = 16;
2576
2578
  break;
2577
2579
  }
2578
2580
  _getRequiredWallet = getRequiredWallet(swap), type = _getRequiredWallet.type, address = _getRequiredWallet.address;
@@ -2589,51 +2591,65 @@ function _executeTransaction() {
2589
2591
  };
2590
2592
  requestBlock(blockedFor);
2591
2593
  return _context.abrupt("return");
2592
- case 15:
2593
- /*
2594
- For avoiding conflict by making too many requests to wallet, we need to make sure
2595
- We only run one request at a time (In parallel mode).
2596
- */
2597
- needsToBlockQueue = isNeedBlockQueueForParallel(currentStep);
2598
- if (!(needsToBlockQueue && !isClaimed)) {
2599
- _context.next = 20;
2594
+ case 16:
2595
+ _context.next = 18;
2596
+ return isNetworkMatchedForTransaction(swap, currentStep, wallets, meta, providers);
2597
+ case 18:
2598
+ networkMatched = _context.sent;
2599
+ claimerId = claimedBy();
2600
+ isClaimedByAnyQueue = !!claimerId && !isClaimed;
2601
+ if (!(isClaimedByAnyQueue && !networkMatched)) {
2602
+ _context.next = 28;
2600
2603
  break;
2601
2604
  }
2605
+ details = ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES;
2602
2606
  _blockedFor = {
2603
2607
  reason: BlockReason.DEPENDS_ON_OTHER_QUEUES,
2604
- description: 'Waiting for other swaps to complete',
2605
- details: {}
2608
+ details: details
2606
2609
  };
2607
2610
  requestBlock(_blockedFor);
2608
2611
  return _context.abrupt("return");
2609
- case 20:
2610
- _context.next = 22;
2611
- return isNetworkMatchedForTransaction(swap, currentStep, wallets, meta, providers);
2612
- case 22:
2613
- networkMatched = _context.sent;
2612
+ case 28:
2614
2613
  if (networkMatched) {
2615
- _context.next = 31;
2614
+ _context.next = 36;
2616
2615
  break;
2617
2616
  }
2618
2617
  fromBlockchain = getCurrentBlockchainOf(swap, currentStep);
2619
- details = ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(fromBlockchain);
2618
+ _details = ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(fromBlockchain);
2620
2619
  _blockedFor2 = {
2621
2620
  reason: BlockReason.WAIT_FOR_NETWORK_CHANGE,
2622
- details: details
2621
+ details: _details
2623
2622
  };
2624
2623
  requestBlock(_blockedFor2);
2625
2624
  return _context.abrupt("return");
2626
- case 31:
2625
+ case 36:
2627
2626
  // Update network to mark it as network changed successfully.
2628
2627
  updateNetworkStatus(actions, {
2629
2628
  message: '',
2630
2629
  details: 'Wallet network changed successfully',
2631
2630
  status: PendingSwapNetworkStatus.NetworkChanged
2632
2631
  });
2633
- case 32:
2632
+ case 37:
2633
+ /*
2634
+ For avoiding conflict by making too many requests to wallet, we need to make sure
2635
+ We only run one request at a time (In parallel mode).
2636
+ */
2637
+ needsToBlockQueue = isNeedBlockQueueForParallel(currentStep);
2638
+ if (!(needsToBlockQueue && !isClaimed)) {
2639
+ _context.next = 42;
2640
+ break;
2641
+ }
2642
+ _blockedFor3 = {
2643
+ reason: BlockReason.DEPENDS_ON_OTHER_QUEUES,
2644
+ description: ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES,
2645
+ details: {}
2646
+ };
2647
+ requestBlock(_blockedFor3);
2648
+ return _context.abrupt("return");
2649
+ case 42:
2634
2650
  // All the conditions are met. We can safely send the tx to wallet for sign.
2635
2651
  singTransaction(actions);
2636
- case 33:
2652
+ case 43:
2637
2653
  case "end":
2638
2654
  return _context.stop();
2639
2655
  }