@depay/widgets 7.0.3 → 7.2.1
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/README.md +18 -3
- package/dist/esm/index.bundle.js +15 -15
- package/dist/esm/index.js +442 -98
- package/dist/umd/index.bundle.js +15 -15
- package/dist/umd/index.js +442 -98
- package/package.json +15 -16
package/dist/umd/index.js
CHANGED
|
@@ -1319,7 +1319,7 @@
|
|
|
1319
1319
|
});
|
|
1320
1320
|
|
|
1321
1321
|
var DialogStyle = (function (style) {
|
|
1322
|
-
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\n }\n\n .contained .ReactDialog {\n position: absolute;\n height: 100%;\n min-height: 100%;\n width: 100%;\n min-width: 100%;\n }\n\n .contained .ReactDialogBackground {\n position: absolute;\n }\n\n .contained .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n top: 0;\n }\n\n .Dialog {\n margin: 0 auto;\n position: relative;\n width: 420px;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n border-radius: 13px;\n background: rgb(248,248,248);\n }\n\n @media (max-width: 450px) {\n\n .Dialog {\n border-radius: 0;\n width: 100%;\n }\n }\n\n @media (orientation: portrait) and (max-width: 800px) {\n\n .ReactDialogAnimation {\n width: 100%;\n }\n\n .ReactDialog {\n height: 100%;\n min-height: 100%;\n }\n\n .ReactDialogStack {\n align-items: flex-end;\n }\n\n .Dialog {\n align-content: stretch;\n border-radius: 13px;\n border-top-radius: 13px;\n display: flex;\n flex-direction: column;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n }\n\n .DialogFooter {\n padding-bottom: 20px;\n }\n\n .ReactDialogAnimation {\n margin-bottom: -100px !important;\n top: inherit !important;\n position: relative;\n transition: opacity 0.4s ease, margin-bottom 0.4s ease;\n }\n\n .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n margin-bottom: 0px !important;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n\n .ReactShadowDOMInsideContainer > .ReactDialog {\n align-items: flex-end;\n }\n }\n\n .DialogBody {\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .DialogBody.ScrollHeight {\n height: 30vh !important;\n max-height: 30vh !important;\n }\n\n .DialogHeader {\n border-top-left-radius: 13px;\n border-top-right-radius: 13px;\n min-height: 54px;\n position: relative;\n width: 100%;\n }\n\n .DialogHeaderActionRight {\n position: absolute;\n top: 0;\n right: 0;\n height: 48px;\n }\n\n .DialogHeaderActionLeft {\n position: absolute;\n top: 0;\n left: 0;\n height: 48px;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 13px;\n border-bottom-right-radius: 13px;\n line-height: 24px;\n min-height: 32px;\n position: relative;\n text-align: center;\n }\n\n ";
|
|
1322
|
+
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\n }\n\n .contained .ReactDialog {\n position: absolute;\n height: 100%;\n min-height: 100%;\n width: 100%;\n min-width: 100%;\n }\n\n .contained .ReactDialogBackground {\n position: absolute;\n }\n\n .contained .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n top: 0;\n }\n\n .Dialog {\n margin: 0 auto;\n position: relative;\n width: 420px;\n box-shadow: 0 0 20px rgba(0,0,0,0.1);\n border-radius: 13px;\n background: rgb(248,248,248);\n }\n\n @media (max-width: 450px) {\n\n .Dialog {\n border-radius: 0;\n width: 100%;\n }\n }\n\n @media (orientation: portrait) and (max-width: 800px) {\n\n .ReactDialogAnimation {\n width: 100%;\n }\n\n .ReactDialog {\n height: 100%;\n min-height: 100%;\n }\n\n .ReactDialogStack {\n align-items: flex-end;\n }\n\n .Dialog {\n align-content: stretch;\n border-radius: 13px;\n border-top-radius: 13px;\n display: flex;\n flex-direction: column;\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n }\n\n .DialogFooter {\n padding-bottom: 20px;\n }\n\n .ReactDialogAnimation {\n margin-bottom: -100px !important;\n top: inherit !important;\n position: relative;\n transition: opacity 0.4s ease, margin-bottom 0.4s ease;\n }\n\n .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n margin-bottom: 0px !important;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n\n .ReactShadowDOMInsideContainer > .ReactDialog {\n align-items: flex-end;\n }\n }\n\n .DialogBody {\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n .DialogBody.ScrollHeight {\n height: 30vh !important;\n max-height: 30vh !important;\n }\n\n .DialogHeader {\n border-top-left-radius: 13px;\n border-top-right-radius: 13px;\n min-height: 54px;\n position: relative;\n width: 100%;\n }\n\n .DialogHeaderActionRight {\n position: absolute;\n top: 0;\n right: 0;\n height: 48px;\n }\n\n .DialogHeaderActionLeft {\n position: absolute;\n top: 0;\n left: 0;\n height: 48px;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 13px;\n border-bottom-right-radius: 13px;\n line-height: 24px;\n min-height: 32px;\n position: relative;\n text-align: center;\n }\n\n ";
|
|
1323
1323
|
});
|
|
1324
1324
|
|
|
1325
1325
|
var FontStyle = (function (style) {
|
|
@@ -2022,7 +2022,6 @@
|
|
|
2022
2022
|
}
|
|
2023
2023
|
|
|
2024
2024
|
setPaymentState('initialized');
|
|
2025
|
-
setPayment(null);
|
|
2026
2025
|
setClosable(true);
|
|
2027
2026
|
setUpdatable(true);
|
|
2028
2027
|
getPaymentRoutes({});
|
|
@@ -2232,14 +2231,14 @@
|
|
|
2232
2231
|
return obj;
|
|
2233
2232
|
}
|
|
2234
2233
|
|
|
2235
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2234
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2236
2235
|
|
|
2237
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2236
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2238
2237
|
|
|
2239
2238
|
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
2240
2239
|
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
2241
2240
|
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
2242
|
-
return _objectSpread(_objectSpread({}, accept), {}, {
|
|
2241
|
+
return _objectSpread$1(_objectSpread$1({}, accept), {}, {
|
|
2243
2242
|
toAddress: toAddress,
|
|
2244
2243
|
toContract: toContract
|
|
2245
2244
|
});
|
|
@@ -2270,6 +2269,9 @@
|
|
|
2270
2269
|
});
|
|
2271
2270
|
});
|
|
2272
2271
|
|
|
2272
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2273
|
+
|
|
2274
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2273
2275
|
var PaymentRoutingProvider = (function (props) {
|
|
2274
2276
|
var _useState = React.useState(),
|
|
2275
2277
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -2278,18 +2280,23 @@
|
|
|
2278
2280
|
|
|
2279
2281
|
var _useState3 = React.useState(),
|
|
2280
2282
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
+
updatedRouteWithNewPrice = _useState4[0],
|
|
2284
|
+
setUpdatedRouteWithNewPrice = _useState4[1];
|
|
2283
2285
|
|
|
2284
|
-
var _useState5 = React.useState(
|
|
2286
|
+
var _useState5 = React.useState(),
|
|
2285
2287
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
+
selectedRoute = _useState6[0],
|
|
2289
|
+
setSelectedRoute = _useState6[1];
|
|
2288
2290
|
|
|
2289
|
-
var _useState7 = React.useState(
|
|
2291
|
+
var _useState7 = React.useState(false),
|
|
2290
2292
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
+
slowRouting = _useState8[0],
|
|
2294
|
+
setSlowRouting = _useState8[1];
|
|
2295
|
+
|
|
2296
|
+
var _useState9 = React.useState(0),
|
|
2297
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
2298
|
+
reloadCount = _useState10[0],
|
|
2299
|
+
setReloadCount = _useState10[1];
|
|
2293
2300
|
|
|
2294
2301
|
var _useContext = React.useContext(WalletContext),
|
|
2295
2302
|
account = _useContext.account;
|
|
@@ -2300,41 +2307,292 @@
|
|
|
2300
2307
|
var _useContext3 = React.useContext(ConfigurationContext),
|
|
2301
2308
|
recover = _useContext3.recover;
|
|
2302
2309
|
|
|
2303
|
-
var
|
|
2304
|
-
|
|
2305
|
-
|
|
2310
|
+
var calculateAmountInWithSlippage = /*#__PURE__*/function () {
|
|
2311
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
|
|
2312
|
+
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN;
|
|
2313
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
2314
|
+
while (1) {
|
|
2315
|
+
switch (_context2.prev = _context2.next) {
|
|
2316
|
+
case 0:
|
|
2317
|
+
if (!route.directTransfer) {
|
|
2318
|
+
_context2.next = 2;
|
|
2319
|
+
break;
|
|
2320
|
+
}
|
|
2306
2321
|
|
|
2307
|
-
|
|
2308
|
-
props.setMaxRoute(null);
|
|
2309
|
-
}
|
|
2310
|
-
} else {
|
|
2311
|
-
roundAmounts(routes).then(function (roundedRoutes) {
|
|
2312
|
-
var selected;
|
|
2322
|
+
return _context2.abrupt("return");
|
|
2313
2323
|
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2324
|
+
case 2:
|
|
2325
|
+
_context2.next = 4;
|
|
2326
|
+
return web3Client.request({
|
|
2327
|
+
blockchain: route.blockchain,
|
|
2328
|
+
method: 'latestBlockNumber'
|
|
2329
|
+
});
|
|
2319
2330
|
|
|
2320
|
-
|
|
2321
|
-
|
|
2331
|
+
case 4:
|
|
2332
|
+
currentBlock = _context2.sent;
|
|
2333
|
+
blocks = [];
|
|
2334
|
+
|
|
2335
|
+
for (i = 0; i <= 2; i++) {
|
|
2336
|
+
blocks.push(currentBlock - i);
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
exchangeRoute = route.exchangeRoutes[0];
|
|
2340
|
+
|
|
2341
|
+
if (!(typeof exchangeRoute == 'undefined' || typeof exchangeRoute.exchange == 'undefined')) {
|
|
2342
|
+
_context2.next = 10;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
return _context2.abrupt("return");
|
|
2347
|
+
|
|
2348
|
+
case 10:
|
|
2349
|
+
_context2.next = 12;
|
|
2350
|
+
return Promise.all(blocks.map( /*#__PURE__*/function () {
|
|
2351
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(block) {
|
|
2352
|
+
var amountIn;
|
|
2353
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
2354
|
+
while (1) {
|
|
2355
|
+
switch (_context.prev = _context.next) {
|
|
2356
|
+
case 0:
|
|
2357
|
+
_context.next = 2;
|
|
2358
|
+
return exchangeRoute.exchange.getAmountIn({
|
|
2359
|
+
path: exchangeRoute.path,
|
|
2360
|
+
amountOut: exchangeRoute.amountOutMin,
|
|
2361
|
+
block: block
|
|
2362
|
+
});
|
|
2363
|
+
|
|
2364
|
+
case 2:
|
|
2365
|
+
amountIn = _context.sent;
|
|
2366
|
+
return _context.abrupt("return", amountIn);
|
|
2367
|
+
|
|
2368
|
+
case 4:
|
|
2369
|
+
case "end":
|
|
2370
|
+
return _context.stop();
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}, _callee);
|
|
2374
|
+
}));
|
|
2375
|
+
|
|
2376
|
+
return function (_x2) {
|
|
2377
|
+
return _ref2.apply(this, arguments);
|
|
2378
|
+
};
|
|
2379
|
+
}()));
|
|
2380
|
+
|
|
2381
|
+
case 12:
|
|
2382
|
+
lastAmountsIn = _context2.sent;
|
|
2383
|
+
|
|
2384
|
+
if (!(!lastAmountsIn[0] || !lastAmountsIn[1] || !lastAmountsIn[2])) {
|
|
2385
|
+
_context2.next = 15;
|
|
2386
|
+
break;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
return _context2.abrupt("return");
|
|
2390
|
+
|
|
2391
|
+
case 15:
|
|
2392
|
+
if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
|
|
2393
|
+
_context2.next = 29;
|
|
2394
|
+
break;
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
|
|
2398
|
+
difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
|
|
2399
|
+
|
|
2400
|
+
if (difference1.lt(difference2)) {
|
|
2401
|
+
slippage = difference2.add(difference2.sub(difference1));
|
|
2402
|
+
} else {
|
|
2403
|
+
slippage = difference1.add(difference1.sub(difference2));
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
newAmountBN = lastAmountsIn[0].add(slippage);
|
|
2407
|
+
_context2.next = 22;
|
|
2408
|
+
return route.fromToken.readable(newAmountBN);
|
|
2409
|
+
|
|
2410
|
+
case 22:
|
|
2411
|
+
readableAmount = _context2.sent;
|
|
2412
|
+
_context2.next = 25;
|
|
2413
|
+
return route.fromToken.BigNumber(round(readableAmount));
|
|
2414
|
+
|
|
2415
|
+
case 25:
|
|
2416
|
+
roundedAmountBN = _context2.sent;
|
|
2417
|
+
|
|
2418
|
+
if (!(route.fromAmount == roundedAmountBN.toString())) {
|
|
2419
|
+
_context2.next = 28;
|
|
2420
|
+
break;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
return _context2.abrupt("return");
|
|
2424
|
+
|
|
2425
|
+
case 28:
|
|
2426
|
+
return _context2.abrupt("return", newAmountBN);
|
|
2427
|
+
|
|
2428
|
+
case 29:
|
|
2429
|
+
case "end":
|
|
2430
|
+
return _context2.stop();
|
|
2431
|
+
}
|
|
2322
2432
|
}
|
|
2433
|
+
}, _callee2);
|
|
2434
|
+
}));
|
|
2435
|
+
|
|
2436
|
+
return function calculateAmountInWithSlippage(_x) {
|
|
2437
|
+
return _ref.apply(this, arguments);
|
|
2438
|
+
};
|
|
2439
|
+
}();
|
|
2440
|
+
|
|
2441
|
+
var onRoutesUpdate = /*#__PURE__*/function () {
|
|
2442
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(routes) {
|
|
2443
|
+
return regenerator.wrap(function _callee5$(_context5) {
|
|
2444
|
+
while (1) {
|
|
2445
|
+
switch (_context5.prev = _context5.next) {
|
|
2446
|
+
case 0:
|
|
2447
|
+
if (routes.length == 0) {
|
|
2448
|
+
setAllRoutes([]);
|
|
2449
|
+
|
|
2450
|
+
if (props.setMaxRoute) {
|
|
2451
|
+
props.setMaxRoute(null);
|
|
2452
|
+
}
|
|
2453
|
+
} else {
|
|
2454
|
+
roundAmounts(routes).then( /*#__PURE__*/function () {
|
|
2455
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(roundedRoutes) {
|
|
2456
|
+
var selectRoute, newSelectRoute, amountInWithSlippage, _amountInWithSlippage;
|
|
2457
|
+
|
|
2458
|
+
return regenerator.wrap(function _callee4$(_context4) {
|
|
2459
|
+
while (1) {
|
|
2460
|
+
switch (_context4.prev = _context4.next) {
|
|
2461
|
+
case 0:
|
|
2462
|
+
if (!(typeof selectedRoute == 'undefined')) {
|
|
2463
|
+
_context4.next = 4;
|
|
2464
|
+
break;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
selectRoute = roundedRoutes[0];
|
|
2468
|
+
_context4.next = 13;
|
|
2469
|
+
break;
|
|
2470
|
+
|
|
2471
|
+
case 4:
|
|
2472
|
+
newSelectRoute = roundedRoutes[allRoutes.findIndex(function (route) {
|
|
2473
|
+
return route.fromToken == selectedRoute.fromToken && route.blockchain == selectedRoute.blockchain;
|
|
2474
|
+
})];
|
|
2475
|
+
|
|
2476
|
+
if (!(newSelectRoute && selectedRoute.fromAmount !== newSelectRoute.fromAmount)) {
|
|
2477
|
+
_context4.next = 13;
|
|
2478
|
+
break;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
_context4.next = 8;
|
|
2482
|
+
return calculateAmountInWithSlippage(newSelectRoute);
|
|
2483
|
+
|
|
2484
|
+
case 8:
|
|
2485
|
+
amountInWithSlippage = _context4.sent;
|
|
2486
|
+
|
|
2487
|
+
if (!amountInWithSlippage) {
|
|
2488
|
+
_context4.next = 12;
|
|
2489
|
+
break;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
_context4.next = 12;
|
|
2493
|
+
return roundAmount(newSelectRoute, amountInWithSlippage);
|
|
2494
|
+
|
|
2495
|
+
case 12:
|
|
2496
|
+
setUpdatedRouteWithNewPrice(newSelectRoute);
|
|
2497
|
+
|
|
2498
|
+
case 13:
|
|
2499
|
+
if (!selectRoute) {
|
|
2500
|
+
_context4.next = 21;
|
|
2501
|
+
break;
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
_context4.next = 16;
|
|
2505
|
+
return calculateAmountInWithSlippage(selectRoute);
|
|
2506
|
+
|
|
2507
|
+
case 16:
|
|
2508
|
+
_amountInWithSlippage = _context4.sent;
|
|
2509
|
+
|
|
2510
|
+
if (!_amountInWithSlippage) {
|
|
2511
|
+
_context4.next = 20;
|
|
2512
|
+
break;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
_context4.next = 20;
|
|
2516
|
+
return roundAmount(selectRoute, _amountInWithSlippage);
|
|
2517
|
+
|
|
2518
|
+
case 20:
|
|
2519
|
+
setSelectedRoute(selectRoute);
|
|
2520
|
+
|
|
2521
|
+
case 21:
|
|
2522
|
+
_context4.next = 23;
|
|
2523
|
+
return Promise.all(roundedRoutes.map( /*#__PURE__*/function () {
|
|
2524
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(route, index) {
|
|
2525
|
+
var amountInWithSlippage;
|
|
2526
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
2527
|
+
while (1) {
|
|
2528
|
+
switch (_context3.prev = _context3.next) {
|
|
2529
|
+
case 0:
|
|
2530
|
+
_context3.next = 2;
|
|
2531
|
+
return calculateAmountInWithSlippage(route);
|
|
2532
|
+
|
|
2533
|
+
case 2:
|
|
2534
|
+
amountInWithSlippage = _context3.sent;
|
|
2535
|
+
|
|
2536
|
+
if (!amountInWithSlippage) {
|
|
2537
|
+
_context3.next = 6;
|
|
2538
|
+
break;
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
_context3.next = 6;
|
|
2542
|
+
return roundAmount(route, amountInWithSlippage);
|
|
2543
|
+
|
|
2544
|
+
case 6:
|
|
2545
|
+
return _context3.abrupt("return", route);
|
|
2546
|
+
|
|
2547
|
+
case 7:
|
|
2548
|
+
case "end":
|
|
2549
|
+
return _context3.stop();
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
}, _callee3);
|
|
2553
|
+
}));
|
|
2554
|
+
|
|
2555
|
+
return function (_x5, _x6) {
|
|
2556
|
+
return _ref5.apply(this, arguments);
|
|
2557
|
+
};
|
|
2558
|
+
}())).then(setAllRoutes);
|
|
2559
|
+
|
|
2560
|
+
case 23:
|
|
2561
|
+
if (props.setMaxRoute) {
|
|
2562
|
+
props.setMaxRoute(findMaxRoute(roundedRoutes));
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
case 24:
|
|
2566
|
+
case "end":
|
|
2567
|
+
return _context4.stop();
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
}, _callee4);
|
|
2571
|
+
}));
|
|
2323
2572
|
|
|
2324
|
-
|
|
2325
|
-
|
|
2573
|
+
return function (_x4) {
|
|
2574
|
+
return _ref4.apply(this, arguments);
|
|
2575
|
+
};
|
|
2576
|
+
}());
|
|
2577
|
+
}
|
|
2326
2578
|
|
|
2327
|
-
|
|
2328
|
-
|
|
2579
|
+
case 1:
|
|
2580
|
+
case "end":
|
|
2581
|
+
return _context5.stop();
|
|
2582
|
+
}
|
|
2329
2583
|
}
|
|
2330
|
-
});
|
|
2331
|
-
}
|
|
2332
|
-
|
|
2584
|
+
}, _callee5);
|
|
2585
|
+
}));
|
|
2586
|
+
|
|
2587
|
+
return function onRoutesUpdate(_x3) {
|
|
2588
|
+
return _ref3.apply(this, arguments);
|
|
2589
|
+
};
|
|
2590
|
+
}();
|
|
2333
2591
|
|
|
2334
|
-
var getPaymentRoutes = function getPaymentRoutes(
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
var updatable =
|
|
2592
|
+
var getPaymentRoutes = function getPaymentRoutes(_ref6) {
|
|
2593
|
+
_ref6.allRoutes;
|
|
2594
|
+
_ref6.selectedRoute;
|
|
2595
|
+
var updatable = _ref6.updatable;
|
|
2338
2596
|
|
|
2339
2597
|
if (updatable == false || !props.accept || !account) {
|
|
2340
2598
|
return;
|
|
@@ -2351,72 +2609,144 @@
|
|
|
2351
2609
|
});
|
|
2352
2610
|
};
|
|
2353
2611
|
|
|
2354
|
-
var
|
|
2355
|
-
|
|
2356
|
-
|
|
2612
|
+
var updateRouteAmount = function updateRouteAmount(route, amountBN) {
|
|
2613
|
+
route.fromAmount = amountBN.toString();
|
|
2614
|
+
route.transaction.params.amounts[0] = amountBN.toString();
|
|
2615
|
+
|
|
2616
|
+
if (route.transaction.value && route.transaction.value.toString() != '0') {
|
|
2617
|
+
route.transaction.value = amountBN.toString();
|
|
2618
|
+
}
|
|
2619
|
+
};
|
|
2620
|
+
|
|
2621
|
+
var roundAmount = /*#__PURE__*/function () {
|
|
2622
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(route, amountBN) {
|
|
2623
|
+
var readableAmount, roundedAmountBN;
|
|
2624
|
+
return regenerator.wrap(function _callee6$(_context6) {
|
|
2357
2625
|
while (1) {
|
|
2358
|
-
switch (
|
|
2626
|
+
switch (_context6.prev = _context6.next) {
|
|
2359
2627
|
case 0:
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
while (1) {
|
|
2365
|
-
switch (_context.prev = _context.next) {
|
|
2366
|
-
case 0:
|
|
2367
|
-
if (!route.directTransfer) {
|
|
2368
|
-
_context.next = 2;
|
|
2369
|
-
break;
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
|
-
return _context.abrupt("return", route);
|
|
2628
|
+
if (!route.directTransfer) {
|
|
2629
|
+
_context6.next = 2;
|
|
2630
|
+
break;
|
|
2631
|
+
}
|
|
2373
2632
|
|
|
2374
|
-
|
|
2375
|
-
_context.next = 4;
|
|
2376
|
-
return route.fromToken.readable(route.transaction.params.amounts[0]);
|
|
2633
|
+
return _context6.abrupt("return", route);
|
|
2377
2634
|
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
return route.fromToken.BigNumber(round(readableAmount));
|
|
2635
|
+
case 2:
|
|
2636
|
+
_context6.next = 4;
|
|
2637
|
+
return route.fromToken.readable(amountBN || route.transaction.params.amounts[0]);
|
|
2382
2638
|
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2639
|
+
case 4:
|
|
2640
|
+
readableAmount = _context6.sent;
|
|
2641
|
+
_context6.next = 7;
|
|
2642
|
+
return route.fromToken.BigNumber(round(readableAmount));
|
|
2387
2643
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2644
|
+
case 7:
|
|
2645
|
+
roundedAmountBN = _context6.sent;
|
|
2646
|
+
updateRouteAmount(route, roundedAmountBN);
|
|
2647
|
+
return _context6.abrupt("return", route);
|
|
2391
2648
|
|
|
2392
|
-
|
|
2649
|
+
case 10:
|
|
2650
|
+
case "end":
|
|
2651
|
+
return _context6.stop();
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
}, _callee6);
|
|
2655
|
+
}));
|
|
2393
2656
|
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
}
|
|
2399
|
-
}, _callee);
|
|
2400
|
-
}));
|
|
2657
|
+
return function roundAmount(_x7, _x8) {
|
|
2658
|
+
return _ref7.apply(this, arguments);
|
|
2659
|
+
};
|
|
2660
|
+
}();
|
|
2401
2661
|
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2662
|
+
var roundAmounts = /*#__PURE__*/function () {
|
|
2663
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(routes) {
|
|
2664
|
+
return regenerator.wrap(function _callee7$(_context7) {
|
|
2665
|
+
while (1) {
|
|
2666
|
+
switch (_context7.prev = _context7.next) {
|
|
2667
|
+
case 0:
|
|
2668
|
+
return _context7.abrupt("return", Promise.all(routes.map(function (route) {
|
|
2669
|
+
return roundAmount(route);
|
|
2670
|
+
})));
|
|
2406
2671
|
|
|
2407
2672
|
case 1:
|
|
2408
2673
|
case "end":
|
|
2409
|
-
return
|
|
2674
|
+
return _context7.stop();
|
|
2410
2675
|
}
|
|
2411
2676
|
}
|
|
2412
|
-
},
|
|
2677
|
+
}, _callee7);
|
|
2413
2678
|
}));
|
|
2414
2679
|
|
|
2415
|
-
return function roundAmounts(
|
|
2416
|
-
return
|
|
2680
|
+
return function roundAmounts(_x9) {
|
|
2681
|
+
return _ref8.apply(this, arguments);
|
|
2417
2682
|
};
|
|
2418
2683
|
}();
|
|
2419
2684
|
|
|
2685
|
+
var updateRouteWithNewPrice = /*#__PURE__*/function () {
|
|
2686
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
|
|
2687
|
+
return regenerator.wrap(function _callee8$(_context8) {
|
|
2688
|
+
while (1) {
|
|
2689
|
+
switch (_context8.prev = _context8.next) {
|
|
2690
|
+
case 0:
|
|
2691
|
+
setSelectedRoute(_objectSpread({}, updatedRouteWithNewPrice));
|
|
2692
|
+
setUpdatedRouteWithNewPrice(null);
|
|
2693
|
+
|
|
2694
|
+
case 2:
|
|
2695
|
+
case "end":
|
|
2696
|
+
return _context8.stop();
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}, _callee8);
|
|
2700
|
+
}));
|
|
2701
|
+
|
|
2702
|
+
return function updateRouteWithNewPrice() {
|
|
2703
|
+
return _ref9.apply(this, arguments);
|
|
2704
|
+
};
|
|
2705
|
+
}();
|
|
2706
|
+
|
|
2707
|
+
React.useEffect(function () {
|
|
2708
|
+
function updateRouteWithAmountInWithSlippage() {
|
|
2709
|
+
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
function _updateRouteWithAmountInWithSlippage() {
|
|
2713
|
+
_updateRouteWithAmountInWithSlippage = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
|
|
2714
|
+
var amountInWithSlippage;
|
|
2715
|
+
return regenerator.wrap(function _callee9$(_context9) {
|
|
2716
|
+
while (1) {
|
|
2717
|
+
switch (_context9.prev = _context9.next) {
|
|
2718
|
+
case 0:
|
|
2719
|
+
_context9.next = 2;
|
|
2720
|
+
return calculateAmountInWithSlippage(selectedRoute);
|
|
2721
|
+
|
|
2722
|
+
case 2:
|
|
2723
|
+
amountInWithSlippage = _context9.sent;
|
|
2724
|
+
|
|
2725
|
+
if (!amountInWithSlippage) {
|
|
2726
|
+
_context9.next = 7;
|
|
2727
|
+
break;
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
_context9.next = 6;
|
|
2731
|
+
return roundAmount(selectedRoute, amountInWithSlippage);
|
|
2732
|
+
|
|
2733
|
+
case 6:
|
|
2734
|
+
setUpdatedRouteWithNewPrice(selectedRoute);
|
|
2735
|
+
|
|
2736
|
+
case 7:
|
|
2737
|
+
case "end":
|
|
2738
|
+
return _context9.stop();
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
}, _callee9);
|
|
2742
|
+
}));
|
|
2743
|
+
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
if (selectedRoute) {
|
|
2747
|
+
updateRouteWithAmountInWithSlippage();
|
|
2748
|
+
}
|
|
2749
|
+
}, [selectedRoute]);
|
|
2420
2750
|
React.useEffect(function () {
|
|
2421
2751
|
var timeout = setTimeout(function () {
|
|
2422
2752
|
setReloadCount(reloadCount + 1);
|
|
@@ -2432,12 +2762,7 @@
|
|
|
2432
2762
|
}, [reloadCount, allRoutes, selectedRoute, updatable]);
|
|
2433
2763
|
React.useEffect(function () {
|
|
2434
2764
|
if (account && props.accept && recover == undefined) {
|
|
2435
|
-
setAllRoutes(undefined);
|
|
2436
|
-
setSelectedRoute(undefined);
|
|
2437
2765
|
getPaymentRoutes({});
|
|
2438
|
-
} else {
|
|
2439
|
-
setAllRoutes(undefined);
|
|
2440
|
-
setSelectedRoute(undefined);
|
|
2441
2766
|
}
|
|
2442
2767
|
}, [account, props.accept]);
|
|
2443
2768
|
return /*#__PURE__*/React__default["default"].createElement(PaymentRoutingContext.Provider, {
|
|
@@ -2447,7 +2772,9 @@
|
|
|
2447
2772
|
getPaymentRoutes: getPaymentRoutes,
|
|
2448
2773
|
allRoutes: allRoutes,
|
|
2449
2774
|
setAllRoutes: setAllRoutes,
|
|
2450
|
-
slowRouting: slowRouting
|
|
2775
|
+
slowRouting: slowRouting,
|
|
2776
|
+
updatedRouteWithNewPrice: updatedRouteWithNewPrice,
|
|
2777
|
+
updateRouteWithNewPrice: updateRouteWithNewPrice
|
|
2451
2778
|
}
|
|
2452
2779
|
}, props.children);
|
|
2453
2780
|
});
|
|
@@ -2638,12 +2965,14 @@
|
|
|
2638
2965
|
|
|
2639
2966
|
var _useContext6 = React.useContext(PaymentRoutingContext);
|
|
2640
2967
|
_useContext6.allRoutes;
|
|
2968
|
+
var setSelectedRoute = _useContext6.setSelectedRoute;
|
|
2641
2969
|
|
|
2642
2970
|
var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
|
|
2643
2971
|
var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
|
|
2644
2972
|
var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
|
|
2645
2973
|
|
|
2646
2974
|
var changeAmountAndGoBack = function changeAmountAndGoBack() {
|
|
2975
|
+
setSelectedRoute(undefined);
|
|
2647
2976
|
setAmount(toValidValue(parseFloat(inputAmount)));
|
|
2648
2977
|
navigate('back');
|
|
2649
2978
|
};
|
|
@@ -3001,11 +3330,15 @@
|
|
|
3001
3330
|
paymentValue = _useContext5.paymentValue,
|
|
3002
3331
|
paymentValueLoss = _useContext5.paymentValueLoss;
|
|
3003
3332
|
|
|
3004
|
-
var _useContext6 = React.useContext(
|
|
3005
|
-
_useContext6.
|
|
3333
|
+
var _useContext6 = React.useContext(PaymentRoutingContext),
|
|
3334
|
+
updatedRouteWithNewPrice = _useContext6.updatedRouteWithNewPrice,
|
|
3335
|
+
updateRouteWithNewPrice = _useContext6.updateRouteWithNewPrice;
|
|
3336
|
+
|
|
3337
|
+
var _useContext7 = React.useContext(reactDialogStack.NavigateStackContext);
|
|
3338
|
+
_useContext7.navigate;
|
|
3006
3339
|
|
|
3007
|
-
var
|
|
3008
|
-
close =
|
|
3340
|
+
var _useContext8 = React.useContext(ClosableContext),
|
|
3341
|
+
close = _useContext8.close;
|
|
3009
3342
|
|
|
3010
3343
|
var trackingInfo = function trackingInfo() {
|
|
3011
3344
|
if (tracking != true) {
|
|
@@ -3145,7 +3478,18 @@
|
|
|
3145
3478
|
displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
|
|
3146
3479
|
}
|
|
3147
3480
|
|
|
3148
|
-
if (
|
|
3481
|
+
if (updatedRouteWithNewPrice) {
|
|
3482
|
+
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3483
|
+
className: "PaddingBottomXS"
|
|
3484
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3485
|
+
className: "Alert"
|
|
3486
|
+
}, /*#__PURE__*/React__default["default"].createElement("strong", null, "Price updated!"))), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
3487
|
+
className: "ButtonPrimary",
|
|
3488
|
+
onClick: function onClick() {
|
|
3489
|
+
updateRouteWithNewPrice();
|
|
3490
|
+
}
|
|
3491
|
+
}, "Reload"));
|
|
3492
|
+
} else if (paymentValueLoss) {
|
|
3149
3493
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3150
3494
|
className: "PaddingBottomXS"
|
|
3151
3495
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|