@rango-dev/queue-manager-rango-preset 0.1.10-next.87 → 0.1.10-next.90
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/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- 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 +226 -169
- 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 +227 -170
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/services/httpService.d.ts.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/constants.ts +1 -0
- package/src/helpers.ts +259 -200
- package/src/migration.ts +13 -1
- package/src/services/httpService.ts +5 -2
- package/src/shared.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../src/services/httpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../src/services/httpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,eAAO,MAAM,WAAW,aAGvB,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare type Blockchain = {
|
|
|
37
37
|
export declare type Wallet = {
|
|
38
38
|
blockchains: Blockchain[];
|
|
39
39
|
};
|
|
40
|
-
export declare type EventType = 'swap_started' | 'confirm_contract' | 'confirm_transfer' | 'task_failed' | 'task_completed' | 'task_canceled' | 'task_paused' | 'contract_confirmed' | 'contract_rejected' | 'transfer_confirmed' | 'transfer_rejected' | 'calling_smart_contract' | 'smart_contract_called' | 'smart_contract_call_failed' | 'step_completed_with_output' | 'waiting_for_network_change' | 'waiting_for_connecting_wallet' | 'network_changed' | 'not_enough_balance' | 'check_fee_failed' | 'route_failed_to_find';
|
|
40
|
+
export declare type EventType = 'swap_started' | 'confirm_contract' | 'confirm_transfer' | 'task_failed' | 'task_completed' | 'task_canceled' | 'task_paused' | 'contract_confirmed' | 'contract_rejected' | 'transfer_confirmed' | 'transfer_rejected' | 'calling_smart_contract' | 'smart_contract_called' | 'smart_contract_call_failed' | 'step_completed_with_output' | 'waiting_for_network_change' | 'waiting_for_connecting_wallet' | 'network_changed' | 'not_enough_balance' | 'check_fee_failed' | 'route_failed_to_find' | 'transaction_expired';
|
|
41
41
|
export declare type SwapSavedSettings = {
|
|
42
42
|
slippage: string;
|
|
43
43
|
disabledSwappersIds: string[];
|
|
@@ -129,6 +129,7 @@ export declare type PendingSwap = {
|
|
|
129
129
|
steps: PendingSwapStep[];
|
|
130
130
|
simulationResult: SimulationResult;
|
|
131
131
|
validateBalanceOrFee: boolean;
|
|
132
|
+
hasAlreadyProceededToSign?: boolean | null;
|
|
132
133
|
};
|
|
133
134
|
export declare const getCurrentBlockchainOfOrNull: (swap: PendingSwap, step: PendingSwapStep) => Network | null;
|
|
134
135
|
export declare const getCurrentBlockchainOf: (swap: PendingSwap, step: PendingSwapStep) => Network;
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,QAAQ,IAAI,mBA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9 +51,14 @@ import {
|
|
|
51
51
|
SwapStatus,
|
|
52
52
|
Wallet,
|
|
53
53
|
WalletTypeAndAddress,
|
|
54
|
+
SwapProgressNotification,
|
|
54
55
|
} from './shared';
|
|
55
56
|
import { logRPCError } from './shared-sentry';
|
|
56
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
PrettyError,
|
|
59
|
+
mapAppErrorCodesToAPIErrorCode,
|
|
60
|
+
APIErrorCode,
|
|
61
|
+
} from './shared-errors';
|
|
57
62
|
import { httpService } from './services';
|
|
58
63
|
|
|
59
64
|
type WhenTaskBlocked = Parameters<NonNullable<SwapQueueDef['whenTaskBlocked']>>;
|
|
@@ -107,6 +112,7 @@ export function updateSwapStatus({
|
|
|
107
112
|
message,
|
|
108
113
|
details,
|
|
109
114
|
errorCode = null,
|
|
115
|
+
hasAlreadyProceededToSign,
|
|
110
116
|
}: {
|
|
111
117
|
getStorage: ExecuterActions<
|
|
112
118
|
SwapStorage,
|
|
@@ -123,6 +129,7 @@ export function updateSwapStatus({
|
|
|
123
129
|
message?: string;
|
|
124
130
|
details?: string | null | undefined;
|
|
125
131
|
errorCode?: string | null;
|
|
132
|
+
hasAlreadyProceededToSign?: boolean;
|
|
126
133
|
}): {
|
|
127
134
|
swap: PendingSwap;
|
|
128
135
|
step: PendingSwapStep | null;
|
|
@@ -132,7 +139,7 @@ export function updateSwapStatus({
|
|
|
132
139
|
if (!!nextStepStatus && !!currentStep) currentStep.status = nextStepStatus;
|
|
133
140
|
|
|
134
141
|
if (!!nextStatus) swap.status = nextStatus;
|
|
135
|
-
|
|
142
|
+
swap.hasAlreadyProceededToSign = hasAlreadyProceededToSign;
|
|
136
143
|
if (!!nextStatus && ['failed', 'success'].includes(nextStatus))
|
|
137
144
|
swap.finishTime = new Date().getTime().toString();
|
|
138
145
|
|
|
@@ -152,7 +159,9 @@ export function updateSwapStatus({
|
|
|
152
159
|
.reportFailure({
|
|
153
160
|
requestId: swap.requestId,
|
|
154
161
|
step: currentStep?.id || 1,
|
|
155
|
-
eventType: mapAppErrorCodesToAPIErrorCode(
|
|
162
|
+
eventType: mapAppErrorCodesToAPIErrorCode(
|
|
163
|
+
hasAlreadyProceededToSign ? APIErrorCode.TX_FAIL : errorCode
|
|
164
|
+
),
|
|
156
165
|
reason: errorReason || '',
|
|
157
166
|
data: walletType ? { wallet: walletType } : undefined,
|
|
158
167
|
})
|
|
@@ -186,6 +195,7 @@ export function setStepTransactionIds(
|
|
|
186
195
|
notifier: SwapQueueContext['notifier']
|
|
187
196
|
): void {
|
|
188
197
|
const swap = getStorage().swapDetails;
|
|
198
|
+
swap.hasAlreadyProceededToSign = null;
|
|
189
199
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
190
200
|
const currentStep = getCurrentStep(swap)!;
|
|
191
201
|
currentStep.executedTransactionId = txId || currentStep.executedTransactionId;
|
|
@@ -196,6 +206,18 @@ export function setStepTransactionIds(
|
|
|
196
206
|
notifier({ eventType: eventType, swap: swap, step: currentStep });
|
|
197
207
|
}
|
|
198
208
|
|
|
209
|
+
export function getSwapNotitfication(
|
|
210
|
+
eventType: EventType,
|
|
211
|
+
updateResult: { swap: PendingSwap; step: PendingSwapStep | null }
|
|
212
|
+
): SwapProgressNotification {
|
|
213
|
+
if (updateResult.swap.hasAlreadyProceededToSign) {
|
|
214
|
+
return {
|
|
215
|
+
eventType: 'transaction_expired',
|
|
216
|
+
...updateResult,
|
|
217
|
+
};
|
|
218
|
+
} else return { eventType, ...updateResult };
|
|
219
|
+
}
|
|
220
|
+
|
|
199
221
|
/**
|
|
200
222
|
* If a swap needs a wallet to be connected,
|
|
201
223
|
* By calling this function some related fields will be updated to show a correct message and state for notfiying the user.
|
|
@@ -1059,7 +1081,11 @@ export function singTransaction(
|
|
|
1059
1081
|
return;
|
|
1060
1082
|
}
|
|
1061
1083
|
|
|
1062
|
-
const
|
|
1084
|
+
const hasAlreadyProceededToSign =
|
|
1085
|
+
typeof swap.hasAlreadyProceededToSign === 'boolean';
|
|
1086
|
+
const executeMessage = hasAlreadyProceededToSign
|
|
1087
|
+
? 'Transaction is expired. Please try again'
|
|
1088
|
+
: 'executing transaction';
|
|
1063
1089
|
const executeDetails = `${
|
|
1064
1090
|
sourceWallet.walletType === WalletType.WALLET_CONNECT
|
|
1065
1091
|
? 'Check your mobile phone'
|
|
@@ -1070,232 +1096,265 @@ export function singTransaction(
|
|
|
1070
1096
|
const updateResult = updateSwapStatus({
|
|
1071
1097
|
getStorage,
|
|
1072
1098
|
setStorage,
|
|
1073
|
-
nextStepStatus: 'running',
|
|
1099
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1100
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1074
1101
|
message: executeMessage,
|
|
1075
1102
|
details: executeDetails,
|
|
1076
|
-
|
|
1077
|
-
notifier({
|
|
1078
|
-
eventType: 'confirm_transfer',
|
|
1079
|
-
...updateResult,
|
|
1103
|
+
hasAlreadyProceededToSign,
|
|
1080
1104
|
});
|
|
1081
1105
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1106
|
+
const notification = getSwapNotitfication('confirm_transfer', updateResult);
|
|
1107
|
+
notifier(notification);
|
|
1108
|
+
|
|
1109
|
+
if (notification.eventType !== 'transaction_expired') {
|
|
1110
|
+
walletSigners
|
|
1111
|
+
.getSigner(TransactionType.TRANSFER)
|
|
1112
|
+
.signAndSendTx(transferTransaction, walletAddress, null)
|
|
1113
|
+
.then(
|
|
1114
|
+
(txId) => {
|
|
1115
|
+
setStepTransactionIds(
|
|
1116
|
+
actions,
|
|
1117
|
+
txId,
|
|
1118
|
+
'transfer_confirmed',
|
|
1119
|
+
notifier
|
|
1120
|
+
);
|
|
1121
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1122
|
+
next();
|
|
1123
|
+
onFinish();
|
|
1124
|
+
},
|
|
1125
|
+
(error) => {
|
|
1126
|
+
if (swap.status === 'failed') return;
|
|
1127
|
+
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1128
|
+
prettifyErrorMessage(error);
|
|
1129
|
+
const updateResult = updateSwapStatus({
|
|
1130
|
+
getStorage,
|
|
1131
|
+
setStorage,
|
|
1132
|
+
nextStatus: 'failed',
|
|
1133
|
+
nextStepStatus: 'failed',
|
|
1134
|
+
message: extraMessage,
|
|
1135
|
+
details: extraMessageDetail,
|
|
1136
|
+
errorCode: extraMessageErrorCode,
|
|
1137
|
+
});
|
|
1138
|
+
notifier({
|
|
1139
|
+
eventType: 'transfer_rejected',
|
|
1140
|
+
...updateResult,
|
|
1141
|
+
});
|
|
1142
|
+
failed();
|
|
1143
|
+
onFinish();
|
|
1144
|
+
}
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1113
1147
|
} else if (!!evmTransaction) {
|
|
1114
1148
|
const updateResult = updateSwapStatus({
|
|
1115
1149
|
getStorage,
|
|
1116
1150
|
setStorage,
|
|
1117
|
-
nextStepStatus: 'running',
|
|
1151
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1152
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1118
1153
|
message: executeMessage,
|
|
1119
1154
|
details: executeDetails,
|
|
1155
|
+
hasAlreadyProceededToSign,
|
|
1120
1156
|
});
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
(
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1139
|
-
prettifyErrorMessage(error);
|
|
1140
|
-
if (
|
|
1141
|
-
error &&
|
|
1142
|
-
error?.root &&
|
|
1143
|
-
error?.root?.message &&
|
|
1144
|
-
error?.root?.code &&
|
|
1145
|
-
error?.root?.reason
|
|
1146
|
-
) {
|
|
1147
|
-
logRPCError(
|
|
1148
|
-
error.root,
|
|
1149
|
-
swap,
|
|
1150
|
-
currentStep,
|
|
1151
|
-
sourceWallet?.walletType
|
|
1157
|
+
const notification = getSwapNotitfication(
|
|
1158
|
+
'calling_smart_contract',
|
|
1159
|
+
updateResult
|
|
1160
|
+
);
|
|
1161
|
+
notifier(notification);
|
|
1162
|
+
|
|
1163
|
+
if (notification.eventType !== 'transaction_expired') {
|
|
1164
|
+
walletSigners
|
|
1165
|
+
.getSigner(TransactionType.EVM)
|
|
1166
|
+
.signAndSendTx(evmTransaction, walletAddress, null)
|
|
1167
|
+
.then(
|
|
1168
|
+
(id) => {
|
|
1169
|
+
setStepTransactionIds(
|
|
1170
|
+
actions,
|
|
1171
|
+
id,
|
|
1172
|
+
'smart_contract_called',
|
|
1173
|
+
notifier
|
|
1152
1174
|
);
|
|
1175
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1176
|
+
next();
|
|
1177
|
+
onFinish();
|
|
1178
|
+
},
|
|
1179
|
+
(error) => {
|
|
1180
|
+
if (swap.status === 'failed') return;
|
|
1181
|
+
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1182
|
+
prettifyErrorMessage(error);
|
|
1183
|
+
if (
|
|
1184
|
+
error &&
|
|
1185
|
+
error?.root &&
|
|
1186
|
+
error?.root?.message &&
|
|
1187
|
+
error?.root?.code &&
|
|
1188
|
+
error?.root?.reason
|
|
1189
|
+
) {
|
|
1190
|
+
logRPCError(
|
|
1191
|
+
error.root,
|
|
1192
|
+
swap,
|
|
1193
|
+
currentStep,
|
|
1194
|
+
sourceWallet?.walletType
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
const updateResult = updateSwapStatus({
|
|
1198
|
+
getStorage,
|
|
1199
|
+
setStorage,
|
|
1200
|
+
nextStatus: 'failed',
|
|
1201
|
+
nextStepStatus: 'failed',
|
|
1202
|
+
message: extraMessage,
|
|
1203
|
+
details: extraMessageDetail,
|
|
1204
|
+
errorCode: extraMessageErrorCode,
|
|
1205
|
+
});
|
|
1206
|
+
notifier({
|
|
1207
|
+
eventType: 'smart_contract_call_failed',
|
|
1208
|
+
...updateResult,
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
failed();
|
|
1212
|
+
onFinish();
|
|
1153
1213
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
setStorage,
|
|
1157
|
-
nextStatus: 'failed',
|
|
1158
|
-
nextStepStatus: 'failed',
|
|
1159
|
-
message: extraMessage,
|
|
1160
|
-
details: extraMessageDetail,
|
|
1161
|
-
errorCode: extraMessageErrorCode,
|
|
1162
|
-
});
|
|
1163
|
-
notifier({
|
|
1164
|
-
eventType: 'smart_contract_call_failed',
|
|
1165
|
-
...updateResult,
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
|
-
failed();
|
|
1169
|
-
onFinish();
|
|
1170
|
-
}
|
|
1171
|
-
);
|
|
1214
|
+
);
|
|
1215
|
+
}
|
|
1172
1216
|
} else if (!!cosmosTransaction) {
|
|
1173
1217
|
const updateResult = updateSwapStatus({
|
|
1174
1218
|
getStorage,
|
|
1175
1219
|
setStorage,
|
|
1176
|
-
nextStepStatus: 'running',
|
|
1220
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1221
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1177
1222
|
message: executeMessage,
|
|
1178
1223
|
details: executeDetails,
|
|
1224
|
+
hasAlreadyProceededToSign,
|
|
1179
1225
|
});
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1226
|
+
const notification = getSwapNotitfication(
|
|
1227
|
+
'calling_smart_contract',
|
|
1228
|
+
updateResult
|
|
1229
|
+
);
|
|
1230
|
+
notifier(notification);
|
|
1231
|
+
|
|
1232
|
+
if (notification.eventType !== 'transaction_expired') {
|
|
1233
|
+
// If keplr wallet is executing contracts on terra, throw error. keplr doesn't support transfer or execute contracts. only IBC messages are supported
|
|
1234
|
+
if (
|
|
1235
|
+
(currentStep?.swapperId.toString() === 'TerraSwap' ||
|
|
1236
|
+
(currentStep?.swapperId.toString() === 'ThorChain' &&
|
|
1237
|
+
currentStep?.fromBlockchain === Network.TERRA) ||
|
|
1238
|
+
(currentStep?.swapperId.toString() === 'Terra Bridge' &&
|
|
1239
|
+
currentStep.fromBlockchain === Network.TERRA)) && // here we must allow ibc on terrastatus
|
|
1240
|
+
sourceWallet.walletType === WalletType.KEPLR
|
|
1241
|
+
) {
|
|
1242
|
+
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1243
|
+
prettifyErrorMessage(
|
|
1244
|
+
'Keplr only supports IBC Transactions on Terra. ' +
|
|
1245
|
+
'Using Terra Bridge, TerraSwap and THORChain is not possible with Keplr. Please use TerraStation or Leap wallet'
|
|
1246
|
+
);
|
|
1247
|
+
const updateResult = updateSwapStatus({
|
|
1248
|
+
getStorage,
|
|
1249
|
+
setStorage,
|
|
1250
|
+
nextStatus: 'failed',
|
|
1251
|
+
nextStepStatus: 'failed',
|
|
1252
|
+
message: extraMessage,
|
|
1253
|
+
details: extraMessageDetail,
|
|
1254
|
+
errorCode: extraMessageErrorCode,
|
|
1255
|
+
});
|
|
1256
|
+
notifier({
|
|
1257
|
+
eventType: 'smart_contract_call_failed',
|
|
1258
|
+
...updateResult,
|
|
1259
|
+
});
|
|
1260
|
+
failed();
|
|
1261
|
+
onFinish();
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1184
1264
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1265
|
+
walletSigners
|
|
1266
|
+
.getSigner(TransactionType.COSMOS)
|
|
1267
|
+
.signAndSendTx(cosmosTransaction, walletAddress, null)
|
|
1268
|
+
.then(
|
|
1269
|
+
// todo
|
|
1270
|
+
(id: string | null) => {
|
|
1271
|
+
setStepTransactionIds(
|
|
1272
|
+
actions,
|
|
1273
|
+
id,
|
|
1274
|
+
'smart_contract_called',
|
|
1275
|
+
notifier
|
|
1276
|
+
);
|
|
1277
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1278
|
+
next();
|
|
1279
|
+
onFinish();
|
|
1280
|
+
},
|
|
1281
|
+
(error: string | null) => {
|
|
1282
|
+
if (swap.status === 'failed') return;
|
|
1283
|
+
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1284
|
+
prettifyErrorMessage(error);
|
|
1285
|
+
const updateResult = updateSwapStatus({
|
|
1286
|
+
getStorage,
|
|
1287
|
+
setStorage,
|
|
1288
|
+
nextStatus: 'failed',
|
|
1289
|
+
nextStepStatus: 'failed',
|
|
1290
|
+
message: extraMessage,
|
|
1291
|
+
details: extraMessageDetail,
|
|
1292
|
+
errorCode: extraMessageErrorCode,
|
|
1293
|
+
});
|
|
1294
|
+
notifier({
|
|
1295
|
+
eventType: 'smart_contract_call_failed',
|
|
1296
|
+
...updateResult,
|
|
1297
|
+
});
|
|
1298
|
+
failed();
|
|
1299
|
+
onFinish();
|
|
1300
|
+
}
|
|
1198
1301
|
);
|
|
1199
|
-
const updateResult = updateSwapStatus({
|
|
1200
|
-
getStorage,
|
|
1201
|
-
setStorage,
|
|
1202
|
-
nextStatus: 'failed',
|
|
1203
|
-
nextStepStatus: 'failed',
|
|
1204
|
-
message: extraMessage,
|
|
1205
|
-
details: extraMessageDetail,
|
|
1206
|
-
errorCode: extraMessageErrorCode,
|
|
1207
|
-
});
|
|
1208
|
-
notifier({
|
|
1209
|
-
eventType: 'smart_contract_call_failed',
|
|
1210
|
-
...updateResult,
|
|
1211
|
-
});
|
|
1212
|
-
failed();
|
|
1213
|
-
onFinish();
|
|
1214
|
-
return;
|
|
1215
1302
|
}
|
|
1216
|
-
|
|
1217
|
-
walletSigners
|
|
1218
|
-
.getSigner(TransactionType.COSMOS)
|
|
1219
|
-
.signAndSendTx(cosmosTransaction, walletAddress, null)
|
|
1220
|
-
.then(
|
|
1221
|
-
// todo
|
|
1222
|
-
(id: string | null) => {
|
|
1223
|
-
setStepTransactionIds(actions, id, 'smart_contract_called', notifier);
|
|
1224
|
-
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1225
|
-
next();
|
|
1226
|
-
onFinish();
|
|
1227
|
-
},
|
|
1228
|
-
(error: string | null) => {
|
|
1229
|
-
if (swap.status === 'failed') return;
|
|
1230
|
-
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1231
|
-
prettifyErrorMessage(error);
|
|
1232
|
-
const updateResult = updateSwapStatus({
|
|
1233
|
-
getStorage,
|
|
1234
|
-
setStorage,
|
|
1235
|
-
nextStatus: 'failed',
|
|
1236
|
-
nextStepStatus: 'failed',
|
|
1237
|
-
message: extraMessage,
|
|
1238
|
-
details: extraMessageDetail,
|
|
1239
|
-
errorCode: extraMessageErrorCode,
|
|
1240
|
-
});
|
|
1241
|
-
notifier({
|
|
1242
|
-
eventType: 'smart_contract_call_failed',
|
|
1243
|
-
...updateResult,
|
|
1244
|
-
});
|
|
1245
|
-
failed();
|
|
1246
|
-
onFinish();
|
|
1247
|
-
}
|
|
1248
|
-
);
|
|
1249
1303
|
} else if (!!solanaTransaction) {
|
|
1250
1304
|
const updateResult = updateSwapStatus({
|
|
1251
1305
|
getStorage,
|
|
1252
1306
|
setStorage,
|
|
1253
|
-
nextStepStatus: 'running',
|
|
1307
|
+
nextStepStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1308
|
+
nextStatus: hasAlreadyProceededToSign ? 'failed' : 'running',
|
|
1254
1309
|
message: executeMessage,
|
|
1255
1310
|
details: executeDetails,
|
|
1311
|
+
hasAlreadyProceededToSign,
|
|
1256
1312
|
});
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
(
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1313
|
+
const notification = getSwapNotitfication(
|
|
1314
|
+
'calling_smart_contract',
|
|
1315
|
+
updateResult
|
|
1316
|
+
);
|
|
1317
|
+
notifier(notification);
|
|
1318
|
+
|
|
1319
|
+
if (notification.eventType !== 'transaction_expired') {
|
|
1320
|
+
const tx = solanaTransaction;
|
|
1321
|
+
walletSigners
|
|
1322
|
+
.getSigner(TransactionType.SOLANA)
|
|
1323
|
+
.signAndSendTx(tx, walletAddress, null)
|
|
1324
|
+
.then(
|
|
1325
|
+
(txId) => {
|
|
1326
|
+
setStepTransactionIds(
|
|
1327
|
+
actions,
|
|
1328
|
+
txId,
|
|
1329
|
+
'smart_contract_called',
|
|
1330
|
+
notifier
|
|
1331
|
+
);
|
|
1332
|
+
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
1333
|
+
next();
|
|
1334
|
+
onFinish();
|
|
1335
|
+
},
|
|
1336
|
+
(error) => {
|
|
1337
|
+
if (swap.status === 'failed') return;
|
|
1338
|
+
const { extraMessage, extraMessageDetail, extraMessageErrorCode } =
|
|
1339
|
+
prettifyErrorMessage(error);
|
|
1340
|
+
const updateResult = updateSwapStatus({
|
|
1341
|
+
getStorage,
|
|
1342
|
+
setStorage,
|
|
1343
|
+
nextStatus: 'failed',
|
|
1344
|
+
nextStepStatus: 'failed',
|
|
1345
|
+
message: extraMessage,
|
|
1346
|
+
details: extraMessageDetail,
|
|
1347
|
+
errorCode: extraMessageErrorCode,
|
|
1348
|
+
});
|
|
1349
|
+
notifier({
|
|
1350
|
+
eventType: 'smart_contract_call_failed',
|
|
1351
|
+
...updateResult,
|
|
1352
|
+
});
|
|
1353
|
+
failed();
|
|
1354
|
+
onFinish();
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1299
1358
|
} else if (!!tronTransaction) {
|
|
1300
1359
|
const updateResult = updateSwapStatus({
|
|
1301
1360
|
getStorage,
|
package/src/migration.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
PersistedQueue,
|
|
3
3
|
Persistor,
|
|
4
4
|
Status,
|
|
5
|
+
DB_NAME,
|
|
5
6
|
} from '@rango-dev/queue-manager-core';
|
|
6
7
|
import { v4 as uuid } from 'uuid';
|
|
7
8
|
import { PendingSwap } from './shared';
|
|
@@ -18,6 +19,16 @@ function migrated(): boolean {
|
|
|
18
19
|
return !!window.localStorage.getItem(MIGRATED_KEY);
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
async function hasQueueManagerOnIDB(): Promise<boolean> {
|
|
23
|
+
try {
|
|
24
|
+
return (await (window.indexedDB as any).databases())
|
|
25
|
+
.map((db: any) => db.name)
|
|
26
|
+
.includes(DB_NAME);
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
/**
|
|
22
33
|
*
|
|
23
34
|
* By calling this function, we first check if the data already migrated or not,
|
|
@@ -26,9 +37,10 @@ function migrated(): boolean {
|
|
|
26
37
|
*/
|
|
27
38
|
async function migration(): Promise<boolean> {
|
|
28
39
|
const swapsFromStorage = window.localStorage.getItem('pendingSwaps');
|
|
40
|
+
const hasIndexDB = await hasQueueManagerOnIDB();
|
|
29
41
|
|
|
30
42
|
// For new users or already migrated.
|
|
31
|
-
if (!swapsFromStorage || migrated()) {
|
|
43
|
+
if (!swapsFromStorage || migrated() || hasIndexDB) {
|
|
32
44
|
return true;
|
|
33
45
|
}
|
|
34
46
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { RangoClient } from 'rango-sdk';
|
|
2
|
-
import { RANGO_DAPP_API_KEY } from '../constants';
|
|
2
|
+
import { RANGO_DAPP_API_KEY, RANGO_DAPP_API_BASE_URL } from '../constants';
|
|
3
3
|
|
|
4
|
-
export const httpService = new RangoClient(
|
|
4
|
+
export const httpService = new RangoClient(
|
|
5
|
+
RANGO_DAPP_API_KEY || '',
|
|
6
|
+
RANGO_DAPP_API_BASE_URL
|
|
7
|
+
);
|