@rango-dev/queue-manager-rango-preset 0.1.13-next.2 → 0.1.14
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/CHANGELOG.md +15 -0
- package/dist/actions/checkStatus.d.ts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +54 -34
- 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 +54 -34
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/checkStatus.ts +24 -8
- package/src/actions/scheduleNextStep.ts +3 -3
- package/src/helpers.ts +28 -10
- package/src/shared-errors.ts +1 -1
- package/src/shared.ts +1 -0
|
@@ -498,7 +498,7 @@ var PrettyError = /*#__PURE__*/function (_Error) {
|
|
|
498
498
|
return _this;
|
|
499
499
|
}
|
|
500
500
|
PrettyError.isPrettyError = function isPrettyError(obj) {
|
|
501
|
-
return obj instanceof PrettyError || Object.prototype.hasOwnProperty('_isPrettyError');
|
|
501
|
+
return obj instanceof PrettyError || Object.prototype.hasOwnProperty.call(obj, '_isPrettyError');
|
|
502
502
|
};
|
|
503
503
|
var _proto = PrettyError.prototype;
|
|
504
504
|
_proto.getErrorDetail = function getErrorDetail() {
|
|
@@ -1131,25 +1131,30 @@ function _getChainId() {
|
|
|
1131
1131
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1132
1132
|
while (1) switch (_context.prev = _context.next) {
|
|
1133
1133
|
case 0:
|
|
1134
|
-
_context.
|
|
1134
|
+
_context.prev = 0;
|
|
1135
|
+
_context.next = 3;
|
|
1135
1136
|
return provider.request({
|
|
1136
1137
|
method: 'eth_chainId'
|
|
1137
1138
|
});
|
|
1138
|
-
case
|
|
1139
|
+
case 3:
|
|
1139
1140
|
_context.t0 = _context.sent;
|
|
1140
1141
|
if (_context.t0) {
|
|
1141
|
-
_context.next =
|
|
1142
|
+
_context.next = 6;
|
|
1142
1143
|
break;
|
|
1143
1144
|
}
|
|
1144
1145
|
_context.t0 = provider == null ? void 0 : provider.chainId;
|
|
1145
|
-
case
|
|
1146
|
+
case 6:
|
|
1146
1147
|
chainId = _context.t0;
|
|
1147
1148
|
return _context.abrupt("return", chainId);
|
|
1148
|
-
case
|
|
1149
|
+
case 10:
|
|
1150
|
+
_context.prev = 10;
|
|
1151
|
+
_context.t1 = _context["catch"](0);
|
|
1152
|
+
return _context.abrupt("return", provider == null ? void 0 : provider.chainId);
|
|
1153
|
+
case 13:
|
|
1149
1154
|
case "end":
|
|
1150
1155
|
return _context.stop();
|
|
1151
1156
|
}
|
|
1152
|
-
}, _callee);
|
|
1157
|
+
}, _callee, null, [[0, 10]]);
|
|
1153
1158
|
}));
|
|
1154
1159
|
return _getChainId.apply(this, arguments);
|
|
1155
1160
|
}
|
|
@@ -1437,7 +1442,7 @@ function isRequiredWalletConnected(swap, getState) {
|
|
|
1437
1442
|
var matched = connectedAccounts.some(function (account) {
|
|
1438
1443
|
var _readAccountAddress = readAccountAddress(account),
|
|
1439
1444
|
accountAddress = _readAccountAddress.address;
|
|
1440
|
-
return address === accountAddress;
|
|
1445
|
+
return address.toLocaleLowerCase() === accountAddress.toLocaleLowerCase();
|
|
1441
1446
|
});
|
|
1442
1447
|
return {
|
|
1443
1448
|
ok: matched,
|
|
@@ -1517,7 +1522,7 @@ function singTransaction(actions) {
|
|
|
1517
1522
|
errorCode: extraMessageErrorCode
|
|
1518
1523
|
});
|
|
1519
1524
|
notifier(_extends({
|
|
1520
|
-
eventType: 'contract_rejected'
|
|
1525
|
+
eventType: extraMessageErrorCode === 'REJECTED_BY_USER' ? 'contract_rejected' : 'smart_contract_call_failed'
|
|
1521
1526
|
}, updateResult));
|
|
1522
1527
|
failed();
|
|
1523
1528
|
onFinish();
|
|
@@ -1563,7 +1568,7 @@ function singTransaction(actions) {
|
|
|
1563
1568
|
errorCode: extraMessageErrorCode
|
|
1564
1569
|
});
|
|
1565
1570
|
notifier(_extends({
|
|
1566
|
-
eventType: 'contract_rejected'
|
|
1571
|
+
eventType: extraMessageErrorCode === 'REJECTED_BY_USER' ? 'contract_rejected' : 'smart_contract_call_failed'
|
|
1567
1572
|
}, updateResult));
|
|
1568
1573
|
failed();
|
|
1569
1574
|
onFinish();
|
|
@@ -1609,7 +1614,7 @@ function singTransaction(actions) {
|
|
|
1609
1614
|
errorCode: extraMessageErrorCode
|
|
1610
1615
|
});
|
|
1611
1616
|
notifier(_extends({
|
|
1612
|
-
eventType: 'contract_rejected'
|
|
1617
|
+
eventType: extraMessageErrorCode === 'REJECTED_BY_USER' ? 'contract_rejected' : 'smart_contract_call_failed'
|
|
1613
1618
|
}, updateResult));
|
|
1614
1619
|
failed();
|
|
1615
1620
|
onFinish();
|
|
@@ -1659,7 +1664,7 @@ function singTransaction(actions) {
|
|
|
1659
1664
|
errorCode: extraMessageErrorCode
|
|
1660
1665
|
});
|
|
1661
1666
|
notifier(_extends({
|
|
1662
|
-
eventType: 'transfer_rejected'
|
|
1667
|
+
eventType: extraMessageErrorCode === 'REJECTED_BY_USER' ? 'transfer_rejected' : 'transfer_failed'
|
|
1663
1668
|
}, updateResult));
|
|
1664
1669
|
failed();
|
|
1665
1670
|
onFinish();
|
|
@@ -1707,7 +1712,7 @@ function singTransaction(actions) {
|
|
|
1707
1712
|
errorCode: extraMessageErrorCode
|
|
1708
1713
|
});
|
|
1709
1714
|
notifier(_extends({
|
|
1710
|
-
eventType: 'smart_contract_call_failed'
|
|
1715
|
+
eventType: extraMessageErrorCode === 'REJECTED_BY_USER' ? 'contract_rejected' : 'smart_contract_call_failed'
|
|
1711
1716
|
}, updateResult));
|
|
1712
1717
|
failed();
|
|
1713
1718
|
onFinish();
|
|
@@ -2186,12 +2191,12 @@ function checkTransactionStatus(_x) {
|
|
|
2186
2191
|
*/
|
|
2187
2192
|
function _checkTransactionStatus() {
|
|
2188
2193
|
_checkTransactionStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
2189
|
-
var _status, _status2, _status3, _status4, _status5, _status6, _status7,
|
|
2190
|
-
var getStorage, setStorage, next, schedule, retry, context, swap, currentStep, txId, status, outputAmount, prevOutputAmount, newTransaction, nextStep;
|
|
2194
|
+
var _status, _status2, _status3, _status4, _status5, _status6, _status7, _status9, _status10, _status11;
|
|
2195
|
+
var getStorage, setStorage, next, schedule, retry, failed, context, swap, currentStep, txId, status, outputAmount, prevOutputAmount, newTransaction, nextStep, _status8;
|
|
2191
2196
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2192
2197
|
while (1) switch (_context.prev = _context.next) {
|
|
2193
2198
|
case 0:
|
|
2194
|
-
getStorage = _ref.getStorage, setStorage = _ref.setStorage, next = _ref.next, schedule = _ref.schedule, retry = _ref.retry, context = _ref.context;
|
|
2199
|
+
getStorage = _ref.getStorage, setStorage = _ref.setStorage, next = _ref.next, schedule = _ref.schedule, retry = _ref.retry, failed = _ref.failed, context = _ref.context;
|
|
2195
2200
|
swap = getStorage().swapDetails; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2196
2201
|
currentStep = getCurrentStep(swap);
|
|
2197
2202
|
txId = currentStep.executedTransactionId;
|
|
@@ -2279,26 +2284,36 @@ function _checkTransactionStatus() {
|
|
|
2279
2284
|
} else if (currentStep.status === 'failed') {
|
|
2280
2285
|
swap.extraMessage = 'Transaction failed in blockchain';
|
|
2281
2286
|
swap.extraMessageSeverity = MessageSeverity.error;
|
|
2282
|
-
swap.extraMessageDetail = '';
|
|
2287
|
+
swap.extraMessageDetail = ((_status8 = status) == null ? void 0 : _status8.extraMessage) || '';
|
|
2288
|
+
swap.status = 'failed';
|
|
2289
|
+
swap.finishTime = new Date().getTime().toString();
|
|
2283
2290
|
}
|
|
2284
2291
|
// Sync data with storage
|
|
2285
2292
|
setStorage(_extends({}, getStorage(), {
|
|
2286
2293
|
swapDetails: swap
|
|
2287
2294
|
}));
|
|
2288
|
-
if (!(((
|
|
2289
|
-
_context.next =
|
|
2295
|
+
if (!(((_status9 = status) == null ? void 0 : _status9.status) === 'failed')) {
|
|
2296
|
+
_context.next = 38;
|
|
2297
|
+
break;
|
|
2298
|
+
}
|
|
2299
|
+
failed();
|
|
2300
|
+
_context.next = 46;
|
|
2301
|
+
break;
|
|
2302
|
+
case 38:
|
|
2303
|
+
if (!(((_status10 = status) == null ? void 0 : _status10.status) === 'success' || ((_status11 = status) == null ? void 0 : _status11.status) === 'running' && !!status.newTx)) {
|
|
2304
|
+
_context.next = 43;
|
|
2290
2305
|
break;
|
|
2291
2306
|
}
|
|
2292
2307
|
schedule(SwapActionTypes.SCHEDULE_NEXT_STEP);
|
|
2293
2308
|
next();
|
|
2294
|
-
_context.next =
|
|
2309
|
+
_context.next = 46;
|
|
2295
2310
|
break;
|
|
2296
|
-
case
|
|
2297
|
-
_context.next =
|
|
2311
|
+
case 43:
|
|
2312
|
+
_context.next = 45;
|
|
2298
2313
|
return delay(INTERVAL_FOR_CHECK);
|
|
2299
|
-
case
|
|
2314
|
+
case 45:
|
|
2300
2315
|
retry();
|
|
2301
|
-
case
|
|
2316
|
+
case 46:
|
|
2302
2317
|
case "end":
|
|
2303
2318
|
return _context.stop();
|
|
2304
2319
|
}
|
|
@@ -2319,7 +2334,7 @@ function checkApprovalStatus(_x2) {
|
|
|
2319
2334
|
*/
|
|
2320
2335
|
function _checkApprovalStatus() {
|
|
2321
2336
|
_checkApprovalStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
|
|
2322
|
-
var getStorage, setStorage, next, schedule, retry, failed, context, swap, currentStep, isApproved, response, updateResult;
|
|
2337
|
+
var getStorage, setStorage, next, schedule, retry, failed, context, swap, currentStep, isApproved, response, message, details, updateResult;
|
|
2323
2338
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2324
2339
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2325
2340
|
case 0:
|
|
@@ -2339,7 +2354,14 @@ function _checkApprovalStatus() {
|
|
|
2339
2354
|
return _context2.abrupt("return");
|
|
2340
2355
|
case 10:
|
|
2341
2356
|
isApproved = response.isApproved;
|
|
2342
|
-
if (!isApproved && response.txStatus === 'failed') {
|
|
2357
|
+
if (!isApproved && (response.txStatus === 'failed' || response.txStatus === 'success')) {
|
|
2358
|
+
if (response.txStatus === 'failed') {
|
|
2359
|
+
message = 'Approve transaction failed';
|
|
2360
|
+
details = 'Smart contract approval failed in blockchain.';
|
|
2361
|
+
} else {
|
|
2362
|
+
message = 'Not enough approval';
|
|
2363
|
+
if (response.requiredApprovedAmount && response.currentApprovedAmount) details = "Required approval: " + response.requiredApprovedAmount + ", current approval: " + response.currentApprovedAmount;else details = "You still don't have enough approval for this swap.";
|
|
2364
|
+
}
|
|
2343
2365
|
// approve transaction failed on
|
|
2344
2366
|
// we should fail the whole swap
|
|
2345
2367
|
updateResult = updateSwapStatus({
|
|
@@ -2348,14 +2370,13 @@ function _checkApprovalStatus() {
|
|
|
2348
2370
|
nextStatus: 'failed',
|
|
2349
2371
|
nextStepStatus: 'failed',
|
|
2350
2372
|
errorCode: 'SEND_TX_FAILED',
|
|
2351
|
-
message:
|
|
2352
|
-
details:
|
|
2373
|
+
message: message,
|
|
2374
|
+
details: details
|
|
2353
2375
|
});
|
|
2354
2376
|
context.notifier(_extends({
|
|
2355
2377
|
eventType: 'smart_contract_call_failed'
|
|
2356
2378
|
}, updateResult));
|
|
2357
2379
|
failed();
|
|
2358
|
-
// onFinish();
|
|
2359
2380
|
} else if (!isApproved) {
|
|
2360
2381
|
// it is needed to set notification after reloading the page
|
|
2361
2382
|
context.notifier({
|
|
@@ -2676,12 +2697,14 @@ function scheduleNextStep(_ref) {
|
|
|
2676
2697
|
context = _ref.context;
|
|
2677
2698
|
var swap = getStorage().swapDetails;
|
|
2678
2699
|
var currentStep = getCurrentStep(swap);
|
|
2679
|
-
|
|
2700
|
+
var isFailed = swap.steps.find(function (step) {
|
|
2701
|
+
return step.status === 'failed';
|
|
2702
|
+
});
|
|
2703
|
+
if (!!currentStep && !isFailed) {
|
|
2680
2704
|
if (isTxAlreadyCreated(swap, currentStep)) {
|
|
2681
2705
|
schedule(SwapActionTypes.EXECUTE_TRANSACTION);
|
|
2682
2706
|
return next();
|
|
2683
2707
|
}
|
|
2684
|
-
// TODO double check it after approval changes
|
|
2685
2708
|
if (currentStep != null && currentStep.executedTransactionId) {
|
|
2686
2709
|
schedule(SwapActionTypes.CHECK_TRANSACTION_STATUS);
|
|
2687
2710
|
return next();
|
|
@@ -2693,9 +2716,6 @@ function scheduleNextStep(_ref) {
|
|
|
2693
2716
|
schedule(SwapActionTypes.CREATE_TRANSACTION);
|
|
2694
2717
|
next();
|
|
2695
2718
|
} else {
|
|
2696
|
-
var isFailed = swap.steps.find(function (step) {
|
|
2697
|
-
return step.status === 'failed';
|
|
2698
|
-
});
|
|
2699
2719
|
swap.status = isFailed ? 'failed' : 'success';
|
|
2700
2720
|
swap.finishTime = new Date().getTime().toString();
|
|
2701
2721
|
setStorage(_extends({}, getStorage(), {
|