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