@rango-dev/queue-manager-rango-preset 0.23.0 → 0.24.0

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,16 @@
1
- import type { SwapQueueContext, SwapStorage } from '../types';
2
- import type { ExecuterActions } from '@rango-dev/queue-manager-core';
3
- import type { PendingSwapStep } from 'rango-types';
4
-
1
+ import { ExecuterActions } from '@rango-dev/queue-manager-core';
2
+ import {
3
+ StepEventType,
4
+ SwapActionTypes,
5
+ SwapQueueContext,
6
+ SwapStorage,
7
+ } from '../types';
5
8
  import {
6
9
  getCurrentStep,
7
10
  getLastSuccessfulStep,
8
11
  isTxAlreadyCreated,
9
12
  } from '../helpers';
10
13
  import { notifier } from '../services/eventEmitter';
11
- import { StepEventType, SwapActionTypes } from '../types';
12
14
 
13
15
  /**
14
16
  *
@@ -28,9 +30,7 @@ export function scheduleNextStep({
28
30
  }: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>): void {
29
31
  const swap = getStorage().swapDetails;
30
32
  const currentStep = getCurrentStep(swap);
31
- const isFailed = swap.steps.find(
32
- (step: PendingSwapStep) => step.status === 'failed'
33
- );
33
+ const isFailed = swap.steps.find((step) => step.status === 'failed');
34
34
 
35
35
  if (!!currentStep && !isFailed) {
36
36
  if (isTxAlreadyCreated(swap, currentStep)) {
@@ -84,10 +84,7 @@ export function scheduleNextStep({
84
84
  step: null,
85
85
  });
86
86
 
87
- if (isFailed) {
88
- failed();
89
- } else {
90
- next();
91
- }
87
+ if (isFailed) failed();
88
+ else next();
92
89
  }
93
90
  }
package/src/helpers.ts CHANGED
@@ -1,50 +1,37 @@
1
- /* eslint-disable destructuring/in-params */
2
- /* eslint-disable @typescript-eslint/no-magic-numbers */
3
- /* eslint-disable @typescript-eslint/no-floating-promises */
4
- import type { SwapStatus, Wallet } from './shared';
5
- import type {
6
- ArrayElement,
7
- Step,
8
- SwapQueueContext,
9
- SwapQueueDef,
10
- SwapStorage,
11
- } from './types';
12
- import type {
1
+ import {
13
2
  ExecuterActions,
14
- Manager,
15
3
  QueueInfo,
16
4
  QueueName,
17
5
  QueueType,
18
6
  } from '@rango-dev/queue-manager-core';
19
- import type {
7
+ import {
8
+ ArrayElement,
9
+ BlockReason,
10
+ StepEventType,
11
+ SwapActionTypes,
12
+ SwapQueueContext,
13
+ SwapQueueDef,
14
+ SwapStorage,
15
+ StepExecutionEventStatus,
16
+ StepExecutionBlockedEventStatus,
17
+ Step,
18
+ } from './types';
19
+ import {
20
+ getBlockChainNameFromId,
20
21
  Meta,
21
22
  Network,
22
- Providers,
23
+ Networks,
23
24
  WalletState,
24
25
  WalletType,
25
26
  } from '@rango-dev/wallets-shared';
26
- import type {
27
- CreateTransactionResponse,
28
- EvmBlockchainMeta,
29
- Transaction,
30
- } from 'rango-sdk';
31
- import type {
32
- APIErrorCode,
33
- PendingSwap,
34
- PendingSwapStep,
35
- SignerErrorCode,
36
- StepStatus,
37
- } from 'rango-types';
27
+ import { Providers, readAccountAddress } from '@rango-dev/wallets-react';
38
28
 
39
- import { Status } from '@rango-dev/queue-manager-core';
40
- import { readAccountAddress } from '@rango-dev/wallets-core';
41
29
  import {
42
- getBlockChainNameFromId,
43
- getEvmProvider,
44
- splitWalletNetwork,
45
- } from '@rango-dev/wallets-shared';
46
- import { TransactionType } from 'rango-sdk';
47
- import { PendingSwapNetworkStatus } from 'rango-types';
30
+ Transaction,
31
+ TransactionType,
32
+ EvmBlockchainMeta,
33
+ CreateTransactionResponse,
34
+ } from 'rango-sdk';
48
35
 
49
36
  import {
50
37
  DEFAULT_ERROR_CODE,
@@ -52,30 +39,32 @@ import {
52
39
  ERROR_MESSAGE_WAIT_FOR_WALLET,
53
40
  ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION,
54
41
  } from './constants';
55
- import { httpService } from './services';
56
- import { notifier } from './services/eventEmitter';
42
+ import { Manager } from '@rango-dev/queue-manager-core';
43
+ import { Status } from '@rango-dev/queue-manager-core';
57
44
  import {
58
- getCurrentAddressOf,
59
45
  getCurrentBlockchainOf,
60
46
  getCurrentBlockchainOfOrNull,
61
- getRelatedWallet,
62
- getRelatedWalletOrNull,
63
47
  getScannerUrl,
48
+ getRelatedWalletOrNull,
64
49
  MessageSeverity,
50
+ PendingSwap,
51
+ PendingSwapNetworkStatus,
52
+ PendingSwapStep,
53
+ StepStatus,
54
+ SwapStatus,
55
+ Wallet,
56
+ getRelatedWallet,
57
+ getCurrentAddressOf,
65
58
  } from './shared';
59
+ import { logRPCError } from './shared-sentry';
66
60
  import {
61
+ PrettyError,
67
62
  mapAppErrorCodesToAPIErrorCode,
68
63
  prettifyErrorMessage,
69
- PrettyError,
70
64
  } from './shared-errors';
71
- import { logRPCError } from './shared-sentry';
72
- import {
73
- BlockReason,
74
- StepEventType,
75
- StepExecutionBlockedEventStatus,
76
- StepExecutionEventStatus,
77
- SwapActionTypes,
78
- } from './types';
65
+ import { httpService } from './services';
66
+ import { APIErrorCode, SignerErrorCode } from 'rango-types/lib';
67
+ import { notifier } from './services/eventEmitter';
79
68
 
80
69
  type WhenTaskBlocked = Parameters<NonNullable<SwapQueueDef['whenTaskBlocked']>>;
81
70
  type WhenTaskBlockedEvent = WhenTaskBlocked[0];
@@ -119,9 +108,7 @@ export function inMemoryTransactionsData() {
119
108
  swapTransactionToDataMap[hash] || {},
120
109
  setTransactionDataByHash: (hash: string, data: TransactionData) => {
121
110
  const r = swapTransactionToDataMap[hash];
122
- if (!r) {
123
- swapTransactionToDataMap[hash] = {};
124
- }
111
+ if (!r) swapTransactionToDataMap[hash] = {};
125
112
  swapTransactionToDataMap[hash].response =
126
113
  data.response || swapTransactionToDataMap[hash].response;
127
114
  swapTransactionToDataMap[hash].receiptReceived =
@@ -132,6 +119,29 @@ export function inMemoryTransactionsData() {
132
119
  };
133
120
  }
134
121
 
122
+ /**
123
+ * Sample inputs are:
124
+ * - "metamask-ETH"
125
+ * - "metamask-BSC-BSC:0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
126
+ * - "token-pocket-BSC-BSC:0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
127
+ * Returns "wallet and network" separately, even if the wallet is dashed inside.
128
+ *
129
+ */
130
+
131
+ export function splitWalletNetwork(input: string): string[] {
132
+ const removedAddressInput = input?.split(':')[0] || '';
133
+ const splittedInput = removedAddressInput.split('-');
134
+ const network = splittedInput[splittedInput.length - 1];
135
+ const walletNetwork = splittedInput.slice(0, -1);
136
+
137
+ if (walletNetwork[walletNetwork.length - 1] === network) {
138
+ walletNetwork.pop();
139
+ }
140
+ const wallet = walletNetwork.join('-');
141
+
142
+ return [wallet, network];
143
+ }
144
+
135
145
  /**
136
146
  *
137
147
  * Returns `steps`, if it's a `running` swap.
@@ -203,25 +213,19 @@ export const setCurrentStepTx = (
203
213
  const txType = transaction.type;
204
214
  switch (txType) {
205
215
  case TransactionType.EVM:
206
- if (transaction.isApprovalTx) {
216
+ if (transaction.isApprovalTx)
207
217
  currentStep.evmApprovalTransaction = transaction;
208
- } else {
209
- currentStep.evmTransaction = transaction;
210
- }
218
+ else currentStep.evmTransaction = transaction;
211
219
  break;
212
220
  case TransactionType.TRON:
213
- if (transaction.isApprovalTx) {
221
+ if (transaction.isApprovalTx)
214
222
  currentStep.tronApprovalTransaction = transaction;
215
- } else {
216
- currentStep.tronTransaction = transaction;
217
- }
223
+ else currentStep.tronTransaction = transaction;
218
224
  break;
219
225
  case TransactionType.STARKNET:
220
- if (transaction.isApprovalTx) {
226
+ if (transaction.isApprovalTx)
221
227
  currentStep.starknetApprovalTransaction = transaction;
222
- } else {
223
- currentStep.starknetTransaction = transaction;
224
- }
228
+ else currentStep.starknetTransaction = transaction;
225
229
  break;
226
230
  case TransactionType.COSMOS:
227
231
  currentStep.cosmosTransaction = transaction;
@@ -319,17 +323,12 @@ export function updateSwapStatus({
319
323
  swap,
320
324
  step: currentStep,
321
325
  };
322
- if (!!nextStepStatus && !!currentStep) {
323
- currentStep.status = nextStepStatus;
324
- }
326
+ if (!!nextStepStatus && !!currentStep) currentStep.status = nextStepStatus;
325
327
 
326
- if (nextStatus) {
327
- swap.status = nextStatus;
328
- }
328
+ if (nextStatus) swap.status = nextStatus;
329
329
  swap.hasAlreadyProceededToSign = hasAlreadyProceededToSign;
330
- if (!!nextStatus && ['failed', 'success'].includes(nextStatus)) {
330
+ if (!!nextStatus && ['failed', 'success'].includes(nextStatus))
331
331
  swap.finishTime = new Date().getTime().toString();
332
- }
333
332
 
334
333
  if (!!message || !!details) {
335
334
  swap.extraMessage = message || '';
@@ -342,7 +341,7 @@ export function updateSwapStatus({
342
341
  details && details.includes('Warning')
343
342
  ? 'Swap canceled by user.'
344
343
  : details;
345
- const walletType = getRelatedWalletOrNull(swap, currentStep)?.walletType;
344
+ const walletType = getRelatedWalletOrNull(swap, currentStep!)?.walletType;
346
345
  swap.extraMessageSeverity = MessageSeverity.error;
347
346
 
348
347
  const failureType = mapAppErrorCodesToAPIErrorCode(errorCode);
@@ -362,23 +361,15 @@ export function updateSwapStatus({
362
361
  })
363
362
  .then()
364
363
  .catch();
365
- } else if (!!nextStepStatus && ['running'].includes(nextStepStatus)) {
364
+ } else if (!!nextStepStatus && ['running'].includes(nextStepStatus))
366
365
  swap.extraMessageSeverity = MessageSeverity.info;
367
- } else if (
368
- !!nextStepStatus &&
369
- ['success', 'approved'].includes(nextStepStatus)
370
- ) {
366
+ else if (!!nextStepStatus && ['success', 'approved'].includes(nextStepStatus))
371
367
  swap.extraMessageSeverity = MessageSeverity.success;
372
- } else if (
373
- nextStepStatus &&
374
- ['waitingForApproval'].includes(nextStepStatus)
375
- ) {
368
+ else if (nextStepStatus && ['waitingForApproval'].includes(nextStepStatus))
376
369
  swap.extraMessageSeverity = MessageSeverity.warning;
377
- }
378
370
 
379
- if (nextStepStatus === 'running' && currentStep) {
371
+ if (nextStepStatus === 'running' && currentStep)
380
372
  currentStep.startTransactionTime = new Date().getTime();
381
- }
382
373
 
383
374
  setStorage({
384
375
  ...getStorage(),
@@ -404,7 +395,7 @@ export function setStepTransactionIds(
404
395
  const currentStep = getCurrentStep(swap)!;
405
396
  currentStep.executedTransactionId = txId;
406
397
  currentStep.executedTransactionTime = new Date().getTime().toString();
407
- if (explorerUrl?.url) {
398
+ if (explorerUrl?.url)
408
399
  currentStep.explorerUrl = [
409
400
  ...(currentStep.explorerUrl || []),
410
401
  {
@@ -412,15 +403,11 @@ export function setStepTransactionIds(
412
403
  description: explorerUrl.description || null,
413
404
  },
414
405
  ];
415
- }
416
406
 
417
407
  const isApproval = isApprovalCurrentStepTx(currentStep);
418
408
 
419
- if (isApproval) {
420
- swap.extraMessage = 'Checking approve transaction status ...';
421
- } else {
422
- swap.extraMessage = 'Checking transaction status ...';
423
- }
409
+ if (isApproval) swap.extraMessage = 'Checking approve transaction status ...';
410
+ else swap.extraMessage = 'Checking transaction status ...';
424
411
 
425
412
  swap.extraMessageDetail = '';
426
413
  swap.extraMessageSeverity = MessageSeverity.info;
@@ -460,9 +447,7 @@ export function markRunningSwapAsWaitingForConnectingWallet(
460
447
  ): void {
461
448
  const swap = getStorage().swapDetails as SwapStorage['swapDetails'];
462
449
  const currentStep = getCurrentStep(swap);
463
- if (!currentStep) {
464
- return;
465
- }
450
+ if (!currentStep) return;
466
451
  const currentTime = new Date();
467
452
  swap.lastNotificationTime = currentTime.getTime().toString();
468
453
 
@@ -503,9 +488,7 @@ export function markRunningSwapAsSwitchingNetwork({
503
488
  const swap = getStorage().swapDetails as SwapStorage['swapDetails'];
504
489
 
505
490
  const currentStep = getCurrentStep(swap);
506
- if (!currentStep) {
507
- return;
508
- }
491
+ if (!currentStep) return;
509
492
 
510
493
  // Generate message
511
494
  const { type } = getRequiredWallet(swap);
@@ -546,9 +529,7 @@ export function markRunningSwapAsDependsOnOtherQueues({
546
529
  | undefined {
547
530
  const swap = getStorage().swapDetails as SwapStorage['swapDetails'];
548
531
  const currentStep = getCurrentStep(swap);
549
- if (!currentStep) {
550
- return;
551
- }
532
+ if (!currentStep) return;
552
533
 
553
534
  swap.networkStatusExtraMessage = '';
554
535
  swap.networkStatusExtraMessageDetail = '';
@@ -574,7 +555,7 @@ export function markRunningSwapAsDependsOnOtherQueues({
574
555
  };
575
556
  }
576
557
 
577
- export async function delay(ms: number): Promise<unknown> {
558
+ export function delay(ms: number): Promise<unknown> {
578
559
  return new Promise((res) => setTimeout(res, ms));
579
560
  }
580
561
 
@@ -605,6 +586,23 @@ export function isWalletNull(wallet: Wallet | null): boolean {
605
586
  );
606
587
  }
607
588
 
589
+ /**
590
+ * On our implementation for `wallets` package, We keep the instance in 2 ways
591
+ * If it's a single chain wallet, it returns the instance directly,
592
+ * If it's a multichain wallet, it returns a `Map` of instances.
593
+ * This function will get the `ETHEREUM` instance in both types.
594
+ */
595
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
+ export function getEvmProvider(providers: Providers, type: WalletType): any {
597
+ if (type && providers[type]) {
598
+ // we need this because provider can return an instance or a map of instances, so what you are doing here is try to detect that.
599
+ if (providers[type].size) return providers[type].get(Networks.ETHEREUM);
600
+
601
+ return providers[type];
602
+ }
603
+ return null;
604
+ }
605
+
608
606
  /**
609
607
  * In a `PendingSwap`, each step needs a wallet to proceed,
610
608
  * By using this function we can access what wallet exactly we need to run current step.
@@ -665,9 +663,7 @@ export async function isNetworkMatchedForTransaction(
665
663
  return false;
666
664
  }
667
665
  const fromBlockChain = getCurrentBlockchainOfOrNull(swap, step);
668
- if (!fromBlockChain) {
669
- return false;
670
- }
666
+ if (!fromBlockChain) return false;
671
667
 
672
668
  if (
673
669
  meta.evmBasedChains.find(
@@ -689,15 +685,13 @@ export async function isNetworkMatchedForTransaction(
689
685
  if (
690
686
  blockChain &&
691
687
  blockChain.toLowerCase() === fromBlockChain.toLowerCase()
692
- ) {
688
+ )
693
689
  return true;
694
- }
695
690
  if (
696
691
  blockChain &&
697
692
  blockChain.toLowerCase() !== fromBlockChain.toLowerCase()
698
- ) {
693
+ )
699
694
  return false;
700
- }
701
695
  }
702
696
  }
703
697
  } catch (e) {
@@ -837,9 +831,7 @@ export function onBlockForChangeNetwork(
837
831
  const swap = queue.getStorage().swapDetails as SwapStorage['swapDetails'];
838
832
  const currentStep = getCurrentStep(swap);
839
833
 
840
- if (!currentStep || swap.status !== 'running') {
841
- return;
842
- }
834
+ if (!currentStep || swap.status !== 'running') return;
843
835
 
844
836
  const result = markRunningSwapAsSwitchingNetwork({
845
837
  getStorage: queue.getStorage.bind(queue),
@@ -912,9 +904,7 @@ export function onDependsOnOtherQueues(
912
904
  const claimerId = claimedBy();
913
905
  const isClaimedByAnyQueue = !!claimerId;
914
906
 
915
- if (claimerId === queue.id) {
916
- return;
917
- }
907
+ if (claimerId === queue.id) return;
918
908
 
919
909
  // Check if any queue `claimed` before, if yes, we don't should do anything.
920
910
  if (isClaimedByAnyQueue) {
@@ -970,9 +960,7 @@ export function isRequiredWalletConnected(
970
960
  const walletState = getState(type);
971
961
  const { accounts, connected } = walletState;
972
962
  const connectedAccounts = accounts || [];
973
- if (!connected) {
974
- return { ok: false, reason: 'not_connected' };
975
- }
963
+ if (!connected) return { ok: false, reason: 'not_connected' };
976
964
 
977
965
  const matched = connectedAccounts.some((account) => {
978
966
  const { address: accountAddress } = readAccountAddress(account);
@@ -981,7 +969,7 @@ export function isRequiredWalletConnected(
981
969
  return { ok: matched, reason: 'account_miss_match' };
982
970
  }
983
971
 
984
- export function signTransaction(
972
+ export function singTransaction(
985
973
  actions: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>
986
974
  ): void {
987
975
  const { setTransactionDataByHash } = inMemoryTransactionsData();
@@ -1087,12 +1075,11 @@ export function signTransaction(
1087
1075
  },
1088
1076
  ...updateResult,
1089
1077
  });
1090
- } else {
1078
+ } else
1091
1079
  notifier({
1092
1080
  event: { type: eventType, status: StepExecutionEventStatus.SEND_TX },
1093
1081
  ...updateResult,
1094
1082
  });
1095
- }
1096
1083
 
1097
1084
  if (hasAlreadyProceededToSign) {
1098
1085
  failed();
@@ -1122,9 +1109,7 @@ export function signTransaction(
1122
1109
  onFinish();
1123
1110
  },
1124
1111
  (error) => {
1125
- if (swap.status === 'failed') {
1126
- return;
1127
- }
1112
+ if (swap.status === 'failed') return;
1128
1113
 
1129
1114
  const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
1130
1115
  prettifyErrorMessage(error);
@@ -1168,9 +1153,7 @@ export function checkWaitingForConnectWalletChange(params: {
1168
1153
  const { wallet_network, evmChains, manager } = params;
1169
1154
  const [wallet, network] = splitWalletNetwork(wallet_network);
1170
1155
  // We only need change network for EVM chains.
1171
- if (!evmChains.some((chain) => chain.name == network)) {
1172
- return;
1173
- }
1156
+ if (!evmChains.some((chain) => chain.name == network)) return;
1174
1157
 
1175
1158
  manager?.getAll().forEach((q) => {
1176
1159
  const queueStorage = q.list.getStorage() as SwapStorage | undefined;
@@ -1284,9 +1267,7 @@ export function getRunningSwaps(manager: Manager): PendingSwap[] {
1284
1267
  // retry only on affected queues
1285
1268
  const queueStorage = q.list.getStorage() as SwapStorage | undefined;
1286
1269
  const swap = queueStorage?.swapDetails;
1287
- if (!swap || swap.status !== 'running') {
1288
- return;
1289
- }
1270
+ if (!swap || swap.status !== 'running') return;
1290
1271
  result.push(swap);
1291
1272
  });
1292
1273
  return result;
@@ -1309,11 +1290,9 @@ export function resetRunningSwapNotifsOnPageLoad(runningSwaps: PendingSwap[]) {
1309
1290
  | StepExecutionBlockedEventStatus.WAITING_FOR_QUEUE
1310
1291
  | StepExecutionBlockedEventStatus.WAITING_FOR_WALLET_CONNECT
1311
1292
  | undefined;
1312
- if (
1313
- currentStep?.networkStatus === PendingSwapNetworkStatus.WaitingForQueue
1314
- ) {
1293
+ if (currentStep?.networkStatus === PendingSwapNetworkStatus.WaitingForQueue)
1315
1294
  eventSubtype = StepExecutionBlockedEventStatus.WAITING_FOR_QUEUE;
1316
- } else if (swap?.status === 'running') {
1295
+ else if (swap?.status === 'running') {
1317
1296
  eventSubtype = StepExecutionBlockedEventStatus.WAITING_FOR_WALLET_CONNECT;
1318
1297
  }
1319
1298
  if (!!eventType && !!notifier) {
@@ -1398,25 +1377,22 @@ export function retryOn(
1398
1377
  finalQueueToBeRun = onlyWalletMatched[0];
1399
1378
  }
1400
1379
 
1401
- if (!canSwitchNetworkTo?.(wallet, network)) {
1402
- finalQueueToBeRun?.unblock();
1403
- } else {
1404
- finalQueueToBeRun?.checkBlock();
1405
- }
1380
+ if (!canSwitchNetworkTo?.(wallet, network)) finalQueueToBeRun?.unblock();
1381
+ else finalQueueToBeRun?.checkBlock();
1406
1382
  }
1407
1383
 
1408
- /*
1409
- *For avoiding conflict by making too many requests to wallet, we need to make sure
1410
- *We only run one request at a time (In parallel mode).
1411
- */
1384
+ /*
1385
+ For avoiding conflict by making too many requests to wallet, we need to make sure
1386
+ We only run one request at a time (In parallel mode).
1387
+ */
1412
1388
  export function isNeedBlockQueueForParallel(step: PendingSwapStep): boolean {
1413
1389
  return !!step.evmTransaction || !!step.evmApprovalTransaction;
1414
1390
  }
1415
1391
 
1416
1392
  /*
1417
- *Create transaction endpoint doesn't return error code on http status code,
1418
- *For backward compatibilty with server and sdk, we use this wrapper to reject the promise.
1419
- */
1393
+ Create transaction endpoint doesn't return error code on http status code,
1394
+ For backward compatibilty with server and sdk, we use this wrapper to reject the promise.
1395
+ */
1420
1396
  export async function throwOnOK(
1421
1397
  rawResponse: Promise<CreateTransactionResponse>
1422
1398
  ): Promise<CreateTransactionResponse> {
@@ -1462,9 +1438,7 @@ export function cancelSwap(
1462
1438
  });
1463
1439
 
1464
1440
  reset();
1465
- if (manager) {
1466
- manager?.retry();
1467
- }
1441
+ if (manager) manager?.retry();
1468
1442
 
1469
1443
  return updateResult;
1470
1444
  }
package/src/index.ts CHANGED
@@ -33,21 +33,29 @@ export {
33
33
  StepExecutionEventStatus,
34
34
  StepExecutionBlockedEventStatus,
35
35
  } from './types';
36
- export type { PendingSwapWithQueueID, EventType } from './shared';
36
+ export type {
37
+ PendingSwapWithQueueID,
38
+ PendingSwapStep,
39
+ PendingSwap,
40
+ EventType,
41
+ } from './shared';
37
42
  export {
38
43
  getCurrentBlockchainOfOrNull,
39
44
  getRelatedWalletOrNull,
40
45
  getRelatedWallet,
41
46
  MessageSeverity,
47
+ PendingSwapNetworkStatus,
42
48
  calculatePendingSwap,
43
49
  } from './shared';
44
50
  export {
45
51
  updateSwapStatus,
46
52
  checkWaitingForNetworkChange,
47
53
  getCurrentStep,
54
+ getEvmProvider,
48
55
  cancelSwap,
49
56
  getRequiredWallet,
50
57
  getRunningSwaps,
58
+ splitWalletNetwork,
51
59
  resetRunningSwapNotifsOnPageLoad,
52
60
  isApprovalTX,
53
61
  getLastSuccessfulStep,
package/src/migration.ts CHANGED
@@ -1,9 +1,11 @@
1
- import type { PersistedQueue } from '@rango-dev/queue-manager-core';
2
- import type { PendingSwap } from 'rango-types';
3
-
4
- import { DB_NAME, Persistor, Status } from '@rango-dev/queue-manager-core';
1
+ import {
2
+ PersistedQueue,
3
+ Persistor,
4
+ Status,
5
+ DB_NAME,
6
+ } from '@rango-dev/queue-manager-core';
5
7
  import { v4 as uuid } from 'uuid';
6
-
8
+ import { PendingSwap } from './shared';
7
9
  import { SwapActionTypes } from './types';
8
10
 
9
11
  const MIGRATED_KEY = 'migratedToQueueManager';
@@ -47,9 +49,9 @@ async function migration(): Promise<boolean> {
47
49
  const convertedSwaps: PersistedQueue[] = [];
48
50
 
49
51
  swaps.forEach((swap) => {
50
- /*
51
- *For running task we need to add some more work
52
- *We need to create a queue task to be run and resume the running task from queue manager.
52
+ /*
53
+ For running task we need to add some more work
54
+ We need to create a queue task to be run and resume the running task from queue manager.
53
55
  */
54
56
  if (swap.status === 'running') {
55
57
  const taskId = uuid();
@@ -110,9 +112,7 @@ async function migration(): Promise<boolean> {
110
112
  // Getting an instance from persistor, so we can directly put our data inside it.
111
113
  const persistor = new Persistor();
112
114
 
113
- const promises = convertedSwaps.map(async (queue) =>
114
- persistor.insertQueue(queue)
115
- );
115
+ const promises = convertedSwaps.map((queue) => persistor.insertQueue(queue));
116
116
  await Promise.all(promises);
117
117
 
118
118
  // Mark as the data has been successfully migrated.