@rango-dev/queue-manager-rango-preset 0.1.15-next.3 → 0.1.15-next.4
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/helpers.d.ts +39 -13
- package/dist/helpers.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +396 -580
- 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 +398 -582
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/shared.d.ts +5 -5
- package/dist/shared.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/actions/checkStatus.ts +171 -73
- package/src/actions/createTransaction.ts +5 -50
- package/src/helpers.ts +256 -672
- package/src/shared.ts +31 -33
package/src/helpers.ts
CHANGED
|
@@ -21,16 +21,16 @@ import {
|
|
|
21
21
|
import { Providers, readAccountAddress } from '@rango-dev/wallets-core';
|
|
22
22
|
|
|
23
23
|
import {
|
|
24
|
-
TronTransaction,
|
|
25
|
-
StarknetTransaction,
|
|
26
|
-
CosmosTransaction,
|
|
27
|
-
EvmTransaction,
|
|
28
|
-
SolanaTransaction,
|
|
29
|
-
Transfer as TransferTransaction,
|
|
30
24
|
Transaction,
|
|
31
25
|
TransactionType,
|
|
32
26
|
EvmBlockchainMeta,
|
|
33
27
|
CreateTransactionResponse,
|
|
28
|
+
isEvmTransaction,
|
|
29
|
+
isCosmosTransaction,
|
|
30
|
+
isSolanaTransaction,
|
|
31
|
+
isTronTransaction,
|
|
32
|
+
isStarknetTransaction,
|
|
33
|
+
isTransferTransaction,
|
|
34
34
|
} from 'rango-sdk';
|
|
35
35
|
|
|
36
36
|
import {
|
|
@@ -44,9 +44,7 @@ import {
|
|
|
44
44
|
EventType,
|
|
45
45
|
getCurrentBlockchainOf,
|
|
46
46
|
getCurrentBlockchainOfOrNull,
|
|
47
|
-
|
|
48
|
-
getStarknetApproveUrl,
|
|
49
|
-
getTronApproveUrl,
|
|
47
|
+
getScannerUrl,
|
|
50
48
|
getRelatedWalletOrNull,
|
|
51
49
|
MessageSeverity,
|
|
52
50
|
PendingSwap,
|
|
@@ -55,7 +53,6 @@ import {
|
|
|
55
53
|
StepStatus,
|
|
56
54
|
SwapStatus,
|
|
57
55
|
Wallet,
|
|
58
|
-
SwapProgressNotification,
|
|
59
56
|
getRelatedWallet,
|
|
60
57
|
getCurrentAddressOf,
|
|
61
58
|
} from './shared';
|
|
@@ -93,6 +90,23 @@ export function claimQueue() {
|
|
|
93
90
|
};
|
|
94
91
|
}
|
|
95
92
|
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* We use module-level variable to keep track of
|
|
96
|
+
* map of transactions hash to the TransactionResponse
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
let swapTransactionToResponseMap: { [id: string]: any } = {};
|
|
100
|
+
export function useTransactionsResponse() {
|
|
101
|
+
return {
|
|
102
|
+
getTransactionResponseByHash: (hash: string) =>
|
|
103
|
+
swapTransactionToResponseMap[hash],
|
|
104
|
+
setTransactionResponseByHash: (hash: string, response: any) => {
|
|
105
|
+
swapTransactionToResponseMap[hash] = response;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
96
110
|
/**
|
|
97
111
|
* Sample inputs are:
|
|
98
112
|
* - "metamask-ETH"
|
|
@@ -130,6 +144,110 @@ export const getCurrentStep = (swap: PendingSwap): PendingSwapStep | null => {
|
|
|
130
144
|
);
|
|
131
145
|
};
|
|
132
146
|
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
* Returns current step transaction
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
export const getCurrentStepTx = (
|
|
153
|
+
currentStep: PendingSwapStep
|
|
154
|
+
): Transaction | null => {
|
|
155
|
+
const {
|
|
156
|
+
evmTransaction,
|
|
157
|
+
evmApprovalTransaction,
|
|
158
|
+
cosmosTransaction,
|
|
159
|
+
solanaTransaction,
|
|
160
|
+
transferTransaction,
|
|
161
|
+
starknetApprovalTransaction,
|
|
162
|
+
starknetTransaction,
|
|
163
|
+
tronApprovalTransaction,
|
|
164
|
+
tronTransaction,
|
|
165
|
+
} = currentStep;
|
|
166
|
+
return (
|
|
167
|
+
evmTransaction ||
|
|
168
|
+
evmApprovalTransaction ||
|
|
169
|
+
cosmosTransaction ||
|
|
170
|
+
solanaTransaction ||
|
|
171
|
+
transferTransaction ||
|
|
172
|
+
starknetApprovalTransaction ||
|
|
173
|
+
starknetTransaction ||
|
|
174
|
+
tronApprovalTransaction ||
|
|
175
|
+
tronTransaction
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
*
|
|
181
|
+
* Set current step transaction
|
|
182
|
+
*
|
|
183
|
+
*/
|
|
184
|
+
export const setCurrentStepTx = (
|
|
185
|
+
currentStep: PendingSwapStep,
|
|
186
|
+
transaction: Transaction
|
|
187
|
+
): PendingSwapStep => {
|
|
188
|
+
currentStep.transferTransaction = null;
|
|
189
|
+
currentStep.cosmosTransaction = null;
|
|
190
|
+
currentStep.evmTransaction = null;
|
|
191
|
+
currentStep.solanaTransaction = null;
|
|
192
|
+
currentStep.evmApprovalTransaction = null;
|
|
193
|
+
currentStep.starknetApprovalTransaction = null;
|
|
194
|
+
currentStep.starknetTransaction = null;
|
|
195
|
+
currentStep.tronApprovalTransaction = null;
|
|
196
|
+
currentStep.tronTransaction = null;
|
|
197
|
+
|
|
198
|
+
if (isEvmTransaction(transaction)) {
|
|
199
|
+
if (transaction.isApprovalTx)
|
|
200
|
+
currentStep.evmApprovalTransaction = transaction;
|
|
201
|
+
else currentStep.evmTransaction = transaction;
|
|
202
|
+
} else if (isCosmosTransaction(transaction)) {
|
|
203
|
+
currentStep.cosmosTransaction = transaction;
|
|
204
|
+
} else if (isSolanaTransaction(transaction)) {
|
|
205
|
+
currentStep.solanaTransaction = transaction;
|
|
206
|
+
} else if (isTransferTransaction(transaction)) {
|
|
207
|
+
currentStep.transferTransaction = transaction;
|
|
208
|
+
} else if (isStarknetTransaction(transaction)) {
|
|
209
|
+
if (transaction.isApprovalTx)
|
|
210
|
+
currentStep.starknetApprovalTransaction = transaction;
|
|
211
|
+
else currentStep.starknetTransaction = transaction;
|
|
212
|
+
} else if (isTronTransaction(transaction)) {
|
|
213
|
+
if (transaction.isApprovalTx)
|
|
214
|
+
currentStep.tronApprovalTransaction = transaction;
|
|
215
|
+
else currentStep.tronTransaction = transaction;
|
|
216
|
+
}
|
|
217
|
+
return currentStep;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* Returns current step transaction type
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
export const getCurrentStepTxType = (
|
|
226
|
+
currentStep: PendingSwapStep
|
|
227
|
+
): TransactionType | undefined => {
|
|
228
|
+
return getCurrentStepTx(currentStep)?.type;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
*
|
|
233
|
+
* Returns a boolean indicating that current step is an approval tx or not.
|
|
234
|
+
*
|
|
235
|
+
*/
|
|
236
|
+
export const isApprovalCurrentStepTx = (
|
|
237
|
+
currentStep: PendingSwapStep
|
|
238
|
+
): boolean => {
|
|
239
|
+
const {
|
|
240
|
+
evmApprovalTransaction,
|
|
241
|
+
starknetApprovalTransaction,
|
|
242
|
+
tronApprovalTransaction,
|
|
243
|
+
} = currentStep;
|
|
244
|
+
return !!(
|
|
245
|
+
evmApprovalTransaction ||
|
|
246
|
+
starknetApprovalTransaction ||
|
|
247
|
+
tronApprovalTransaction
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
|
|
133
251
|
/**
|
|
134
252
|
* When we are doing a swap, there are some common fields that will be updated together.
|
|
135
253
|
* This function helps us to update a swap status and also it will update some more fields like `extraMessageSeverity` based on the input.
|
|
@@ -218,12 +336,17 @@ export function updateSwapStatus({
|
|
|
218
336
|
};
|
|
219
337
|
}
|
|
220
338
|
|
|
339
|
+
/**
|
|
340
|
+
*
|
|
341
|
+
* Set current step transaction hash, update pending swap status, and notify user if needed
|
|
342
|
+
*
|
|
343
|
+
*/
|
|
221
344
|
export function setStepTransactionIds(
|
|
222
345
|
{ getStorage, setStorage }: ExecuterActions<SwapStorage, SwapActionTypes>,
|
|
223
346
|
txId: string | null,
|
|
224
347
|
notifier: SwapQueueContext['notifier'],
|
|
225
348
|
eventType?: EventType,
|
|
226
|
-
|
|
349
|
+
explorerUrl?: { url?: string; description?: string }
|
|
227
350
|
): void {
|
|
228
351
|
const swap = getStorage().swapDetails;
|
|
229
352
|
swap.hasAlreadyProceededToSign = null;
|
|
@@ -231,12 +354,12 @@ export function setStepTransactionIds(
|
|
|
231
354
|
const currentStep = getCurrentStep(swap)!;
|
|
232
355
|
currentStep.executedTransactionId = txId;
|
|
233
356
|
currentStep.executedTransactionTime = new Date().getTime().toString();
|
|
234
|
-
if (!!
|
|
357
|
+
if (!!explorerUrl?.url)
|
|
235
358
|
currentStep.explorerUrl = [
|
|
236
359
|
...(currentStep.explorerUrl || []),
|
|
237
360
|
{
|
|
238
|
-
url:
|
|
239
|
-
description:
|
|
361
|
+
url: explorerUrl.url,
|
|
362
|
+
description: explorerUrl.description || null,
|
|
240
363
|
},
|
|
241
364
|
];
|
|
242
365
|
if (eventType === 'check_tx_status') {
|
|
@@ -257,18 +380,6 @@ export function setStepTransactionIds(
|
|
|
257
380
|
notifier({ eventType: eventType, swap: swap, step: currentStep });
|
|
258
381
|
}
|
|
259
382
|
|
|
260
|
-
export function getSwapNotitfication(
|
|
261
|
-
eventType: EventType,
|
|
262
|
-
updateResult: { swap: PendingSwap; step: PendingSwapStep | null }
|
|
263
|
-
): SwapProgressNotification {
|
|
264
|
-
if (updateResult.swap.hasAlreadyProceededToSign) {
|
|
265
|
-
return {
|
|
266
|
-
eventType: 'transaction_expired',
|
|
267
|
-
...updateResult,
|
|
268
|
-
};
|
|
269
|
-
} else return { eventType, ...updateResult };
|
|
270
|
-
}
|
|
271
|
-
|
|
272
383
|
/**
|
|
273
384
|
* If a swap needs a wallet to be connected,
|
|
274
385
|
* By calling this function some related fields will be updated to show a correct message and state for notfiying the user.
|
|
@@ -395,22 +506,6 @@ export function delay(ms: number): Promise<unknown> {
|
|
|
395
506
|
return new Promise((res) => setTimeout(res, ms));
|
|
396
507
|
}
|
|
397
508
|
|
|
398
|
-
export const isEvmTransaction = (tx: Transaction): tx is EvmTransaction =>
|
|
399
|
-
tx.type === TransactionType.EVM;
|
|
400
|
-
|
|
401
|
-
export const isCosmosTransaction = (tx: Transaction): tx is CosmosTransaction =>
|
|
402
|
-
tx.type === TransactionType.COSMOS;
|
|
403
|
-
export const isSolanaTransaction = (tx: Transaction): tx is SolanaTransaction =>
|
|
404
|
-
tx.type === TransactionType.SOLANA;
|
|
405
|
-
export const isTrasnferTransaction = (
|
|
406
|
-
tx: Transaction
|
|
407
|
-
): tx is TransferTransaction => tx.type === TransactionType.TRANSFER;
|
|
408
|
-
export const isStarknetTransaction = (
|
|
409
|
-
tx: Transaction
|
|
410
|
-
): tx is StarknetTransaction => tx.type === TransactionType.STARKNET;
|
|
411
|
-
export const isTronTransaction = (tx: Transaction): tx is TronTransaction =>
|
|
412
|
-
tx.type === TransactionType.TRON;
|
|
413
|
-
|
|
414
509
|
/**
|
|
415
510
|
*
|
|
416
511
|
* To execute a swap, we are keeping the user prefrences on what wallet they are going to use for a sepecific blockchain
|
|
@@ -793,26 +888,18 @@ export function isRequiredWalletConnected(
|
|
|
793
888
|
export function singTransaction(
|
|
794
889
|
actions: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>
|
|
795
890
|
): void {
|
|
891
|
+
const { setTransactionResponseByHash } = useTransactionsResponse();
|
|
796
892
|
const { getStorage, setStorage, failed, next, schedule, context } = actions;
|
|
797
893
|
const { meta, getSigners, notifier, isMobileWallet } = context;
|
|
798
894
|
const swap = getStorage().swapDetails;
|
|
799
895
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
800
896
|
const currentStep = getCurrentStep(swap)!;
|
|
801
|
-
|
|
802
|
-
evmTransaction,
|
|
803
|
-
evmApprovalTransaction,
|
|
804
|
-
cosmosTransaction,
|
|
805
|
-
solanaTransaction,
|
|
806
|
-
transferTransaction,
|
|
807
|
-
tronTransaction,
|
|
808
|
-
tronApprovalTransaction,
|
|
809
|
-
starknetTransaction,
|
|
810
|
-
starknetApprovalTransaction,
|
|
811
|
-
} = currentStep;
|
|
897
|
+
|
|
812
898
|
const sourceWallet = getRelatedWallet(swap, currentStep);
|
|
899
|
+
const mobileWallet = isMobileWallet(sourceWallet?.walletType);
|
|
813
900
|
const walletAddress = getCurrentAddressOf(swap, currentStep);
|
|
814
901
|
const walletSigners = getSigners(sourceWallet.walletType);
|
|
815
|
-
const
|
|
902
|
+
const currentStepBlockchain = getCurrentBlockchainOf(swap, currentStep);
|
|
816
903
|
|
|
817
904
|
const onFinish = () => {
|
|
818
905
|
// TODO resetClaimedBy is undefined here
|
|
@@ -821,636 +908,133 @@ export function singTransaction(
|
|
|
821
908
|
}
|
|
822
909
|
};
|
|
823
910
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
911
|
+
const tx = getCurrentStepTx(currentStep);
|
|
912
|
+
const txType = tx?.type;
|
|
913
|
+
const isApproval = isApprovalCurrentStepTx(currentStep);
|
|
914
|
+
const isSmartContractCall = [
|
|
915
|
+
TransactionType.EVM,
|
|
916
|
+
TransactionType.STARKNET,
|
|
917
|
+
TransactionType.TRON,
|
|
918
|
+
].includes(txType!);
|
|
831
919
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
mobileWallet ? 'on your mobile phone' : ''
|
|
835
|
-
}`;
|
|
836
|
-
const updateResult = updateSwapStatus({
|
|
837
|
-
getStorage,
|
|
838
|
-
setStorage,
|
|
839
|
-
nextStepStatus: 'waitingForApproval',
|
|
840
|
-
message,
|
|
841
|
-
details:
|
|
842
|
-
'Waiting for approve transaction to be mined and confirmed successfully',
|
|
843
|
-
});
|
|
844
|
-
notifier({
|
|
845
|
-
eventType: 'confirm_approve_contract',
|
|
846
|
-
...updateResult,
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
// Execute transaction
|
|
850
|
-
walletSigners
|
|
851
|
-
.getSigner(TransactionType.EVM)
|
|
852
|
-
.signAndSendTx(evmApprovalTransaction, walletAddress, null)
|
|
853
|
-
.then(
|
|
854
|
-
(hash) => {
|
|
855
|
-
const approveUrl = getEvmApproveUrl(
|
|
856
|
-
hash,
|
|
857
|
-
getCurrentBlockchainOf(swap, currentStep),
|
|
858
|
-
meta.evmBasedChains
|
|
859
|
-
);
|
|
860
|
-
setStepTransactionIds(
|
|
861
|
-
actions,
|
|
862
|
-
hash,
|
|
863
|
-
notifier,
|
|
864
|
-
'check_approve_tx_status',
|
|
865
|
-
approveUrl
|
|
866
|
-
);
|
|
867
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
868
|
-
next();
|
|
869
|
-
onFinish();
|
|
870
|
-
},
|
|
871
|
-
|
|
872
|
-
(error) => {
|
|
873
|
-
if (swap.status === 'failed') return;
|
|
874
|
-
|
|
875
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
876
|
-
prettifyErrorMessage(error);
|
|
877
|
-
if (
|
|
878
|
-
error &&
|
|
879
|
-
error?.root &&
|
|
880
|
-
error?.root?.message &&
|
|
881
|
-
error?.root?.code &&
|
|
882
|
-
error?.root?.reason
|
|
883
|
-
) {
|
|
884
|
-
logRPCError(
|
|
885
|
-
error.root,
|
|
886
|
-
swap,
|
|
887
|
-
currentStep,
|
|
888
|
-
sourceWallet?.walletType
|
|
889
|
-
);
|
|
890
|
-
}
|
|
891
|
-
const updateResult = updateSwapStatus({
|
|
892
|
-
getStorage,
|
|
893
|
-
setStorage,
|
|
894
|
-
nextStatus: 'failed',
|
|
895
|
-
nextStepStatus: 'failed',
|
|
896
|
-
message: extraMessage,
|
|
897
|
-
details: extraMessageDetail,
|
|
898
|
-
errorCode: extraMessageErrorCode,
|
|
899
|
-
});
|
|
900
|
-
notifier({
|
|
901
|
-
eventType:
|
|
902
|
-
extraMessageErrorCode === 'REJECTED_BY_USER'
|
|
903
|
-
? 'contract_rejected'
|
|
904
|
-
: 'smart_contract_call_failed',
|
|
905
|
-
...updateResult,
|
|
906
|
-
});
|
|
907
|
-
|
|
908
|
-
failed();
|
|
909
|
-
onFinish();
|
|
910
|
-
}
|
|
911
|
-
);
|
|
912
|
-
return;
|
|
913
|
-
} else if (!!tronApprovalTransaction) {
|
|
914
|
-
// Update swap status
|
|
915
|
-
const message = `Waiting for approval of ${currentStep?.fromSymbol} coin ${
|
|
916
|
-
mobileWallet ? 'on your mobile phone' : ''
|
|
917
|
-
}`;
|
|
918
|
-
const updateResult = updateSwapStatus({
|
|
919
|
-
getStorage,
|
|
920
|
-
setStorage,
|
|
921
|
-
nextStepStatus: 'waitingForApproval',
|
|
922
|
-
message,
|
|
923
|
-
details:
|
|
924
|
-
'Waiting for approve transaction to be mined and confirmed successfully',
|
|
925
|
-
});
|
|
926
|
-
notifier({
|
|
927
|
-
eventType: 'confirm_approve_contract',
|
|
928
|
-
...updateResult,
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
// Execute transaction
|
|
932
|
-
walletSigners
|
|
933
|
-
.getSigner(TransactionType.TRON)
|
|
934
|
-
.signAndSendTx(tronApprovalTransaction, walletAddress, null)
|
|
935
|
-
.then(
|
|
936
|
-
(hash) => {
|
|
937
|
-
const approveUrl = getTronApproveUrl(hash);
|
|
938
|
-
setStepTransactionIds(
|
|
939
|
-
actions,
|
|
940
|
-
hash,
|
|
941
|
-
notifier,
|
|
942
|
-
'check_approve_tx_status',
|
|
943
|
-
approveUrl
|
|
944
|
-
);
|
|
945
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
946
|
-
next();
|
|
947
|
-
onFinish();
|
|
948
|
-
},
|
|
949
|
-
|
|
950
|
-
(error) => {
|
|
951
|
-
if (swap.status === 'failed') return;
|
|
952
|
-
|
|
953
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
954
|
-
prettifyErrorMessage(error);
|
|
955
|
-
if (
|
|
956
|
-
error &&
|
|
957
|
-
error?.root &&
|
|
958
|
-
error?.root?.message &&
|
|
959
|
-
error?.root?.code &&
|
|
960
|
-
error?.root?.reason
|
|
961
|
-
) {
|
|
962
|
-
logRPCError(
|
|
963
|
-
error.root,
|
|
964
|
-
swap,
|
|
965
|
-
currentStep,
|
|
966
|
-
sourceWallet?.walletType
|
|
967
|
-
);
|
|
968
|
-
}
|
|
920
|
+
const hasAlreadyProceededToSign =
|
|
921
|
+
typeof swap.hasAlreadyProceededToSign === 'boolean';
|
|
969
922
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
message: extraMessage,
|
|
976
|
-
details: extraMessageDetail,
|
|
977
|
-
errorCode: extraMessageErrorCode,
|
|
978
|
-
});
|
|
979
|
-
notifier({
|
|
980
|
-
eventType:
|
|
981
|
-
extraMessageErrorCode === 'REJECTED_BY_USER'
|
|
982
|
-
? 'contract_rejected'
|
|
983
|
-
: 'smart_contract_call_failed',
|
|
984
|
-
...updateResult,
|
|
985
|
-
});
|
|
923
|
+
let nextStatus: SwapStatus | undefined,
|
|
924
|
+
nextStepStatus: StepStatus,
|
|
925
|
+
eventType: EventType,
|
|
926
|
+
message: string,
|
|
927
|
+
details: string;
|
|
986
928
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
);
|
|
991
|
-
return;
|
|
992
|
-
} else if (!!starknetApprovalTransaction) {
|
|
993
|
-
// Update swap status
|
|
994
|
-
const message = `Waiting for approval of ${currentStep?.fromSymbol} coin ${
|
|
995
|
-
mobileWallet ? 'on your mobile phone' : ''
|
|
929
|
+
if (isApproval) {
|
|
930
|
+
message = `Waiting for approval of ${currentStep?.fromSymbol} coin ${
|
|
931
|
+
mobileWallet ? 'on your mobile phone!' : ''
|
|
996
932
|
}`;
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
setStepTransactionIds(
|
|
1018
|
-
actions,
|
|
1019
|
-
hash,
|
|
1020
|
-
notifier,
|
|
1021
|
-
'check_approve_tx_status',
|
|
1022
|
-
approveUrl
|
|
1023
|
-
);
|
|
1024
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1025
|
-
next();
|
|
1026
|
-
onFinish();
|
|
1027
|
-
},
|
|
1028
|
-
|
|
1029
|
-
(error) => {
|
|
1030
|
-
if (swap.status === 'failed') return;
|
|
1031
|
-
|
|
1032
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1033
|
-
prettifyErrorMessage(error);
|
|
1034
|
-
if (
|
|
1035
|
-
error &&
|
|
1036
|
-
error?.root &&
|
|
1037
|
-
error?.root?.message &&
|
|
1038
|
-
error?.root?.code &&
|
|
1039
|
-
error?.root?.reason
|
|
1040
|
-
) {
|
|
1041
|
-
logRPCError(
|
|
1042
|
-
error.root,
|
|
1043
|
-
swap,
|
|
1044
|
-
currentStep,
|
|
1045
|
-
sourceWallet?.walletType
|
|
1046
|
-
);
|
|
1047
|
-
}
|
|
933
|
+
details =
|
|
934
|
+
'Waiting for approve transaction to be mined and confirmed successfully';
|
|
935
|
+
nextStepStatus = 'waitingForApproval';
|
|
936
|
+
nextStatus = undefined;
|
|
937
|
+
eventType = 'confirm_approve_contract';
|
|
938
|
+
} else if (hasAlreadyProceededToSign) {
|
|
939
|
+
message = 'Transaction is expired. Please try again.';
|
|
940
|
+
nextStepStatus = 'failed';
|
|
941
|
+
nextStatus = 'failed';
|
|
942
|
+
details = '';
|
|
943
|
+
eventType = 'transaction_expired';
|
|
944
|
+
} else {
|
|
945
|
+
message = 'Executing transaction ...';
|
|
946
|
+
nextStepStatus = 'running';
|
|
947
|
+
nextStatus = 'running';
|
|
948
|
+
details = `${mobileWallet ? 'Check your mobile phone!' : ''}`;
|
|
949
|
+
eventType = isSmartContractCall
|
|
950
|
+
? 'calling_smart_contract'
|
|
951
|
+
: 'confirm_transfer';
|
|
952
|
+
}
|
|
1048
953
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
954
|
+
const updateResult = updateSwapStatus({
|
|
955
|
+
getStorage,
|
|
956
|
+
setStorage,
|
|
957
|
+
nextStepStatus,
|
|
958
|
+
nextStatus,
|
|
959
|
+
message: message,
|
|
960
|
+
details: details,
|
|
961
|
+
hasAlreadyProceededToSign: isApproval
|
|
962
|
+
? undefined
|
|
963
|
+
: hasAlreadyProceededToSign,
|
|
964
|
+
errorCode: hasAlreadyProceededToSign ? 'TX_EXPIRED' : undefined,
|
|
965
|
+
});
|
|
966
|
+
notifier({
|
|
967
|
+
eventType,
|
|
968
|
+
...updateResult,
|
|
969
|
+
});
|
|
1065
970
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
);
|
|
971
|
+
if (hasAlreadyProceededToSign) {
|
|
972
|
+
failed();
|
|
973
|
+
onFinish();
|
|
1070
974
|
return;
|
|
1071
975
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
errorCode: errorCodeBasedOnHasAlreadyProceededToSign,
|
|
1094
|
-
});
|
|
1095
|
-
|
|
1096
|
-
const notification = getSwapNotitfication('confirm_transfer', updateResult);
|
|
1097
|
-
notifier(notification);
|
|
1098
|
-
|
|
1099
|
-
if (notification.eventType === 'transaction_expired') {
|
|
1100
|
-
failed();
|
|
1101
|
-
onFinish();
|
|
1102
|
-
} else {
|
|
1103
|
-
walletSigners
|
|
1104
|
-
.getSigner(TransactionType.TRANSFER)
|
|
1105
|
-
.signAndSendTx(transferTransaction, walletAddress, null)
|
|
1106
|
-
.then(
|
|
1107
|
-
(txId) => {
|
|
1108
|
-
setStepTransactionIds(actions, txId, notifier, 'check_tx_status');
|
|
1109
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1110
|
-
next();
|
|
1111
|
-
onFinish();
|
|
1112
|
-
},
|
|
1113
|
-
(error) => {
|
|
1114
|
-
if (swap.status === 'failed') return;
|
|
1115
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1116
|
-
prettifyErrorMessage(error);
|
|
1117
|
-
const updateResult = updateSwapStatus({
|
|
1118
|
-
getStorage,
|
|
1119
|
-
setStorage,
|
|
1120
|
-
nextStatus: 'failed',
|
|
1121
|
-
nextStepStatus: 'failed',
|
|
1122
|
-
message: extraMessage,
|
|
1123
|
-
details: extraMessageDetail,
|
|
1124
|
-
errorCode: extraMessageErrorCode,
|
|
1125
|
-
});
|
|
1126
|
-
notifier({
|
|
1127
|
-
eventType:
|
|
1128
|
-
extraMessageErrorCode === 'REJECTED_BY_USER'
|
|
1129
|
-
? 'transfer_rejected'
|
|
1130
|
-
: 'transfer_failed',
|
|
1131
|
-
...updateResult,
|
|
1132
|
-
});
|
|
1133
|
-
failed();
|
|
1134
|
-
onFinish();
|
|
1135
|
-
}
|
|
1136
|
-
);
|
|
1137
|
-
}
|
|
1138
|
-
} else if (!!evmTransaction) {
|
|
1139
|
-
const updateResult = updateSwapStatus({
|
|
1140
|
-
getStorage,
|
|
1141
|
-
setStorage,
|
|
1142
|
-
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1143
|
-
nextStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1144
|
-
message: executeMessage,
|
|
1145
|
-
details: executeDetails,
|
|
1146
|
-
hasAlreadyProceededToSign,
|
|
1147
|
-
errorCode: errorCodeBasedOnHasAlreadyProceededToSign,
|
|
1148
|
-
});
|
|
1149
|
-
const notification = getSwapNotitfication(
|
|
1150
|
-
'calling_smart_contract',
|
|
1151
|
-
updateResult
|
|
1152
|
-
);
|
|
1153
|
-
notifier(notification);
|
|
1154
|
-
|
|
1155
|
-
if (notification.eventType === 'transaction_expired') {
|
|
1156
|
-
failed();
|
|
1157
|
-
onFinish();
|
|
1158
|
-
} else {
|
|
1159
|
-
walletSigners
|
|
1160
|
-
.getSigner(TransactionType.EVM)
|
|
1161
|
-
.signAndSendTx(evmTransaction, walletAddress, null)
|
|
1162
|
-
.then(
|
|
1163
|
-
(id) => {
|
|
1164
|
-
setStepTransactionIds(actions, id, notifier, 'check_tx_status');
|
|
1165
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1166
|
-
next();
|
|
1167
|
-
onFinish();
|
|
1168
|
-
},
|
|
1169
|
-
(error) => {
|
|
1170
|
-
if (swap.status === 'failed') return;
|
|
1171
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1172
|
-
prettifyErrorMessage(error);
|
|
1173
|
-
if (
|
|
1174
|
-
error &&
|
|
1175
|
-
error?.root &&
|
|
1176
|
-
error?.root?.message &&
|
|
1177
|
-
error?.root?.code &&
|
|
1178
|
-
error?.root?.reason
|
|
1179
|
-
) {
|
|
1180
|
-
logRPCError(
|
|
1181
|
-
error.root,
|
|
1182
|
-
swap,
|
|
1183
|
-
currentStep,
|
|
1184
|
-
sourceWallet?.walletType
|
|
1185
|
-
);
|
|
1186
|
-
}
|
|
1187
|
-
const updateResult = updateSwapStatus({
|
|
1188
|
-
getStorage,
|
|
1189
|
-
setStorage,
|
|
1190
|
-
nextStatus: 'failed',
|
|
1191
|
-
nextStepStatus: 'failed',
|
|
1192
|
-
message: extraMessage,
|
|
1193
|
-
details: extraMessageDetail,
|
|
1194
|
-
errorCode: extraMessageErrorCode,
|
|
1195
|
-
});
|
|
1196
|
-
notifier({
|
|
1197
|
-
eventType:
|
|
1198
|
-
extraMessageErrorCode === 'REJECTED_BY_USER'
|
|
1199
|
-
? 'contract_rejected'
|
|
1200
|
-
: 'smart_contract_call_failed',
|
|
1201
|
-
...updateResult,
|
|
1202
|
-
});
|
|
1203
|
-
|
|
1204
|
-
failed();
|
|
1205
|
-
onFinish();
|
|
1206
|
-
}
|
|
1207
|
-
);
|
|
1208
|
-
}
|
|
1209
|
-
} else if (!!cosmosTransaction) {
|
|
1210
|
-
const updateResult = updateSwapStatus({
|
|
1211
|
-
getStorage,
|
|
1212
|
-
setStorage,
|
|
1213
|
-
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1214
|
-
nextStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1215
|
-
message: executeMessage,
|
|
1216
|
-
details: executeDetails,
|
|
1217
|
-
hasAlreadyProceededToSign,
|
|
1218
|
-
errorCode: errorCodeBasedOnHasAlreadyProceededToSign,
|
|
1219
|
-
});
|
|
1220
|
-
const notification = getSwapNotitfication(
|
|
1221
|
-
'calling_smart_contract',
|
|
1222
|
-
updateResult
|
|
1223
|
-
);
|
|
1224
|
-
notifier(notification);
|
|
1225
|
-
|
|
1226
|
-
if (notification.eventType === 'transaction_expired') {
|
|
1227
|
-
failed();
|
|
1228
|
-
onFinish();
|
|
1229
|
-
} else {
|
|
1230
|
-
walletSigners
|
|
1231
|
-
.getSigner(TransactionType.COSMOS)
|
|
1232
|
-
.signAndSendTx(cosmosTransaction, walletAddress, null)
|
|
1233
|
-
.then(
|
|
1234
|
-
// todo
|
|
1235
|
-
(id: string | null) => {
|
|
1236
|
-
setStepTransactionIds(actions, id, notifier, 'check_tx_status');
|
|
1237
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1238
|
-
next();
|
|
1239
|
-
onFinish();
|
|
1240
|
-
},
|
|
1241
|
-
(error: string | null) => {
|
|
1242
|
-
if (swap.status === 'failed') return;
|
|
1243
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1244
|
-
prettifyErrorMessage(error);
|
|
1245
|
-
const updateResult = updateSwapStatus({
|
|
1246
|
-
getStorage,
|
|
1247
|
-
setStorage,
|
|
1248
|
-
nextStatus: 'failed',
|
|
1249
|
-
nextStepStatus: 'failed',
|
|
1250
|
-
message: extraMessage,
|
|
1251
|
-
details: extraMessageDetail,
|
|
1252
|
-
errorCode: extraMessageErrorCode,
|
|
1253
|
-
});
|
|
1254
|
-
notifier({
|
|
1255
|
-
eventType: 'smart_contract_call_failed',
|
|
1256
|
-
...updateResult,
|
|
1257
|
-
});
|
|
1258
|
-
failed();
|
|
1259
|
-
onFinish();
|
|
1260
|
-
}
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
} else if (!!solanaTransaction) {
|
|
1264
|
-
const updateResult = updateSwapStatus({
|
|
1265
|
-
getStorage,
|
|
1266
|
-
setStorage,
|
|
1267
|
-
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1268
|
-
nextStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1269
|
-
message: executeMessage,
|
|
1270
|
-
details: executeDetails,
|
|
1271
|
-
hasAlreadyProceededToSign,
|
|
1272
|
-
errorCode: errorCodeBasedOnHasAlreadyProceededToSign,
|
|
1273
|
-
});
|
|
1274
|
-
const notification = getSwapNotitfication(
|
|
1275
|
-
'calling_smart_contract',
|
|
1276
|
-
updateResult
|
|
1277
|
-
);
|
|
1278
|
-
notifier(notification);
|
|
1279
|
-
|
|
1280
|
-
if (notification.eventType === 'transaction_expired') {
|
|
1281
|
-
failed();
|
|
1282
|
-
onFinish();
|
|
1283
|
-
} else {
|
|
1284
|
-
const tx = solanaTransaction;
|
|
1285
|
-
walletSigners
|
|
1286
|
-
.getSigner(TransactionType.SOLANA)
|
|
1287
|
-
.signAndSendTx(tx, walletAddress, null)
|
|
1288
|
-
.then(
|
|
1289
|
-
(txId) => {
|
|
1290
|
-
setStepTransactionIds(actions, txId, notifier, 'check_tx_status');
|
|
1291
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1292
|
-
next();
|
|
1293
|
-
onFinish();
|
|
1294
|
-
},
|
|
1295
|
-
(error) => {
|
|
1296
|
-
if (swap.status === 'failed') return;
|
|
1297
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1298
|
-
prettifyErrorMessage(error);
|
|
1299
|
-
const updateResult = updateSwapStatus({
|
|
1300
|
-
getStorage,
|
|
1301
|
-
setStorage,
|
|
1302
|
-
nextStatus: 'failed',
|
|
1303
|
-
nextStepStatus: 'failed',
|
|
1304
|
-
message: extraMessage,
|
|
1305
|
-
details: extraMessageDetail,
|
|
1306
|
-
errorCode: extraMessageErrorCode,
|
|
1307
|
-
});
|
|
1308
|
-
notifier({
|
|
1309
|
-
eventType: 'smart_contract_call_failed',
|
|
1310
|
-
...updateResult,
|
|
1311
|
-
});
|
|
1312
|
-
failed();
|
|
1313
|
-
onFinish();
|
|
1314
|
-
}
|
|
1315
|
-
);
|
|
1316
|
-
}
|
|
1317
|
-
} else if (!!tronTransaction) {
|
|
1318
|
-
const updateResult = updateSwapStatus({
|
|
1319
|
-
getStorage,
|
|
1320
|
-
setStorage,
|
|
1321
|
-
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1322
|
-
nextStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1323
|
-
message: executeMessage,
|
|
1324
|
-
details: executeDetails,
|
|
1325
|
-
hasAlreadyProceededToSign,
|
|
1326
|
-
errorCode: errorCodeBasedOnHasAlreadyProceededToSign,
|
|
1327
|
-
});
|
|
1328
|
-
const notification = getSwapNotitfication(
|
|
1329
|
-
'calling_smart_contract',
|
|
1330
|
-
updateResult
|
|
1331
|
-
);
|
|
1332
|
-
notifier(notification);
|
|
1333
|
-
|
|
1334
|
-
if (notification.eventType === 'transaction_expired') {
|
|
1335
|
-
failed();
|
|
976
|
+
const signer = walletSigners.getSigner(txType!);
|
|
977
|
+
signer.signAndSendTx(tx!, walletAddress, null).then(
|
|
978
|
+
({ hash, response }) => {
|
|
979
|
+
const explorerUrl = getScannerUrl(
|
|
980
|
+
hash,
|
|
981
|
+
currentStepBlockchain,
|
|
982
|
+
meta.blockchains
|
|
983
|
+
);
|
|
984
|
+
setStepTransactionIds(
|
|
985
|
+
actions,
|
|
986
|
+
hash,
|
|
987
|
+
notifier,
|
|
988
|
+
isApproval ? 'check_approve_tx_status' : 'check_tx_status',
|
|
989
|
+
explorerUrl
|
|
990
|
+
? { url: explorerUrl, description: isApproval ? 'Approve' : 'Swap' }
|
|
991
|
+
: undefined
|
|
992
|
+
);
|
|
993
|
+
// response used for evm transactions to get receipt and track replaced
|
|
994
|
+
response && setTransactionResponseByHash(hash, response);
|
|
995
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
996
|
+
next();
|
|
1336
997
|
onFinish();
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
errorCode: extraMessageErrorCode,
|
|
1374
|
-
});
|
|
1375
|
-
notifier({
|
|
1376
|
-
eventType: 'smart_contract_call_failed',
|
|
1377
|
-
...updateResult,
|
|
1378
|
-
});
|
|
1379
|
-
|
|
1380
|
-
failed();
|
|
1381
|
-
onFinish();
|
|
1382
|
-
}
|
|
1383
|
-
);
|
|
1384
|
-
}
|
|
1385
|
-
} else if (!!starknetTransaction) {
|
|
1386
|
-
const updateResult = updateSwapStatus({
|
|
1387
|
-
getStorage,
|
|
1388
|
-
setStorage,
|
|
1389
|
-
nextStepStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1390
|
-
nextStatus: nextStepStatusBasedOnHasAlreadyProceededToSign,
|
|
1391
|
-
message: executeMessage,
|
|
1392
|
-
details: executeDetails,
|
|
1393
|
-
hasAlreadyProceededToSign,
|
|
1394
|
-
errorCode: errorCodeBasedOnHasAlreadyProceededToSign,
|
|
1395
|
-
});
|
|
1396
|
-
const notification = getSwapNotitfication(
|
|
1397
|
-
'calling_smart_contract',
|
|
1398
|
-
updateResult
|
|
1399
|
-
);
|
|
1400
|
-
notifier(notification);
|
|
1401
|
-
|
|
1402
|
-
if (notification.eventType === 'transaction_expired') {
|
|
998
|
+
},
|
|
999
|
+
(error) => {
|
|
1000
|
+
if (swap.status === 'failed') return;
|
|
1001
|
+
|
|
1002
|
+
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1003
|
+
prettifyErrorMessage(error);
|
|
1004
|
+
|
|
1005
|
+
// if it is an rpc error with details, send the log to sentry
|
|
1006
|
+
if (
|
|
1007
|
+
error &&
|
|
1008
|
+
error?.root &&
|
|
1009
|
+
error?.root?.message &&
|
|
1010
|
+
error?.root?.code &&
|
|
1011
|
+
error?.root?.reason
|
|
1012
|
+
)
|
|
1013
|
+
logRPCError(error.root, swap, currentStep, sourceWallet?.walletType);
|
|
1014
|
+
|
|
1015
|
+
const updateResult = updateSwapStatus({
|
|
1016
|
+
getStorage,
|
|
1017
|
+
setStorage,
|
|
1018
|
+
nextStatus: 'failed',
|
|
1019
|
+
nextStepStatus: 'failed',
|
|
1020
|
+
message: extraMessage,
|
|
1021
|
+
details: extraMessageDetail,
|
|
1022
|
+
errorCode: extraMessageErrorCode,
|
|
1023
|
+
});
|
|
1024
|
+
const eventType =
|
|
1025
|
+
extraMessageErrorCode === 'REJECTED_BY_USER'
|
|
1026
|
+
? 'contract_rejected'
|
|
1027
|
+
: isSmartContractCall
|
|
1028
|
+
? 'smart_contract_call_failed'
|
|
1029
|
+
: 'transfer_failed';
|
|
1030
|
+
notifier({
|
|
1031
|
+
eventType,
|
|
1032
|
+
...updateResult,
|
|
1033
|
+
});
|
|
1403
1034
|
failed();
|
|
1404
1035
|
onFinish();
|
|
1405
|
-
} else {
|
|
1406
|
-
walletSigners
|
|
1407
|
-
.getSigner(TransactionType.STARKNET)
|
|
1408
|
-
.signAndSendTx(starknetTransaction, walletAddress, null)
|
|
1409
|
-
.then(
|
|
1410
|
-
(id) => {
|
|
1411
|
-
setStepTransactionIds(actions, id, notifier, 'check_tx_status');
|
|
1412
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1413
|
-
next();
|
|
1414
|
-
onFinish();
|
|
1415
|
-
},
|
|
1416
|
-
(error) => {
|
|
1417
|
-
if (swap.status === 'failed') return;
|
|
1418
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1419
|
-
prettifyErrorMessage(error);
|
|
1420
|
-
if (
|
|
1421
|
-
error &&
|
|
1422
|
-
error?.root &&
|
|
1423
|
-
error?.root?.message &&
|
|
1424
|
-
error?.root?.code &&
|
|
1425
|
-
error?.root?.reason
|
|
1426
|
-
) {
|
|
1427
|
-
logRPCError(
|
|
1428
|
-
error.root,
|
|
1429
|
-
swap,
|
|
1430
|
-
currentStep,
|
|
1431
|
-
sourceWallet?.walletType
|
|
1432
|
-
);
|
|
1433
|
-
}
|
|
1434
|
-
const updateResult = updateSwapStatus({
|
|
1435
|
-
getStorage,
|
|
1436
|
-
setStorage,
|
|
1437
|
-
nextStatus: 'failed',
|
|
1438
|
-
nextStepStatus: 'failed',
|
|
1439
|
-
message: extraMessage,
|
|
1440
|
-
details: extraMessageDetail,
|
|
1441
|
-
errorCode: extraMessageErrorCode,
|
|
1442
|
-
});
|
|
1443
|
-
notifier({
|
|
1444
|
-
eventType: 'smart_contract_call_failed',
|
|
1445
|
-
...updateResult,
|
|
1446
|
-
});
|
|
1447
|
-
|
|
1448
|
-
failed();
|
|
1449
|
-
onFinish();
|
|
1450
|
-
}
|
|
1451
|
-
);
|
|
1452
1036
|
}
|
|
1453
|
-
|
|
1037
|
+
);
|
|
1454
1038
|
}
|
|
1455
1039
|
|
|
1456
1040
|
export function checkWaitingForConnectWalletChange(params: {
|