@rango-dev/queue-manager-rango-preset 0.1.10-next.95 → 0.1.10-next.96

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.
@@ -708,6 +708,14 @@ function claimQueue() {
708
708
  }
709
709
  };
710
710
  }
711
+ /**
712
+ *
713
+ * Returns "wallet and network" separately, even if the wallet is dashed inside.
714
+ *
715
+ */
716
+ function splitWalletNetwork(input) {
717
+ return input == null ? void 0 : input.split(/-(?=[^-]*$)/);
718
+ }
711
719
  /**
712
720
  *
713
721
  * Returns `steps`, if it's a `running` swap.
@@ -1789,9 +1797,9 @@ function checkWaitingForConnectWalletChange(params) {
1789
1797
  var wallet_network = params.wallet_network,
1790
1798
  evmChains = params.evmChains,
1791
1799
  manager = params.manager;
1792
- var _wallet_network$split = wallet_network.split('-'),
1793
- wallet = _wallet_network$split[0],
1794
- network = _wallet_network$split[1];
1800
+ var _splitWalletNetwork = splitWalletNetwork(wallet_network),
1801
+ wallet = _splitWalletNetwork[0],
1802
+ network = _splitWalletNetwork[1];
1795
1803
  // We only need change network for EVM chains.
1796
1804
  if (!evmChains.some(function (chain) {
1797
1805
  return chain.name == network;
@@ -1809,7 +1817,7 @@ function checkWaitingForConnectWalletChange(params) {
1809
1817
  var task = q.list.state.tasks[taskId];
1810
1818
  return task.status === Status.BLOCKED && [BlockReason.WAIT_FOR_CONNECT_WALLET].includes((_task$blockedFor = task.blockedFor) == null ? void 0 : _task$blockedFor.reason);
1811
1819
  });
1812
- if (currentStepRequiredWallet === wallet && hasWaitingForConnect) {
1820
+ if (currentStepRequiredWallet === wallet && hasWaitingForConnect && getCurrentBlockchainOfOrNull(swap, currentStep) != network) {
1813
1821
  var queueInstance = q.list;
1814
1822
  var _getRequiredWallet5 = getRequiredWallet(swap),
1815
1823
  type = _getRequiredWallet5.type;
@@ -1873,9 +1881,9 @@ function retryOn(wallet_network, manager, options) {
1873
1881
  fallbackToOnlyWallet: true
1874
1882
  };
1875
1883
  }
1876
- var _wallet_network$split2 = wallet_network.split('-'),
1877
- wallet = _wallet_network$split2[0],
1878
- network = _wallet_network$split2[1];
1884
+ var _splitWalletNetwork2 = splitWalletNetwork(wallet_network),
1885
+ wallet = _splitWalletNetwork2[0],
1886
+ network = _splitWalletNetwork2[1];
1879
1887
  if (!wallet || !network) {
1880
1888
  return;
1881
1889
  }
@@ -2029,6 +2037,7 @@ function _checkTransactionStatus() {
2029
2037
  currentStep.starknetTransaction = null;
2030
2038
  currentStep.tronApprovalTransaction = null;
2031
2039
  currentStep.tronTransaction = null;
2040
+ currentStep.fromBlockchain = newTransaction.blockChain;
2032
2041
  if (isEvmTransaction(newTransaction)) {
2033
2042
  if (newTransaction.isApprovalTx) currentStep.evmApprovalTransaction = newTransaction;else currentStep.evmTransaction = newTransaction;
2034
2043
  } else if (isCosmosTransaction(newTransaction)) {
@@ -2295,7 +2304,7 @@ function executeTransaction(_x) {
2295
2304
  function _executeTransaction() {
2296
2305
  _executeTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(actions) {
2297
2306
  var _context$_queue;
2298
- var getStorage, context, meta, wallets, providers, isClaimed, requestBlock, swap, currentStep, isWrongAddress, _getRequiredWallet, type, address, description, blockedFor, needsToBlockQueue, _blockedFor, networkMatched, fromBlockchain, details, _blockedFor2;
2307
+ 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;
2299
2308
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2300
2309
  while (1) switch (_context.prev = _context.next) {
2301
2310
  case 0:
@@ -2314,25 +2323,31 @@ function _executeTransaction() {
2314
2323
  /* Make sure wallet is connected and also the connected wallet is matched with tx by checking address. */
2315
2324
  isWrongAddress = !isRequiredWalletConnected(swap, context.state);
2316
2325
  if (!isWrongAddress) {
2317
- _context.next = 14;
2326
+ _context.next = 15;
2318
2327
  break;
2319
2328
  }
2320
2329
  _getRequiredWallet = getRequiredWallet(swap), type = _getRequiredWallet.type, address = _getRequiredWallet.address;
2321
- description = !wallets ? ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type) : ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address);
2330
+ isWalletInCompatible = wallets == null ? void 0 : (_wallets$blockchains = wallets.blockchains) == null ? void 0 : _wallets$blockchains.find(function (w) {
2331
+ var _w$accounts;
2332
+ return !((_w$accounts = w.accounts) != null && _w$accounts.find(function (account) {
2333
+ return account.walletType === type;
2334
+ }));
2335
+ });
2336
+ description = !wallets || isWalletInCompatible ? ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type) : ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address);
2322
2337
  blockedFor = {
2323
2338
  reason: BlockReason.WAIT_FOR_CONNECT_WALLET,
2324
2339
  description: description
2325
2340
  };
2326
2341
  requestBlock(blockedFor);
2327
2342
  return _context.abrupt("return");
2328
- case 14:
2343
+ case 15:
2329
2344
  /*
2330
2345
  For avoiding conflict by making too many requests to wallet, we need to make sure
2331
2346
  We only run one request at a time (In parallel mode).
2332
2347
  */
2333
2348
  needsToBlockQueue = isNeedBlockQueueForParallel(currentStep);
2334
2349
  if (!(needsToBlockQueue && !isClaimed && context.claimedBy)) {
2335
- _context.next = 19;
2350
+ _context.next = 20;
2336
2351
  break;
2337
2352
  }
2338
2353
  _blockedFor = {
@@ -2342,13 +2357,13 @@ function _executeTransaction() {
2342
2357
  };
2343
2358
  requestBlock(_blockedFor);
2344
2359
  return _context.abrupt("return");
2345
- case 19:
2346
- _context.next = 21;
2360
+ case 20:
2361
+ _context.next = 22;
2347
2362
  return isNetworkMatchedForTransaction(swap, currentStep, wallets, meta, providers);
2348
- case 21:
2363
+ case 22:
2349
2364
  networkMatched = _context.sent;
2350
2365
  if (networkMatched) {
2351
- _context.next = 30;
2366
+ _context.next = 31;
2352
2367
  break;
2353
2368
  }
2354
2369
  fromBlockchain = getCurrentBlockchainOf(swap, currentStep);
@@ -2359,17 +2374,17 @@ function _executeTransaction() {
2359
2374
  };
2360
2375
  requestBlock(_blockedFor2);
2361
2376
  return _context.abrupt("return");
2362
- case 30:
2377
+ case 31:
2363
2378
  // Update network to mark it as network changed successfully.
2364
2379
  updateNetworkStatus(actions, {
2365
2380
  message: '',
2366
2381
  details: 'Wallet network changed successfully',
2367
2382
  status: PendingSwapNetworkStatus.NetworkChanged
2368
2383
  });
2369
- case 31:
2384
+ case 32:
2370
2385
  // All the conditions are met. We can safely send the tx to wallet for sign.
2371
2386
  singTransaction(actions);
2372
- case 32:
2387
+ case 33:
2373
2388
  case "end":
2374
2389
  return _context.stop();
2375
2390
  }