@rango-dev/queue-manager-rango-preset 0.1.13-next.10 → 0.1.13-next.12
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/queue-manager-rango-preset.cjs.development.js +36 -21
- 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 +36 -21
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/actions/checkStatus.ts +24 -8
- package/src/actions/scheduleNextStep.ts +3 -3
- package/src/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -28,6 +28,7 @@ async function checkTransactionStatus({
|
|
|
28
28
|
next,
|
|
29
29
|
schedule,
|
|
30
30
|
retry,
|
|
31
|
+
failed,
|
|
31
32
|
context,
|
|
32
33
|
}: ExecuterActions<
|
|
33
34
|
SwapStorage,
|
|
@@ -132,14 +133,17 @@ async function checkTransactionStatus({
|
|
|
132
133
|
} else if (currentStep.status === 'failed') {
|
|
133
134
|
swap.extraMessage = 'Transaction failed in blockchain';
|
|
134
135
|
swap.extraMessageSeverity = MessageSeverity.error;
|
|
135
|
-
swap.extraMessageDetail = '';
|
|
136
|
+
swap.extraMessageDetail = status?.extraMessage || '';
|
|
137
|
+
swap.status = 'failed';
|
|
138
|
+
swap.finishTime = new Date().getTime().toString();
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
// Sync data with storage
|
|
139
142
|
setStorage({ ...getStorage(), swapDetails: swap });
|
|
140
143
|
|
|
141
|
-
if (
|
|
142
|
-
|
|
144
|
+
if (status?.status === 'failed') {
|
|
145
|
+
failed();
|
|
146
|
+
} else if (
|
|
143
147
|
status?.status === 'success' ||
|
|
144
148
|
(status?.status === 'running' && !!status.newTx)
|
|
145
149
|
) {
|
|
@@ -181,7 +185,20 @@ async function checkApprovalStatus({
|
|
|
181
185
|
if (currentStep?.status === 'failed') return;
|
|
182
186
|
|
|
183
187
|
isApproved = response.isApproved;
|
|
184
|
-
if (
|
|
188
|
+
if (
|
|
189
|
+
!isApproved &&
|
|
190
|
+
(response.txStatus === 'failed' || response.txStatus === 'success')
|
|
191
|
+
) {
|
|
192
|
+
let message, details;
|
|
193
|
+
if (response.txStatus === 'failed') {
|
|
194
|
+
message = 'Approve transaction failed';
|
|
195
|
+
details = 'Smart contract approval failed in blockchain.';
|
|
196
|
+
} else {
|
|
197
|
+
message = 'Not enough approval';
|
|
198
|
+
if (response.requiredApprovedAmount && response.currentApprovedAmount)
|
|
199
|
+
details = `Required approval: ${response.requiredApprovedAmount}, current approval: ${response.currentApprovedAmount}`;
|
|
200
|
+
else details = `You still don't have enough approval for this swap.`;
|
|
201
|
+
}
|
|
185
202
|
// approve transaction failed on
|
|
186
203
|
// we should fail the whole swap
|
|
187
204
|
const updateResult = updateSwapStatus({
|
|
@@ -190,15 +207,14 @@ async function checkApprovalStatus({
|
|
|
190
207
|
nextStatus: 'failed',
|
|
191
208
|
nextStepStatus: 'failed',
|
|
192
209
|
errorCode: 'SEND_TX_FAILED',
|
|
193
|
-
message:
|
|
194
|
-
details:
|
|
210
|
+
message: message,
|
|
211
|
+
details: details,
|
|
195
212
|
});
|
|
196
213
|
context.notifier({
|
|
197
|
-
eventType: 'smart_contract_call_failed',
|
|
214
|
+
eventType: 'smart_contract_call_failed', // TODO better event type
|
|
198
215
|
...updateResult,
|
|
199
216
|
});
|
|
200
217
|
failed();
|
|
201
|
-
// onFinish();
|
|
202
218
|
} else if (!isApproved) {
|
|
203
219
|
// it is needed to set notification after reloading the page
|
|
204
220
|
context.notifier({
|
|
@@ -21,13 +21,14 @@ export function scheduleNextStep({
|
|
|
21
21
|
}: ExecuterActions<SwapStorage, SwapActionTypes, SwapQueueContext>): void {
|
|
22
22
|
const swap = getStorage().swapDetails;
|
|
23
23
|
const currentStep = getCurrentStep(swap);
|
|
24
|
-
|
|
24
|
+
const isFailed = swap.steps.find((step) => step.status === 'failed');
|
|
25
|
+
|
|
26
|
+
if (!!currentStep && !isFailed) {
|
|
25
27
|
if (isTxAlreadyCreated(swap, currentStep)) {
|
|
26
28
|
schedule(SwapActionTypes.EXECUTE_TRANSACTION);
|
|
27
29
|
return next();
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
// TODO double check it after approval changes
|
|
31
32
|
if (currentStep?.executedTransactionId) {
|
|
32
33
|
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
33
34
|
return next();
|
|
@@ -40,7 +41,6 @@ export function scheduleNextStep({
|
|
|
40
41
|
schedule(SwapActionTypes.CREATE_TRANSACTION);
|
|
41
42
|
next();
|
|
42
43
|
} else {
|
|
43
|
-
const isFailed = swap.steps.find((step) => step.status === 'failed');
|
|
44
44
|
swap.status = isFailed ? 'failed' : 'success';
|
|
45
45
|
swap.finishTime = new Date().getTime().toString();
|
|
46
46
|
|
package/src/.DS_Store
DELETED
|
Binary file
|