@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/umd/index.bundle.js
CHANGED
|
@@ -49490,7 +49490,7 @@
|
|
|
49490
49490
|
});
|
|
49491
49491
|
|
|
49492
49492
|
var DialogStyle = (function (style) {
|
|
49493
|
-
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
|
|
49493
|
+
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 ";
|
|
49494
49494
|
});
|
|
49495
49495
|
|
|
49496
49496
|
var FontStyle = (function (style) {
|
|
@@ -61724,20 +61724,22 @@
|
|
|
61724
61724
|
var ChangableAmountProvider = (function (props) {
|
|
61725
61725
|
var configurationsMissAmounts = function configurationsMissAmounts(configurations) {
|
|
61726
61726
|
return !configurations.every(function (configuration) {
|
|
61727
|
-
return typeof configuration.amount != 'undefined';
|
|
61727
|
+
return typeof configuration.amount != 'undefined' || typeof configuration.fromAmount != 'undefined';
|
|
61728
61728
|
});
|
|
61729
61729
|
};
|
|
61730
61730
|
|
|
61731
|
-
var
|
|
61731
|
+
var _useContext = react.useContext(ConfigurationContext),
|
|
61732
|
+
amountConfiguration = _useContext.amount;
|
|
61733
|
+
_useContext.toAmount;
|
|
61734
|
+
var recover = _useContext.recover;
|
|
61735
|
+
|
|
61736
|
+
var _useState = react.useState(recover == undefined ? configurationsMissAmounts(props.accept) : false),
|
|
61732
61737
|
_useState2 = _slicedToArray(_useState, 2),
|
|
61733
61738
|
amountsMissing = _useState2[0],
|
|
61734
61739
|
setAmountsMissing = _useState2[1];
|
|
61735
61740
|
|
|
61736
|
-
var
|
|
61737
|
-
account =
|
|
61738
|
-
|
|
61739
|
-
var _useContext2 = react.useContext(ConfigurationContext),
|
|
61740
|
-
amountConfiguration = _useContext2.amount;
|
|
61741
|
+
var _useContext2 = react.useContext(WalletContext),
|
|
61742
|
+
account = _useContext2.account;
|
|
61741
61743
|
|
|
61742
61744
|
var _useContext3 = react.useContext(ConversionRateContext),
|
|
61743
61745
|
conversionRate = _useContext3.conversionRate;
|
|
@@ -61766,8 +61768,12 @@
|
|
|
61766
61768
|
setMaxAmount = _useState10[1];
|
|
61767
61769
|
|
|
61768
61770
|
react.useEffect(function () {
|
|
61771
|
+
if (recover) {
|
|
61772
|
+
return;
|
|
61773
|
+
}
|
|
61774
|
+
|
|
61769
61775
|
setAmountsMissing(configurationsMissAmounts(props.accept));
|
|
61770
|
-
}, [props.accept]);
|
|
61776
|
+
}, [props.accept, recover]);
|
|
61771
61777
|
|
|
61772
61778
|
var getAmounts = function getAmounts() {
|
|
61773
61779
|
return new Promise(function (resolve, reject) {
|
|
@@ -61803,6 +61809,10 @@
|
|
|
61803
61809
|
};
|
|
61804
61810
|
|
|
61805
61811
|
react.useEffect(function () {
|
|
61812
|
+
if (recover) {
|
|
61813
|
+
return;
|
|
61814
|
+
}
|
|
61815
|
+
|
|
61806
61816
|
if (amountsMissing && account && conversionRate) {
|
|
61807
61817
|
getAmounts().then(function (amounts) {
|
|
61808
61818
|
setAcceptWithAmount(props.accept.map(function (configuration, index) {
|
|
@@ -61821,7 +61831,7 @@
|
|
|
61821
61831
|
}));
|
|
61822
61832
|
})["catch"](setError);
|
|
61823
61833
|
}
|
|
61824
|
-
}, [amountsMissing, account, conversionRate, amount]);
|
|
61834
|
+
}, [amountsMissing, account, conversionRate, amount, recover]);
|
|
61825
61835
|
react.useEffect(function () {
|
|
61826
61836
|
if (amountsMissing && maxRoute) {
|
|
61827
61837
|
maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
|
|
@@ -62440,10 +62450,12 @@
|
|
|
62440
62450
|
var _useContext2 = react.useContext(ConfigurationContext),
|
|
62441
62451
|
_sent = _useContext2.sent,
|
|
62442
62452
|
confirmed = _useContext2.confirmed,
|
|
62443
|
-
failed = _useContext2.failed
|
|
62453
|
+
failed = _useContext2.failed,
|
|
62454
|
+
recover = _useContext2.recover;
|
|
62444
62455
|
|
|
62445
62456
|
var _useContext3 = react.useContext(PaymentRoutingContext),
|
|
62446
|
-
selectedRoute = _useContext3.selectedRoute
|
|
62457
|
+
selectedRoute = _useContext3.selectedRoute,
|
|
62458
|
+
getPaymentRoutes = _useContext3.getPaymentRoutes;
|
|
62447
62459
|
|
|
62448
62460
|
var _useContext4 = react.useContext(ClosableContext),
|
|
62449
62461
|
open = _useContext4.open,
|
|
@@ -62509,8 +62521,10 @@
|
|
|
62509
62521
|
}
|
|
62510
62522
|
|
|
62511
62523
|
setPaymentState('initialized');
|
|
62524
|
+
setPayment(null);
|
|
62512
62525
|
setClosable(true);
|
|
62513
62526
|
setUpdatable(true);
|
|
62527
|
+
getPaymentRoutes({});
|
|
62514
62528
|
navigate('PaymentError');
|
|
62515
62529
|
};
|
|
62516
62530
|
|
|
@@ -62596,6 +62610,39 @@
|
|
|
62596
62610
|
setPaymentState('confirmed');
|
|
62597
62611
|
}
|
|
62598
62612
|
}, [release]);
|
|
62613
|
+
react.useEffect(function () {
|
|
62614
|
+
if (recover) {
|
|
62615
|
+
setClosable(false);
|
|
62616
|
+
setUpdatable(false);
|
|
62617
|
+
setPaymentState('paying');
|
|
62618
|
+
setTransaction({
|
|
62619
|
+
blockchain: recover.blockchain,
|
|
62620
|
+
id: recover.transaction,
|
|
62621
|
+
url: Blockchain.findByName(recover.blockchain).explorerUrlFor({
|
|
62622
|
+
transaction: {
|
|
62623
|
+
id: recover.transaction
|
|
62624
|
+
}
|
|
62625
|
+
})
|
|
62626
|
+
});
|
|
62627
|
+
var paymentToken = new Token({
|
|
62628
|
+
blockchain: recover.blockchain,
|
|
62629
|
+
address: recover.token
|
|
62630
|
+
});
|
|
62631
|
+
Promise.all([paymentToken.name(), paymentToken.symbol()]).then(function (_ref2) {
|
|
62632
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
62633
|
+
name = _ref3[0],
|
|
62634
|
+
symbol = _ref3[1];
|
|
62635
|
+
|
|
62636
|
+
setPayment({
|
|
62637
|
+
blockchain: recover.blockchain,
|
|
62638
|
+
token: recover.token,
|
|
62639
|
+
name: name,
|
|
62640
|
+
symbol: symbol.toUpperCase(),
|
|
62641
|
+
amount: recover.amount
|
|
62642
|
+
});
|
|
62643
|
+
})["catch"](setError);
|
|
62644
|
+
}
|
|
62645
|
+
}, [recover]);
|
|
62599
62646
|
react.useEffect(function () {
|
|
62600
62647
|
if (foundTransaction && foundTransaction.id && foundTransaction.status) {
|
|
62601
62648
|
var newTransaction;
|
|
@@ -62620,16 +62667,16 @@
|
|
|
62620
62667
|
react.useEffect(function () {
|
|
62621
62668
|
if (selectedRoute) {
|
|
62622
62669
|
var fromToken = selectedRoute.fromToken;
|
|
62623
|
-
selectedRoute.
|
|
62624
|
-
|
|
62625
|
-
|
|
62626
|
-
|
|
62627
|
-
|
|
62628
|
-
amount = _ref3[2];
|
|
62670
|
+
Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref4) {
|
|
62671
|
+
var _ref5 = _slicedToArray(_ref4, 3),
|
|
62672
|
+
name = _ref5[0],
|
|
62673
|
+
symbol = _ref5[1],
|
|
62674
|
+
amount = _ref5[2];
|
|
62629
62675
|
|
|
62630
62676
|
setPayment({
|
|
62677
|
+
blockchain: selectedRoute.blockchain,
|
|
62631
62678
|
route: selectedRoute,
|
|
62632
|
-
token:
|
|
62679
|
+
token: fromToken.address,
|
|
62633
62680
|
name: name,
|
|
62634
62681
|
symbol: symbol.toUpperCase(),
|
|
62635
62682
|
amount: amount
|
|
@@ -67641,14 +67688,16 @@
|
|
|
67641
67688
|
|
|
67642
67689
|
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
67643
67690
|
class PaymentRoute {
|
|
67644
|
-
constructor({ blockchain, fromToken, toToken, toDecimals, toAmount,
|
|
67691
|
+
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, toToken, toDecimals, toAmount, toAddress, toContract }) {
|
|
67645
67692
|
this.blockchain = blockchain;
|
|
67693
|
+
this.fromAddress = fromAddress;
|
|
67646
67694
|
this.fromToken = fromToken;
|
|
67695
|
+
this.fromAmount = _optionalChain([fromAmount, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
|
|
67696
|
+
this.fromDecimals = _optionalChain([fromDecimals, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
67647
67697
|
this.fromBalance = 0;
|
|
67648
67698
|
this.toToken = toToken;
|
|
67699
|
+
this.toAmount = _optionalChain([toAmount, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
|
|
67649
67700
|
this.toDecimals = toDecimals;
|
|
67650
|
-
this.toAmount = _optionalChain([toAmount, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
|
|
67651
|
-
this.fromAddress = fromAddress;
|
|
67652
67701
|
this.toAddress = toAddress;
|
|
67653
67702
|
this.toContract = toContract;
|
|
67654
67703
|
this.exchangeRoutes = [];
|
|
@@ -67708,22 +67757,43 @@
|
|
|
67708
67757
|
return Promise.all(tokens.map(async (fromToken)=>{
|
|
67709
67758
|
let relevantConfigurations = accept.filter((configuration)=>(configuration.blockchain == fromToken.blockchain));
|
|
67710
67759
|
return Promise.all(relevantConfigurations.map(async (configuration)=>{
|
|
67711
|
-
|
|
67712
|
-
|
|
67713
|
-
|
|
67714
|
-
|
|
67715
|
-
|
|
67716
|
-
|
|
67717
|
-
|
|
67718
|
-
|
|
67719
|
-
|
|
67720
|
-
|
|
67721
|
-
|
|
67722
|
-
|
|
67723
|
-
|
|
67724
|
-
|
|
67760
|
+
if(configuration.token && configuration.amount) {
|
|
67761
|
+
let blockchain = configuration.blockchain;
|
|
67762
|
+
let toToken = new Token({ blockchain, address: configuration.token });
|
|
67763
|
+
let toDecimals = await toToken.decimals();
|
|
67764
|
+
let toAmount = (await toToken.BigNumber(configuration.amount)).toString();
|
|
67765
|
+
|
|
67766
|
+
return new PaymentRoute({
|
|
67767
|
+
blockchain,
|
|
67768
|
+
fromToken,
|
|
67769
|
+
toToken,
|
|
67770
|
+
toAmount,
|
|
67771
|
+
toDecimals,
|
|
67772
|
+
fromAddress: configuration.fromAddress,
|
|
67773
|
+
toAddress: configuration.toAddress,
|
|
67774
|
+
toContract: configuration.toContract
|
|
67775
|
+
})
|
|
67776
|
+
} else if(configuration.fromToken && configuration.fromAmount && fromToken.address.toLowerCase() == configuration.fromToken.toLowerCase()) {
|
|
67777
|
+
let blockchain = configuration.blockchain;
|
|
67778
|
+
let fromAmount = (await fromToken.BigNumber(configuration.fromAmount)).toString();
|
|
67779
|
+
let fromDecimals = await fromToken.decimals();
|
|
67780
|
+
let toToken = new Token({ blockchain, address: configuration.toToken });
|
|
67781
|
+
let toDecimals = await toToken.decimals();
|
|
67782
|
+
|
|
67783
|
+
return new PaymentRoute({
|
|
67784
|
+
blockchain,
|
|
67785
|
+
fromToken,
|
|
67786
|
+
fromAmount,
|
|
67787
|
+
fromDecimals,
|
|
67788
|
+
toToken,
|
|
67789
|
+
toDecimals,
|
|
67790
|
+
fromAddress: configuration.fromAddress,
|
|
67791
|
+
toAddress: configuration.toAddress,
|
|
67792
|
+
toContract: configuration.toContract
|
|
67793
|
+
})
|
|
67794
|
+
}
|
|
67725
67795
|
}))
|
|
67726
|
-
})).then((routes)=> routes.flat())
|
|
67796
|
+
})).then((routes)=> routes.flat().filter(el => el))
|
|
67727
67797
|
}
|
|
67728
67798
|
|
|
67729
67799
|
async function route({ accept, whitelist, blacklist, apiKey, event, fee }) {
|
|
@@ -67779,14 +67849,25 @@
|
|
|
67779
67849
|
return await Promise.all(
|
|
67780
67850
|
routes.map((route) => {
|
|
67781
67851
|
if(route.directTransfer) { return [] }
|
|
67782
|
-
|
|
67783
|
-
|
|
67784
|
-
|
|
67785
|
-
|
|
67786
|
-
|
|
67787
|
-
|
|
67788
|
-
|
|
67789
|
-
|
|
67852
|
+
if(route.toToken && route.toAmount) {
|
|
67853
|
+
return route$8({
|
|
67854
|
+
blockchain: route.blockchain,
|
|
67855
|
+
tokenIn: route.fromToken.address,
|
|
67856
|
+
tokenOut: route.toToken.address,
|
|
67857
|
+
amountOutMin: route.toAmount,
|
|
67858
|
+
fromAddress: route.fromAddress,
|
|
67859
|
+
toAddress: route.toAddress
|
|
67860
|
+
})
|
|
67861
|
+
} else if(route.fromToken && route.fromAmount) {
|
|
67862
|
+
return route$8({
|
|
67863
|
+
blockchain: route.blockchain,
|
|
67864
|
+
tokenIn: route.fromToken.address,
|
|
67865
|
+
tokenOut: route.toToken.address,
|
|
67866
|
+
amountIn: route.fromAmount,
|
|
67867
|
+
fromAddress: route.fromAddress,
|
|
67868
|
+
toAddress: route.toAddress
|
|
67869
|
+
})
|
|
67870
|
+
}
|
|
67790
67871
|
}),
|
|
67791
67872
|
).then((exchangeRoutes) => {
|
|
67792
67873
|
return routes.map((route, index) => {
|
|
@@ -67816,8 +67897,10 @@
|
|
|
67816
67897
|
return routes.filter((route) => {
|
|
67817
67898
|
if (route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase()) {
|
|
67818
67899
|
return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.toAmount))
|
|
67819
|
-
} else {
|
|
67900
|
+
} else if(route.fromAmount && route.toAmount) {
|
|
67820
67901
|
return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.exchangeRoutes[0].amountInMax))
|
|
67902
|
+
} else if(route.exchangeRoutes[0] && route.exchangeRoutes[0].amountIn) {
|
|
67903
|
+
return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.exchangeRoutes[0].amountIn))
|
|
67821
67904
|
}
|
|
67822
67905
|
})
|
|
67823
67906
|
};
|
|
@@ -67970,6 +68053,9 @@
|
|
|
67970
68053
|
var _useContext2 = react.useContext(UpdatableContext),
|
|
67971
68054
|
updatable = _useContext2.updatable;
|
|
67972
68055
|
|
|
68056
|
+
var _useContext3 = react.useContext(ConfigurationContext),
|
|
68057
|
+
recover = _useContext3.recover;
|
|
68058
|
+
|
|
67973
68059
|
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
67974
68060
|
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
67975
68061
|
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
@@ -68097,7 +68183,7 @@
|
|
|
68097
68183
|
};
|
|
68098
68184
|
}, [reloadCount, allRoutes, selectedRoute, updatable]);
|
|
68099
68185
|
react.useEffect(function () {
|
|
68100
|
-
if (account && props.accept) {
|
|
68186
|
+
if (account && props.accept && recover == undefined) {
|
|
68101
68187
|
setAllRoutes(undefined);
|
|
68102
68188
|
setSelectedRoute(undefined);
|
|
68103
68189
|
getPaymentRoutes({});
|
|
@@ -68110,6 +68196,7 @@
|
|
|
68110
68196
|
value: {
|
|
68111
68197
|
selectedRoute: selectedRoute,
|
|
68112
68198
|
setSelectedRoute: setSelectedRoute,
|
|
68199
|
+
getPaymentRoutes: getPaymentRoutes,
|
|
68113
68200
|
allRoutes: allRoutes,
|
|
68114
68201
|
setAllRoutes: setAllRoutes
|
|
68115
68202
|
}
|
|
@@ -68136,15 +68223,20 @@
|
|
|
68136
68223
|
paymentValue = _useState2[0],
|
|
68137
68224
|
setPaymentValue = _useState2[1];
|
|
68138
68225
|
|
|
68226
|
+
var _useState3 = react.useState(),
|
|
68227
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
68228
|
+
paymentValueLoss = _useState4[0],
|
|
68229
|
+
setPaymentValueLoss = _useState4[1];
|
|
68230
|
+
|
|
68139
68231
|
var _useContext5 = react.useContext(ConfigurationContext),
|
|
68140
68232
|
currency = _useContext5.currency;
|
|
68141
68233
|
|
|
68142
|
-
var
|
|
68143
|
-
|
|
68144
|
-
reloadCount =
|
|
68145
|
-
setReloadCount =
|
|
68234
|
+
var _useState5 = react.useState(0),
|
|
68235
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
68236
|
+
reloadCount = _useState6[0],
|
|
68237
|
+
setReloadCount = _useState6[1];
|
|
68146
68238
|
|
|
68147
|
-
var
|
|
68239
|
+
var updatePaymentValue = function updatePaymentValue(_ref) {
|
|
68148
68240
|
var updatable = _ref.updatable,
|
|
68149
68241
|
payment = _ref.payment;
|
|
68150
68242
|
|
|
@@ -68159,29 +68251,51 @@
|
|
|
68159
68251
|
amountIn: payment.route.toAmount,
|
|
68160
68252
|
fromAddress: account,
|
|
68161
68253
|
toAddress: account
|
|
68162
|
-
}),
|
|
68254
|
+
}), !payment.route.directTransfer ? route$8({
|
|
68255
|
+
blockchain: payment.route.blockchain,
|
|
68256
|
+
tokenIn: payment.route.toToken.address,
|
|
68257
|
+
tokenOut: payment.route.fromToken.address,
|
|
68258
|
+
amountIn: payment.route.toAmount,
|
|
68259
|
+
fromAddress: account,
|
|
68260
|
+
toAddress: account
|
|
68261
|
+
}) : Promise.resolve([]), new Token({
|
|
68163
68262
|
blockchain: payment.route.blockchain,
|
|
68164
68263
|
address: CONSTANTS$2[payment.route.blockchain].USD
|
|
68165
68264
|
}).decimals()]).then(function (_ref2) {
|
|
68166
|
-
var _ref3 = _slicedToArray(_ref2,
|
|
68167
|
-
|
|
68168
|
-
|
|
68265
|
+
var _ref3 = _slicedToArray(_ref2, 3),
|
|
68266
|
+
toTokenUSDExchangeRoutes = _ref3[0],
|
|
68267
|
+
reverseRoutes = _ref3[1],
|
|
68268
|
+
USDDecimals = _ref3[2];
|
|
68269
|
+
|
|
68270
|
+
var toTokenUSDRoute = toTokenUSDExchangeRoutes[0];
|
|
68271
|
+
var reverseRoute = reverseRoutes[0];
|
|
68272
|
+
|
|
68273
|
+
if (reverseRoute) {
|
|
68274
|
+
var reverseAmountOutBN = BigNumber$4.from(reverseRoute.amountOut);
|
|
68275
|
+
var paymentAmountInBN = BigNumber$4.from(payment.route.fromAmount);
|
|
68276
|
+
var divPercent = 100 - reverseAmountOutBN.mul(BigNumber$4.from('100')).div(paymentAmountInBN).abs().toString();
|
|
68277
|
+
|
|
68278
|
+
if (divPercent >= 5) {
|
|
68279
|
+
setPaymentValueLoss(divPercent);
|
|
68280
|
+
} else {
|
|
68281
|
+
setPaymentValueLoss(null);
|
|
68282
|
+
}
|
|
68283
|
+
}
|
|
68169
68284
|
|
|
68170
|
-
var
|
|
68171
|
-
var USDAmount;
|
|
68285
|
+
var toTokenUSDAmount;
|
|
68172
68286
|
|
|
68173
68287
|
if (payment.route.toToken.address.toLowerCase() == CONSTANTS$2[payment.route.blockchain].USD.toLowerCase()) {
|
|
68174
|
-
|
|
68175
|
-
} else if (
|
|
68288
|
+
toTokenUSDAmount = payment.route.toAmount.toString();
|
|
68289
|
+
} else if (toTokenUSDRoute == undefined) {
|
|
68176
68290
|
setPaymentValue('');
|
|
68177
68291
|
return;
|
|
68178
68292
|
} else {
|
|
68179
|
-
|
|
68293
|
+
toTokenUSDAmount = toTokenUSDRoute.amountOut.toString();
|
|
68180
68294
|
}
|
|
68181
68295
|
|
|
68182
|
-
var
|
|
68296
|
+
var toTokenUSDValue = formatUnits(toTokenUSDAmount, USDDecimals);
|
|
68183
68297
|
Currency.fromUSD({
|
|
68184
|
-
amount:
|
|
68298
|
+
amount: toTokenUSDValue,
|
|
68185
68299
|
code: currency,
|
|
68186
68300
|
apiKey: apiKey
|
|
68187
68301
|
}).then(setPaymentValue)["catch"](setError);
|
|
@@ -68190,7 +68304,7 @@
|
|
|
68190
68304
|
|
|
68191
68305
|
react.useEffect(function () {
|
|
68192
68306
|
if (account && payment) {
|
|
68193
|
-
|
|
68307
|
+
updatePaymentValue({
|
|
68194
68308
|
updatable: updatable,
|
|
68195
68309
|
payment: payment
|
|
68196
68310
|
});
|
|
@@ -68199,7 +68313,7 @@
|
|
|
68199
68313
|
react.useEffect(function () {
|
|
68200
68314
|
var timeout = setTimeout(function () {
|
|
68201
68315
|
setReloadCount(reloadCount + 1);
|
|
68202
|
-
|
|
68316
|
+
updatePaymentValue({
|
|
68203
68317
|
updatable: updatable
|
|
68204
68318
|
});
|
|
68205
68319
|
}, 15000);
|
|
@@ -68209,7 +68323,8 @@
|
|
|
68209
68323
|
}, [reloadCount, updatable]);
|
|
68210
68324
|
return /*#__PURE__*/react.createElement(PaymentValueContext.Provider, {
|
|
68211
68325
|
value: {
|
|
68212
|
-
paymentValue: paymentValue
|
|
68326
|
+
paymentValue: paymentValue,
|
|
68327
|
+
paymentValueLoss: paymentValueLoss
|
|
68213
68328
|
}
|
|
68214
68329
|
}, props.children);
|
|
68215
68330
|
});
|
|
@@ -70357,7 +70472,8 @@
|
|
|
70357
70472
|
approvalTransaction = _useContext4.approvalTransaction;
|
|
70358
70473
|
|
|
70359
70474
|
var _useContext5 = react.useContext(PaymentValueContext),
|
|
70360
|
-
paymentValue = _useContext5.paymentValue
|
|
70475
|
+
paymentValue = _useContext5.paymentValue,
|
|
70476
|
+
paymentValueLoss = _useContext5.paymentValueLoss;
|
|
70361
70477
|
|
|
70362
70478
|
var _useContext6 = react.useContext(NavigateStackContext);
|
|
70363
70479
|
_useContext6.navigate;
|
|
@@ -70466,7 +70582,7 @@
|
|
|
70466
70582
|
};
|
|
70467
70583
|
|
|
70468
70584
|
var approvalButton = function approvalButton() {
|
|
70469
|
-
if (!payment.route.approvalRequired || payment.route.directTransfer) {
|
|
70585
|
+
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
|
|
70470
70586
|
return null;
|
|
70471
70587
|
} else if (paymentState == 'initialized') {
|
|
70472
70588
|
return /*#__PURE__*/react.createElement("div", {
|
|
@@ -70503,7 +70619,16 @@
|
|
|
70503
70619
|
displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
|
|
70504
70620
|
}
|
|
70505
70621
|
|
|
70506
|
-
if (
|
|
70622
|
+
if (paymentValueLoss) {
|
|
70623
|
+
return /*#__PURE__*/react.createElement("div", null, /*#__PURE__*/react.createElement("div", {
|
|
70624
|
+
className: "PaddingBottomXS"
|
|
70625
|
+
}, /*#__PURE__*/react.createElement("div", {
|
|
70626
|
+
className: "Alert"
|
|
70627
|
+
}, /*#__PURE__*/react.createElement("strong", null, "Payment token would lose ", paymentValueLoss, "% of it's value!"))), /*#__PURE__*/react.createElement("button", {
|
|
70628
|
+
className: "ButtonPrimary disabled",
|
|
70629
|
+
onClick: function onClick() {}
|
|
70630
|
+
}, "Pay ", displayedAmount));
|
|
70631
|
+
} else if ((paymentState == 'initialized' || paymentState == 'approving') && payment.route) {
|
|
70507
70632
|
return /*#__PURE__*/react.createElement("button", {
|
|
70508
70633
|
className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
|
|
70509
70634
|
onClick: function onClick() {
|
|
@@ -70652,8 +70777,11 @@
|
|
|
70652
70777
|
var _useContext2 = react.useContext(PaymentContext),
|
|
70653
70778
|
transaction = _useContext2.transaction;
|
|
70654
70779
|
|
|
70780
|
+
var _useContext3 = react.useContext(ConfigurationContext),
|
|
70781
|
+
recover = _useContext3.recover;
|
|
70782
|
+
|
|
70655
70783
|
return /*#__PURE__*/react.createElement(Dialog, {
|
|
70656
|
-
stacked: true,
|
|
70784
|
+
stacked: recover ? false : true,
|
|
70657
70785
|
header: /*#__PURE__*/react.createElement("div", {
|
|
70658
70786
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
70659
70787
|
}),
|
|
@@ -70666,7 +70794,7 @@
|
|
|
70666
70794
|
className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
|
|
70667
70795
|
}, "Payment Failed"), /*#__PURE__*/react.createElement("div", {
|
|
70668
70796
|
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
70669
|
-
}, /*#__PURE__*/react.createElement("strong", {
|
|
70797
|
+
}, recover == undefined && /*#__PURE__*/react.createElement("strong", {
|
|
70670
70798
|
className: "FontSizeM"
|
|
70671
70799
|
}, "Unfortunately executing your payment failed. You can go back and try again."), transaction && /*#__PURE__*/react.createElement("div", {
|
|
70672
70800
|
className: "PaddingTopS"
|
|
@@ -70679,7 +70807,7 @@
|
|
|
70679
70807
|
}, "View on explorer")))),
|
|
70680
70808
|
footer: /*#__PURE__*/react.createElement("div", {
|
|
70681
70809
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
70682
|
-
}, /*#__PURE__*/react.createElement("button", {
|
|
70810
|
+
}, recover == undefined && /*#__PURE__*/react.createElement("button", {
|
|
70683
70811
|
className: "ButtonPrimary",
|
|
70684
70812
|
onClick: function onClick() {
|
|
70685
70813
|
return navigate('back');
|
|
@@ -71017,9 +71145,12 @@
|
|
|
71017
71145
|
var _useContext = react.useContext(ErrorContext);
|
|
71018
71146
|
_useContext.errorCallback;
|
|
71019
71147
|
|
|
71148
|
+
var _useContext2 = react.useContext(ConfigurationContext),
|
|
71149
|
+
recover = _useContext2.recover;
|
|
71150
|
+
|
|
71020
71151
|
react.useEffect(function () {
|
|
71021
71152
|
if (polling) {
|
|
71022
|
-
var
|
|
71153
|
+
var poll = function poll() {
|
|
71023
71154
|
fetch("https://api.depay.fi/v2/transactions/".concat(givenTransaction.blockchain, "/").concat(givenTransaction.from.toLowerCase(), "/").concat(givenTransaction.nonce)).then(function (response) {
|
|
71024
71155
|
if (response.status == 200) {
|
|
71025
71156
|
response.json().then(function (data) {
|
|
@@ -71033,7 +71164,10 @@
|
|
|
71033
71164
|
});
|
|
71034
71165
|
}
|
|
71035
71166
|
});
|
|
71036
|
-
}
|
|
71167
|
+
};
|
|
71168
|
+
|
|
71169
|
+
var pollingInterval = setInterval(poll, 5000);
|
|
71170
|
+
poll();
|
|
71037
71171
|
return function () {
|
|
71038
71172
|
clearInterval(pollingInterval);
|
|
71039
71173
|
};
|
|
@@ -71113,11 +71247,25 @@
|
|
|
71113
71247
|
|
|
71114
71248
|
var initializeTracking = function initializeTracking(transaction, afterBlock) {
|
|
71115
71249
|
setGivenTransaction(transaction);
|
|
71116
|
-
|
|
71250
|
+
|
|
71251
|
+
if (recover == undefined) {
|
|
71252
|
+
createTracking(transaction, afterBlock, 1);
|
|
71253
|
+
}
|
|
71254
|
+
|
|
71117
71255
|
openSocket(transaction);
|
|
71118
71256
|
setPolling(true);
|
|
71119
71257
|
};
|
|
71120
71258
|
|
|
71259
|
+
react.useEffect(function () {
|
|
71260
|
+
if (recover) {
|
|
71261
|
+
initializeTracking({
|
|
71262
|
+
blockchain: recover.blockchain,
|
|
71263
|
+
id: recover.transaction,
|
|
71264
|
+
from: recover.sender,
|
|
71265
|
+
nonce: recover.nonce
|
|
71266
|
+
}, recover.afterBlock);
|
|
71267
|
+
}
|
|
71268
|
+
}, [recover]);
|
|
71121
71269
|
return /*#__PURE__*/react.createElement(TransactionTrackingContext.Provider, {
|
|
71122
71270
|
value: {
|
|
71123
71271
|
initializeTracking: initializeTracking,
|
|
@@ -71127,8 +71275,11 @@
|
|
|
71127
71275
|
});
|
|
71128
71276
|
|
|
71129
71277
|
var WalletProvider = (function (props) {
|
|
71130
|
-
var _useContext = react.useContext(
|
|
71131
|
-
_useContext.
|
|
71278
|
+
var _useContext = react.useContext(ConfigurationContext),
|
|
71279
|
+
recover = _useContext.recover;
|
|
71280
|
+
|
|
71281
|
+
var _useContext2 = react.useContext(ErrorContext);
|
|
71282
|
+
_useContext2.setError;
|
|
71132
71283
|
|
|
71133
71284
|
var _useState = react.useState(),
|
|
71134
71285
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -71157,7 +71308,7 @@
|
|
|
71157
71308
|
}
|
|
71158
71309
|
};
|
|
71159
71310
|
|
|
71160
|
-
if (walletState == 'connected') {
|
|
71311
|
+
if (walletState == 'connected' || recover != undefined) {
|
|
71161
71312
|
return /*#__PURE__*/react.createElement(WalletContext.Provider, {
|
|
71162
71313
|
value: {
|
|
71163
71314
|
account: account,
|
|
@@ -71545,7 +71696,8 @@
|
|
|
71545
71696
|
|
|
71546
71697
|
var PaymentOverviewDialog = (function (props) {
|
|
71547
71698
|
var _useContext = react.useContext(ConfigurationContext),
|
|
71548
|
-
currencyCode = _useContext.currencyCode
|
|
71699
|
+
currencyCode = _useContext.currencyCode,
|
|
71700
|
+
recover = _useContext.recover;
|
|
71549
71701
|
|
|
71550
71702
|
var _useContext2 = react.useContext(PaymentContext),
|
|
71551
71703
|
payment = _useContext2.payment,
|
|
@@ -71561,7 +71713,7 @@
|
|
|
71561
71713
|
var _useContext5 = react.useContext(NavigateStackContext),
|
|
71562
71714
|
navigate = _useContext5.navigate;
|
|
71563
71715
|
|
|
71564
|
-
if (payment == undefined || paymentValue == undefined) {
|
|
71716
|
+
if (payment == undefined || recover == undefined && paymentValue == undefined) {
|
|
71565
71717
|
return /*#__PURE__*/react.createElement(PaymentOverviewSkeleton, null);
|
|
71566
71718
|
}
|
|
71567
71719
|
|
|
@@ -71612,7 +71764,7 @@
|
|
|
71612
71764
|
className: "CardImage",
|
|
71613
71765
|
title: payment.name
|
|
71614
71766
|
}, /*#__PURE__*/react.createElement(TokenImage, {
|
|
71615
|
-
blockchain: payment.
|
|
71767
|
+
blockchain: payment.blockchain,
|
|
71616
71768
|
address: payment.token
|
|
71617
71769
|
})), /*#__PURE__*/react.createElement("div", {
|
|
71618
71770
|
className: "CardBody"
|
|
@@ -71664,12 +71816,21 @@
|
|
|
71664
71816
|
|
|
71665
71817
|
var preflight$1 = /*#__PURE__*/function () {
|
|
71666
71818
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref) {
|
|
71667
|
-
var accept;
|
|
71819
|
+
var accept, recover;
|
|
71668
71820
|
return regenerator.wrap(function _callee$(_context) {
|
|
71669
71821
|
while (1) {
|
|
71670
71822
|
switch (_context.prev = _context.next) {
|
|
71671
71823
|
case 0:
|
|
71672
|
-
accept = _ref.accept;
|
|
71824
|
+
accept = _ref.accept, recover = _ref.recover;
|
|
71825
|
+
|
|
71826
|
+
if (!recover) {
|
|
71827
|
+
_context.next = 3;
|
|
71828
|
+
break;
|
|
71829
|
+
}
|
|
71830
|
+
|
|
71831
|
+
return _context.abrupt("return");
|
|
71832
|
+
|
|
71833
|
+
case 3:
|
|
71673
71834
|
accept.forEach(function (configuration) {
|
|
71674
71835
|
if (typeof configuration.blockchain === 'undefined') {
|
|
71675
71836
|
throw 'You need to set the blockchain your want to receive the payment on!';
|
|
@@ -71679,16 +71840,20 @@
|
|
|
71679
71840
|
throw 'You need to set a supported blockchain!';
|
|
71680
71841
|
}
|
|
71681
71842
|
|
|
71682
|
-
if (typeof configuration.token === 'undefined') {
|
|
71843
|
+
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
71683
71844
|
throw 'You need to set the token you want to receive as payment!';
|
|
71684
71845
|
}
|
|
71685
71846
|
|
|
71847
|
+
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
71848
|
+
throw 'You need to set the fromToken, fromAmount and toToken!';
|
|
71849
|
+
}
|
|
71850
|
+
|
|
71686
71851
|
if (typeof configuration.receiver === 'undefined') {
|
|
71687
71852
|
throw 'You need to set the receiver address that you want to receive the payment!';
|
|
71688
71853
|
}
|
|
71689
71854
|
});
|
|
71690
71855
|
|
|
71691
|
-
case
|
|
71856
|
+
case 4:
|
|
71692
71857
|
case "end":
|
|
71693
71858
|
return _context.stop();
|
|
71694
71859
|
}
|
|
@@ -71703,16 +71868,17 @@
|
|
|
71703
71868
|
|
|
71704
71869
|
var Payment = /*#__PURE__*/function () {
|
|
71705
71870
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
71706
|
-
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, document, unmount;
|
|
71871
|
+
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, document, unmount;
|
|
71707
71872
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
71708
71873
|
while (1) {
|
|
71709
71874
|
switch (_context2.prev = _context2.next) {
|
|
71710
71875
|
case 0:
|
|
71711
|
-
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;
|
|
71876
|
+
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;
|
|
71712
71877
|
_context2.prev = 1;
|
|
71713
71878
|
_context2.next = 4;
|
|
71714
71879
|
return preflight$1({
|
|
71715
|
-
accept: accept
|
|
71880
|
+
accept: accept,
|
|
71881
|
+
recover: recover
|
|
71716
71882
|
});
|
|
71717
71883
|
|
|
71718
71884
|
case 4:
|
|
@@ -71739,7 +71905,8 @@
|
|
|
71739
71905
|
blacklist: blacklist,
|
|
71740
71906
|
providers: providers,
|
|
71741
71907
|
track: track,
|
|
71742
|
-
fee: fee
|
|
71908
|
+
fee: fee,
|
|
71909
|
+
recover: recover
|
|
71743
71910
|
}
|
|
71744
71911
|
}, /*#__PURE__*/react.createElement(UpdatableProvider, null, /*#__PURE__*/react.createElement(ClosableProvider, {
|
|
71745
71912
|
unmount: unmount
|