@rango-dev/queue-manager-rango-preset 0.1.10-next.87 → 0.1.10-next.89
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.
- package/dist/helpers.d.ts +7 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/migration.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +224 -168
- package/dist/queue-manager-rango-preset.cjs.development.js.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.production.min.js +1 -1
- package/dist/queue-manager-rango-preset.cjs.production.min.js.map +1 -1
- package/dist/queue-manager-rango-preset.esm.js +225 -169
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/shared.d.ts +2 -1
- package/dist/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers.ts +259 -200
- package/src/migration.ts +13 -1
- package/src/shared.ts +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WalletType, Network, getBlockChainNameFromId } from '@rango-dev/wallets-shared';
|
|
2
2
|
import { readAccountAddress } from '@rango-dev/wallets-core';
|
|
3
3
|
import { RangoClient, TransactionType } from 'rango-sdk';
|
|
4
|
-
import { Status, Persistor } from '@rango-dev/queue-manager-core';
|
|
4
|
+
import { Status, Persistor, DB_NAME } from '@rango-dev/queue-manager-core';
|
|
5
5
|
import { isSignerErrorCode, SignerErrorCode, SignerError } from 'rango-types';
|
|
6
6
|
import { captureException } from '@sentry/browser';
|
|
7
7
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
@@ -730,11 +730,13 @@ function updateSwapStatus(_ref) {
|
|
|
730
730
|
message = _ref.message,
|
|
731
731
|
details = _ref.details,
|
|
732
732
|
_ref$errorCode = _ref.errorCode,
|
|
733
|
-
errorCode = _ref$errorCode === void 0 ? null : _ref$errorCode
|
|
733
|
+
errorCode = _ref$errorCode === void 0 ? null : _ref$errorCode,
|
|
734
|
+
hasAlreadyProceededToSign = _ref.hasAlreadyProceededToSign;
|
|
734
735
|
var swap = getStorage().swapDetails;
|
|
735
736
|
var currentStep = getCurrentStep(swap);
|
|
736
737
|
if (!!nextStepStatus && !!currentStep) currentStep.status = nextStepStatus;
|
|
737
738
|
if (!!nextStatus) swap.status = nextStatus;
|
|
739
|
+
swap.hasAlreadyProceededToSign = hasAlreadyProceededToSign;
|
|
738
740
|
if (!!nextStatus && ['failed', 'success'].includes(nextStatus)) swap.finishTime = new Date().getTime().toString();
|
|
739
741
|
if (!!message) swap.extraMessage = message;
|
|
740
742
|
if (!!details) swap.extraMessageDetail = details;
|
|
@@ -747,7 +749,7 @@ function updateSwapStatus(_ref) {
|
|
|
747
749
|
httpService.reportFailure({
|
|
748
750
|
requestId: swap.requestId,
|
|
749
751
|
step: (currentStep == null ? void 0 : currentStep.id) || 1,
|
|
750
|
-
eventType: mapAppErrorCodesToAPIErrorCode(errorCode),
|
|
752
|
+
eventType: mapAppErrorCodesToAPIErrorCode(hasAlreadyProceededToSign ? APIErrorCode.TX_FAIL : errorCode),
|
|
751
753
|
reason: errorReason || '',
|
|
752
754
|
data: walletType ? {
|
|
753
755
|
wallet: walletType
|
|
@@ -767,6 +769,7 @@ function setStepTransactionIds(_ref2, txId, eventType, notifier) {
|
|
|
767
769
|
var getStorage = _ref2.getStorage,
|
|
768
770
|
setStorage = _ref2.setStorage;
|
|
769
771
|
var swap = getStorage().swapDetails;
|
|
772
|
+
swap.hasAlreadyProceededToSign = null;
|
|
770
773
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
771
774
|
var currentStep = getCurrentStep(swap);
|
|
772
775
|
currentStep.executedTransactionId = txId || currentStep.executedTransactionId;
|
|
@@ -779,6 +782,15 @@ function setStepTransactionIds(_ref2, txId, eventType, notifier) {
|
|
|
779
782
|
step: currentStep
|
|
780
783
|
});
|
|
781
784
|
}
|
|
785
|
+
function getSwapNotitfication(eventType, updateResult) {
|
|
786
|
+
if (updateResult.swap.hasAlreadyProceededToSign) {
|
|
787
|
+
return _extends({
|
|
788
|
+
eventType: 'transaction_expired'
|
|
789
|
+
}, updateResult);
|
|
790
|
+
} else return _extends({
|
|
791
|
+
eventType: eventType
|
|
792
|
+
}, updateResult);
|
|
793
|
+
}
|
|
782
794
|
/**
|
|
783
795
|
* If a swap needs a wallet to be connected,
|
|
784
796
|
* By calling this function some related fields will be updated to show a correct message and state for notfiying the user.
|
|
@@ -1470,187 +1482,200 @@ function singTransaction(actions) {
|
|
|
1470
1482
|
});
|
|
1471
1483
|
return;
|
|
1472
1484
|
}
|
|
1473
|
-
var
|
|
1485
|
+
var hasAlreadyProceededToSign = typeof swap.hasAlreadyProceededToSign === 'boolean';
|
|
1486
|
+
var executeMessage = hasAlreadyProceededToSign ? 'Transaction is expired. Please try again' : 'executing transaction';
|
|
1474
1487
|
var executeDetails = "" + (sourceWallet.walletType === WalletType.WALLET_CONNECT ? 'Check your mobile phone' : '');
|
|
1475
1488
|
if (!!transferTransaction) {
|
|
1476
1489
|
var _updateResult3 = updateSwapStatus({
|
|
1477
1490
|
getStorage: getStorage,
|
|
1478
1491
|
setStorage: setStorage,
|
|
1479
|
-
nextStepStatus: 'running',
|
|
1492
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1493
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1480
1494
|
message: executeMessage,
|
|
1481
|
-
details: executeDetails
|
|
1495
|
+
details: executeDetails,
|
|
1496
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1482
1497
|
});
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1498
|
+
var notification = getSwapNotitfication('confirm_transfer', _updateResult3);
|
|
1499
|
+
notifier(notification);
|
|
1500
|
+
if (notification.eventType !== 'transaction_expired') {
|
|
1501
|
+
walletSigners.getSigner(TransactionType.TRANSFER).signAndSendTx(transferTransaction, walletAddress, null).then(function (txId) {
|
|
1502
|
+
setStepTransactionIds(actions, txId, 'transfer_confirmed', notifier);
|
|
1503
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1504
|
+
next();
|
|
1505
|
+
onFinish();
|
|
1506
|
+
}, function (error) {
|
|
1507
|
+
if (swap.status === 'failed') return;
|
|
1508
|
+
var _prettifyErrorMessage4 = prettifyErrorMessage(error),
|
|
1509
|
+
extraMessage = _prettifyErrorMessage4.extraMessage,
|
|
1510
|
+
extraMessageDetail = _prettifyErrorMessage4.extraMessageDetail,
|
|
1511
|
+
extraMessageErrorCode = _prettifyErrorMessage4.extraMessageErrorCode;
|
|
1512
|
+
var updateResult = updateSwapStatus({
|
|
1513
|
+
getStorage: getStorage,
|
|
1514
|
+
setStorage: setStorage,
|
|
1515
|
+
nextStatus: 'failed',
|
|
1516
|
+
nextStepStatus: 'failed',
|
|
1517
|
+
message: extraMessage,
|
|
1518
|
+
details: extraMessageDetail,
|
|
1519
|
+
errorCode: extraMessageErrorCode
|
|
1520
|
+
});
|
|
1521
|
+
notifier(_extends({
|
|
1522
|
+
eventType: 'transfer_rejected'
|
|
1523
|
+
}, updateResult));
|
|
1524
|
+
failed();
|
|
1525
|
+
onFinish();
|
|
1505
1526
|
});
|
|
1506
|
-
|
|
1507
|
-
eventType: 'transfer_rejected'
|
|
1508
|
-
}, updateResult));
|
|
1509
|
-
failed();
|
|
1510
|
-
onFinish();
|
|
1511
|
-
});
|
|
1527
|
+
}
|
|
1512
1528
|
} else if (!!evmTransaction) {
|
|
1513
1529
|
var _updateResult4 = updateSwapStatus({
|
|
1514
1530
|
getStorage: getStorage,
|
|
1515
1531
|
setStorage: setStorage,
|
|
1516
|
-
nextStepStatus: 'running',
|
|
1532
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1533
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1517
1534
|
message: executeMessage,
|
|
1518
|
-
details: executeDetails
|
|
1535
|
+
details: executeDetails,
|
|
1536
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1519
1537
|
});
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1538
|
+
var _notification = getSwapNotitfication('calling_smart_contract', _updateResult4);
|
|
1539
|
+
notifier(_notification);
|
|
1540
|
+
if (_notification.eventType !== 'transaction_expired') {
|
|
1541
|
+
walletSigners.getSigner(TransactionType.EVM).signAndSendTx(evmTransaction, walletAddress, null).then(function (id) {
|
|
1542
|
+
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1543
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1544
|
+
next();
|
|
1545
|
+
onFinish();
|
|
1546
|
+
}, function (error) {
|
|
1547
|
+
var _error$root10, _error$root11, _error$root12;
|
|
1548
|
+
if (swap.status === 'failed') return;
|
|
1549
|
+
var _prettifyErrorMessage5 = prettifyErrorMessage(error),
|
|
1550
|
+
extraMessage = _prettifyErrorMessage5.extraMessage,
|
|
1551
|
+
extraMessageDetail = _prettifyErrorMessage5.extraMessageDetail,
|
|
1552
|
+
extraMessageErrorCode = _prettifyErrorMessage5.extraMessageErrorCode;
|
|
1553
|
+
if (error && error != null && error.root && error != null && (_error$root10 = error.root) != null && _error$root10.message && error != null && (_error$root11 = error.root) != null && _error$root11.code && error != null && (_error$root12 = error.root) != null && _error$root12.reason) {
|
|
1554
|
+
logRPCError(error.root, swap, currentStep, sourceWallet == null ? void 0 : sourceWallet.walletType);
|
|
1555
|
+
}
|
|
1556
|
+
var updateResult = updateSwapStatus({
|
|
1557
|
+
getStorage: getStorage,
|
|
1558
|
+
setStorage: setStorage,
|
|
1559
|
+
nextStatus: 'failed',
|
|
1560
|
+
nextStepStatus: 'failed',
|
|
1561
|
+
message: extraMessage,
|
|
1562
|
+
details: extraMessageDetail,
|
|
1563
|
+
errorCode: extraMessageErrorCode
|
|
1564
|
+
});
|
|
1565
|
+
notifier(_extends({
|
|
1566
|
+
eventType: 'smart_contract_call_failed'
|
|
1567
|
+
}, updateResult));
|
|
1568
|
+
failed();
|
|
1569
|
+
onFinish();
|
|
1546
1570
|
});
|
|
1547
|
-
|
|
1548
|
-
eventType: 'smart_contract_call_failed'
|
|
1549
|
-
}, updateResult));
|
|
1550
|
-
failed();
|
|
1551
|
-
onFinish();
|
|
1552
|
-
});
|
|
1571
|
+
}
|
|
1553
1572
|
} else if (!!cosmosTransaction) {
|
|
1554
1573
|
var _updateResult5 = updateSwapStatus({
|
|
1555
1574
|
getStorage: getStorage,
|
|
1556
1575
|
setStorage: setStorage,
|
|
1557
|
-
nextStepStatus: 'running',
|
|
1576
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1577
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1558
1578
|
message: executeMessage,
|
|
1559
|
-
details: executeDetails
|
|
1579
|
+
details: executeDetails,
|
|
1580
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1560
1581
|
});
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1582
|
+
var _notification2 = getSwapNotitfication('calling_smart_contract', _updateResult5);
|
|
1583
|
+
notifier(_notification2);
|
|
1584
|
+
if (_notification2.eventType !== 'transaction_expired') {
|
|
1585
|
+
// If keplr wallet is executing contracts on terra, throw error. keplr doesn't support transfer or execute contracts. only IBC messages are supported
|
|
1586
|
+
if (((currentStep == null ? void 0 : currentStep.swapperId.toString()) === 'TerraSwap' || (currentStep == null ? void 0 : currentStep.swapperId.toString()) === 'ThorChain' && (currentStep == null ? void 0 : currentStep.fromBlockchain) === Network.TERRA || (currentStep == null ? void 0 : currentStep.swapperId.toString()) === 'Terra Bridge' && currentStep.fromBlockchain === Network.TERRA) &&
|
|
1587
|
+
// here we must allow ibc on terrastatus
|
|
1588
|
+
sourceWallet.walletType === WalletType.KEPLR) {
|
|
1589
|
+
var _prettifyErrorMessage6 = prettifyErrorMessage('Keplr only supports IBC Transactions on Terra. ' + 'Using Terra Bridge, TerraSwap and THORChain is not possible with Keplr. Please use TerraStation or Leap wallet'),
|
|
1590
|
+
extraMessage = _prettifyErrorMessage6.extraMessage,
|
|
1591
|
+
extraMessageDetail = _prettifyErrorMessage6.extraMessageDetail,
|
|
1592
|
+
extraMessageErrorCode = _prettifyErrorMessage6.extraMessageErrorCode;
|
|
1593
|
+
var _updateResult6 = updateSwapStatus({
|
|
1594
|
+
getStorage: getStorage,
|
|
1595
|
+
setStorage: setStorage,
|
|
1596
|
+
nextStatus: 'failed',
|
|
1597
|
+
nextStepStatus: 'failed',
|
|
1598
|
+
message: extraMessage,
|
|
1599
|
+
details: extraMessageDetail,
|
|
1600
|
+
errorCode: extraMessageErrorCode
|
|
1601
|
+
});
|
|
1602
|
+
notifier(_extends({
|
|
1603
|
+
eventType: 'smart_contract_call_failed'
|
|
1604
|
+
}, _updateResult6));
|
|
1605
|
+
failed();
|
|
1606
|
+
onFinish();
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
walletSigners.getSigner(TransactionType.COSMOS).signAndSendTx(cosmosTransaction, walletAddress, null).then(
|
|
1610
|
+
// todo
|
|
1611
|
+
function (id) {
|
|
1612
|
+
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1613
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1614
|
+
next();
|
|
1615
|
+
onFinish();
|
|
1616
|
+
}, function (error) {
|
|
1617
|
+
if (swap.status === 'failed') return;
|
|
1618
|
+
var _prettifyErrorMessage7 = prettifyErrorMessage(error),
|
|
1619
|
+
extraMessage = _prettifyErrorMessage7.extraMessage,
|
|
1620
|
+
extraMessageDetail = _prettifyErrorMessage7.extraMessageDetail,
|
|
1621
|
+
extraMessageErrorCode = _prettifyErrorMessage7.extraMessageErrorCode;
|
|
1622
|
+
var updateResult = updateSwapStatus({
|
|
1623
|
+
getStorage: getStorage,
|
|
1624
|
+
setStorage: setStorage,
|
|
1625
|
+
nextStatus: 'failed',
|
|
1626
|
+
nextStepStatus: 'failed',
|
|
1627
|
+
message: extraMessage,
|
|
1628
|
+
details: extraMessageDetail,
|
|
1629
|
+
errorCode: extraMessageErrorCode
|
|
1630
|
+
});
|
|
1631
|
+
notifier(_extends({
|
|
1632
|
+
eventType: 'smart_contract_call_failed'
|
|
1633
|
+
}, updateResult));
|
|
1634
|
+
failed();
|
|
1635
|
+
onFinish();
|
|
1580
1636
|
});
|
|
1581
|
-
notifier(_extends({
|
|
1582
|
-
eventType: 'smart_contract_call_failed'
|
|
1583
|
-
}, _updateResult6));
|
|
1584
|
-
failed();
|
|
1585
|
-
onFinish();
|
|
1586
|
-
return;
|
|
1587
1637
|
}
|
|
1588
|
-
walletSigners.getSigner(TransactionType.COSMOS).signAndSendTx(cosmosTransaction, walletAddress, null).then(
|
|
1589
|
-
// todo
|
|
1590
|
-
function (id) {
|
|
1591
|
-
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1592
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1593
|
-
next();
|
|
1594
|
-
onFinish();
|
|
1595
|
-
}, function (error) {
|
|
1596
|
-
if (swap.status === 'failed') return;
|
|
1597
|
-
var _prettifyErrorMessage7 = prettifyErrorMessage(error),
|
|
1598
|
-
extraMessage = _prettifyErrorMessage7.extraMessage,
|
|
1599
|
-
extraMessageDetail = _prettifyErrorMessage7.extraMessageDetail,
|
|
1600
|
-
extraMessageErrorCode = _prettifyErrorMessage7.extraMessageErrorCode;
|
|
1601
|
-
var updateResult = updateSwapStatus({
|
|
1602
|
-
getStorage: getStorage,
|
|
1603
|
-
setStorage: setStorage,
|
|
1604
|
-
nextStatus: 'failed',
|
|
1605
|
-
nextStepStatus: 'failed',
|
|
1606
|
-
message: extraMessage,
|
|
1607
|
-
details: extraMessageDetail,
|
|
1608
|
-
errorCode: extraMessageErrorCode
|
|
1609
|
-
});
|
|
1610
|
-
notifier(_extends({
|
|
1611
|
-
eventType: 'smart_contract_call_failed'
|
|
1612
|
-
}, updateResult));
|
|
1613
|
-
failed();
|
|
1614
|
-
onFinish();
|
|
1615
|
-
});
|
|
1616
1638
|
} else if (!!solanaTransaction) {
|
|
1617
1639
|
var _updateResult7 = updateSwapStatus({
|
|
1618
1640
|
getStorage: getStorage,
|
|
1619
1641
|
setStorage: setStorage,
|
|
1620
|
-
nextStepStatus: 'running',
|
|
1642
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1643
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1621
1644
|
message: executeMessage,
|
|
1622
|
-
details: executeDetails
|
|
1645
|
+
details: executeDetails,
|
|
1646
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1623
1647
|
});
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1648
|
+
var _notification3 = getSwapNotitfication('calling_smart_contract', _updateResult7);
|
|
1649
|
+
notifier(_notification3);
|
|
1650
|
+
if (_notification3.eventType !== 'transaction_expired') {
|
|
1651
|
+
var tx = solanaTransaction;
|
|
1652
|
+
walletSigners.getSigner(TransactionType.SOLANA).signAndSendTx(tx, walletAddress, null).then(function (txId) {
|
|
1653
|
+
setStepTransactionIds(actions, txId, 'smart_contract_called', notifier);
|
|
1654
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1655
|
+
next();
|
|
1656
|
+
onFinish();
|
|
1657
|
+
}, function (error) {
|
|
1658
|
+
if (swap.status === 'failed') return;
|
|
1659
|
+
var _prettifyErrorMessage8 = prettifyErrorMessage(error),
|
|
1660
|
+
extraMessage = _prettifyErrorMessage8.extraMessage,
|
|
1661
|
+
extraMessageDetail = _prettifyErrorMessage8.extraMessageDetail,
|
|
1662
|
+
extraMessageErrorCode = _prettifyErrorMessage8.extraMessageErrorCode;
|
|
1663
|
+
var updateResult = updateSwapStatus({
|
|
1664
|
+
getStorage: getStorage,
|
|
1665
|
+
setStorage: setStorage,
|
|
1666
|
+
nextStatus: 'failed',
|
|
1667
|
+
nextStepStatus: 'failed',
|
|
1668
|
+
message: extraMessage,
|
|
1669
|
+
details: extraMessageDetail,
|
|
1670
|
+
errorCode: extraMessageErrorCode
|
|
1671
|
+
});
|
|
1672
|
+
notifier(_extends({
|
|
1673
|
+
eventType: 'smart_contract_call_failed'
|
|
1674
|
+
}, updateResult));
|
|
1675
|
+
failed();
|
|
1676
|
+
onFinish();
|
|
1647
1677
|
});
|
|
1648
|
-
|
|
1649
|
-
eventType: 'smart_contract_call_failed'
|
|
1650
|
-
}, updateResult));
|
|
1651
|
-
failed();
|
|
1652
|
-
onFinish();
|
|
1653
|
-
});
|
|
1678
|
+
}
|
|
1654
1679
|
} else if (!!tronTransaction) {
|
|
1655
1680
|
var _updateResult8 = updateSwapStatus({
|
|
1656
1681
|
getStorage: getStorage,
|
|
@@ -2358,28 +2383,59 @@ var MIGRATED_KEY = 'migratedToQueueManager';
|
|
|
2358
2383
|
function migrated() {
|
|
2359
2384
|
return !!window.localStorage.getItem(MIGRATED_KEY);
|
|
2360
2385
|
}
|
|
2386
|
+
function hasQueueManagerOnIDB() {
|
|
2387
|
+
return _hasQueueManagerOnIDB.apply(this, arguments);
|
|
2388
|
+
}
|
|
2361
2389
|
/**
|
|
2362
2390
|
*
|
|
2363
2391
|
* By calling this function, we first check if the data already migrated or not,
|
|
2364
2392
|
* If not, starting to migrating to IndexedDb with proper format that queue manager is understand.
|
|
2365
2393
|
*
|
|
2366
2394
|
*/
|
|
2395
|
+
function _hasQueueManagerOnIDB() {
|
|
2396
|
+
_hasQueueManagerOnIDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2397
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2398
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2399
|
+
case 0:
|
|
2400
|
+
_context.prev = 0;
|
|
2401
|
+
_context.next = 3;
|
|
2402
|
+
return window.indexedDB.databases();
|
|
2403
|
+
case 3:
|
|
2404
|
+
return _context.abrupt("return", _context.sent.map(function (db) {
|
|
2405
|
+
return db.name;
|
|
2406
|
+
}).includes(DB_NAME));
|
|
2407
|
+
case 6:
|
|
2408
|
+
_context.prev = 6;
|
|
2409
|
+
_context.t0 = _context["catch"](0);
|
|
2410
|
+
return _context.abrupt("return", false);
|
|
2411
|
+
case 9:
|
|
2412
|
+
case "end":
|
|
2413
|
+
return _context.stop();
|
|
2414
|
+
}
|
|
2415
|
+
}, _callee, null, [[0, 6]]);
|
|
2416
|
+
}));
|
|
2417
|
+
return _hasQueueManagerOnIDB.apply(this, arguments);
|
|
2418
|
+
}
|
|
2367
2419
|
function migration() {
|
|
2368
2420
|
return _migration.apply(this, arguments);
|
|
2369
2421
|
}
|
|
2370
2422
|
function _migration() {
|
|
2371
|
-
_migration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2372
|
-
var swapsFromStorage, swaps, convertedSwaps, persistor, promises;
|
|
2373
|
-
return _regeneratorRuntime().wrap(function
|
|
2374
|
-
while (1) switch (
|
|
2423
|
+
_migration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2424
|
+
var swapsFromStorage, hasIndexDB, swaps, convertedSwaps, persistor, promises;
|
|
2425
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2426
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2375
2427
|
case 0:
|
|
2376
|
-
swapsFromStorage = window.localStorage.getItem('pendingSwaps');
|
|
2377
|
-
|
|
2378
|
-
|
|
2428
|
+
swapsFromStorage = window.localStorage.getItem('pendingSwaps');
|
|
2429
|
+
_context2.next = 3;
|
|
2430
|
+
return hasQueueManagerOnIDB();
|
|
2431
|
+
case 3:
|
|
2432
|
+
hasIndexDB = _context2.sent;
|
|
2433
|
+
if (!(!swapsFromStorage || migrated() || hasIndexDB)) {
|
|
2434
|
+
_context2.next = 6;
|
|
2379
2435
|
break;
|
|
2380
2436
|
}
|
|
2381
|
-
return
|
|
2382
|
-
case
|
|
2437
|
+
return _context2.abrupt("return", true);
|
|
2438
|
+
case 6:
|
|
2383
2439
|
// For old users, but they didn't do any swaps yet.
|
|
2384
2440
|
swaps = JSON.parse(swapsFromStorage);
|
|
2385
2441
|
convertedSwaps = [];
|
|
@@ -2442,17 +2498,17 @@ function _migration() {
|
|
|
2442
2498
|
promises = convertedSwaps.map(function (queue) {
|
|
2443
2499
|
return persistor.insertQueue(queue);
|
|
2444
2500
|
});
|
|
2445
|
-
|
|
2501
|
+
_context2.next = 13;
|
|
2446
2502
|
return Promise.all(promises);
|
|
2447
|
-
case
|
|
2503
|
+
case 13:
|
|
2448
2504
|
// Mark as the data has been successfully migrated.
|
|
2449
2505
|
window.localStorage.setItem(MIGRATED_KEY, '1');
|
|
2450
|
-
return
|
|
2451
|
-
case
|
|
2506
|
+
return _context2.abrupt("return", true);
|
|
2507
|
+
case 15:
|
|
2452
2508
|
case "end":
|
|
2453
|
-
return
|
|
2509
|
+
return _context2.stop();
|
|
2454
2510
|
}
|
|
2455
|
-
},
|
|
2511
|
+
}, _callee2);
|
|
2456
2512
|
}));
|
|
2457
2513
|
return _migration.apply(this, arguments);
|
|
2458
2514
|
}
|