@rango-dev/queue-manager-rango-preset 0.1.14 → 0.1.15-next.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.
- package/CHANGELOG.md +0 -4
- package/dist/helpers.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +47 -80
- 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 +48 -81
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers.ts +25 -95
- package/src/shared.ts +1 -1
- package/src/types.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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
4
|
import { Status, Persistor, DB_NAME } from '@rango-dev/queue-manager-core';
|
|
@@ -679,7 +679,7 @@ function getRelatedWallet(swap, currentStep) {
|
|
|
679
679
|
var blockchain = (walletKV == null ? void 0 : walletKV.k) || null;
|
|
680
680
|
var wallet = (walletKV == null ? void 0 : walletKV.v) || null;
|
|
681
681
|
var walletType = wallet == null ? void 0 : wallet.walletType;
|
|
682
|
-
if (
|
|
682
|
+
if (wallet === null) throw PrettyError.AssertionFailed("Wallet for source " + blockchain + " not passed: walletType: " + walletType);
|
|
683
683
|
return wallet;
|
|
684
684
|
}
|
|
685
685
|
function getRelatedWalletOrNull(swap, currentStep) {
|
|
@@ -990,9 +990,7 @@ function markRunningSwapAsSwitchingNetwork(_ref4) {
|
|
|
990
990
|
type = _getRequiredWallet.type;
|
|
991
991
|
var fromBlockchain = getCurrentBlockchainOf(swap, currentStep);
|
|
992
992
|
var reason = "Change " + type + " wallet network to " + fromBlockchain;
|
|
993
|
-
var
|
|
994
|
-
if (type === WalletType.META_MASK) metamaskMessage = "(Networks -> Select '" + fromBlockchain + "' network.)";
|
|
995
|
-
var reasonDetail = "Please change your " + type + " wallet network to " + fromBlockchain + ". " + metamaskMessage;
|
|
993
|
+
var reasonDetail = "Please change your " + type + " wallet network to " + fromBlockchain + ".";
|
|
996
994
|
var currentTime = new Date();
|
|
997
995
|
swap.lastNotificationTime = currentTime.getTime().toString();
|
|
998
996
|
currentStep.networkStatus = PendingSwapNetworkStatus.WaitingForNetworkChange;
|
|
@@ -1183,26 +1181,22 @@ function _isNetworkMatchedForTransaction() {
|
|
|
1183
1181
|
if (!meta.evmBasedChains.find(function (evmBlochain) {
|
|
1184
1182
|
return evmBlochain.name === fromBlockChain;
|
|
1185
1183
|
})) {
|
|
1186
|
-
_context2.next =
|
|
1184
|
+
_context2.next = 25;
|
|
1187
1185
|
break;
|
|
1188
1186
|
}
|
|
1189
1187
|
_context2.prev = 6;
|
|
1190
1188
|
sourceWallet = swap.wallets[fromBlockChain];
|
|
1191
1189
|
if (!sourceWallet) {
|
|
1192
|
-
_context2.next =
|
|
1193
|
-
break;
|
|
1194
|
-
}
|
|
1195
|
-
if (![WalletType.META_MASK, WalletType.BINANCE_CHAIN, WalletType.XDEFI, WalletType.WALLET_CONNECT, WalletType.TRUST_WALLET, WalletType.COIN98, WalletType.EXODUS, WalletType.OKX, WalletType.COINBASE, WalletType.TOKEN_POCKET, WalletType.MATH, WalletType.SAFEPAL, WalletType.COSMOSTATION, WalletType.CLOVER, WalletType.BRAVE, WalletType.FRONTIER, WalletType.KUCOIN, WalletType.ENKRYPT].includes(sourceWallet.walletType)) {
|
|
1196
|
-
_context2.next = 22;
|
|
1190
|
+
_context2.next = 19;
|
|
1197
1191
|
break;
|
|
1198
1192
|
}
|
|
1199
1193
|
provider = getEvmProvider(providers, sourceWallet.walletType);
|
|
1200
|
-
_context2.next =
|
|
1194
|
+
_context2.next = 12;
|
|
1201
1195
|
return getChainId(provider);
|
|
1202
|
-
case
|
|
1196
|
+
case 12:
|
|
1203
1197
|
chainId = _context2.sent;
|
|
1204
1198
|
if (!chainId) {
|
|
1205
|
-
_context2.next =
|
|
1199
|
+
_context2.next = 19;
|
|
1206
1200
|
break;
|
|
1207
1201
|
}
|
|
1208
1202
|
blockChain = getBlockChainNameFromId(chainId, Object.entries(meta.blockchains).map(function (_ref6) {
|
|
@@ -1210,37 +1204,32 @@ function _isNetworkMatchedForTransaction() {
|
|
|
1210
1204
|
return blockchainMeta;
|
|
1211
1205
|
}));
|
|
1212
1206
|
if (!(blockChain && blockChain.toLowerCase() === fromBlockChain.toLowerCase())) {
|
|
1213
|
-
_context2.next =
|
|
1207
|
+
_context2.next = 17;
|
|
1214
1208
|
break;
|
|
1215
1209
|
}
|
|
1216
1210
|
return _context2.abrupt("return", true);
|
|
1217
|
-
case
|
|
1211
|
+
case 17:
|
|
1218
1212
|
if (!(blockChain && blockChain.toLowerCase() !== fromBlockChain.toLowerCase())) {
|
|
1219
|
-
_context2.next =
|
|
1213
|
+
_context2.next = 19;
|
|
1220
1214
|
break;
|
|
1221
1215
|
}
|
|
1222
1216
|
return _context2.abrupt("return", false);
|
|
1223
|
-
case
|
|
1224
|
-
_context2.next =
|
|
1225
|
-
break;
|
|
1226
|
-
case 22:
|
|
1227
|
-
return _context2.abrupt("return", true);
|
|
1228
|
-
case 23:
|
|
1229
|
-
_context2.next = 28;
|
|
1217
|
+
case 19:
|
|
1218
|
+
_context2.next = 24;
|
|
1230
1219
|
break;
|
|
1231
|
-
case
|
|
1232
|
-
_context2.prev =
|
|
1220
|
+
case 21:
|
|
1221
|
+
_context2.prev = 21;
|
|
1233
1222
|
_context2.t0 = _context2["catch"](6);
|
|
1234
1223
|
console.log(_context2.t0);
|
|
1235
|
-
case
|
|
1224
|
+
case 24:
|
|
1236
1225
|
return _context2.abrupt("return", false);
|
|
1237
|
-
case
|
|
1226
|
+
case 25:
|
|
1238
1227
|
return _context2.abrupt("return", true);
|
|
1239
|
-
case
|
|
1228
|
+
case 26:
|
|
1240
1229
|
case "end":
|
|
1241
1230
|
return _context2.stop();
|
|
1242
1231
|
}
|
|
1243
|
-
}, _callee2, null, [[6,
|
|
1232
|
+
}, _callee2, null, [[6, 21]]);
|
|
1244
1233
|
}));
|
|
1245
1234
|
return _isNetworkMatchedForTransaction.apply(this, arguments);
|
|
1246
1235
|
}
|
|
@@ -1458,7 +1447,8 @@ function singTransaction(actions) {
|
|
|
1458
1447
|
context = actions.context;
|
|
1459
1448
|
var meta = context.meta,
|
|
1460
1449
|
getSigners = context.getSigners,
|
|
1461
|
-
notifier = context.notifier
|
|
1450
|
+
notifier = context.notifier,
|
|
1451
|
+
isMobileWallet = context.isMobileWallet;
|
|
1462
1452
|
var swap = getStorage().swapDetails;
|
|
1463
1453
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1464
1454
|
var currentStep = getCurrentStep(swap);
|
|
@@ -1474,6 +1464,7 @@ function singTransaction(actions) {
|
|
|
1474
1464
|
var sourceWallet = getRelatedWallet(swap, currentStep);
|
|
1475
1465
|
var walletAddress = getCurrentAddressOf(swap, currentStep);
|
|
1476
1466
|
var walletSigners = getSigners(sourceWallet.walletType);
|
|
1467
|
+
var mobileWallet = isMobileWallet(sourceWallet.walletType);
|
|
1477
1468
|
var onFinish = function onFinish() {
|
|
1478
1469
|
// TODO resetClaimedBy is undefined here
|
|
1479
1470
|
if (actions.context.resetClaimedBy) {
|
|
@@ -1484,7 +1475,7 @@ function singTransaction(actions) {
|
|
|
1484
1475
|
var spenderContract = evmApprovalTransaction == null ? void 0 : evmApprovalTransaction.to;
|
|
1485
1476
|
if (!spenderContract) throw PrettyError.AssertionFailed('contract address is null for checking approval');
|
|
1486
1477
|
// Update swap status
|
|
1487
|
-
var message = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (
|
|
1478
|
+
var message = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (mobileWallet ? 'on your mobile phone' : '');
|
|
1488
1479
|
var updateResult = updateSwapStatus({
|
|
1489
1480
|
getStorage: getStorage,
|
|
1490
1481
|
setStorage: setStorage,
|
|
@@ -1530,7 +1521,7 @@ function singTransaction(actions) {
|
|
|
1530
1521
|
return;
|
|
1531
1522
|
} else if (!!tronApprovalTransaction) {
|
|
1532
1523
|
// Update swap status
|
|
1533
|
-
var _message = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (
|
|
1524
|
+
var _message = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (mobileWallet ? 'on your mobile phone' : '');
|
|
1534
1525
|
var _updateResult = updateSwapStatus({
|
|
1535
1526
|
getStorage: getStorage,
|
|
1536
1527
|
setStorage: setStorage,
|
|
@@ -1576,7 +1567,7 @@ function singTransaction(actions) {
|
|
|
1576
1567
|
return;
|
|
1577
1568
|
} else if (!!starknetApprovalTransaction) {
|
|
1578
1569
|
// Update swap status
|
|
1579
|
-
var _message2 = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (
|
|
1570
|
+
var _message2 = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (mobileWallet ? 'on your mobile phone' : '');
|
|
1580
1571
|
var _updateResult2 = updateSwapStatus({
|
|
1581
1572
|
getStorage: getStorage,
|
|
1582
1573
|
setStorage: setStorage,
|
|
@@ -1625,7 +1616,7 @@ function singTransaction(actions) {
|
|
|
1625
1616
|
var nextStepStatusBasedOnHasAlreadyProceededToSign = hasAlreadyProceededToSign ? 'failed' : 'running';
|
|
1626
1617
|
var errorCodeBasedOnHasAlreadyProceededToSign = hasAlreadyProceededToSign ? 'TX_EXPIRED' : null;
|
|
1627
1618
|
var executeMessage = hasAlreadyProceededToSign ? 'Transaction is expired. Please try again' : 'executing transaction';
|
|
1628
|
-
var executeDetails =
|
|
1619
|
+
var executeDetails = mobileWallet ? 'Check your mobile phone' : '';
|
|
1629
1620
|
if (!!transferTransaction) {
|
|
1630
1621
|
var _updateResult3 = updateSwapStatus({
|
|
1631
1622
|
getStorage: getStorage,
|
|
@@ -1735,30 +1726,6 @@ function singTransaction(actions) {
|
|
|
1735
1726
|
failed();
|
|
1736
1727
|
onFinish();
|
|
1737
1728
|
} else {
|
|
1738
|
-
// If keplr wallet is executing contracts on terra, throw error. keplr doesn't support transfer or execute contracts. only IBC messages are supported
|
|
1739
|
-
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) &&
|
|
1740
|
-
// here we must allow ibc on terrastatus
|
|
1741
|
-
sourceWallet.walletType === WalletType.KEPLR) {
|
|
1742
|
-
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'),
|
|
1743
|
-
extraMessage = _prettifyErrorMessage6.extraMessage,
|
|
1744
|
-
extraMessageDetail = _prettifyErrorMessage6.extraMessageDetail,
|
|
1745
|
-
extraMessageErrorCode = _prettifyErrorMessage6.extraMessageErrorCode;
|
|
1746
|
-
var _updateResult6 = updateSwapStatus({
|
|
1747
|
-
getStorage: getStorage,
|
|
1748
|
-
setStorage: setStorage,
|
|
1749
|
-
nextStatus: 'failed',
|
|
1750
|
-
nextStepStatus: 'failed',
|
|
1751
|
-
message: extraMessage,
|
|
1752
|
-
details: extraMessageDetail,
|
|
1753
|
-
errorCode: extraMessageErrorCode
|
|
1754
|
-
});
|
|
1755
|
-
notifier(_extends({
|
|
1756
|
-
eventType: 'smart_contract_call_failed'
|
|
1757
|
-
}, _updateResult6));
|
|
1758
|
-
failed();
|
|
1759
|
-
onFinish();
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
1729
|
walletSigners.getSigner(TransactionType.COSMOS).signAndSendTx(cosmosTransaction, walletAddress, null).then(
|
|
1763
1730
|
// todo
|
|
1764
1731
|
function (id) {
|
|
@@ -1768,10 +1735,10 @@ function singTransaction(actions) {
|
|
|
1768
1735
|
onFinish();
|
|
1769
1736
|
}, function (error) {
|
|
1770
1737
|
if (swap.status === 'failed') return;
|
|
1771
|
-
var
|
|
1772
|
-
extraMessage =
|
|
1773
|
-
extraMessageDetail =
|
|
1774
|
-
extraMessageErrorCode =
|
|
1738
|
+
var _prettifyErrorMessage6 = prettifyErrorMessage(error),
|
|
1739
|
+
extraMessage = _prettifyErrorMessage6.extraMessage,
|
|
1740
|
+
extraMessageDetail = _prettifyErrorMessage6.extraMessageDetail,
|
|
1741
|
+
extraMessageErrorCode = _prettifyErrorMessage6.extraMessageErrorCode;
|
|
1775
1742
|
var updateResult = updateSwapStatus({
|
|
1776
1743
|
getStorage: getStorage,
|
|
1777
1744
|
setStorage: setStorage,
|
|
@@ -1789,7 +1756,7 @@ function singTransaction(actions) {
|
|
|
1789
1756
|
});
|
|
1790
1757
|
}
|
|
1791
1758
|
} else if (!!solanaTransaction) {
|
|
1792
|
-
var
|
|
1759
|
+
var _updateResult6 = updateSwapStatus({
|
|
1793
1760
|
getStorage: getStorage,
|
|
1794
1761
|
setStorage: setStorage,
|
|
1795
1762
|
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
@@ -1799,7 +1766,7 @@ function singTransaction(actions) {
|
|
|
1799
1766
|
hasAlreadyProceededToSign: hasAlreadyProceededToSign,
|
|
1800
1767
|
errorCode: errorCodeBasedOnHasAlreadyProceededToSign
|
|
1801
1768
|
});
|
|
1802
|
-
var _notification3 = getSwapNotitfication('calling_smart_contract',
|
|
1769
|
+
var _notification3 = getSwapNotitfication('calling_smart_contract', _updateResult6);
|
|
1803
1770
|
notifier(_notification3);
|
|
1804
1771
|
if (_notification3.eventType === 'transaction_expired') {
|
|
1805
1772
|
failed();
|
|
@@ -1813,10 +1780,10 @@ function singTransaction(actions) {
|
|
|
1813
1780
|
onFinish();
|
|
1814
1781
|
}, function (error) {
|
|
1815
1782
|
if (swap.status === 'failed') return;
|
|
1816
|
-
var
|
|
1817
|
-
extraMessage =
|
|
1818
|
-
extraMessageDetail =
|
|
1819
|
-
extraMessageErrorCode =
|
|
1783
|
+
var _prettifyErrorMessage7 = prettifyErrorMessage(error),
|
|
1784
|
+
extraMessage = _prettifyErrorMessage7.extraMessage,
|
|
1785
|
+
extraMessageDetail = _prettifyErrorMessage7.extraMessageDetail,
|
|
1786
|
+
extraMessageErrorCode = _prettifyErrorMessage7.extraMessageErrorCode;
|
|
1820
1787
|
var updateResult = updateSwapStatus({
|
|
1821
1788
|
getStorage: getStorage,
|
|
1822
1789
|
setStorage: setStorage,
|
|
@@ -1834,7 +1801,7 @@ function singTransaction(actions) {
|
|
|
1834
1801
|
});
|
|
1835
1802
|
}
|
|
1836
1803
|
} else if (!!tronTransaction) {
|
|
1837
|
-
var
|
|
1804
|
+
var _updateResult7 = updateSwapStatus({
|
|
1838
1805
|
getStorage: getStorage,
|
|
1839
1806
|
setStorage: setStorage,
|
|
1840
1807
|
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
@@ -1844,7 +1811,7 @@ function singTransaction(actions) {
|
|
|
1844
1811
|
hasAlreadyProceededToSign: hasAlreadyProceededToSign,
|
|
1845
1812
|
errorCode: errorCodeBasedOnHasAlreadyProceededToSign
|
|
1846
1813
|
});
|
|
1847
|
-
var _notification4 = getSwapNotitfication('calling_smart_contract',
|
|
1814
|
+
var _notification4 = getSwapNotitfication('calling_smart_contract', _updateResult7);
|
|
1848
1815
|
notifier(_notification4);
|
|
1849
1816
|
if (_notification4.eventType === 'transaction_expired') {
|
|
1850
1817
|
failed();
|
|
@@ -1858,10 +1825,10 @@ function singTransaction(actions) {
|
|
|
1858
1825
|
}, function (error) {
|
|
1859
1826
|
var _error$root13, _error$root14, _error$root15;
|
|
1860
1827
|
if (swap.status === 'failed') return;
|
|
1861
|
-
var
|
|
1862
|
-
extraMessage =
|
|
1863
|
-
extraMessageDetail =
|
|
1864
|
-
extraMessageErrorCode =
|
|
1828
|
+
var _prettifyErrorMessage8 = prettifyErrorMessage(error),
|
|
1829
|
+
extraMessage = _prettifyErrorMessage8.extraMessage,
|
|
1830
|
+
extraMessageDetail = _prettifyErrorMessage8.extraMessageDetail,
|
|
1831
|
+
extraMessageErrorCode = _prettifyErrorMessage8.extraMessageErrorCode;
|
|
1865
1832
|
if (error && error != null && error.root && error != null && (_error$root13 = error.root) != null && _error$root13.message && error != null && (_error$root14 = error.root) != null && _error$root14.code && error != null && (_error$root15 = error.root) != null && _error$root15.reason) {
|
|
1866
1833
|
logRPCError(error.root, swap, currentStep, sourceWallet == null ? void 0 : sourceWallet.walletType);
|
|
1867
1834
|
}
|
|
@@ -1882,7 +1849,7 @@ function singTransaction(actions) {
|
|
|
1882
1849
|
});
|
|
1883
1850
|
}
|
|
1884
1851
|
} else if (!!starknetTransaction) {
|
|
1885
|
-
var
|
|
1852
|
+
var _updateResult8 = updateSwapStatus({
|
|
1886
1853
|
getStorage: getStorage,
|
|
1887
1854
|
setStorage: setStorage,
|
|
1888
1855
|
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
@@ -1892,7 +1859,7 @@ function singTransaction(actions) {
|
|
|
1892
1859
|
hasAlreadyProceededToSign: hasAlreadyProceededToSign,
|
|
1893
1860
|
errorCode: errorCodeBasedOnHasAlreadyProceededToSign
|
|
1894
1861
|
});
|
|
1895
|
-
var _notification5 = getSwapNotitfication('calling_smart_contract',
|
|
1862
|
+
var _notification5 = getSwapNotitfication('calling_smart_contract', _updateResult8);
|
|
1896
1863
|
notifier(_notification5);
|
|
1897
1864
|
if (_notification5.eventType === 'transaction_expired') {
|
|
1898
1865
|
failed();
|
|
@@ -1906,10 +1873,10 @@ function singTransaction(actions) {
|
|
|
1906
1873
|
}, function (error) {
|
|
1907
1874
|
var _error$root16, _error$root17, _error$root18;
|
|
1908
1875
|
if (swap.status === 'failed') return;
|
|
1909
|
-
var
|
|
1910
|
-
extraMessage =
|
|
1911
|
-
extraMessageDetail =
|
|
1912
|
-
extraMessageErrorCode =
|
|
1876
|
+
var _prettifyErrorMessage9 = prettifyErrorMessage(error),
|
|
1877
|
+
extraMessage = _prettifyErrorMessage9.extraMessage,
|
|
1878
|
+
extraMessageDetail = _prettifyErrorMessage9.extraMessageDetail,
|
|
1879
|
+
extraMessageErrorCode = _prettifyErrorMessage9.extraMessageErrorCode;
|
|
1913
1880
|
if (error && error != null && error.root && error != null && (_error$root16 = error.root) != null && _error$root16.message && error != null && (_error$root17 = error.root) != null && _error$root17.code && error != null && (_error$root18 = error.root) != null && _error$root18.reason) {
|
|
1914
1881
|
logRPCError(error.root, swap, currentStep, sourceWallet == null ? void 0 : sourceWallet.walletType);
|
|
1915
1882
|
}
|