@depay/widgets 7.0.2 → 7.1.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 +13 -13
- package/dist/esm/index.js +442 -98
- package/dist/umd/index.bundle.js +13 -13
- package/dist/umd/index.js +442 -98
- package/package.json +10 -11
package/dist/esm/index.js
CHANGED
|
@@ -1324,7 +1324,7 @@ var CardStyle = (function (style) {
|
|
|
1324
1324
|
});
|
|
1325
1325
|
|
|
1326
1326
|
var DialogStyle = (function (style) {
|
|
1327
|
-
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 ";
|
|
1327
|
+
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 ";
|
|
1328
1328
|
});
|
|
1329
1329
|
|
|
1330
1330
|
var FontStyle = (function (style) {
|
|
@@ -2027,7 +2027,6 @@ var PaymentProvider = (function (props) {
|
|
|
2027
2027
|
}
|
|
2028
2028
|
|
|
2029
2029
|
setPaymentState('initialized');
|
|
2030
|
-
setPayment(null);
|
|
2031
2030
|
setClosable(true);
|
|
2032
2031
|
setUpdatable(true);
|
|
2033
2032
|
getPaymentRoutes({});
|
|
@@ -2237,14 +2236,14 @@ function _defineProperty(obj, key, value) {
|
|
|
2237
2236
|
return obj;
|
|
2238
2237
|
}
|
|
2239
2238
|
|
|
2240
|
-
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; }
|
|
2239
|
+
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; }
|
|
2241
2240
|
|
|
2242
|
-
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; }
|
|
2241
|
+
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; }
|
|
2243
2242
|
|
|
2244
2243
|
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
2245
2244
|
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
2246
2245
|
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
2247
|
-
return _objectSpread(_objectSpread({}, accept), {}, {
|
|
2246
|
+
return _objectSpread$1(_objectSpread$1({}, accept), {}, {
|
|
2248
2247
|
toAddress: toAddress,
|
|
2249
2248
|
toContract: toContract
|
|
2250
2249
|
});
|
|
@@ -2275,6 +2274,9 @@ var routePayments = (function (_ref) {
|
|
|
2275
2274
|
});
|
|
2276
2275
|
});
|
|
2277
2276
|
|
|
2277
|
+
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; }
|
|
2278
|
+
|
|
2279
|
+
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; }
|
|
2278
2280
|
var PaymentRoutingProvider = (function (props) {
|
|
2279
2281
|
var _useState = useState(),
|
|
2280
2282
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -2283,18 +2285,23 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2283
2285
|
|
|
2284
2286
|
var _useState3 = useState(),
|
|
2285
2287
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
+
updatedRouteWithNewPrice = _useState4[0],
|
|
2289
|
+
setUpdatedRouteWithNewPrice = _useState4[1];
|
|
2288
2290
|
|
|
2289
|
-
var _useState5 = useState(
|
|
2291
|
+
var _useState5 = useState(),
|
|
2290
2292
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
+
selectedRoute = _useState6[0],
|
|
2294
|
+
setSelectedRoute = _useState6[1];
|
|
2293
2295
|
|
|
2294
|
-
var _useState7 = useState(
|
|
2296
|
+
var _useState7 = useState(false),
|
|
2295
2297
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
+
slowRouting = _useState8[0],
|
|
2299
|
+
setSlowRouting = _useState8[1];
|
|
2300
|
+
|
|
2301
|
+
var _useState9 = useState(0),
|
|
2302
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
2303
|
+
reloadCount = _useState10[0],
|
|
2304
|
+
setReloadCount = _useState10[1];
|
|
2298
2305
|
|
|
2299
2306
|
var _useContext = useContext(WalletContext),
|
|
2300
2307
|
account = _useContext.account;
|
|
@@ -2305,41 +2312,292 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2305
2312
|
var _useContext3 = useContext(ConfigurationContext),
|
|
2306
2313
|
recover = _useContext3.recover;
|
|
2307
2314
|
|
|
2308
|
-
var
|
|
2309
|
-
|
|
2310
|
-
|
|
2315
|
+
var calculateAmountInWithSlippage = /*#__PURE__*/function () {
|
|
2316
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(route) {
|
|
2317
|
+
var currentBlock, blocks, i, exchangeRoute, lastAmountsIn, difference1, difference2, slippage, newAmountBN, readableAmount, roundedAmountBN;
|
|
2318
|
+
return regenerator.wrap(function _callee2$(_context2) {
|
|
2319
|
+
while (1) {
|
|
2320
|
+
switch (_context2.prev = _context2.next) {
|
|
2321
|
+
case 0:
|
|
2322
|
+
if (!route.directTransfer) {
|
|
2323
|
+
_context2.next = 2;
|
|
2324
|
+
break;
|
|
2325
|
+
}
|
|
2311
2326
|
|
|
2312
|
-
|
|
2313
|
-
props.setMaxRoute(null);
|
|
2314
|
-
}
|
|
2315
|
-
} else {
|
|
2316
|
-
roundAmounts(routes).then(function (roundedRoutes) {
|
|
2317
|
-
var selected;
|
|
2327
|
+
return _context2.abrupt("return");
|
|
2318
2328
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2329
|
+
case 2:
|
|
2330
|
+
_context2.next = 4;
|
|
2331
|
+
return request({
|
|
2332
|
+
blockchain: route.blockchain,
|
|
2333
|
+
method: 'latestBlockNumber'
|
|
2334
|
+
});
|
|
2324
2335
|
|
|
2325
|
-
|
|
2326
|
-
|
|
2336
|
+
case 4:
|
|
2337
|
+
currentBlock = _context2.sent;
|
|
2338
|
+
blocks = [];
|
|
2339
|
+
|
|
2340
|
+
for (i = 0; i <= 2; i++) {
|
|
2341
|
+
blocks.push(currentBlock - i);
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
exchangeRoute = route.exchangeRoutes[0];
|
|
2345
|
+
|
|
2346
|
+
if (!(typeof exchangeRoute == 'undefined' || typeof exchangeRoute.exchange == 'undefined')) {
|
|
2347
|
+
_context2.next = 10;
|
|
2348
|
+
break;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
return _context2.abrupt("return");
|
|
2352
|
+
|
|
2353
|
+
case 10:
|
|
2354
|
+
_context2.next = 12;
|
|
2355
|
+
return Promise.all(blocks.map( /*#__PURE__*/function () {
|
|
2356
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(block) {
|
|
2357
|
+
var amountIn;
|
|
2358
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
2359
|
+
while (1) {
|
|
2360
|
+
switch (_context.prev = _context.next) {
|
|
2361
|
+
case 0:
|
|
2362
|
+
_context.next = 2;
|
|
2363
|
+
return exchangeRoute.exchange.getAmountIn({
|
|
2364
|
+
path: exchangeRoute.path,
|
|
2365
|
+
amountOut: exchangeRoute.amountOutMin,
|
|
2366
|
+
block: block
|
|
2367
|
+
});
|
|
2368
|
+
|
|
2369
|
+
case 2:
|
|
2370
|
+
amountIn = _context.sent;
|
|
2371
|
+
return _context.abrupt("return", amountIn);
|
|
2372
|
+
|
|
2373
|
+
case 4:
|
|
2374
|
+
case "end":
|
|
2375
|
+
return _context.stop();
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
}, _callee);
|
|
2379
|
+
}));
|
|
2380
|
+
|
|
2381
|
+
return function (_x2) {
|
|
2382
|
+
return _ref2.apply(this, arguments);
|
|
2383
|
+
};
|
|
2384
|
+
}()));
|
|
2385
|
+
|
|
2386
|
+
case 12:
|
|
2387
|
+
lastAmountsIn = _context2.sent;
|
|
2388
|
+
|
|
2389
|
+
if (!(!lastAmountsIn[0] || !lastAmountsIn[1] || !lastAmountsIn[2])) {
|
|
2390
|
+
_context2.next = 15;
|
|
2391
|
+
break;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
return _context2.abrupt("return");
|
|
2395
|
+
|
|
2396
|
+
case 15:
|
|
2397
|
+
if (!(lastAmountsIn[0].gt(lastAmountsIn[1]) && lastAmountsIn[1].gt(lastAmountsIn[2]))) {
|
|
2398
|
+
_context2.next = 29;
|
|
2399
|
+
break;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
difference1 = lastAmountsIn[0].sub(lastAmountsIn[1]);
|
|
2403
|
+
difference2 = lastAmountsIn[1].sub(lastAmountsIn[2]);
|
|
2404
|
+
|
|
2405
|
+
if (difference1.lt(difference2)) {
|
|
2406
|
+
slippage = difference2.add(difference2.sub(difference1));
|
|
2407
|
+
} else {
|
|
2408
|
+
slippage = difference1.add(difference1.sub(difference2));
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
newAmountBN = lastAmountsIn[0].add(slippage);
|
|
2412
|
+
_context2.next = 22;
|
|
2413
|
+
return route.fromToken.readable(newAmountBN);
|
|
2414
|
+
|
|
2415
|
+
case 22:
|
|
2416
|
+
readableAmount = _context2.sent;
|
|
2417
|
+
_context2.next = 25;
|
|
2418
|
+
return route.fromToken.BigNumber(round(readableAmount));
|
|
2419
|
+
|
|
2420
|
+
case 25:
|
|
2421
|
+
roundedAmountBN = _context2.sent;
|
|
2422
|
+
|
|
2423
|
+
if (!(route.fromAmount == roundedAmountBN.toString())) {
|
|
2424
|
+
_context2.next = 28;
|
|
2425
|
+
break;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
return _context2.abrupt("return");
|
|
2429
|
+
|
|
2430
|
+
case 28:
|
|
2431
|
+
return _context2.abrupt("return", newAmountBN);
|
|
2432
|
+
|
|
2433
|
+
case 29:
|
|
2434
|
+
case "end":
|
|
2435
|
+
return _context2.stop();
|
|
2436
|
+
}
|
|
2327
2437
|
}
|
|
2438
|
+
}, _callee2);
|
|
2439
|
+
}));
|
|
2440
|
+
|
|
2441
|
+
return function calculateAmountInWithSlippage(_x) {
|
|
2442
|
+
return _ref.apply(this, arguments);
|
|
2443
|
+
};
|
|
2444
|
+
}();
|
|
2445
|
+
|
|
2446
|
+
var onRoutesUpdate = /*#__PURE__*/function () {
|
|
2447
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(routes) {
|
|
2448
|
+
return regenerator.wrap(function _callee5$(_context5) {
|
|
2449
|
+
while (1) {
|
|
2450
|
+
switch (_context5.prev = _context5.next) {
|
|
2451
|
+
case 0:
|
|
2452
|
+
if (routes.length == 0) {
|
|
2453
|
+
setAllRoutes([]);
|
|
2454
|
+
|
|
2455
|
+
if (props.setMaxRoute) {
|
|
2456
|
+
props.setMaxRoute(null);
|
|
2457
|
+
}
|
|
2458
|
+
} else {
|
|
2459
|
+
roundAmounts(routes).then( /*#__PURE__*/function () {
|
|
2460
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(roundedRoutes) {
|
|
2461
|
+
var selectRoute, newSelectRoute, amountInWithSlippage, _amountInWithSlippage;
|
|
2462
|
+
|
|
2463
|
+
return regenerator.wrap(function _callee4$(_context4) {
|
|
2464
|
+
while (1) {
|
|
2465
|
+
switch (_context4.prev = _context4.next) {
|
|
2466
|
+
case 0:
|
|
2467
|
+
if (!(typeof selectedRoute == 'undefined')) {
|
|
2468
|
+
_context4.next = 4;
|
|
2469
|
+
break;
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
selectRoute = roundedRoutes[0];
|
|
2473
|
+
_context4.next = 13;
|
|
2474
|
+
break;
|
|
2475
|
+
|
|
2476
|
+
case 4:
|
|
2477
|
+
newSelectRoute = roundedRoutes[allRoutes.findIndex(function (route) {
|
|
2478
|
+
return route.fromToken == selectedRoute.fromToken && route.blockchain == selectedRoute.blockchain;
|
|
2479
|
+
})];
|
|
2480
|
+
|
|
2481
|
+
if (!(newSelectRoute && selectedRoute.fromAmount !== newSelectRoute.fromAmount)) {
|
|
2482
|
+
_context4.next = 13;
|
|
2483
|
+
break;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
_context4.next = 8;
|
|
2487
|
+
return calculateAmountInWithSlippage(newSelectRoute);
|
|
2488
|
+
|
|
2489
|
+
case 8:
|
|
2490
|
+
amountInWithSlippage = _context4.sent;
|
|
2491
|
+
|
|
2492
|
+
if (!amountInWithSlippage) {
|
|
2493
|
+
_context4.next = 12;
|
|
2494
|
+
break;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
_context4.next = 12;
|
|
2498
|
+
return roundAmount(newSelectRoute, amountInWithSlippage);
|
|
2499
|
+
|
|
2500
|
+
case 12:
|
|
2501
|
+
setUpdatedRouteWithNewPrice(newSelectRoute);
|
|
2502
|
+
|
|
2503
|
+
case 13:
|
|
2504
|
+
if (!selectRoute) {
|
|
2505
|
+
_context4.next = 21;
|
|
2506
|
+
break;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
_context4.next = 16;
|
|
2510
|
+
return calculateAmountInWithSlippage(selectRoute);
|
|
2511
|
+
|
|
2512
|
+
case 16:
|
|
2513
|
+
_amountInWithSlippage = _context4.sent;
|
|
2514
|
+
|
|
2515
|
+
if (!_amountInWithSlippage) {
|
|
2516
|
+
_context4.next = 20;
|
|
2517
|
+
break;
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
_context4.next = 20;
|
|
2521
|
+
return roundAmount(selectRoute, _amountInWithSlippage);
|
|
2522
|
+
|
|
2523
|
+
case 20:
|
|
2524
|
+
setSelectedRoute(selectRoute);
|
|
2525
|
+
|
|
2526
|
+
case 21:
|
|
2527
|
+
_context4.next = 23;
|
|
2528
|
+
return Promise.all(roundedRoutes.map( /*#__PURE__*/function () {
|
|
2529
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(route, index) {
|
|
2530
|
+
var amountInWithSlippage;
|
|
2531
|
+
return regenerator.wrap(function _callee3$(_context3) {
|
|
2532
|
+
while (1) {
|
|
2533
|
+
switch (_context3.prev = _context3.next) {
|
|
2534
|
+
case 0:
|
|
2535
|
+
_context3.next = 2;
|
|
2536
|
+
return calculateAmountInWithSlippage(route);
|
|
2537
|
+
|
|
2538
|
+
case 2:
|
|
2539
|
+
amountInWithSlippage = _context3.sent;
|
|
2540
|
+
|
|
2541
|
+
if (!amountInWithSlippage) {
|
|
2542
|
+
_context3.next = 6;
|
|
2543
|
+
break;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
_context3.next = 6;
|
|
2547
|
+
return roundAmount(route, amountInWithSlippage);
|
|
2548
|
+
|
|
2549
|
+
case 6:
|
|
2550
|
+
return _context3.abrupt("return", route);
|
|
2551
|
+
|
|
2552
|
+
case 7:
|
|
2553
|
+
case "end":
|
|
2554
|
+
return _context3.stop();
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}, _callee3);
|
|
2558
|
+
}));
|
|
2559
|
+
|
|
2560
|
+
return function (_x5, _x6) {
|
|
2561
|
+
return _ref5.apply(this, arguments);
|
|
2562
|
+
};
|
|
2563
|
+
}())).then(setAllRoutes);
|
|
2564
|
+
|
|
2565
|
+
case 23:
|
|
2566
|
+
if (props.setMaxRoute) {
|
|
2567
|
+
props.setMaxRoute(findMaxRoute(roundedRoutes));
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
case 24:
|
|
2571
|
+
case "end":
|
|
2572
|
+
return _context4.stop();
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
}, _callee4);
|
|
2576
|
+
}));
|
|
2328
2577
|
|
|
2329
|
-
|
|
2330
|
-
|
|
2578
|
+
return function (_x4) {
|
|
2579
|
+
return _ref4.apply(this, arguments);
|
|
2580
|
+
};
|
|
2581
|
+
}());
|
|
2582
|
+
}
|
|
2331
2583
|
|
|
2332
|
-
|
|
2333
|
-
|
|
2584
|
+
case 1:
|
|
2585
|
+
case "end":
|
|
2586
|
+
return _context5.stop();
|
|
2587
|
+
}
|
|
2334
2588
|
}
|
|
2335
|
-
});
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2589
|
+
}, _callee5);
|
|
2590
|
+
}));
|
|
2591
|
+
|
|
2592
|
+
return function onRoutesUpdate(_x3) {
|
|
2593
|
+
return _ref3.apply(this, arguments);
|
|
2594
|
+
};
|
|
2595
|
+
}();
|
|
2338
2596
|
|
|
2339
|
-
var getPaymentRoutes = function getPaymentRoutes(
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
var updatable =
|
|
2597
|
+
var getPaymentRoutes = function getPaymentRoutes(_ref6) {
|
|
2598
|
+
_ref6.allRoutes;
|
|
2599
|
+
_ref6.selectedRoute;
|
|
2600
|
+
var updatable = _ref6.updatable;
|
|
2343
2601
|
|
|
2344
2602
|
if (updatable == false || !props.accept || !account) {
|
|
2345
2603
|
return;
|
|
@@ -2356,72 +2614,144 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2356
2614
|
});
|
|
2357
2615
|
};
|
|
2358
2616
|
|
|
2359
|
-
var
|
|
2360
|
-
|
|
2361
|
-
|
|
2617
|
+
var updateRouteAmount = function updateRouteAmount(route, amountBN) {
|
|
2618
|
+
route.fromAmount = amountBN.toString();
|
|
2619
|
+
route.transaction.params.amounts[0] = amountBN.toString();
|
|
2620
|
+
|
|
2621
|
+
if (route.transaction.value && route.transaction.value.toString() != '0') {
|
|
2622
|
+
route.transaction.value = amountBN.toString();
|
|
2623
|
+
}
|
|
2624
|
+
};
|
|
2625
|
+
|
|
2626
|
+
var roundAmount = /*#__PURE__*/function () {
|
|
2627
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(route, amountBN) {
|
|
2628
|
+
var readableAmount, roundedAmountBN;
|
|
2629
|
+
return regenerator.wrap(function _callee6$(_context6) {
|
|
2362
2630
|
while (1) {
|
|
2363
|
-
switch (
|
|
2631
|
+
switch (_context6.prev = _context6.next) {
|
|
2364
2632
|
case 0:
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
while (1) {
|
|
2370
|
-
switch (_context.prev = _context.next) {
|
|
2371
|
-
case 0:
|
|
2372
|
-
if (!route.directTransfer) {
|
|
2373
|
-
_context.next = 2;
|
|
2374
|
-
break;
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
return _context.abrupt("return", route);
|
|
2633
|
+
if (!route.directTransfer) {
|
|
2634
|
+
_context6.next = 2;
|
|
2635
|
+
break;
|
|
2636
|
+
}
|
|
2378
2637
|
|
|
2379
|
-
|
|
2380
|
-
_context.next = 4;
|
|
2381
|
-
return route.fromToken.readable(route.transaction.params.amounts[0]);
|
|
2638
|
+
return _context6.abrupt("return", route);
|
|
2382
2639
|
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
return route.fromToken.BigNumber(round(readableAmount));
|
|
2640
|
+
case 2:
|
|
2641
|
+
_context6.next = 4;
|
|
2642
|
+
return route.fromToken.readable(amountBN || route.transaction.params.amounts[0]);
|
|
2387
2643
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2644
|
+
case 4:
|
|
2645
|
+
readableAmount = _context6.sent;
|
|
2646
|
+
_context6.next = 7;
|
|
2647
|
+
return route.fromToken.BigNumber(round(readableAmount));
|
|
2392
2648
|
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2649
|
+
case 7:
|
|
2650
|
+
roundedAmountBN = _context6.sent;
|
|
2651
|
+
updateRouteAmount(route, roundedAmountBN);
|
|
2652
|
+
return _context6.abrupt("return", route);
|
|
2396
2653
|
|
|
2397
|
-
|
|
2654
|
+
case 10:
|
|
2655
|
+
case "end":
|
|
2656
|
+
return _context6.stop();
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
}, _callee6);
|
|
2660
|
+
}));
|
|
2398
2661
|
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
}
|
|
2404
|
-
}, _callee);
|
|
2405
|
-
}));
|
|
2662
|
+
return function roundAmount(_x7, _x8) {
|
|
2663
|
+
return _ref7.apply(this, arguments);
|
|
2664
|
+
};
|
|
2665
|
+
}();
|
|
2406
2666
|
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2667
|
+
var roundAmounts = /*#__PURE__*/function () {
|
|
2668
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(routes) {
|
|
2669
|
+
return regenerator.wrap(function _callee7$(_context7) {
|
|
2670
|
+
while (1) {
|
|
2671
|
+
switch (_context7.prev = _context7.next) {
|
|
2672
|
+
case 0:
|
|
2673
|
+
return _context7.abrupt("return", Promise.all(routes.map(function (route) {
|
|
2674
|
+
return roundAmount(route);
|
|
2675
|
+
})));
|
|
2411
2676
|
|
|
2412
2677
|
case 1:
|
|
2413
2678
|
case "end":
|
|
2414
|
-
return
|
|
2679
|
+
return _context7.stop();
|
|
2415
2680
|
}
|
|
2416
2681
|
}
|
|
2417
|
-
},
|
|
2682
|
+
}, _callee7);
|
|
2418
2683
|
}));
|
|
2419
2684
|
|
|
2420
|
-
return function roundAmounts(
|
|
2421
|
-
return
|
|
2685
|
+
return function roundAmounts(_x9) {
|
|
2686
|
+
return _ref8.apply(this, arguments);
|
|
2422
2687
|
};
|
|
2423
2688
|
}();
|
|
2424
2689
|
|
|
2690
|
+
var updateRouteWithNewPrice = /*#__PURE__*/function () {
|
|
2691
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
|
|
2692
|
+
return regenerator.wrap(function _callee8$(_context8) {
|
|
2693
|
+
while (1) {
|
|
2694
|
+
switch (_context8.prev = _context8.next) {
|
|
2695
|
+
case 0:
|
|
2696
|
+
setSelectedRoute(_objectSpread({}, updatedRouteWithNewPrice));
|
|
2697
|
+
setUpdatedRouteWithNewPrice(null);
|
|
2698
|
+
|
|
2699
|
+
case 2:
|
|
2700
|
+
case "end":
|
|
2701
|
+
return _context8.stop();
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
}, _callee8);
|
|
2705
|
+
}));
|
|
2706
|
+
|
|
2707
|
+
return function updateRouteWithNewPrice() {
|
|
2708
|
+
return _ref9.apply(this, arguments);
|
|
2709
|
+
};
|
|
2710
|
+
}();
|
|
2711
|
+
|
|
2712
|
+
useEffect(function () {
|
|
2713
|
+
function updateRouteWithAmountInWithSlippage() {
|
|
2714
|
+
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
function _updateRouteWithAmountInWithSlippage() {
|
|
2718
|
+
_updateRouteWithAmountInWithSlippage = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
|
|
2719
|
+
var amountInWithSlippage;
|
|
2720
|
+
return regenerator.wrap(function _callee9$(_context9) {
|
|
2721
|
+
while (1) {
|
|
2722
|
+
switch (_context9.prev = _context9.next) {
|
|
2723
|
+
case 0:
|
|
2724
|
+
_context9.next = 2;
|
|
2725
|
+
return calculateAmountInWithSlippage(selectedRoute);
|
|
2726
|
+
|
|
2727
|
+
case 2:
|
|
2728
|
+
amountInWithSlippage = _context9.sent;
|
|
2729
|
+
|
|
2730
|
+
if (!amountInWithSlippage) {
|
|
2731
|
+
_context9.next = 7;
|
|
2732
|
+
break;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
_context9.next = 6;
|
|
2736
|
+
return roundAmount(selectedRoute, amountInWithSlippage);
|
|
2737
|
+
|
|
2738
|
+
case 6:
|
|
2739
|
+
setUpdatedRouteWithNewPrice(selectedRoute);
|
|
2740
|
+
|
|
2741
|
+
case 7:
|
|
2742
|
+
case "end":
|
|
2743
|
+
return _context9.stop();
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
}, _callee9);
|
|
2747
|
+
}));
|
|
2748
|
+
return _updateRouteWithAmountInWithSlippage.apply(this, arguments);
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
if (selectedRoute) {
|
|
2752
|
+
updateRouteWithAmountInWithSlippage();
|
|
2753
|
+
}
|
|
2754
|
+
}, [selectedRoute]);
|
|
2425
2755
|
useEffect(function () {
|
|
2426
2756
|
var timeout = setTimeout(function () {
|
|
2427
2757
|
setReloadCount(reloadCount + 1);
|
|
@@ -2437,12 +2767,7 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2437
2767
|
}, [reloadCount, allRoutes, selectedRoute, updatable]);
|
|
2438
2768
|
useEffect(function () {
|
|
2439
2769
|
if (account && props.accept && recover == undefined) {
|
|
2440
|
-
setAllRoutes(undefined);
|
|
2441
|
-
setSelectedRoute(undefined);
|
|
2442
2770
|
getPaymentRoutes({});
|
|
2443
|
-
} else {
|
|
2444
|
-
setAllRoutes(undefined);
|
|
2445
|
-
setSelectedRoute(undefined);
|
|
2446
2771
|
}
|
|
2447
2772
|
}, [account, props.accept]);
|
|
2448
2773
|
return /*#__PURE__*/React.createElement(PaymentRoutingContext.Provider, {
|
|
@@ -2452,7 +2777,9 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2452
2777
|
getPaymentRoutes: getPaymentRoutes,
|
|
2453
2778
|
allRoutes: allRoutes,
|
|
2454
2779
|
setAllRoutes: setAllRoutes,
|
|
2455
|
-
slowRouting: slowRouting
|
|
2780
|
+
slowRouting: slowRouting,
|
|
2781
|
+
updatedRouteWithNewPrice: updatedRouteWithNewPrice,
|
|
2782
|
+
updateRouteWithNewPrice: updateRouteWithNewPrice
|
|
2456
2783
|
}
|
|
2457
2784
|
}, props.children);
|
|
2458
2785
|
});
|
|
@@ -2643,12 +2970,14 @@ var ChangeAmountDialog = (function (props) {
|
|
|
2643
2970
|
|
|
2644
2971
|
var _useContext6 = useContext(PaymentRoutingContext);
|
|
2645
2972
|
_useContext6.allRoutes;
|
|
2973
|
+
var setSelectedRoute = _useContext6.setSelectedRoute;
|
|
2646
2974
|
|
|
2647
2975
|
var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
|
|
2648
2976
|
var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
|
|
2649
2977
|
var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
|
|
2650
2978
|
|
|
2651
2979
|
var changeAmountAndGoBack = function changeAmountAndGoBack() {
|
|
2980
|
+
setSelectedRoute(undefined);
|
|
2652
2981
|
setAmount(toValidValue(parseFloat(inputAmount)));
|
|
2653
2982
|
navigate('back');
|
|
2654
2983
|
};
|
|
@@ -3006,11 +3335,15 @@ var Footer = (function () {
|
|
|
3006
3335
|
paymentValue = _useContext5.paymentValue,
|
|
3007
3336
|
paymentValueLoss = _useContext5.paymentValueLoss;
|
|
3008
3337
|
|
|
3009
|
-
var _useContext6 = useContext(
|
|
3010
|
-
_useContext6.
|
|
3338
|
+
var _useContext6 = useContext(PaymentRoutingContext),
|
|
3339
|
+
updatedRouteWithNewPrice = _useContext6.updatedRouteWithNewPrice,
|
|
3340
|
+
updateRouteWithNewPrice = _useContext6.updateRouteWithNewPrice;
|
|
3341
|
+
|
|
3342
|
+
var _useContext7 = useContext(NavigateStackContext);
|
|
3343
|
+
_useContext7.navigate;
|
|
3011
3344
|
|
|
3012
|
-
var
|
|
3013
|
-
close =
|
|
3345
|
+
var _useContext8 = useContext(ClosableContext),
|
|
3346
|
+
close = _useContext8.close;
|
|
3014
3347
|
|
|
3015
3348
|
var trackingInfo = function trackingInfo() {
|
|
3016
3349
|
if (tracking != true) {
|
|
@@ -3150,7 +3483,18 @@ var Footer = (function () {
|
|
|
3150
3483
|
displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
|
|
3151
3484
|
}
|
|
3152
3485
|
|
|
3153
|
-
if (
|
|
3486
|
+
if (updatedRouteWithNewPrice) {
|
|
3487
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
3488
|
+
className: "PaddingBottomXS"
|
|
3489
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3490
|
+
className: "Alert"
|
|
3491
|
+
}, /*#__PURE__*/React.createElement("strong", null, "Price updated!"))), /*#__PURE__*/React.createElement("button", {
|
|
3492
|
+
className: "ButtonPrimary",
|
|
3493
|
+
onClick: function onClick() {
|
|
3494
|
+
updateRouteWithNewPrice();
|
|
3495
|
+
}
|
|
3496
|
+
}, "Reload"));
|
|
3497
|
+
} else if (paymentValueLoss) {
|
|
3154
3498
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
3155
3499
|
className: "PaddingBottomXS"
|
|
3156
3500
|
}, /*#__PURE__*/React.createElement("div", {
|