@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
package/dist/helpers.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Meta, Network, WalletState, WalletType } from '@rango-dev/wallets-share
|
|
|
4
4
|
import { Providers } from '@rango-dev/wallets-core';
|
|
5
5
|
import { TronTransaction, StarknetTransaction, CosmosTransaction, EvmTransaction, SolanaTransaction, Transfer as TransferTransaction, Transaction, EvmBlockchainMeta } from 'rango-sdk';
|
|
6
6
|
import { Manager } from '@rango-dev/queue-manager-core';
|
|
7
|
-
import { EventType, PendingSwap, PendingSwapNetworkStatus, PendingSwapStep, StepStatus, SwapStatus, Wallet, WalletTypeAndAddress } from './shared';
|
|
7
|
+
import { EventType, PendingSwap, PendingSwapNetworkStatus, PendingSwapStep, StepStatus, SwapStatus, Wallet, WalletTypeAndAddress, SwapProgressNotification } from './shared';
|
|
8
8
|
declare type WhenTaskBlocked = Parameters<NonNullable<SwapQueueDef['whenTaskBlocked']>>;
|
|
9
9
|
declare type WhenTaskBlockedEvent = WhenTaskBlocked[0];
|
|
10
10
|
declare type WhenTaskBlockedMeta = WhenTaskBlocked[1];
|
|
@@ -19,7 +19,7 @@ export declare const getCurrentStep: (swap: PendingSwap) => PendingSwapStep | nu
|
|
|
19
19
|
* When we are doing a swap, there are some common fields that will be updated together.
|
|
20
20
|
* This function helps us to update a swap status and also it will update some more fields like `extraMessageSeverity` based on the input.
|
|
21
21
|
*/
|
|
22
|
-
export declare function updateSwapStatus({ getStorage, setStorage, nextStatus, nextStepStatus, message, details, errorCode, }: {
|
|
22
|
+
export declare function updateSwapStatus({ getStorage, setStorage, nextStatus, nextStepStatus, message, details, errorCode, hasAlreadyProceededToSign, }: {
|
|
23
23
|
getStorage: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>['getStorage'];
|
|
24
24
|
setStorage: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>['setStorage'];
|
|
25
25
|
nextStatus?: SwapStatus;
|
|
@@ -27,11 +27,16 @@ export declare function updateSwapStatus({ getStorage, setStorage, nextStatus, n
|
|
|
27
27
|
message?: string;
|
|
28
28
|
details?: string | null | undefined;
|
|
29
29
|
errorCode?: string | null;
|
|
30
|
+
hasAlreadyProceededToSign?: boolean;
|
|
30
31
|
}): {
|
|
31
32
|
swap: PendingSwap;
|
|
32
33
|
step: PendingSwapStep | null;
|
|
33
34
|
};
|
|
34
35
|
export declare function setStepTransactionIds({ getStorage, setStorage }: ExecuterActions<SwapStorage, SwapActionTypes>, txId: string | null, eventType: EventType, notifier: SwapQueueContext['notifier']): void;
|
|
36
|
+
export declare function getSwapNotitfication(eventType: EventType, updateResult: {
|
|
37
|
+
swap: PendingSwap;
|
|
38
|
+
step: PendingSwapStep | null;
|
|
39
|
+
}): SwapProgressNotification;
|
|
35
40
|
/**
|
|
36
41
|
* If a swap needs a wallet to be connected,
|
|
37
42
|
* By calling this function some related fields will be updated to show a correct message and state for notfiying the user.
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["src/helpers.ts"],"names":[],"mappings":"AAAA,O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;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,mBAAmB,GACxB,IAAI,CA0BN;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,mBAAmB,GACxB,IAAI,CA8BN;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,mBAAmB,GACxB,IAAI,CAqDN;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,WAAW,GAC1C,OAAO,CAaT;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,eAAe,CAAC,WAAW,EAAE,eAAe,EAAE,gBAAgB,CAAC,GACvE,IAAI,CAgrBN;AAED,wBAAgB,kCAAkC,CAAC,MAAM,EAAE;IACzD,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC,GAAG,IAAI,CAmDP;AAED,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CA8BpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,OAAO,EACjB,OAAO;;CAAiC,GACvC,IAAI,CAsDN;AAMD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAM1E"}
|
package/dist/migration.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["src/migration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["src/migration.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,iBAAS,QAAQ,IAAI,OAAO,CAE3B;AAYD;;;;;GAKG;AACH,iBAAe,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAoF3C;AAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -734,11 +734,13 @@ function updateSwapStatus(_ref) {
|
|
|
734
734
|
message = _ref.message,
|
|
735
735
|
details = _ref.details,
|
|
736
736
|
_ref$errorCode = _ref.errorCode,
|
|
737
|
-
errorCode = _ref$errorCode === void 0 ? null : _ref$errorCode
|
|
737
|
+
errorCode = _ref$errorCode === void 0 ? null : _ref$errorCode,
|
|
738
|
+
hasAlreadyProceededToSign = _ref.hasAlreadyProceededToSign;
|
|
738
739
|
var swap = getStorage().swapDetails;
|
|
739
740
|
var currentStep = getCurrentStep(swap);
|
|
740
741
|
if (!!nextStepStatus && !!currentStep) currentStep.status = nextStepStatus;
|
|
741
742
|
if (!!nextStatus) swap.status = nextStatus;
|
|
743
|
+
swap.hasAlreadyProceededToSign = hasAlreadyProceededToSign;
|
|
742
744
|
if (!!nextStatus && ['failed', 'success'].includes(nextStatus)) swap.finishTime = new Date().getTime().toString();
|
|
743
745
|
if (!!message) swap.extraMessage = message;
|
|
744
746
|
if (!!details) swap.extraMessageDetail = details;
|
|
@@ -751,7 +753,7 @@ function updateSwapStatus(_ref) {
|
|
|
751
753
|
httpService.reportFailure({
|
|
752
754
|
requestId: swap.requestId,
|
|
753
755
|
step: (currentStep == null ? void 0 : currentStep.id) || 1,
|
|
754
|
-
eventType: mapAppErrorCodesToAPIErrorCode(errorCode),
|
|
756
|
+
eventType: mapAppErrorCodesToAPIErrorCode(hasAlreadyProceededToSign ? APIErrorCode.TX_FAIL : errorCode),
|
|
755
757
|
reason: errorReason || '',
|
|
756
758
|
data: walletType ? {
|
|
757
759
|
wallet: walletType
|
|
@@ -771,6 +773,7 @@ function setStepTransactionIds(_ref2, txId, eventType, notifier) {
|
|
|
771
773
|
var getStorage = _ref2.getStorage,
|
|
772
774
|
setStorage = _ref2.setStorage;
|
|
773
775
|
var swap = getStorage().swapDetails;
|
|
776
|
+
swap.hasAlreadyProceededToSign = null;
|
|
774
777
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
775
778
|
var currentStep = getCurrentStep(swap);
|
|
776
779
|
currentStep.executedTransactionId = txId || currentStep.executedTransactionId;
|
|
@@ -783,6 +786,15 @@ function setStepTransactionIds(_ref2, txId, eventType, notifier) {
|
|
|
783
786
|
step: currentStep
|
|
784
787
|
});
|
|
785
788
|
}
|
|
789
|
+
function getSwapNotitfication(eventType, updateResult) {
|
|
790
|
+
if (updateResult.swap.hasAlreadyProceededToSign) {
|
|
791
|
+
return _extends({
|
|
792
|
+
eventType: 'transaction_expired'
|
|
793
|
+
}, updateResult);
|
|
794
|
+
} else return _extends({
|
|
795
|
+
eventType: eventType
|
|
796
|
+
}, updateResult);
|
|
797
|
+
}
|
|
786
798
|
/**
|
|
787
799
|
* If a swap needs a wallet to be connected,
|
|
788
800
|
* By calling this function some related fields will be updated to show a correct message and state for notfiying the user.
|
|
@@ -1474,187 +1486,200 @@ function singTransaction(actions) {
|
|
|
1474
1486
|
});
|
|
1475
1487
|
return;
|
|
1476
1488
|
}
|
|
1477
|
-
var
|
|
1489
|
+
var hasAlreadyProceededToSign = typeof swap.hasAlreadyProceededToSign === 'boolean';
|
|
1490
|
+
var executeMessage = hasAlreadyProceededToSign ? 'Transaction is expired. Please try again' : 'executing transaction';
|
|
1478
1491
|
var executeDetails = "" + (sourceWallet.walletType === walletsShared.WalletType.WALLET_CONNECT ? 'Check your mobile phone' : '');
|
|
1479
1492
|
if (!!transferTransaction) {
|
|
1480
1493
|
var _updateResult3 = updateSwapStatus({
|
|
1481
1494
|
getStorage: getStorage,
|
|
1482
1495
|
setStorage: setStorage,
|
|
1483
|
-
nextStepStatus: 'running',
|
|
1496
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1497
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1484
1498
|
message: executeMessage,
|
|
1485
|
-
details: executeDetails
|
|
1499
|
+
details: executeDetails,
|
|
1500
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1486
1501
|
});
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1502
|
+
var notification = getSwapNotitfication('confirm_transfer', _updateResult3);
|
|
1503
|
+
notifier(notification);
|
|
1504
|
+
if (notification.eventType !== 'transaction_expired') {
|
|
1505
|
+
walletSigners.getSigner(rangoSdk.TransactionType.TRANSFER).signAndSendTx(transferTransaction, walletAddress, null).then(function (txId) {
|
|
1506
|
+
setStepTransactionIds(actions, txId, 'transfer_confirmed', notifier);
|
|
1507
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1508
|
+
next();
|
|
1509
|
+
onFinish();
|
|
1510
|
+
}, function (error) {
|
|
1511
|
+
if (swap.status === 'failed') return;
|
|
1512
|
+
var _prettifyErrorMessage4 = prettifyErrorMessage(error),
|
|
1513
|
+
extraMessage = _prettifyErrorMessage4.extraMessage,
|
|
1514
|
+
extraMessageDetail = _prettifyErrorMessage4.extraMessageDetail,
|
|
1515
|
+
extraMessageErrorCode = _prettifyErrorMessage4.extraMessageErrorCode;
|
|
1516
|
+
var updateResult = updateSwapStatus({
|
|
1517
|
+
getStorage: getStorage,
|
|
1518
|
+
setStorage: setStorage,
|
|
1519
|
+
nextStatus: 'failed',
|
|
1520
|
+
nextStepStatus: 'failed',
|
|
1521
|
+
message: extraMessage,
|
|
1522
|
+
details: extraMessageDetail,
|
|
1523
|
+
errorCode: extraMessageErrorCode
|
|
1524
|
+
});
|
|
1525
|
+
notifier(_extends({
|
|
1526
|
+
eventType: 'transfer_rejected'
|
|
1527
|
+
}, updateResult));
|
|
1528
|
+
failed();
|
|
1529
|
+
onFinish();
|
|
1509
1530
|
});
|
|
1510
|
-
|
|
1511
|
-
eventType: 'transfer_rejected'
|
|
1512
|
-
}, updateResult));
|
|
1513
|
-
failed();
|
|
1514
|
-
onFinish();
|
|
1515
|
-
});
|
|
1531
|
+
}
|
|
1516
1532
|
} else if (!!evmTransaction) {
|
|
1517
1533
|
var _updateResult4 = updateSwapStatus({
|
|
1518
1534
|
getStorage: getStorage,
|
|
1519
1535
|
setStorage: setStorage,
|
|
1520
|
-
nextStepStatus: 'running',
|
|
1536
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1537
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1521
1538
|
message: executeMessage,
|
|
1522
|
-
details: executeDetails
|
|
1539
|
+
details: executeDetails,
|
|
1540
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1523
1541
|
});
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1542
|
+
var _notification = getSwapNotitfication('calling_smart_contract', _updateResult4);
|
|
1543
|
+
notifier(_notification);
|
|
1544
|
+
if (_notification.eventType !== 'transaction_expired') {
|
|
1545
|
+
walletSigners.getSigner(rangoSdk.TransactionType.EVM).signAndSendTx(evmTransaction, walletAddress, null).then(function (id) {
|
|
1546
|
+
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1547
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1548
|
+
next();
|
|
1549
|
+
onFinish();
|
|
1550
|
+
}, function (error) {
|
|
1551
|
+
var _error$root10, _error$root11, _error$root12;
|
|
1552
|
+
if (swap.status === 'failed') return;
|
|
1553
|
+
var _prettifyErrorMessage5 = prettifyErrorMessage(error),
|
|
1554
|
+
extraMessage = _prettifyErrorMessage5.extraMessage,
|
|
1555
|
+
extraMessageDetail = _prettifyErrorMessage5.extraMessageDetail,
|
|
1556
|
+
extraMessageErrorCode = _prettifyErrorMessage5.extraMessageErrorCode;
|
|
1557
|
+
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) {
|
|
1558
|
+
logRPCError(error.root, swap, currentStep, sourceWallet == null ? void 0 : sourceWallet.walletType);
|
|
1559
|
+
}
|
|
1560
|
+
var updateResult = updateSwapStatus({
|
|
1561
|
+
getStorage: getStorage,
|
|
1562
|
+
setStorage: setStorage,
|
|
1563
|
+
nextStatus: 'failed',
|
|
1564
|
+
nextStepStatus: 'failed',
|
|
1565
|
+
message: extraMessage,
|
|
1566
|
+
details: extraMessageDetail,
|
|
1567
|
+
errorCode: extraMessageErrorCode
|
|
1568
|
+
});
|
|
1569
|
+
notifier(_extends({
|
|
1570
|
+
eventType: 'smart_contract_call_failed'
|
|
1571
|
+
}, updateResult));
|
|
1572
|
+
failed();
|
|
1573
|
+
onFinish();
|
|
1550
1574
|
});
|
|
1551
|
-
|
|
1552
|
-
eventType: 'smart_contract_call_failed'
|
|
1553
|
-
}, updateResult));
|
|
1554
|
-
failed();
|
|
1555
|
-
onFinish();
|
|
1556
|
-
});
|
|
1575
|
+
}
|
|
1557
1576
|
} else if (!!cosmosTransaction) {
|
|
1558
1577
|
var _updateResult5 = updateSwapStatus({
|
|
1559
1578
|
getStorage: getStorage,
|
|
1560
1579
|
setStorage: setStorage,
|
|
1561
|
-
nextStepStatus: 'running',
|
|
1580
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1581
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1562
1582
|
message: executeMessage,
|
|
1563
|
-
details: executeDetails
|
|
1583
|
+
details: executeDetails,
|
|
1584
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1564
1585
|
});
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1586
|
+
var _notification2 = getSwapNotitfication('calling_smart_contract', _updateResult5);
|
|
1587
|
+
notifier(_notification2);
|
|
1588
|
+
if (_notification2.eventType !== 'transaction_expired') {
|
|
1589
|
+
// If keplr wallet is executing contracts on terra, throw error. keplr doesn't support transfer or execute contracts. only IBC messages are supported
|
|
1590
|
+
if (((currentStep == null ? void 0 : currentStep.swapperId.toString()) === 'TerraSwap' || (currentStep == null ? void 0 : currentStep.swapperId.toString()) === 'ThorChain' && (currentStep == null ? void 0 : currentStep.fromBlockchain) === walletsShared.Network.TERRA || (currentStep == null ? void 0 : currentStep.swapperId.toString()) === 'Terra Bridge' && currentStep.fromBlockchain === walletsShared.Network.TERRA) &&
|
|
1591
|
+
// here we must allow ibc on terrastatus
|
|
1592
|
+
sourceWallet.walletType === walletsShared.WalletType.KEPLR) {
|
|
1593
|
+
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'),
|
|
1594
|
+
extraMessage = _prettifyErrorMessage6.extraMessage,
|
|
1595
|
+
extraMessageDetail = _prettifyErrorMessage6.extraMessageDetail,
|
|
1596
|
+
extraMessageErrorCode = _prettifyErrorMessage6.extraMessageErrorCode;
|
|
1597
|
+
var _updateResult6 = updateSwapStatus({
|
|
1598
|
+
getStorage: getStorage,
|
|
1599
|
+
setStorage: setStorage,
|
|
1600
|
+
nextStatus: 'failed',
|
|
1601
|
+
nextStepStatus: 'failed',
|
|
1602
|
+
message: extraMessage,
|
|
1603
|
+
details: extraMessageDetail,
|
|
1604
|
+
errorCode: extraMessageErrorCode
|
|
1605
|
+
});
|
|
1606
|
+
notifier(_extends({
|
|
1607
|
+
eventType: 'smart_contract_call_failed'
|
|
1608
|
+
}, _updateResult6));
|
|
1609
|
+
failed();
|
|
1610
|
+
onFinish();
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
walletSigners.getSigner(rangoSdk.TransactionType.COSMOS).signAndSendTx(cosmosTransaction, walletAddress, null).then(
|
|
1614
|
+
// todo
|
|
1615
|
+
function (id) {
|
|
1616
|
+
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1617
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1618
|
+
next();
|
|
1619
|
+
onFinish();
|
|
1620
|
+
}, function (error) {
|
|
1621
|
+
if (swap.status === 'failed') return;
|
|
1622
|
+
var _prettifyErrorMessage7 = prettifyErrorMessage(error),
|
|
1623
|
+
extraMessage = _prettifyErrorMessage7.extraMessage,
|
|
1624
|
+
extraMessageDetail = _prettifyErrorMessage7.extraMessageDetail,
|
|
1625
|
+
extraMessageErrorCode = _prettifyErrorMessage7.extraMessageErrorCode;
|
|
1626
|
+
var updateResult = updateSwapStatus({
|
|
1627
|
+
getStorage: getStorage,
|
|
1628
|
+
setStorage: setStorage,
|
|
1629
|
+
nextStatus: 'failed',
|
|
1630
|
+
nextStepStatus: 'failed',
|
|
1631
|
+
message: extraMessage,
|
|
1632
|
+
details: extraMessageDetail,
|
|
1633
|
+
errorCode: extraMessageErrorCode
|
|
1634
|
+
});
|
|
1635
|
+
notifier(_extends({
|
|
1636
|
+
eventType: 'smart_contract_call_failed'
|
|
1637
|
+
}, updateResult));
|
|
1638
|
+
failed();
|
|
1639
|
+
onFinish();
|
|
1584
1640
|
});
|
|
1585
|
-
notifier(_extends({
|
|
1586
|
-
eventType: 'smart_contract_call_failed'
|
|
1587
|
-
}, _updateResult6));
|
|
1588
|
-
failed();
|
|
1589
|
-
onFinish();
|
|
1590
|
-
return;
|
|
1591
1641
|
}
|
|
1592
|
-
walletSigners.getSigner(rangoSdk.TransactionType.COSMOS).signAndSendTx(cosmosTransaction, walletAddress, null).then(
|
|
1593
|
-
// todo
|
|
1594
|
-
function (id) {
|
|
1595
|
-
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1596
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1597
|
-
next();
|
|
1598
|
-
onFinish();
|
|
1599
|
-
}, function (error) {
|
|
1600
|
-
if (swap.status === 'failed') return;
|
|
1601
|
-
var _prettifyErrorMessage7 = prettifyErrorMessage(error),
|
|
1602
|
-
extraMessage = _prettifyErrorMessage7.extraMessage,
|
|
1603
|
-
extraMessageDetail = _prettifyErrorMessage7.extraMessageDetail,
|
|
1604
|
-
extraMessageErrorCode = _prettifyErrorMessage7.extraMessageErrorCode;
|
|
1605
|
-
var updateResult = updateSwapStatus({
|
|
1606
|
-
getStorage: getStorage,
|
|
1607
|
-
setStorage: setStorage,
|
|
1608
|
-
nextStatus: 'failed',
|
|
1609
|
-
nextStepStatus: 'failed',
|
|
1610
|
-
message: extraMessage,
|
|
1611
|
-
details: extraMessageDetail,
|
|
1612
|
-
errorCode: extraMessageErrorCode
|
|
1613
|
-
});
|
|
1614
|
-
notifier(_extends({
|
|
1615
|
-
eventType: 'smart_contract_call_failed'
|
|
1616
|
-
}, updateResult));
|
|
1617
|
-
failed();
|
|
1618
|
-
onFinish();
|
|
1619
|
-
});
|
|
1620
1642
|
} else if (!!solanaTransaction) {
|
|
1621
1643
|
var _updateResult7 = updateSwapStatus({
|
|
1622
1644
|
getStorage: getStorage,
|
|
1623
1645
|
setStorage: setStorage,
|
|
1624
|
-
nextStepStatus: 'running',
|
|
1646
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1647
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1625
1648
|
message: executeMessage,
|
|
1626
|
-
details: executeDetails
|
|
1649
|
+
details: executeDetails,
|
|
1650
|
+
hasAlreadyProceededToSign: hasAlreadyProceededToSign
|
|
1627
1651
|
});
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1652
|
+
var _notification3 = getSwapNotitfication('calling_smart_contract', _updateResult7);
|
|
1653
|
+
notifier(_notification3);
|
|
1654
|
+
if (_notification3.eventType !== 'transaction_expired') {
|
|
1655
|
+
var tx = solanaTransaction;
|
|
1656
|
+
walletSigners.getSigner(rangoSdk.TransactionType.SOLANA).signAndSendTx(tx, walletAddress, null).then(function (txId) {
|
|
1657
|
+
setStepTransactionIds(actions, txId, 'smart_contract_called', notifier);
|
|
1658
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1659
|
+
next();
|
|
1660
|
+
onFinish();
|
|
1661
|
+
}, function (error) {
|
|
1662
|
+
if (swap.status === 'failed') return;
|
|
1663
|
+
var _prettifyErrorMessage8 = prettifyErrorMessage(error),
|
|
1664
|
+
extraMessage = _prettifyErrorMessage8.extraMessage,
|
|
1665
|
+
extraMessageDetail = _prettifyErrorMessage8.extraMessageDetail,
|
|
1666
|
+
extraMessageErrorCode = _prettifyErrorMessage8.extraMessageErrorCode;
|
|
1667
|
+
var updateResult = updateSwapStatus({
|
|
1668
|
+
getStorage: getStorage,
|
|
1669
|
+
setStorage: setStorage,
|
|
1670
|
+
nextStatus: 'failed',
|
|
1671
|
+
nextStepStatus: 'failed',
|
|
1672
|
+
message: extraMessage,
|
|
1673
|
+
details: extraMessageDetail,
|
|
1674
|
+
errorCode: extraMessageErrorCode
|
|
1675
|
+
});
|
|
1676
|
+
notifier(_extends({
|
|
1677
|
+
eventType: 'smart_contract_call_failed'
|
|
1678
|
+
}, updateResult));
|
|
1679
|
+
failed();
|
|
1680
|
+
onFinish();
|
|
1651
1681
|
});
|
|
1652
|
-
|
|
1653
|
-
eventType: 'smart_contract_call_failed'
|
|
1654
|
-
}, updateResult));
|
|
1655
|
-
failed();
|
|
1656
|
-
onFinish();
|
|
1657
|
-
});
|
|
1682
|
+
}
|
|
1658
1683
|
} else if (!!tronTransaction) {
|
|
1659
1684
|
var _updateResult8 = updateSwapStatus({
|
|
1660
1685
|
getStorage: getStorage,
|
|
@@ -2362,28 +2387,59 @@ var MIGRATED_KEY = 'migratedToQueueManager';
|
|
|
2362
2387
|
function migrated() {
|
|
2363
2388
|
return !!window.localStorage.getItem(MIGRATED_KEY);
|
|
2364
2389
|
}
|
|
2390
|
+
function hasQueueManagerOnIDB() {
|
|
2391
|
+
return _hasQueueManagerOnIDB.apply(this, arguments);
|
|
2392
|
+
}
|
|
2365
2393
|
/**
|
|
2366
2394
|
*
|
|
2367
2395
|
* By calling this function, we first check if the data already migrated or not,
|
|
2368
2396
|
* If not, starting to migrating to IndexedDb with proper format that queue manager is understand.
|
|
2369
2397
|
*
|
|
2370
2398
|
*/
|
|
2399
|
+
function _hasQueueManagerOnIDB() {
|
|
2400
|
+
_hasQueueManagerOnIDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
2401
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2402
|
+
while (1) switch (_context.prev = _context.next) {
|
|
2403
|
+
case 0:
|
|
2404
|
+
_context.prev = 0;
|
|
2405
|
+
_context.next = 3;
|
|
2406
|
+
return window.indexedDB.databases();
|
|
2407
|
+
case 3:
|
|
2408
|
+
return _context.abrupt("return", _context.sent.map(function (db) {
|
|
2409
|
+
return db.name;
|
|
2410
|
+
}).includes(queueManagerCore.DB_NAME));
|
|
2411
|
+
case 6:
|
|
2412
|
+
_context.prev = 6;
|
|
2413
|
+
_context.t0 = _context["catch"](0);
|
|
2414
|
+
return _context.abrupt("return", false);
|
|
2415
|
+
case 9:
|
|
2416
|
+
case "end":
|
|
2417
|
+
return _context.stop();
|
|
2418
|
+
}
|
|
2419
|
+
}, _callee, null, [[0, 6]]);
|
|
2420
|
+
}));
|
|
2421
|
+
return _hasQueueManagerOnIDB.apply(this, arguments);
|
|
2422
|
+
}
|
|
2371
2423
|
function migration() {
|
|
2372
2424
|
return _migration.apply(this, arguments);
|
|
2373
2425
|
}
|
|
2374
2426
|
function _migration() {
|
|
2375
|
-
_migration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2376
|
-
var swapsFromStorage, swaps, convertedSwaps, persistor, promises;
|
|
2377
|
-
return _regeneratorRuntime().wrap(function
|
|
2378
|
-
while (1) switch (
|
|
2427
|
+
_migration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
2428
|
+
var swapsFromStorage, hasIndexDB, swaps, convertedSwaps, persistor, promises;
|
|
2429
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2430
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2379
2431
|
case 0:
|
|
2380
|
-
swapsFromStorage = window.localStorage.getItem('pendingSwaps');
|
|
2381
|
-
|
|
2382
|
-
|
|
2432
|
+
swapsFromStorage = window.localStorage.getItem('pendingSwaps');
|
|
2433
|
+
_context2.next = 3;
|
|
2434
|
+
return hasQueueManagerOnIDB();
|
|
2435
|
+
case 3:
|
|
2436
|
+
hasIndexDB = _context2.sent;
|
|
2437
|
+
if (!(!swapsFromStorage || migrated() || hasIndexDB)) {
|
|
2438
|
+
_context2.next = 6;
|
|
2383
2439
|
break;
|
|
2384
2440
|
}
|
|
2385
|
-
return
|
|
2386
|
-
case
|
|
2441
|
+
return _context2.abrupt("return", true);
|
|
2442
|
+
case 6:
|
|
2387
2443
|
// For old users, but they didn't do any swaps yet.
|
|
2388
2444
|
swaps = JSON.parse(swapsFromStorage);
|
|
2389
2445
|
convertedSwaps = [];
|
|
@@ -2446,17 +2502,17 @@ function _migration() {
|
|
|
2446
2502
|
promises = convertedSwaps.map(function (queue) {
|
|
2447
2503
|
return persistor.insertQueue(queue);
|
|
2448
2504
|
});
|
|
2449
|
-
|
|
2505
|
+
_context2.next = 13;
|
|
2450
2506
|
return Promise.all(promises);
|
|
2451
|
-
case
|
|
2507
|
+
case 13:
|
|
2452
2508
|
// Mark as the data has been successfully migrated.
|
|
2453
2509
|
window.localStorage.setItem(MIGRATED_KEY, '1');
|
|
2454
|
-
return
|
|
2455
|
-
case
|
|
2510
|
+
return _context2.abrupt("return", true);
|
|
2511
|
+
case 15:
|
|
2456
2512
|
case "end":
|
|
2457
|
-
return
|
|
2513
|
+
return _context2.stop();
|
|
2458
2514
|
}
|
|
2459
|
-
},
|
|
2515
|
+
}, _callee2);
|
|
2460
2516
|
}));
|
|
2461
2517
|
return _migration.apply(this, arguments);
|
|
2462
2518
|
}
|