@rango-dev/queue-manager-rango-preset 0.1.11-next.3 → 0.1.11-next.6
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/configs.d.ts +7 -0
- package/dist/configs.d.ts.map +1 -0
- package/dist/constants.d.ts +0 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +61 -42
- 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 +61 -42
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/services/httpService.d.ts +1 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/checkStatus.ts +2 -2
- package/src/actions/createTransaction.ts +1 -1
- package/src/configs.ts +27 -0
- package/src/constants.ts +0 -3
- package/src/helpers.ts +5 -4
- package/src/index.ts +9 -1
- package/src/services/httpService.ts +7 -8
|
@@ -1,14 +1,43 @@
|
|
|
1
|
-
import { SignerError, isAPIErrorCode, isSignerErrorCode, SignerErrorCode } from 'rango-types';
|
|
2
1
|
import { WalletType, Network, getBlockChainNameFromId } from '@rango-dev/wallets-shared';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
2
|
import { readAccountAddress } from '@rango-dev/wallets-core';
|
|
5
3
|
import { RangoClient, TransactionType } from 'rango-sdk';
|
|
6
4
|
import { Status, Persistor, DB_NAME } from '@rango-dev/queue-manager-core';
|
|
5
|
+
import { SignerError, isAPIErrorCode, isSignerErrorCode, SignerErrorCode } from 'rango-types';
|
|
6
|
+
import BigNumber from 'bignumber.js';
|
|
7
7
|
import { captureException } from '@sentry/browser';
|
|
8
8
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
9
9
|
import { useState, useEffect } from 'react';
|
|
10
10
|
import { v4 } from 'uuid';
|
|
11
11
|
|
|
12
|
+
// this API key is limited and
|
|
13
|
+
// it is only for test purpose
|
|
14
|
+
var RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
|
|
15
|
+
var configs = {
|
|
16
|
+
API_KEY: RANGO_PUBLIC_API_KEY
|
|
17
|
+
};
|
|
18
|
+
function getConfig(name) {
|
|
19
|
+
return configs[name];
|
|
20
|
+
}
|
|
21
|
+
function initConfig(nextConfigs) {
|
|
22
|
+
configs = structuredClone(nextConfigs);
|
|
23
|
+
return configs;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var SwapActionTypes;
|
|
27
|
+
(function (SwapActionTypes) {
|
|
28
|
+
SwapActionTypes["START"] = "START";
|
|
29
|
+
SwapActionTypes["SCHEDULE_NEXT_STEP"] = "SCHEDULE_NEXT_STEP";
|
|
30
|
+
SwapActionTypes["CREATE_TRANSACTION"] = "CREATE_TRANSACTION";
|
|
31
|
+
SwapActionTypes["EXECUTE_TRANSACTION"] = "EXECUTE_TRANSACTION";
|
|
32
|
+
SwapActionTypes["CHECK_TRANSACTION_STATUS"] = "CHECK_TRANSACTION_STATUS";
|
|
33
|
+
})(SwapActionTypes || (SwapActionTypes = {}));
|
|
34
|
+
var BlockReason;
|
|
35
|
+
(function (BlockReason) {
|
|
36
|
+
BlockReason["WAIT_FOR_CONNECT_WALLET"] = "waiting_for_connecting_wallet";
|
|
37
|
+
BlockReason["WAIT_FOR_NETWORK_CHANGE"] = "waiting_for_network_change";
|
|
38
|
+
BlockReason["DEPENDS_ON_OTHER_QUEUES"] = "depends_on_other_queues";
|
|
39
|
+
})(BlockReason || (BlockReason = {}));
|
|
40
|
+
|
|
12
41
|
function _regeneratorRuntime() {
|
|
13
42
|
_regeneratorRuntime = function () {
|
|
14
43
|
return exports;
|
|
@@ -434,6 +463,17 @@ function _assertThisInitialized(self) {
|
|
|
434
463
|
return self;
|
|
435
464
|
}
|
|
436
465
|
|
|
466
|
+
var ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
|
|
467
|
+
var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address) {
|
|
468
|
+
return "Please change your " + (type || 'wallet') + " account to " + (address || 'proper address');
|
|
469
|
+
};
|
|
470
|
+
var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type) {
|
|
471
|
+
return "Please connect to " + (type || 'your wallet') + " by using bellow button or top right button on page.";
|
|
472
|
+
};
|
|
473
|
+
var ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK = function ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(network) {
|
|
474
|
+
return "Please change your network to " + network + ".";
|
|
475
|
+
};
|
|
476
|
+
|
|
437
477
|
var ERROR_ASSERTION_FAILED = 'Assertion failed (Unexpected behaviour)';
|
|
438
478
|
var ERROR_CREATE_TRANSACTION = 'Create transaction failed in Rango Server';
|
|
439
479
|
var ERROR_INPUT_WALLET_NOT_FOUND = 'Input wallet not found';
|
|
@@ -739,34 +779,6 @@ function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validat
|
|
|
739
779
|
};
|
|
740
780
|
}
|
|
741
781
|
|
|
742
|
-
var SwapActionTypes;
|
|
743
|
-
(function (SwapActionTypes) {
|
|
744
|
-
SwapActionTypes["START"] = "START";
|
|
745
|
-
SwapActionTypes["SCHEDULE_NEXT_STEP"] = "SCHEDULE_NEXT_STEP";
|
|
746
|
-
SwapActionTypes["CREATE_TRANSACTION"] = "CREATE_TRANSACTION";
|
|
747
|
-
SwapActionTypes["EXECUTE_TRANSACTION"] = "EXECUTE_TRANSACTION";
|
|
748
|
-
SwapActionTypes["CHECK_TRANSACTION_STATUS"] = "CHECK_TRANSACTION_STATUS";
|
|
749
|
-
})(SwapActionTypes || (SwapActionTypes = {}));
|
|
750
|
-
var BlockReason;
|
|
751
|
-
(function (BlockReason) {
|
|
752
|
-
BlockReason["WAIT_FOR_CONNECT_WALLET"] = "waiting_for_connecting_wallet";
|
|
753
|
-
BlockReason["WAIT_FOR_NETWORK_CHANGE"] = "waiting_for_network_change";
|
|
754
|
-
BlockReason["DEPENDS_ON_OTHER_QUEUES"] = "depends_on_other_queues";
|
|
755
|
-
})(BlockReason || (BlockReason = {}));
|
|
756
|
-
|
|
757
|
-
var RANGO_DAPP_API_KEY = process.env.REACT_APP_API_KEY;
|
|
758
|
-
var RANGO_DAPP_API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
|
|
759
|
-
var ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
|
|
760
|
-
var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address) {
|
|
761
|
-
return "Please change your " + (type || 'wallet') + " account to " + (address || 'proper address');
|
|
762
|
-
};
|
|
763
|
-
var ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION = function ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type) {
|
|
764
|
-
return "Please connect to " + (type || 'your wallet') + " by using bellow button or top right button on page.";
|
|
765
|
-
};
|
|
766
|
-
var ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK = function ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(network) {
|
|
767
|
-
return "Please change your network to " + network + ".";
|
|
768
|
-
};
|
|
769
|
-
|
|
770
782
|
function logRPCError(error, swap, currentStep, walletType) {
|
|
771
783
|
try {
|
|
772
784
|
captureException(error, {
|
|
@@ -785,10 +797,12 @@ function logRPCError(error, swap, currentStep, walletType) {
|
|
|
785
797
|
}
|
|
786
798
|
}
|
|
787
799
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
800
|
+
var rango = undefined;
|
|
801
|
+
var httpService = function httpService() {
|
|
802
|
+
if (rango) return rango;
|
|
803
|
+
rango = new RangoClient(getConfig('API_KEY'));
|
|
804
|
+
return rango;
|
|
805
|
+
};
|
|
792
806
|
|
|
793
807
|
var swapClaimedBy = null;
|
|
794
808
|
/**
|
|
@@ -872,7 +886,7 @@ function updateSwapStatus(_ref) {
|
|
|
872
886
|
var errorReason = details && details.includes('Warning') ? 'Swap canceled by user.' : details;
|
|
873
887
|
var walletType = (_getRelatedWalletOrNu = getRelatedWalletOrNull(swap, currentStep)) == null ? void 0 : _getRelatedWalletOrNu.walletType;
|
|
874
888
|
swap.extraMessageSeverity = MessageSeverity.error;
|
|
875
|
-
httpService.reportFailure({
|
|
889
|
+
httpService().reportFailure({
|
|
876
890
|
requestId: swap.requestId,
|
|
877
891
|
step: (currentStep == null ? void 0 : currentStep.id) || 1,
|
|
878
892
|
eventType: mapAppErrorCodesToAPIErrorCode(errorCode),
|
|
@@ -1453,7 +1467,7 @@ function singTransaction(actions) {
|
|
|
1453
1467
|
var spenderContract = evmApprovalTransaction == null ? void 0 : evmApprovalTransaction.to;
|
|
1454
1468
|
if (!spenderContract) throw PrettyError.AssertionFailed('contract address is null for checking approval');
|
|
1455
1469
|
// Update swap status
|
|
1456
|
-
var message = "
|
|
1470
|
+
var message = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (sourceWallet.walletType === WalletType.WALLET_CONNECT ? 'on your mobile phone' : '');
|
|
1457
1471
|
var updateResult = updateSwapStatus({
|
|
1458
1472
|
getStorage: getStorage,
|
|
1459
1473
|
setStorage: setStorage,
|
|
@@ -1499,7 +1513,7 @@ function singTransaction(actions) {
|
|
|
1499
1513
|
return;
|
|
1500
1514
|
} else if (!!tronApprovalTransaction) {
|
|
1501
1515
|
// Update swap status
|
|
1502
|
-
var _message = "
|
|
1516
|
+
var _message = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (sourceWallet.walletType === WalletType.WALLET_CONNECT ? 'on your mobile phone' : '');
|
|
1503
1517
|
var _updateResult = updateSwapStatus({
|
|
1504
1518
|
getStorage: getStorage,
|
|
1505
1519
|
setStorage: setStorage,
|
|
@@ -1545,7 +1559,7 @@ function singTransaction(actions) {
|
|
|
1545
1559
|
return;
|
|
1546
1560
|
} else if (!!starknetApprovalTransaction) {
|
|
1547
1561
|
// Update swap status
|
|
1548
|
-
var _message2 = "
|
|
1562
|
+
var _message2 = "Waiting for approval of " + (currentStep == null ? void 0 : currentStep.fromSymbol) + " coin " + (sourceWallet.walletType === WalletType.WALLET_CONNECT ? 'on your mobile phone' : '');
|
|
1549
1563
|
var _updateResult2 = updateSwapStatus({
|
|
1550
1564
|
getStorage: getStorage,
|
|
1551
1565
|
setStorage: setStorage,
|
|
@@ -2167,7 +2181,7 @@ function _checkTransactionStatus() {
|
|
|
2167
2181
|
status = null;
|
|
2168
2182
|
_context.prev = 5;
|
|
2169
2183
|
_context.next = 8;
|
|
2170
|
-
return httpService.checkStatus({
|
|
2184
|
+
return httpService().checkStatus({
|
|
2171
2185
|
requestId: swap.requestId,
|
|
2172
2186
|
txId: txId,
|
|
2173
2187
|
step: currentStep.id
|
|
@@ -2299,7 +2313,7 @@ function _checkApprovalStatus() {
|
|
|
2299
2313
|
isApproved = false;
|
|
2300
2314
|
_context2.prev = 4;
|
|
2301
2315
|
_context2.next = 7;
|
|
2302
|
-
return httpService.checkApproval(swap.requestId, currentStep.executedTransactionId || '');
|
|
2316
|
+
return httpService().checkApproval(swap.requestId, currentStep.executedTransactionId || '');
|
|
2303
2317
|
case 7:
|
|
2304
2318
|
response = _context2.sent;
|
|
2305
2319
|
isApproved = response.isApproved;
|
|
@@ -2449,7 +2463,7 @@ function _createTransaction() {
|
|
|
2449
2463
|
};
|
|
2450
2464
|
_context.prev = 6;
|
|
2451
2465
|
_context.next = 9;
|
|
2452
|
-
return throwOnOK(httpService.createTransaction(request));
|
|
2466
|
+
return throwOnOK(httpService().createTransaction(request));
|
|
2453
2467
|
case 9:
|
|
2454
2468
|
_yield$throwOnOK = _context.sent;
|
|
2455
2469
|
transaction = _yield$throwOnOK.transaction;
|
|
@@ -2898,5 +2912,10 @@ function useQueueManager(params) {
|
|
|
2898
2912
|
}, [params.disconnectedWallet]);
|
|
2899
2913
|
}
|
|
2900
2914
|
|
|
2901
|
-
|
|
2915
|
+
function makeQueueDefinition(configs) {
|
|
2916
|
+
initConfig(configs);
|
|
2917
|
+
return swapQueueDef;
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
export { MessageSeverity, PendingSwapNetworkStatus, PrettyError, calculatePendingSwap, cancelSwap, checkWaitingForNetworkChange, getCurrentBlockchainOfOrNull, getCurrentStep, getEvmProvider, getRelatedWallet, getRelatedWalletOrNull, getRequiredWallet, getRunningSwaps, makeQueueDefinition, prettifyErrorMessage, resetRunningSwapNotifsOnPageLoad, splitWalletNetwork, updateSwapStatus, useMigration, useQueueManager };
|
|
2902
2921
|
//# sourceMappingURL=queue-manager-rango-preset.esm.js.map
|