@rango-dev/queue-manager-rango-preset 0.1.10-next.96 → 0.1.10
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/actions/checkStatus.d.ts.map +1 -1
- package/dist/actions/createTransaction.d.ts.map +1 -1
- package/dist/actions/scheduleNextStep.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/helpers.d.ts +46 -14
- package/dist/helpers.d.ts.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.d.ts +4 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +397 -302
- 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 +376 -288
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/shared-errors.d.ts +5 -37
- package/dist/shared-errors.d.ts.map +1 -1
- package/dist/shared.d.ts +20 -17
- package/dist/shared.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/readme.md +1 -9
- package/src/actions/checkStatus.ts +54 -5
- package/src/actions/createTransaction.ts +2 -3
- package/src/actions/executeTransaction.ts +3 -3
- package/src/actions/scheduleNextStep.ts +1 -0
- package/src/constants.ts +1 -1
- package/src/helpers.ts +225 -174
- package/src/hooks.ts +2 -1
- package/src/index.ts +19 -44
- package/src/shared-errors.ts +53 -76
- package/src/shared.ts +34 -54
- package/src/types.ts +1 -0
package/dist/shared-errors.d.ts
CHANGED
|
@@ -1,47 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { APIErrorCode, SignerErrorCode } from 'rango-types';
|
|
2
2
|
export declare type ErrorDetail = {
|
|
3
3
|
extraMessage: string;
|
|
4
4
|
extraMessageDetail?: string | null | undefined;
|
|
5
|
-
extraMessageErrorCode:
|
|
5
|
+
extraMessageErrorCode: SignerErrorCode | APIErrorCode | null;
|
|
6
6
|
};
|
|
7
|
-
export declare enum APIErrorCode {
|
|
8
|
-
TX_FAIL = "TX_FAIL",
|
|
9
|
-
FETCH_TX_FAILED = "FETCH_TX_FAILED",
|
|
10
|
-
USER_REJECT = "USER_REJECT",
|
|
11
|
-
CALL_WALLET_FAILED = "CALL_WALLET_FAILED",
|
|
12
|
-
SEND_TX_FAILED = "SEND_TX_FAILED",
|
|
13
|
-
CALL_OR_SEND_FAILED = "CALL_OR_SEND_FAILED",
|
|
14
|
-
USER_CANCEL = "USER_CANCEL",
|
|
15
|
-
CLIENT_UNEXPECTED_BEHAVIOUR = "CLIENT_UNEXPECTED_BEHAVIOUR"
|
|
16
|
-
}
|
|
17
|
-
export declare enum ApiMethodName {
|
|
18
|
-
RequestingSwapTransaction = "Requesting Swap Transaction",
|
|
19
|
-
CreatingSwap = "Creating Swap",
|
|
20
|
-
CheckingTransactionStatus = "Checking transaction status",
|
|
21
|
-
CreateTransaction = "Create Transaction",
|
|
22
|
-
CheckApproval = "Check TX Approval",
|
|
23
|
-
GettingSwapDetail = "Getting Swap Detail",
|
|
24
|
-
GettingUserLimits = "Getting user limits"
|
|
25
|
-
}
|
|
26
|
-
export declare enum TransactionName {
|
|
27
|
-
GenericTransaction = "transaction",
|
|
28
|
-
SendingOneInchTransaction = "1inch transaction",
|
|
29
|
-
Approval = "approve transaction"
|
|
30
|
-
}
|
|
31
|
-
export declare const ERROR_ASSERTION_FAILED = "Assertion failed (Unexpected behaviour)";
|
|
32
|
-
export declare const ERROR_COMMUNICATING_WITH_API: (apiMethodName: ApiMethodName) => string;
|
|
33
|
-
export declare const ERROR_DESCRIPTION_UNSUPPORTED_TRANSACTION: (method: string, walletType: WalletType) => string;
|
|
34
|
-
export declare const ERROR_SIGNING_TRANSACTION: (transactionName: TransactionName) => string;
|
|
35
|
-
export declare const ERROR_REJECTING_TRANSACTION = "User rejected the message signing";
|
|
36
|
-
export declare const ERROR_CREATE_TRANSACTION = "Create transaction failed in Rango Server";
|
|
37
|
-
export declare const ERROR_INPUT_WALLET_NOT_FOUND = "Input wallet not found";
|
|
38
|
-
export declare const DEFAULT_WALLET_INJECTION_ERROR = "Failed to connect to wallet, if you have turned injection off (disable default wallet for xDefi), turn it on and refresh the page";
|
|
39
7
|
declare type ErrorRoot = string | Record<string, string> | null;
|
|
40
8
|
export declare class PrettyError extends Error {
|
|
41
9
|
private readonly detail?;
|
|
42
10
|
private readonly root?;
|
|
43
11
|
private readonly code?;
|
|
12
|
+
_isPrettyError: boolean;
|
|
44
13
|
constructor(code: APIErrorCode, m: string, root?: ErrorRoot, detail?: string);
|
|
14
|
+
static isPrettyError(obj: unknown): obj is PrettyError;
|
|
45
15
|
getErrorDetail(): ErrorDetail;
|
|
46
16
|
static AssertionFailed(m: string): PrettyError;
|
|
47
17
|
static BadStatusCode(message: string, statusCode: number | string): PrettyError;
|
|
@@ -49,9 +19,7 @@ export declare class PrettyError extends Error {
|
|
|
49
19
|
static WalletMissing(): PrettyError;
|
|
50
20
|
static BlockchainMissing(): PrettyError;
|
|
51
21
|
}
|
|
52
|
-
export declare const ERROR_GETTING_BEST_ROUTE: (status: number | string) => string;
|
|
53
|
-
export declare const ERROR_CONFIRM_SWAP: (status?: string | number | undefined) => string;
|
|
54
|
-
export declare const WARNING_STARKNET_FOUND = "StarknNet blockchain is still an ALPHA version. As such, delays may occur, and catastrophic bugs may lurk.";
|
|
55
22
|
export declare function mapAppErrorCodesToAPIErrorCode(errorCode: string | null): APIErrorCode;
|
|
23
|
+
export declare const prettifyErrorMessage: (obj: unknown) => ErrorDetail;
|
|
56
24
|
export {};
|
|
57
25
|
//# sourceMappingURL=shared-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-errors.d.ts","sourceRoot":"","sources":["src/shared-errors.ts"],"names":[],"mappings":"AAA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,MAAM,oBAAoB,QAAS,OAAO,KAAG,WAsBnD,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Network, WalletType } from '@rango-dev/wallets-shared';
|
|
2
|
-
import { CosmosTransaction, EvmBlockchainMeta, EvmTransaction, SimulationResult, SolanaTransaction, StarknetTransaction, TronTransaction, Transfer as TransferTransaction } from 'rango-sdk';
|
|
3
|
-
import { ErrorDetail } from './shared-errors';
|
|
2
|
+
import { CosmosTransaction, EvmBlockchainMeta, EvmTransaction, SimulationResult, SolanaTransaction, StarknetTransaction, TronTransaction, Transfer as TransferTransaction, AmountRestrictionType } from 'rango-sdk';
|
|
4
3
|
export interface PendingSwapWithQueueID {
|
|
5
4
|
id: string;
|
|
6
5
|
swap: PendingSwap;
|
|
@@ -37,7 +36,7 @@ export declare type Blockchain = {
|
|
|
37
36
|
export declare type Wallet = {
|
|
38
37
|
blockchains: Blockchain[];
|
|
39
38
|
};
|
|
40
|
-
export declare type EventType = 'swap_started' | 'confirm_contract' | 'confirm_transfer' | 'task_failed' | 'task_completed' | 'task_canceled' | 'task_paused' | 'contract_confirmed' | 'contract_rejected' | '
|
|
39
|
+
export declare type EventType = 'swap_started' | 'confirm_contract' | 'confirm_transfer' | 'task_failed' | 'task_completed' | 'task_canceled' | 'task_paused' | 'contract_confirmed' | 'confirm_approve_contract' | 'contract_rejected' | 'check_tx_status' | 'check_approve_tx_status' | 'transfer_rejected' | 'calling_smart_contract' | 'smart_contract_called' | 'smart_contract_call_failed' | 'step_completed_with_output' | 'waiting_for_network_change' | 'waiting_for_connecting_wallet' | 'waiting_for_change_wallet_account' | 'network_changed' | 'not_enough_balance' | 'waiting_for_queue' | 'check_fee_failed' | 'route_failed_to_find' | 'transaction_expired';
|
|
41
40
|
export declare type SwapSavedSettings = {
|
|
42
41
|
slippage: string;
|
|
43
42
|
disabledSwappersIds: string[];
|
|
@@ -60,7 +59,6 @@ export declare type SwapExplorerUrl = {
|
|
|
60
59
|
url: string;
|
|
61
60
|
description: string | null;
|
|
62
61
|
};
|
|
63
|
-
export declare type SwapperId = 'ThorChain' | 'OneInchEth' | 'Binance Bridge' | 'OneInchBsc' | 'OneInchPolygon' | 'Terra Bridge' | 'TerraSwap' | 'Osmosis' | 'Lido' | 'PoS Bridge' | 'Wormhole';
|
|
64
62
|
export declare type StepStatus = 'created' | 'running' | 'failed' | 'success' | 'waitingForApproval' | 'approved';
|
|
65
63
|
export declare type PendingSwapStep = {
|
|
66
64
|
id: number;
|
|
@@ -68,34 +66,37 @@ export declare type PendingSwapStep = {
|
|
|
68
66
|
fromSymbol: string;
|
|
69
67
|
fromSymbolAddress: string | null;
|
|
70
68
|
fromDecimals: number;
|
|
71
|
-
fromAmountPrecision:
|
|
72
|
-
fromAmountMinValue:
|
|
73
|
-
fromAmountMaxValue:
|
|
69
|
+
fromAmountPrecision: string | null;
|
|
70
|
+
fromAmountMinValue: string | null;
|
|
71
|
+
fromAmountMaxValue: string | null;
|
|
72
|
+
fromAmountRestrictionType: AmountRestrictionType | null;
|
|
74
73
|
fromLogo: string;
|
|
75
74
|
toBlockchain: string;
|
|
76
75
|
toSymbol: string;
|
|
77
76
|
toSymbolAddress: string | null;
|
|
78
77
|
toDecimals: number;
|
|
79
78
|
toLogo: string;
|
|
80
|
-
swapperId:
|
|
79
|
+
swapperId: string;
|
|
81
80
|
expectedOutputAmountHumanReadable: string | null;
|
|
82
81
|
startTransactionTime: number;
|
|
83
|
-
|
|
82
|
+
internalSteps: SwapperStatusStep[] | null;
|
|
83
|
+
estimatedTimeInSeconds: number | null;
|
|
84
84
|
status: StepStatus;
|
|
85
85
|
networkStatus: PendingSwapNetworkStatus | null;
|
|
86
86
|
executedTransactionId: string | null;
|
|
87
|
+
executedTransactionTime: string | null;
|
|
87
88
|
explorerUrl: SwapExplorerUrl[] | null;
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
diagnosisUrl: string | null;
|
|
90
|
+
outputAmount: string | null;
|
|
90
91
|
cosmosTransaction: CosmosTransaction | null;
|
|
91
92
|
transferTransaction: TransferTransaction | null;
|
|
92
93
|
solanaTransaction: SolanaTransaction | null;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
tronTransaction: TronTransaction | null;
|
|
94
|
+
evmApprovalTransaction: EvmTransaction | null;
|
|
95
|
+
evmTransaction: EvmTransaction | null;
|
|
96
96
|
tronApprovalTransaction: TronTransaction | null;
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
tronTransaction: TronTransaction | null;
|
|
98
|
+
starknetApprovalTransaction: StarknetTransaction | null;
|
|
99
|
+
starknetTransaction: StarknetTransaction | null;
|
|
99
100
|
};
|
|
100
101
|
export declare type WalletTypeAndAddress = {
|
|
101
102
|
walletType: WalletType;
|
|
@@ -136,8 +137,10 @@ export declare const getCurrentBlockchainOf: (swap: PendingSwap, step: PendingSw
|
|
|
136
137
|
export declare const getEvmApproveUrl: (tx: string, network: Network, evmBasedBlockchains: EvmBlockchainMeta[]) => string;
|
|
137
138
|
export declare const getStarknetApproveUrl: (tx: string) => string;
|
|
138
139
|
export declare const getTronApproveUrl: (tx: string) => string;
|
|
139
|
-
export declare const prettifyErrorMessage: (obj: unknown) => ErrorDetail;
|
|
140
140
|
export declare function getNextStep(swap: PendingSwap, currentStep: PendingSwapStep): PendingSwapStep | null;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the wallet address, based on the current step of `PendingSwap`.
|
|
143
|
+
*/
|
|
141
144
|
export declare const getCurrentAddressOf: (swap: PendingSwap, step: PendingSwapStep) => string;
|
|
142
145
|
export declare function getRelatedWallet(swap: PendingSwap, currentStep: PendingSwapStep): WalletTypeAndAddress;
|
|
143
146
|
export declare function getRelatedWalletOrNull(swap: PendingSwap, currentStep: PendingSwapStep): WalletTypeAndAddress | null;
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["src/shared.ts"],"names":[],"mappings":"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BAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;CACxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/queue-manager-rango-preset",
|
|
3
|
-
"version": "0.1.10
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "dist/queue-manager-rango-preset.esm.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@rango-dev/wallets-shared": "*",
|
|
25
25
|
"@sentry/browser": "*",
|
|
26
26
|
"bignumber.js": "*",
|
|
27
|
+
"rango-sdk": "*",
|
|
27
28
|
"rango-types": "*",
|
|
28
29
|
"uuid": "*"
|
|
29
30
|
},
|
|
@@ -53,7 +54,6 @@
|
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@sentry/browser": "^6.12.0",
|
|
56
|
-
"rango-sdk": "^0.1.19",
|
|
57
57
|
"uuid": "^9.0.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
package/readme.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExecuterActions } from '@rango-dev/queue-manager-core';
|
|
2
|
-
import { Network } from '@rango-dev/wallets-shared';
|
|
3
2
|
import {
|
|
4
3
|
delay,
|
|
5
4
|
getCurrentStep,
|
|
@@ -10,13 +9,14 @@ import {
|
|
|
10
9
|
isTrasnferTransaction,
|
|
11
10
|
isTronTransaction,
|
|
12
11
|
resetNetworkStatus,
|
|
12
|
+
updateSwapStatus,
|
|
13
13
|
} from '../helpers';
|
|
14
14
|
import { SwapActionTypes, SwapQueueContext, SwapStorage } from '../types';
|
|
15
15
|
import { getNextStep, MessageSeverity } from '../shared';
|
|
16
16
|
import { TransactionStatusResponse } from 'rango-sdk';
|
|
17
17
|
import { httpService } from '../services';
|
|
18
18
|
|
|
19
|
-
const INTERVAL_FOR_CHECK =
|
|
19
|
+
const INTERVAL_FOR_CHECK = 3_000;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Subscribe to status of swap transaction by checking from server periodically.
|
|
@@ -73,6 +73,7 @@ async function checkTransactionStatus({
|
|
|
73
73
|
if (!!newTransaction) {
|
|
74
74
|
currentStep.status = 'created';
|
|
75
75
|
currentStep.executedTransactionId = null;
|
|
76
|
+
currentStep.executedTransactionTime = null;
|
|
76
77
|
currentStep.transferTransaction = null;
|
|
77
78
|
currentStep.cosmosTransaction = null;
|
|
78
79
|
currentStep.evmTransaction = null;
|
|
@@ -82,7 +83,6 @@ async function checkTransactionStatus({
|
|
|
82
83
|
currentStep.starknetTransaction = null;
|
|
83
84
|
currentStep.tronApprovalTransaction = null;
|
|
84
85
|
currentStep.tronTransaction = null;
|
|
85
|
-
currentStep.fromBlockchain = newTransaction.blockChain as Network;
|
|
86
86
|
|
|
87
87
|
if (isEvmTransaction(newTransaction)) {
|
|
88
88
|
if (newTransaction.isApprovalTx)
|
|
@@ -111,6 +111,14 @@ async function checkTransactionStatus({
|
|
|
111
111
|
swap: swap,
|
|
112
112
|
step: currentStep,
|
|
113
113
|
});
|
|
114
|
+
else if (prevOutputAmount === null && outputAmount === null) {
|
|
115
|
+
// it is needed to set notification after reloading the page
|
|
116
|
+
context.notifier({
|
|
117
|
+
eventType: 'check_tx_status',
|
|
118
|
+
swap: swap,
|
|
119
|
+
step: currentStep,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
114
122
|
|
|
115
123
|
if (currentStep.status === 'success') {
|
|
116
124
|
const nextStep = getNextStep(swap, currentStep);
|
|
@@ -118,6 +126,10 @@ async function checkTransactionStatus({
|
|
|
118
126
|
swap.extraMessage = !!nextStep
|
|
119
127
|
? `starting next step: ${nextStep.swapperId}: ${nextStep.fromBlockchain} -> ${nextStep.toBlockchain}`
|
|
120
128
|
: '';
|
|
129
|
+
} else if (currentStep.status === 'failed') {
|
|
130
|
+
swap.extraMessage = 'Transaction failed in blockchain';
|
|
131
|
+
swap.extraMessageSeverity = MessageSeverity.error;
|
|
132
|
+
swap.extraMessageDetail = '';
|
|
121
133
|
}
|
|
122
134
|
|
|
123
135
|
// Sync data with storage
|
|
@@ -146,6 +158,7 @@ async function checkApprovalStatus({
|
|
|
146
158
|
next,
|
|
147
159
|
schedule,
|
|
148
160
|
retry,
|
|
161
|
+
failed,
|
|
149
162
|
context,
|
|
150
163
|
}: ExecuterActions<
|
|
151
164
|
SwapStorage,
|
|
@@ -153,14 +166,49 @@ async function checkApprovalStatus({
|
|
|
153
166
|
SwapQueueContext
|
|
154
167
|
>): Promise<void> {
|
|
155
168
|
const swap = getStorage().swapDetails as SwapStorage['swapDetails'];
|
|
169
|
+
// double check it after fixing parallel
|
|
170
|
+
// const onFinish = () => {
|
|
171
|
+
// // TODO resetClaimedBy is undefined here
|
|
172
|
+
// if (context.resetClaimedBy) {
|
|
173
|
+
// context.resetClaimedBy();
|
|
174
|
+
// }
|
|
175
|
+
// };
|
|
156
176
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
157
177
|
const currentStep = getCurrentStep(swap)!;
|
|
158
178
|
let isApproved = false;
|
|
159
179
|
try {
|
|
160
|
-
const response = await httpService.checkApproval(
|
|
180
|
+
const response = await httpService.checkApproval(
|
|
181
|
+
swap.requestId,
|
|
182
|
+
currentStep.executedTransactionId || ''
|
|
183
|
+
);
|
|
161
184
|
isApproved = response.isApproved;
|
|
185
|
+
if (!isApproved && response.txStatus === 'failed') {
|
|
186
|
+
// approve transaction failed on
|
|
187
|
+
// we should fail the whole swap
|
|
188
|
+
const updateResult = updateSwapStatus({
|
|
189
|
+
getStorage,
|
|
190
|
+
setStorage,
|
|
191
|
+
nextStatus: 'failed',
|
|
192
|
+
nextStepStatus: 'failed',
|
|
193
|
+
errorCode: 'SEND_TX_FAILED',
|
|
194
|
+
message: 'Approve transaction failed',
|
|
195
|
+
details: 'Smart contract approval failed in blockchain.',
|
|
196
|
+
});
|
|
197
|
+
context.notifier({
|
|
198
|
+
eventType: 'smart_contract_call_failed',
|
|
199
|
+
...updateResult,
|
|
200
|
+
});
|
|
201
|
+
failed();
|
|
202
|
+
// onFinish();
|
|
203
|
+
} else if (!isApproved) {
|
|
204
|
+
// it is needed to set notification after reloading the page
|
|
205
|
+
context.notifier({
|
|
206
|
+
eventType: 'check_approve_tx_status',
|
|
207
|
+
swap: swap,
|
|
208
|
+
step: currentStep,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
162
211
|
} catch (e) {
|
|
163
|
-
console.error('Failed to check getApprovedAmount', e);
|
|
164
212
|
isApproved = false;
|
|
165
213
|
}
|
|
166
214
|
if (isApproved) {
|
|
@@ -170,6 +218,7 @@ async function checkApprovalStatus({
|
|
|
170
218
|
swap.extraMessageSeverity = MessageSeverity.success;
|
|
171
219
|
currentStep.evmApprovalTransaction = null;
|
|
172
220
|
currentStep.executedTransactionId = null;
|
|
221
|
+
currentStep.executedTransactionTime = null;
|
|
173
222
|
currentStep.starknetApprovalTransaction = null;
|
|
174
223
|
currentStep.tronApprovalTransaction = null;
|
|
175
224
|
|
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
updateSwapStatus,
|
|
12
12
|
throwOnOK,
|
|
13
13
|
} from '../helpers';
|
|
14
|
-
import {
|
|
15
|
-
import { prettifyErrorMessage } from '../shared';
|
|
14
|
+
import { prettifyErrorMessage } from '../shared-errors';
|
|
16
15
|
import { CreateTransactionRequest } from 'rango-sdk';
|
|
17
16
|
import { httpService } from '../services';
|
|
18
17
|
|
|
@@ -110,7 +109,7 @@ export async function createTransaction(
|
|
|
110
109
|
nextStepStatus: 'failed',
|
|
111
110
|
message: extraMessage,
|
|
112
111
|
details: extraMessageDetail,
|
|
113
|
-
errorCode:
|
|
112
|
+
errorCode: 'FETCH_TX_FAILED',
|
|
114
113
|
});
|
|
115
114
|
context.notifier({
|
|
116
115
|
eventType: 'task_failed',
|
|
@@ -54,7 +54,7 @@ export async function executeTransaction(
|
|
|
54
54
|
resetNetworkStatus(actions);
|
|
55
55
|
|
|
56
56
|
/* Make sure wallet is connected and also the connected wallet is matched with tx by checking address. */
|
|
57
|
-
const isWrongAddress = !isRequiredWalletConnected(swap, context.state);
|
|
57
|
+
const isWrongAddress = !isRequiredWalletConnected(swap, context.state).ok;
|
|
58
58
|
if (isWrongAddress) {
|
|
59
59
|
const { type, address } = getRequiredWallet(swap);
|
|
60
60
|
const isWalletInCompatible = wallets?.blockchains?.find(
|
|
@@ -79,10 +79,10 @@ export async function executeTransaction(
|
|
|
79
79
|
*/
|
|
80
80
|
const needsToBlockQueue = isNeedBlockQueueForParallel(currentStep);
|
|
81
81
|
|
|
82
|
-
if (needsToBlockQueue && !isClaimed
|
|
82
|
+
if (needsToBlockQueue && !isClaimed) {
|
|
83
83
|
const blockedFor = {
|
|
84
84
|
reason: BlockReason.DEPENDS_ON_OTHER_QUEUES,
|
|
85
|
-
description: 'Waiting for other
|
|
85
|
+
description: 'Waiting for other swaps to complete',
|
|
86
86
|
details: {},
|
|
87
87
|
};
|
|
88
88
|
requestBlock(blockedFor);
|
package/src/constants.ts
CHANGED
|
@@ -2,7 +2,7 @@ export const RANGO_DAPP_API_KEY = process.env.REACT_APP_API_KEY;
|
|
|
2
2
|
export const RANGO_DAPP_API_BASE_URL = process.env.REACT_APP_API_BASE_URL;
|
|
3
3
|
|
|
4
4
|
export const ERROR_MESSAGE_DEPENDS_ON_OTHER_QUEUES =
|
|
5
|
-
'Waiting for other
|
|
5
|
+
'Waiting for other swaps to complete';
|
|
6
6
|
export const ERROR_MESSAGE_WAIT_FOR_WALLET = 'Waiting for connecting wallet';
|
|
7
7
|
export const ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET = (
|
|
8
8
|
type: string | null,
|