@depay/widgets 6.12.1 → 6.15.0
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 +42 -0
- package/dist/esm/index.bundle.js +256 -89
- package/dist/esm/index.js +193 -62
- package/dist/umd/index.bundle.js +256 -89
- package/dist/umd/index.js +193 -62
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1684,7 +1684,7 @@ var CardStyle = (function (style) {
|
|
|
1684
1684
|
});
|
|
1685
1685
|
|
|
1686
1686
|
var DialogStyle = (function (style) {
|
|
1687
|
-
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\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: 0.8rem;\n background: rgb(248,248,248);\n }\n\n @media screen and (max-width: 450px) {\n \n .Dialog, .ReactDialogAnimation {\n width: 100%;\n }\n\n }\n\n @media (orientation: portrait) and (max-width: 900px) {\n\n .Dialog {\n align-content: stretch;\n display: flex;\n flex-direction: column;\n
|
|
1687
|
+
return "\n\n .ReactDialogBackground {\n backdrop-filter: blur(5px);\n background: rgba(0,0,0,0.7);\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: 0.8rem;\n background: rgb(248,248,248);\n }\n\n @media screen and (max-width: 450px) {\n \n .Dialog, .ReactDialogAnimation {\n width: 100%;\n }\n\n }\n\n @media (orientation: portrait) and (max-width: 900px) {\n\n .Dialog {\n align-content: stretch;\n display: flex;\n flex-direction: column;\n }\n\n .ReactDialogCell {\n vertical-align: bottom;\n }\n\n .DialogBody {\n flex: 1;\n align-items: flex-end;\n }\n\n .DialogFooter {\n padding-bottom: 20px;\n }\n\n .ReactDialogStackCell {\n vertical-align: bottom;\n }\n\n .ReactDialogAnimation {\n bottom: -100px !important;\n top: inherit !important;\n transition: opacity 0.4s ease, bottom 0.4s ease;\n }\n\n .ReactDialog.ReactDialogOpen .ReactDialogAnimation {\n bottom: 0px !important;\n }\n\n .DialogFooter {\n border-bottom-left-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n }\n\n .DialogBody {\n background: rgb(248,248,248);\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 background: rgb(248,248,248);\n border-top-left-radius: 0.8rem;\n border-top-right-radius: 0.8rem;\n min-height: 3.4rem;\n position: relative;\n width: 100%;\n }\n\n .DialogHeaderActionRight {\n position: absolute;\n top: 0;\n right: 0;\n height: 3rem;\n }\n\n .DialogHeaderActionLeft {\n position: absolute;\n top: 0;\n left: 0;\n height: 3rem;\n }\n\n .DialogFooter {\n background: rgb(248,248,248);\n border-bottom-left-radius: 0.8rem;\n border-bottom-right-radius: 0.8rem;\n line-height: 1.5rem;\n min-height: 2rem;\n position: relative;\n text-align: center;\n }\n\n .ReactShadowDOMInsideContainer > .ReactDialog {\n display: table;\n }\n\n ";
|
|
1688
1688
|
});
|
|
1689
1689
|
|
|
1690
1690
|
var FontStyle = (function (style) {
|
|
@@ -2021,20 +2021,22 @@ var WalletContext = /*#__PURE__*/React.createContext();
|
|
|
2021
2021
|
var ChangableAmountProvider = (function (props) {
|
|
2022
2022
|
var configurationsMissAmounts = function configurationsMissAmounts(configurations) {
|
|
2023
2023
|
return !configurations.every(function (configuration) {
|
|
2024
|
-
return typeof configuration.amount != 'undefined';
|
|
2024
|
+
return typeof configuration.amount != 'undefined' || typeof configuration.fromAmount != 'undefined';
|
|
2025
2025
|
});
|
|
2026
2026
|
};
|
|
2027
2027
|
|
|
2028
|
-
var
|
|
2028
|
+
var _useContext = useContext(ConfigurationContext),
|
|
2029
|
+
amountConfiguration = _useContext.amount;
|
|
2030
|
+
_useContext.toAmount;
|
|
2031
|
+
var recover = _useContext.recover;
|
|
2032
|
+
|
|
2033
|
+
var _useState = useState(recover == undefined ? configurationsMissAmounts(props.accept) : false),
|
|
2029
2034
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2030
2035
|
amountsMissing = _useState2[0],
|
|
2031
2036
|
setAmountsMissing = _useState2[1];
|
|
2032
2037
|
|
|
2033
|
-
var
|
|
2034
|
-
account =
|
|
2035
|
-
|
|
2036
|
-
var _useContext2 = useContext(ConfigurationContext),
|
|
2037
|
-
amountConfiguration = _useContext2.amount;
|
|
2038
|
+
var _useContext2 = useContext(WalletContext),
|
|
2039
|
+
account = _useContext2.account;
|
|
2038
2040
|
|
|
2039
2041
|
var _useContext3 = useContext(ConversionRateContext),
|
|
2040
2042
|
conversionRate = _useContext3.conversionRate;
|
|
@@ -2063,8 +2065,12 @@ var ChangableAmountProvider = (function (props) {
|
|
|
2063
2065
|
setMaxAmount = _useState10[1];
|
|
2064
2066
|
|
|
2065
2067
|
useEffect(function () {
|
|
2068
|
+
if (recover) {
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2066
2072
|
setAmountsMissing(configurationsMissAmounts(props.accept));
|
|
2067
|
-
}, [props.accept]);
|
|
2073
|
+
}, [props.accept, recover]);
|
|
2068
2074
|
|
|
2069
2075
|
var getAmounts = function getAmounts() {
|
|
2070
2076
|
return new Promise(function (resolve, reject) {
|
|
@@ -2100,6 +2106,10 @@ var ChangableAmountProvider = (function (props) {
|
|
|
2100
2106
|
};
|
|
2101
2107
|
|
|
2102
2108
|
useEffect(function () {
|
|
2109
|
+
if (recover) {
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2103
2113
|
if (amountsMissing && account && conversionRate) {
|
|
2104
2114
|
getAmounts().then(function (amounts) {
|
|
2105
2115
|
setAcceptWithAmount(props.accept.map(function (configuration, index) {
|
|
@@ -2118,7 +2128,7 @@ var ChangableAmountProvider = (function (props) {
|
|
|
2118
2128
|
}));
|
|
2119
2129
|
})["catch"](setError);
|
|
2120
2130
|
}
|
|
2121
|
-
}, [amountsMissing, account, conversionRate, amount]);
|
|
2131
|
+
}, [amountsMissing, account, conversionRate, amount, recover]);
|
|
2122
2132
|
useEffect(function () {
|
|
2123
2133
|
if (amountsMissing && maxRoute) {
|
|
2124
2134
|
maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
|
|
@@ -2280,10 +2290,12 @@ var PaymentProvider = (function (props) {
|
|
|
2280
2290
|
var _useContext2 = useContext(ConfigurationContext),
|
|
2281
2291
|
_sent = _useContext2.sent,
|
|
2282
2292
|
confirmed = _useContext2.confirmed,
|
|
2283
|
-
failed = _useContext2.failed
|
|
2293
|
+
failed = _useContext2.failed,
|
|
2294
|
+
recover = _useContext2.recover;
|
|
2284
2295
|
|
|
2285
2296
|
var _useContext3 = useContext(PaymentRoutingContext),
|
|
2286
|
-
selectedRoute = _useContext3.selectedRoute
|
|
2297
|
+
selectedRoute = _useContext3.selectedRoute,
|
|
2298
|
+
getPaymentRoutes = _useContext3.getPaymentRoutes;
|
|
2287
2299
|
|
|
2288
2300
|
var _useContext4 = useContext(ClosableContext),
|
|
2289
2301
|
open = _useContext4.open,
|
|
@@ -2349,8 +2361,10 @@ var PaymentProvider = (function (props) {
|
|
|
2349
2361
|
}
|
|
2350
2362
|
|
|
2351
2363
|
setPaymentState('initialized');
|
|
2364
|
+
setPayment(null);
|
|
2352
2365
|
setClosable(true);
|
|
2353
2366
|
setUpdatable(true);
|
|
2367
|
+
getPaymentRoutes({});
|
|
2354
2368
|
navigate('PaymentError');
|
|
2355
2369
|
};
|
|
2356
2370
|
|
|
@@ -2436,6 +2450,39 @@ var PaymentProvider = (function (props) {
|
|
|
2436
2450
|
setPaymentState('confirmed');
|
|
2437
2451
|
}
|
|
2438
2452
|
}, [release]);
|
|
2453
|
+
useEffect(function () {
|
|
2454
|
+
if (recover) {
|
|
2455
|
+
setClosable(false);
|
|
2456
|
+
setUpdatable(false);
|
|
2457
|
+
setPaymentState('paying');
|
|
2458
|
+
setTransaction({
|
|
2459
|
+
blockchain: recover.blockchain,
|
|
2460
|
+
id: recover.transaction,
|
|
2461
|
+
url: Blockchain.findByName(recover.blockchain).explorerUrlFor({
|
|
2462
|
+
transaction: {
|
|
2463
|
+
id: recover.transaction
|
|
2464
|
+
}
|
|
2465
|
+
})
|
|
2466
|
+
});
|
|
2467
|
+
var paymentToken = new Token({
|
|
2468
|
+
blockchain: recover.blockchain,
|
|
2469
|
+
address: recover.token
|
|
2470
|
+
});
|
|
2471
|
+
Promise.all([paymentToken.name(), paymentToken.symbol()]).then(function (_ref2) {
|
|
2472
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
2473
|
+
name = _ref3[0],
|
|
2474
|
+
symbol = _ref3[1];
|
|
2475
|
+
|
|
2476
|
+
setPayment({
|
|
2477
|
+
blockchain: recover.blockchain,
|
|
2478
|
+
token: recover.token,
|
|
2479
|
+
name: name,
|
|
2480
|
+
symbol: symbol.toUpperCase(),
|
|
2481
|
+
amount: recover.amount
|
|
2482
|
+
});
|
|
2483
|
+
})["catch"](setError);
|
|
2484
|
+
}
|
|
2485
|
+
}, [recover]);
|
|
2439
2486
|
useEffect(function () {
|
|
2440
2487
|
if (foundTransaction && foundTransaction.id && foundTransaction.status) {
|
|
2441
2488
|
var newTransaction;
|
|
@@ -2460,16 +2507,16 @@ var PaymentProvider = (function (props) {
|
|
|
2460
2507
|
useEffect(function () {
|
|
2461
2508
|
if (selectedRoute) {
|
|
2462
2509
|
var fromToken = selectedRoute.fromToken;
|
|
2463
|
-
selectedRoute.
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
amount = _ref3[2];
|
|
2510
|
+
Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref4) {
|
|
2511
|
+
var _ref5 = _slicedToArray(_ref4, 3),
|
|
2512
|
+
name = _ref5[0],
|
|
2513
|
+
symbol = _ref5[1],
|
|
2514
|
+
amount = _ref5[2];
|
|
2469
2515
|
|
|
2470
2516
|
setPayment({
|
|
2517
|
+
blockchain: selectedRoute.blockchain,
|
|
2471
2518
|
route: selectedRoute,
|
|
2472
|
-
token:
|
|
2519
|
+
token: fromToken.address,
|
|
2473
2520
|
name: name,
|
|
2474
2521
|
symbol: symbol.toUpperCase(),
|
|
2475
2522
|
amount: amount
|
|
@@ -2552,6 +2599,9 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2552
2599
|
var _useContext2 = useContext(UpdatableContext),
|
|
2553
2600
|
updatable = _useContext2.updatable;
|
|
2554
2601
|
|
|
2602
|
+
var _useContext3 = useContext(ConfigurationContext),
|
|
2603
|
+
recover = _useContext3.recover;
|
|
2604
|
+
|
|
2555
2605
|
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
2556
2606
|
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
2557
2607
|
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
@@ -2679,7 +2729,7 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2679
2729
|
};
|
|
2680
2730
|
}, [reloadCount, allRoutes, selectedRoute, updatable]);
|
|
2681
2731
|
useEffect(function () {
|
|
2682
|
-
if (account && props.accept) {
|
|
2732
|
+
if (account && props.accept && recover == undefined) {
|
|
2683
2733
|
setAllRoutes(undefined);
|
|
2684
2734
|
setSelectedRoute(undefined);
|
|
2685
2735
|
getPaymentRoutes({});
|
|
@@ -2692,6 +2742,7 @@ var PaymentRoutingProvider = (function (props) {
|
|
|
2692
2742
|
value: {
|
|
2693
2743
|
selectedRoute: selectedRoute,
|
|
2694
2744
|
setSelectedRoute: setSelectedRoute,
|
|
2745
|
+
getPaymentRoutes: getPaymentRoutes,
|
|
2695
2746
|
allRoutes: allRoutes,
|
|
2696
2747
|
setAllRoutes: setAllRoutes
|
|
2697
2748
|
}
|
|
@@ -2718,15 +2769,20 @@ var PaymentValueProvider = (function (props) {
|
|
|
2718
2769
|
paymentValue = _useState2[0],
|
|
2719
2770
|
setPaymentValue = _useState2[1];
|
|
2720
2771
|
|
|
2772
|
+
var _useState3 = useState(),
|
|
2773
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2774
|
+
paymentValueLoss = _useState4[0],
|
|
2775
|
+
setPaymentValueLoss = _useState4[1];
|
|
2776
|
+
|
|
2721
2777
|
var _useContext5 = useContext(ConfigurationContext),
|
|
2722
2778
|
currency = _useContext5.currency;
|
|
2723
2779
|
|
|
2724
|
-
var
|
|
2725
|
-
|
|
2726
|
-
reloadCount =
|
|
2727
|
-
setReloadCount =
|
|
2780
|
+
var _useState5 = useState(0),
|
|
2781
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2782
|
+
reloadCount = _useState6[0],
|
|
2783
|
+
setReloadCount = _useState6[1];
|
|
2728
2784
|
|
|
2729
|
-
var
|
|
2785
|
+
var updatePaymentValue = function updatePaymentValue(_ref) {
|
|
2730
2786
|
var updatable = _ref.updatable,
|
|
2731
2787
|
payment = _ref.payment;
|
|
2732
2788
|
|
|
@@ -2741,29 +2797,51 @@ var PaymentValueProvider = (function (props) {
|
|
|
2741
2797
|
amountIn: payment.route.toAmount,
|
|
2742
2798
|
fromAddress: account,
|
|
2743
2799
|
toAddress: account
|
|
2744
|
-
}),
|
|
2800
|
+
}), !payment.route.directTransfer ? route({
|
|
2801
|
+
blockchain: payment.route.blockchain,
|
|
2802
|
+
tokenIn: payment.route.toToken.address,
|
|
2803
|
+
tokenOut: payment.route.fromToken.address,
|
|
2804
|
+
amountIn: payment.route.toAmount,
|
|
2805
|
+
fromAddress: account,
|
|
2806
|
+
toAddress: account
|
|
2807
|
+
}) : Promise.resolve([]), new Token({
|
|
2745
2808
|
blockchain: payment.route.blockchain,
|
|
2746
2809
|
address: CONSTANTS[payment.route.blockchain].USD
|
|
2747
2810
|
}).decimals()]).then(function (_ref2) {
|
|
2748
|
-
var _ref3 = _slicedToArray(_ref2,
|
|
2749
|
-
|
|
2750
|
-
|
|
2811
|
+
var _ref3 = _slicedToArray(_ref2, 3),
|
|
2812
|
+
toTokenUSDExchangeRoutes = _ref3[0],
|
|
2813
|
+
reverseRoutes = _ref3[1],
|
|
2814
|
+
USDDecimals = _ref3[2];
|
|
2751
2815
|
|
|
2752
|
-
var
|
|
2753
|
-
var
|
|
2816
|
+
var toTokenUSDRoute = toTokenUSDExchangeRoutes[0];
|
|
2817
|
+
var reverseRoute = reverseRoutes[0];
|
|
2818
|
+
|
|
2819
|
+
if (reverseRoute) {
|
|
2820
|
+
var reverseAmountOutBN = ethers.BigNumber.from(reverseRoute.amountOut);
|
|
2821
|
+
var paymentAmountInBN = ethers.BigNumber.from(payment.route.fromAmount);
|
|
2822
|
+
var divPercent = 100 - reverseAmountOutBN.mul(ethers.BigNumber.from('100')).div(paymentAmountInBN).abs().toString();
|
|
2823
|
+
|
|
2824
|
+
if (divPercent >= 5) {
|
|
2825
|
+
setPaymentValueLoss(divPercent);
|
|
2826
|
+
} else {
|
|
2827
|
+
setPaymentValueLoss(null);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
var toTokenUSDAmount;
|
|
2754
2832
|
|
|
2755
2833
|
if (payment.route.toToken.address.toLowerCase() == CONSTANTS[payment.route.blockchain].USD.toLowerCase()) {
|
|
2756
|
-
|
|
2757
|
-
} else if (
|
|
2834
|
+
toTokenUSDAmount = payment.route.toAmount.toString();
|
|
2835
|
+
} else if (toTokenUSDRoute == undefined) {
|
|
2758
2836
|
setPaymentValue('');
|
|
2759
2837
|
return;
|
|
2760
2838
|
} else {
|
|
2761
|
-
|
|
2839
|
+
toTokenUSDAmount = toTokenUSDRoute.amountOut.toString();
|
|
2762
2840
|
}
|
|
2763
2841
|
|
|
2764
|
-
var
|
|
2842
|
+
var toTokenUSDValue = ethers.utils.formatUnits(toTokenUSDAmount, USDDecimals);
|
|
2765
2843
|
Currency.fromUSD({
|
|
2766
|
-
amount:
|
|
2844
|
+
amount: toTokenUSDValue,
|
|
2767
2845
|
code: currency,
|
|
2768
2846
|
apiKey: apiKey
|
|
2769
2847
|
}).then(setPaymentValue)["catch"](setError);
|
|
@@ -2772,7 +2850,7 @@ var PaymentValueProvider = (function (props) {
|
|
|
2772
2850
|
|
|
2773
2851
|
useEffect(function () {
|
|
2774
2852
|
if (account && payment) {
|
|
2775
|
-
|
|
2853
|
+
updatePaymentValue({
|
|
2776
2854
|
updatable: updatable,
|
|
2777
2855
|
payment: payment
|
|
2778
2856
|
});
|
|
@@ -2781,7 +2859,7 @@ var PaymentValueProvider = (function (props) {
|
|
|
2781
2859
|
useEffect(function () {
|
|
2782
2860
|
var timeout = setTimeout(function () {
|
|
2783
2861
|
setReloadCount(reloadCount + 1);
|
|
2784
|
-
|
|
2862
|
+
updatePaymentValue({
|
|
2785
2863
|
updatable: updatable
|
|
2786
2864
|
});
|
|
2787
2865
|
}, 15000);
|
|
@@ -2791,7 +2869,8 @@ var PaymentValueProvider = (function (props) {
|
|
|
2791
2869
|
}, [reloadCount, updatable]);
|
|
2792
2870
|
return /*#__PURE__*/React.createElement(PaymentValueContext.Provider, {
|
|
2793
2871
|
value: {
|
|
2794
|
-
paymentValue: paymentValue
|
|
2872
|
+
paymentValue: paymentValue,
|
|
2873
|
+
paymentValueLoss: paymentValueLoss
|
|
2795
2874
|
}
|
|
2796
2875
|
}, props.children);
|
|
2797
2876
|
});
|
|
@@ -3225,7 +3304,8 @@ var Footer = (function () {
|
|
|
3225
3304
|
approvalTransaction = _useContext4.approvalTransaction;
|
|
3226
3305
|
|
|
3227
3306
|
var _useContext5 = useContext(PaymentValueContext),
|
|
3228
|
-
paymentValue = _useContext5.paymentValue
|
|
3307
|
+
paymentValue = _useContext5.paymentValue,
|
|
3308
|
+
paymentValueLoss = _useContext5.paymentValueLoss;
|
|
3229
3309
|
|
|
3230
3310
|
var _useContext6 = useContext(NavigateStackContext);
|
|
3231
3311
|
_useContext6.navigate;
|
|
@@ -3334,7 +3414,7 @@ var Footer = (function () {
|
|
|
3334
3414
|
};
|
|
3335
3415
|
|
|
3336
3416
|
var approvalButton = function approvalButton() {
|
|
3337
|
-
if (!payment.route.approvalRequired || payment.route.directTransfer) {
|
|
3417
|
+
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
|
|
3338
3418
|
return null;
|
|
3339
3419
|
} else if (paymentState == 'initialized') {
|
|
3340
3420
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -3371,7 +3451,16 @@ var Footer = (function () {
|
|
|
3371
3451
|
displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
|
|
3372
3452
|
}
|
|
3373
3453
|
|
|
3374
|
-
if (
|
|
3454
|
+
if (paymentValueLoss) {
|
|
3455
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
3456
|
+
className: "PaddingBottomXS"
|
|
3457
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
3458
|
+
className: "Alert"
|
|
3459
|
+
}, /*#__PURE__*/React.createElement("strong", null, "Payment token would lose ", paymentValueLoss, "% of it's value!"))), /*#__PURE__*/React.createElement("button", {
|
|
3460
|
+
className: "ButtonPrimary disabled",
|
|
3461
|
+
onClick: function onClick() {}
|
|
3462
|
+
}, "Pay ", displayedAmount));
|
|
3463
|
+
} else if ((paymentState == 'initialized' || paymentState == 'approving') && payment.route) {
|
|
3375
3464
|
return /*#__PURE__*/React.createElement("button", {
|
|
3376
3465
|
className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
|
|
3377
3466
|
onClick: function onClick() {
|
|
@@ -3520,8 +3609,11 @@ var PaymentErrorDialog = (function () {
|
|
|
3520
3609
|
var _useContext2 = useContext(PaymentContext),
|
|
3521
3610
|
transaction = _useContext2.transaction;
|
|
3522
3611
|
|
|
3612
|
+
var _useContext3 = useContext(ConfigurationContext),
|
|
3613
|
+
recover = _useContext3.recover;
|
|
3614
|
+
|
|
3523
3615
|
return /*#__PURE__*/React.createElement(Dialog$1, {
|
|
3524
|
-
stacked: true,
|
|
3616
|
+
stacked: recover ? false : true,
|
|
3525
3617
|
header: /*#__PURE__*/React.createElement("div", {
|
|
3526
3618
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
3527
3619
|
}),
|
|
@@ -3534,7 +3626,7 @@ var PaymentErrorDialog = (function () {
|
|
|
3534
3626
|
className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
|
|
3535
3627
|
}, "Payment Failed"), /*#__PURE__*/React.createElement("div", {
|
|
3536
3628
|
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
3537
|
-
}, /*#__PURE__*/React.createElement("strong", {
|
|
3629
|
+
}, recover == undefined && /*#__PURE__*/React.createElement("strong", {
|
|
3538
3630
|
className: "FontSizeM"
|
|
3539
3631
|
}, "Unfortunately executing your payment failed. You can go back and try again."), transaction && /*#__PURE__*/React.createElement("div", {
|
|
3540
3632
|
className: "PaddingTopS"
|
|
@@ -3547,7 +3639,7 @@ var PaymentErrorDialog = (function () {
|
|
|
3547
3639
|
}, "View on explorer")))),
|
|
3548
3640
|
footer: /*#__PURE__*/React.createElement("div", {
|
|
3549
3641
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
3550
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
3642
|
+
}, recover == undefined && /*#__PURE__*/React.createElement("button", {
|
|
3551
3643
|
className: "ButtonPrimary",
|
|
3552
3644
|
onClick: function onClick() {
|
|
3553
3645
|
return navigate('back');
|
|
@@ -3885,9 +3977,12 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
3885
3977
|
var _useContext = useContext(ErrorContext);
|
|
3886
3978
|
_useContext.errorCallback;
|
|
3887
3979
|
|
|
3980
|
+
var _useContext2 = useContext(ConfigurationContext),
|
|
3981
|
+
recover = _useContext2.recover;
|
|
3982
|
+
|
|
3888
3983
|
useEffect(function () {
|
|
3889
3984
|
if (polling) {
|
|
3890
|
-
var
|
|
3985
|
+
var poll = function poll() {
|
|
3891
3986
|
fetch("https://api.depay.fi/v2/transactions/".concat(givenTransaction.blockchain, "/").concat(givenTransaction.from.toLowerCase(), "/").concat(givenTransaction.nonce)).then(function (response) {
|
|
3892
3987
|
if (response.status == 200) {
|
|
3893
3988
|
response.json().then(function (data) {
|
|
@@ -3901,7 +3996,10 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
3901
3996
|
});
|
|
3902
3997
|
}
|
|
3903
3998
|
});
|
|
3904
|
-
}
|
|
3999
|
+
};
|
|
4000
|
+
|
|
4001
|
+
var pollingInterval = setInterval(poll, 5000);
|
|
4002
|
+
poll();
|
|
3905
4003
|
return function () {
|
|
3906
4004
|
clearInterval(pollingInterval);
|
|
3907
4005
|
};
|
|
@@ -3981,11 +4079,25 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
3981
4079
|
|
|
3982
4080
|
var initializeTracking = function initializeTracking(transaction, afterBlock) {
|
|
3983
4081
|
setGivenTransaction(transaction);
|
|
3984
|
-
|
|
4082
|
+
|
|
4083
|
+
if (recover == undefined) {
|
|
4084
|
+
createTracking(transaction, afterBlock, 1);
|
|
4085
|
+
}
|
|
4086
|
+
|
|
3985
4087
|
openSocket(transaction);
|
|
3986
4088
|
setPolling(true);
|
|
3987
4089
|
};
|
|
3988
4090
|
|
|
4091
|
+
useEffect(function () {
|
|
4092
|
+
if (recover) {
|
|
4093
|
+
initializeTracking({
|
|
4094
|
+
blockchain: recover.blockchain,
|
|
4095
|
+
id: recover.transaction,
|
|
4096
|
+
from: recover.sender,
|
|
4097
|
+
nonce: recover.nonce
|
|
4098
|
+
}, recover.afterBlock);
|
|
4099
|
+
}
|
|
4100
|
+
}, [recover]);
|
|
3989
4101
|
return /*#__PURE__*/React.createElement(TransactionTrackingContext.Provider, {
|
|
3990
4102
|
value: {
|
|
3991
4103
|
initializeTracking: initializeTracking,
|
|
@@ -3995,8 +4107,11 @@ var TransactionTrackingProvider = (function (props) {
|
|
|
3995
4107
|
});
|
|
3996
4108
|
|
|
3997
4109
|
var WalletProvider = (function (props) {
|
|
3998
|
-
var _useContext = useContext(
|
|
3999
|
-
_useContext.
|
|
4110
|
+
var _useContext = useContext(ConfigurationContext),
|
|
4111
|
+
recover = _useContext.recover;
|
|
4112
|
+
|
|
4113
|
+
var _useContext2 = useContext(ErrorContext);
|
|
4114
|
+
_useContext2.setError;
|
|
4000
4115
|
|
|
4001
4116
|
var _useState = useState(),
|
|
4002
4117
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -4025,7 +4140,7 @@ var WalletProvider = (function (props) {
|
|
|
4025
4140
|
}
|
|
4026
4141
|
};
|
|
4027
4142
|
|
|
4028
|
-
if (walletState == 'connected') {
|
|
4143
|
+
if (walletState == 'connected' || recover != undefined) {
|
|
4029
4144
|
return /*#__PURE__*/React.createElement(WalletContext.Provider, {
|
|
4030
4145
|
value: {
|
|
4031
4146
|
account: account,
|
|
@@ -4413,7 +4528,8 @@ var PaymentOverviewSkeleton = (function (props) {
|
|
|
4413
4528
|
|
|
4414
4529
|
var PaymentOverviewDialog = (function (props) {
|
|
4415
4530
|
var _useContext = useContext(ConfigurationContext),
|
|
4416
|
-
currencyCode = _useContext.currencyCode
|
|
4531
|
+
currencyCode = _useContext.currencyCode,
|
|
4532
|
+
recover = _useContext.recover;
|
|
4417
4533
|
|
|
4418
4534
|
var _useContext2 = useContext(PaymentContext),
|
|
4419
4535
|
payment = _useContext2.payment,
|
|
@@ -4429,7 +4545,7 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
4429
4545
|
var _useContext5 = useContext(NavigateStackContext),
|
|
4430
4546
|
navigate = _useContext5.navigate;
|
|
4431
4547
|
|
|
4432
|
-
if (payment == undefined || paymentValue == undefined) {
|
|
4548
|
+
if (payment == undefined || recover == undefined && paymentValue == undefined) {
|
|
4433
4549
|
return /*#__PURE__*/React.createElement(PaymentOverviewSkeleton, null);
|
|
4434
4550
|
}
|
|
4435
4551
|
|
|
@@ -4480,7 +4596,7 @@ var PaymentOverviewDialog = (function (props) {
|
|
|
4480
4596
|
className: "CardImage",
|
|
4481
4597
|
title: payment.name
|
|
4482
4598
|
}, /*#__PURE__*/React.createElement(TokenImage, {
|
|
4483
|
-
blockchain: payment.
|
|
4599
|
+
blockchain: payment.blockchain,
|
|
4484
4600
|
address: payment.token
|
|
4485
4601
|
})), /*#__PURE__*/React.createElement("div", {
|
|
4486
4602
|
className: "CardBody"
|
|
@@ -4532,12 +4648,21 @@ var PaymentStack = (function (props) {
|
|
|
4532
4648
|
|
|
4533
4649
|
var preflight$1 = /*#__PURE__*/function () {
|
|
4534
4650
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref) {
|
|
4535
|
-
var accept;
|
|
4651
|
+
var accept, recover;
|
|
4536
4652
|
return regenerator.wrap(function _callee$(_context) {
|
|
4537
4653
|
while (1) {
|
|
4538
4654
|
switch (_context.prev = _context.next) {
|
|
4539
4655
|
case 0:
|
|
4540
|
-
accept = _ref.accept;
|
|
4656
|
+
accept = _ref.accept, recover = _ref.recover;
|
|
4657
|
+
|
|
4658
|
+
if (!recover) {
|
|
4659
|
+
_context.next = 3;
|
|
4660
|
+
break;
|
|
4661
|
+
}
|
|
4662
|
+
|
|
4663
|
+
return _context.abrupt("return");
|
|
4664
|
+
|
|
4665
|
+
case 3:
|
|
4541
4666
|
accept.forEach(function (configuration) {
|
|
4542
4667
|
if (typeof configuration.blockchain === 'undefined') {
|
|
4543
4668
|
throw 'You need to set the blockchain your want to receive the payment on!';
|
|
@@ -4547,16 +4672,20 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
4547
4672
|
throw 'You need to set a supported blockchain!';
|
|
4548
4673
|
}
|
|
4549
4674
|
|
|
4550
|
-
if (typeof configuration.token === 'undefined') {
|
|
4675
|
+
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
4551
4676
|
throw 'You need to set the token you want to receive as payment!';
|
|
4552
4677
|
}
|
|
4553
4678
|
|
|
4679
|
+
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
4680
|
+
throw 'You need to set the fromToken, fromAmount and toToken!';
|
|
4681
|
+
}
|
|
4682
|
+
|
|
4554
4683
|
if (typeof configuration.receiver === 'undefined') {
|
|
4555
4684
|
throw 'You need to set the receiver address that you want to receive the payment!';
|
|
4556
4685
|
}
|
|
4557
4686
|
});
|
|
4558
4687
|
|
|
4559
|
-
case
|
|
4688
|
+
case 4:
|
|
4560
4689
|
case "end":
|
|
4561
4690
|
return _context.stop();
|
|
4562
4691
|
}
|
|
@@ -4571,16 +4700,17 @@ var preflight$1 = /*#__PURE__*/function () {
|
|
|
4571
4700
|
|
|
4572
4701
|
var Payment = /*#__PURE__*/function () {
|
|
4573
4702
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
4574
|
-
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, document, unmount;
|
|
4703
|
+
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, document, unmount;
|
|
4575
4704
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
4576
4705
|
while (1) {
|
|
4577
4706
|
switch (_context2.prev = _context2.next) {
|
|
4578
4707
|
case 0:
|
|
4579
|
-
accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, document = _ref3.document;
|
|
4708
|
+
accept = _ref3.accept, amount = _ref3.amount, event = _ref3.event, sent = _ref3.sent, confirmed = _ref3.confirmed, failed = _ref3.failed, error = _ref3.error, critical = _ref3.critical, style = _ref3.style, whitelist = _ref3.whitelist, blacklist = _ref3.blacklist, providers = _ref3.providers, currency = _ref3.currency, connected = _ref3.connected, closed = _ref3.closed, track = _ref3.track, fee = _ref3.fee, recover = _ref3.recover, document = _ref3.document;
|
|
4580
4709
|
_context2.prev = 1;
|
|
4581
4710
|
_context2.next = 4;
|
|
4582
4711
|
return preflight$1({
|
|
4583
|
-
accept: accept
|
|
4712
|
+
accept: accept,
|
|
4713
|
+
recover: recover
|
|
4584
4714
|
});
|
|
4585
4715
|
|
|
4586
4716
|
case 4:
|
|
@@ -4607,7 +4737,8 @@ var Payment = /*#__PURE__*/function () {
|
|
|
4607
4737
|
blacklist: blacklist,
|
|
4608
4738
|
providers: providers,
|
|
4609
4739
|
track: track,
|
|
4610
|
-
fee: fee
|
|
4740
|
+
fee: fee,
|
|
4741
|
+
recover: recover
|
|
4611
4742
|
}
|
|
4612
4743
|
}, /*#__PURE__*/React.createElement(UpdatableProvider, null, /*#__PURE__*/React.createElement(ClosableProvider, {
|
|
4613
4744
|
unmount: unmount
|