@depay/widgets 6.12.0 → 6.14.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 +207 -76
- package/dist/esm/index.js +144 -49
- package/dist/umd/index.bundle.js +207 -76
- package/dist/umd/index.js +144 -49
- package/package.json +3 -3
package/dist/umd/index.bundle.js
CHANGED
|
@@ -1605,6 +1605,8 @@
|
|
|
1605
1605
|
constructor(props) {
|
|
1606
1606
|
super(props);
|
|
1607
1607
|
|
|
1608
|
+
this.handler = this.onKeyDown.bind(this);
|
|
1609
|
+
|
|
1608
1610
|
this.state = {
|
|
1609
1611
|
open: true,
|
|
1610
1612
|
};
|
|
@@ -1638,22 +1640,22 @@
|
|
|
1638
1640
|
this.setState({ open: true });
|
|
1639
1641
|
}, 10);
|
|
1640
1642
|
});
|
|
1641
|
-
this.props.document.addEventListener('keydown', this.
|
|
1643
|
+
this.props.document.addEventListener('keydown', this.handler, true);
|
|
1642
1644
|
}
|
|
1643
1645
|
|
|
1644
1646
|
componentWillUnmount() {
|
|
1645
|
-
this.props.document.
|
|
1647
|
+
this.props.document.removeEventListener('keydown', this.handler, true);
|
|
1646
1648
|
}
|
|
1647
1649
|
|
|
1648
1650
|
render() {
|
|
1649
1651
|
const classNames = ['ReactDialog', this.state.open ? 'ReactDialogOpen' : ''];
|
|
1650
1652
|
const style = ReactDialogStyle({ background: this.props.background });
|
|
1651
1653
|
return (
|
|
1652
|
-
react.createElement('div', { className: classNames.join(' '), __self: this, __source: {fileName: _jsxFileName$2, lineNumber:
|
|
1653
|
-
, react.createElement('style', {__self: this, __source: {fileName: _jsxFileName$2, lineNumber:
|
|
1654
|
-
, react.createElement('div', { className: "ReactDialogRow", __self: this, __source: {fileName: _jsxFileName$2, lineNumber:
|
|
1655
|
-
, react.createElement('div', { className: "ReactDialogCell", __self: this, __source: {fileName: _jsxFileName$2, lineNumber:
|
|
1656
|
-
, react.createElement('div', { className: "ReactDialogBackground", onClick: this.onClickBackground.bind(this), __self: this, __source: {fileName: _jsxFileName$2, lineNumber:
|
|
1654
|
+
react.createElement('div', { className: classNames.join(' '), __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 56}}
|
|
1655
|
+
, react.createElement('style', {__self: this, __source: {fileName: _jsxFileName$2, lineNumber: 57}}, style)
|
|
1656
|
+
, react.createElement('div', { className: "ReactDialogRow", __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 58}}
|
|
1657
|
+
, react.createElement('div', { className: "ReactDialogCell", __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 59}}
|
|
1658
|
+
, react.createElement('div', { className: "ReactDialogBackground", onClick: this.onClickBackground.bind(this), __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 60}} )
|
|
1657
1659
|
, this.props.children
|
|
1658
1660
|
)
|
|
1659
1661
|
)
|
|
@@ -49488,7 +49490,7 @@
|
|
|
49488
49490
|
});
|
|
49489
49491
|
|
|
49490
49492
|
var DialogStyle = (function (style) {
|
|
49491
|
-
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 ";
|
|
49492
49494
|
});
|
|
49493
49495
|
|
|
49494
49496
|
var FontStyle = (function (style) {
|
|
@@ -61722,20 +61724,22 @@
|
|
|
61722
61724
|
var ChangableAmountProvider = (function (props) {
|
|
61723
61725
|
var configurationsMissAmounts = function configurationsMissAmounts(configurations) {
|
|
61724
61726
|
return !configurations.every(function (configuration) {
|
|
61725
|
-
return typeof configuration.amount != 'undefined';
|
|
61727
|
+
return typeof configuration.amount != 'undefined' || typeof configuration.fromAmount != 'undefined';
|
|
61726
61728
|
});
|
|
61727
61729
|
};
|
|
61728
61730
|
|
|
61729
|
-
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),
|
|
61730
61737
|
_useState2 = _slicedToArray(_useState, 2),
|
|
61731
61738
|
amountsMissing = _useState2[0],
|
|
61732
61739
|
setAmountsMissing = _useState2[1];
|
|
61733
61740
|
|
|
61734
|
-
var
|
|
61735
|
-
account =
|
|
61736
|
-
|
|
61737
|
-
var _useContext2 = react.useContext(ConfigurationContext),
|
|
61738
|
-
amountConfiguration = _useContext2.amount;
|
|
61741
|
+
var _useContext2 = react.useContext(WalletContext),
|
|
61742
|
+
account = _useContext2.account;
|
|
61739
61743
|
|
|
61740
61744
|
var _useContext3 = react.useContext(ConversionRateContext),
|
|
61741
61745
|
conversionRate = _useContext3.conversionRate;
|
|
@@ -61764,8 +61768,12 @@
|
|
|
61764
61768
|
setMaxAmount = _useState10[1];
|
|
61765
61769
|
|
|
61766
61770
|
react.useEffect(function () {
|
|
61771
|
+
if (recover) {
|
|
61772
|
+
return;
|
|
61773
|
+
}
|
|
61774
|
+
|
|
61767
61775
|
setAmountsMissing(configurationsMissAmounts(props.accept));
|
|
61768
|
-
}, [props.accept]);
|
|
61776
|
+
}, [props.accept, recover]);
|
|
61769
61777
|
|
|
61770
61778
|
var getAmounts = function getAmounts() {
|
|
61771
61779
|
return new Promise(function (resolve, reject) {
|
|
@@ -61801,6 +61809,10 @@
|
|
|
61801
61809
|
};
|
|
61802
61810
|
|
|
61803
61811
|
react.useEffect(function () {
|
|
61812
|
+
if (recover) {
|
|
61813
|
+
return;
|
|
61814
|
+
}
|
|
61815
|
+
|
|
61804
61816
|
if (amountsMissing && account && conversionRate) {
|
|
61805
61817
|
getAmounts().then(function (amounts) {
|
|
61806
61818
|
setAcceptWithAmount(props.accept.map(function (configuration, index) {
|
|
@@ -61819,7 +61831,7 @@
|
|
|
61819
61831
|
}));
|
|
61820
61832
|
})["catch"](setError);
|
|
61821
61833
|
}
|
|
61822
|
-
}, [amountsMissing, account, conversionRate, amount]);
|
|
61834
|
+
}, [amountsMissing, account, conversionRate, amount, recover]);
|
|
61823
61835
|
react.useEffect(function () {
|
|
61824
61836
|
if (amountsMissing && maxRoute) {
|
|
61825
61837
|
maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
|
|
@@ -62438,10 +62450,12 @@
|
|
|
62438
62450
|
var _useContext2 = react.useContext(ConfigurationContext),
|
|
62439
62451
|
_sent = _useContext2.sent,
|
|
62440
62452
|
confirmed = _useContext2.confirmed,
|
|
62441
|
-
failed = _useContext2.failed
|
|
62453
|
+
failed = _useContext2.failed,
|
|
62454
|
+
recover = _useContext2.recover;
|
|
62442
62455
|
|
|
62443
62456
|
var _useContext3 = react.useContext(PaymentRoutingContext),
|
|
62444
|
-
selectedRoute = _useContext3.selectedRoute
|
|
62457
|
+
selectedRoute = _useContext3.selectedRoute,
|
|
62458
|
+
getPaymentRoutes = _useContext3.getPaymentRoutes;
|
|
62445
62459
|
|
|
62446
62460
|
var _useContext4 = react.useContext(ClosableContext),
|
|
62447
62461
|
open = _useContext4.open,
|
|
@@ -62507,8 +62521,10 @@
|
|
|
62507
62521
|
}
|
|
62508
62522
|
|
|
62509
62523
|
setPaymentState('initialized');
|
|
62524
|
+
setPayment(null);
|
|
62510
62525
|
setClosable(true);
|
|
62511
62526
|
setUpdatable(true);
|
|
62527
|
+
getPaymentRoutes({});
|
|
62512
62528
|
navigate('PaymentError');
|
|
62513
62529
|
};
|
|
62514
62530
|
|
|
@@ -62594,6 +62610,39 @@
|
|
|
62594
62610
|
setPaymentState('confirmed');
|
|
62595
62611
|
}
|
|
62596
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]);
|
|
62597
62646
|
react.useEffect(function () {
|
|
62598
62647
|
if (foundTransaction && foundTransaction.id && foundTransaction.status) {
|
|
62599
62648
|
var newTransaction;
|
|
@@ -62618,16 +62667,16 @@
|
|
|
62618
62667
|
react.useEffect(function () {
|
|
62619
62668
|
if (selectedRoute) {
|
|
62620
62669
|
var fromToken = selectedRoute.fromToken;
|
|
62621
|
-
selectedRoute.
|
|
62622
|
-
|
|
62623
|
-
|
|
62624
|
-
|
|
62625
|
-
|
|
62626
|
-
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];
|
|
62627
62675
|
|
|
62628
62676
|
setPayment({
|
|
62677
|
+
blockchain: selectedRoute.blockchain,
|
|
62629
62678
|
route: selectedRoute,
|
|
62630
|
-
token:
|
|
62679
|
+
token: fromToken.address,
|
|
62631
62680
|
name: name,
|
|
62632
62681
|
symbol: symbol.toUpperCase(),
|
|
62633
62682
|
amount: amount
|
|
@@ -67639,14 +67688,16 @@
|
|
|
67639
67688
|
|
|
67640
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; }
|
|
67641
67690
|
class PaymentRoute {
|
|
67642
|
-
constructor({ blockchain, fromToken, toToken, toDecimals, toAmount,
|
|
67691
|
+
constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, toToken, toDecimals, toAmount, toAddress, toContract }) {
|
|
67643
67692
|
this.blockchain = blockchain;
|
|
67693
|
+
this.fromAddress = fromAddress;
|
|
67644
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()]);
|
|
67645
67697
|
this.fromBalance = 0;
|
|
67646
67698
|
this.toToken = toToken;
|
|
67699
|
+
this.toAmount = _optionalChain([toAmount, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
|
|
67647
67700
|
this.toDecimals = toDecimals;
|
|
67648
|
-
this.toAmount = _optionalChain([toAmount, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
|
|
67649
|
-
this.fromAddress = fromAddress;
|
|
67650
67701
|
this.toAddress = toAddress;
|
|
67651
67702
|
this.toContract = toContract;
|
|
67652
67703
|
this.exchangeRoutes = [];
|
|
@@ -67706,22 +67757,43 @@
|
|
|
67706
67757
|
return Promise.all(tokens.map(async (fromToken)=>{
|
|
67707
67758
|
let relevantConfigurations = accept.filter((configuration)=>(configuration.blockchain == fromToken.blockchain));
|
|
67708
67759
|
return Promise.all(relevantConfigurations.map(async (configuration)=>{
|
|
67709
|
-
|
|
67710
|
-
|
|
67711
|
-
|
|
67712
|
-
|
|
67713
|
-
|
|
67714
|
-
|
|
67715
|
-
|
|
67716
|
-
|
|
67717
|
-
|
|
67718
|
-
|
|
67719
|
-
|
|
67720
|
-
|
|
67721
|
-
|
|
67722
|
-
|
|
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
|
+
}
|
|
67723
67795
|
}))
|
|
67724
|
-
})).then((routes)=> routes.flat())
|
|
67796
|
+
})).then((routes)=> routes.flat().filter(el => el))
|
|
67725
67797
|
}
|
|
67726
67798
|
|
|
67727
67799
|
async function route({ accept, whitelist, blacklist, apiKey, event, fee }) {
|
|
@@ -67777,14 +67849,25 @@
|
|
|
67777
67849
|
return await Promise.all(
|
|
67778
67850
|
routes.map((route) => {
|
|
67779
67851
|
if(route.directTransfer) { return [] }
|
|
67780
|
-
|
|
67781
|
-
|
|
67782
|
-
|
|
67783
|
-
|
|
67784
|
-
|
|
67785
|
-
|
|
67786
|
-
|
|
67787
|
-
|
|
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
|
+
}
|
|
67788
67871
|
}),
|
|
67789
67872
|
).then((exchangeRoutes) => {
|
|
67790
67873
|
return routes.map((route, index) => {
|
|
@@ -67814,8 +67897,10 @@
|
|
|
67814
67897
|
return routes.filter((route) => {
|
|
67815
67898
|
if (route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase()) {
|
|
67816
67899
|
return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.toAmount))
|
|
67817
|
-
} else {
|
|
67900
|
+
} else if(route.fromAmount && route.toAmount) {
|
|
67818
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))
|
|
67819
67904
|
}
|
|
67820
67905
|
})
|
|
67821
67906
|
};
|
|
@@ -67968,6 +68053,9 @@
|
|
|
67968
68053
|
var _useContext2 = react.useContext(UpdatableContext),
|
|
67969
68054
|
updatable = _useContext2.updatable;
|
|
67970
68055
|
|
|
68056
|
+
var _useContext3 = react.useContext(ConfigurationContext),
|
|
68057
|
+
recover = _useContext3.recover;
|
|
68058
|
+
|
|
67971
68059
|
var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
|
|
67972
68060
|
var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
|
|
67973
68061
|
var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
|
|
@@ -68095,7 +68183,7 @@
|
|
|
68095
68183
|
};
|
|
68096
68184
|
}, [reloadCount, allRoutes, selectedRoute, updatable]);
|
|
68097
68185
|
react.useEffect(function () {
|
|
68098
|
-
if (account && props.accept) {
|
|
68186
|
+
if (account && props.accept && recover == undefined) {
|
|
68099
68187
|
setAllRoutes(undefined);
|
|
68100
68188
|
setSelectedRoute(undefined);
|
|
68101
68189
|
getPaymentRoutes({});
|
|
@@ -68108,6 +68196,7 @@
|
|
|
68108
68196
|
value: {
|
|
68109
68197
|
selectedRoute: selectedRoute,
|
|
68110
68198
|
setSelectedRoute: setSelectedRoute,
|
|
68199
|
+
getPaymentRoutes: getPaymentRoutes,
|
|
68111
68200
|
allRoutes: allRoutes,
|
|
68112
68201
|
setAllRoutes: setAllRoutes
|
|
68113
68202
|
}
|
|
@@ -70464,7 +70553,7 @@
|
|
|
70464
70553
|
};
|
|
70465
70554
|
|
|
70466
70555
|
var approvalButton = function approvalButton() {
|
|
70467
|
-
if (!payment.route.approvalRequired || payment.route.directTransfer) {
|
|
70556
|
+
if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
|
|
70468
70557
|
return null;
|
|
70469
70558
|
} else if (paymentState == 'initialized') {
|
|
70470
70559
|
return /*#__PURE__*/react.createElement("div", {
|
|
@@ -70501,7 +70590,7 @@
|
|
|
70501
70590
|
displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
|
|
70502
70591
|
}
|
|
70503
70592
|
|
|
70504
|
-
if (paymentState == 'initialized' || paymentState == 'approving') {
|
|
70593
|
+
if ((paymentState == 'initialized' || paymentState == 'approving') && payment.route) {
|
|
70505
70594
|
return /*#__PURE__*/react.createElement("button", {
|
|
70506
70595
|
className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
|
|
70507
70596
|
onClick: function onClick() {
|
|
@@ -70650,8 +70739,11 @@
|
|
|
70650
70739
|
var _useContext2 = react.useContext(PaymentContext),
|
|
70651
70740
|
transaction = _useContext2.transaction;
|
|
70652
70741
|
|
|
70742
|
+
var _useContext3 = react.useContext(ConfigurationContext),
|
|
70743
|
+
recover = _useContext3.recover;
|
|
70744
|
+
|
|
70653
70745
|
return /*#__PURE__*/react.createElement(Dialog, {
|
|
70654
|
-
stacked: true,
|
|
70746
|
+
stacked: recover ? false : true,
|
|
70655
70747
|
header: /*#__PURE__*/react.createElement("div", {
|
|
70656
70748
|
className: "PaddingTopS PaddingLeftM PaddingRightM"
|
|
70657
70749
|
}),
|
|
@@ -70664,7 +70756,7 @@
|
|
|
70664
70756
|
className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
|
|
70665
70757
|
}, "Payment Failed"), /*#__PURE__*/react.createElement("div", {
|
|
70666
70758
|
className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
|
|
70667
|
-
}, /*#__PURE__*/react.createElement("strong", {
|
|
70759
|
+
}, recover == undefined && /*#__PURE__*/react.createElement("strong", {
|
|
70668
70760
|
className: "FontSizeM"
|
|
70669
70761
|
}, "Unfortunately executing your payment failed. You can go back and try again."), transaction && /*#__PURE__*/react.createElement("div", {
|
|
70670
70762
|
className: "PaddingTopS"
|
|
@@ -70677,7 +70769,7 @@
|
|
|
70677
70769
|
}, "View on explorer")))),
|
|
70678
70770
|
footer: /*#__PURE__*/react.createElement("div", {
|
|
70679
70771
|
className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
|
|
70680
|
-
}, /*#__PURE__*/react.createElement("button", {
|
|
70772
|
+
}, recover == undefined && /*#__PURE__*/react.createElement("button", {
|
|
70681
70773
|
className: "ButtonPrimary",
|
|
70682
70774
|
onClick: function onClick() {
|
|
70683
70775
|
return navigate('back');
|
|
@@ -71015,9 +71107,12 @@
|
|
|
71015
71107
|
var _useContext = react.useContext(ErrorContext);
|
|
71016
71108
|
_useContext.errorCallback;
|
|
71017
71109
|
|
|
71110
|
+
var _useContext2 = react.useContext(ConfigurationContext),
|
|
71111
|
+
recover = _useContext2.recover;
|
|
71112
|
+
|
|
71018
71113
|
react.useEffect(function () {
|
|
71019
71114
|
if (polling) {
|
|
71020
|
-
var
|
|
71115
|
+
var poll = function poll() {
|
|
71021
71116
|
fetch("https://api.depay.fi/v2/transactions/".concat(givenTransaction.blockchain, "/").concat(givenTransaction.from.toLowerCase(), "/").concat(givenTransaction.nonce)).then(function (response) {
|
|
71022
71117
|
if (response.status == 200) {
|
|
71023
71118
|
response.json().then(function (data) {
|
|
@@ -71031,7 +71126,10 @@
|
|
|
71031
71126
|
});
|
|
71032
71127
|
}
|
|
71033
71128
|
});
|
|
71034
|
-
}
|
|
71129
|
+
};
|
|
71130
|
+
|
|
71131
|
+
var pollingInterval = setInterval(poll, 5000);
|
|
71132
|
+
poll();
|
|
71035
71133
|
return function () {
|
|
71036
71134
|
clearInterval(pollingInterval);
|
|
71037
71135
|
};
|
|
@@ -71111,11 +71209,25 @@
|
|
|
71111
71209
|
|
|
71112
71210
|
var initializeTracking = function initializeTracking(transaction, afterBlock) {
|
|
71113
71211
|
setGivenTransaction(transaction);
|
|
71114
|
-
|
|
71212
|
+
|
|
71213
|
+
if (recover == undefined) {
|
|
71214
|
+
createTracking(transaction, afterBlock, 1);
|
|
71215
|
+
}
|
|
71216
|
+
|
|
71115
71217
|
openSocket(transaction);
|
|
71116
71218
|
setPolling(true);
|
|
71117
71219
|
};
|
|
71118
71220
|
|
|
71221
|
+
react.useEffect(function () {
|
|
71222
|
+
if (recover) {
|
|
71223
|
+
initializeTracking({
|
|
71224
|
+
blockchain: recover.blockchain,
|
|
71225
|
+
id: recover.transaction,
|
|
71226
|
+
from: recover.sender,
|
|
71227
|
+
nonce: recover.nonce
|
|
71228
|
+
}, recover.afterBlock);
|
|
71229
|
+
}
|
|
71230
|
+
}, [recover]);
|
|
71119
71231
|
return /*#__PURE__*/react.createElement(TransactionTrackingContext.Provider, {
|
|
71120
71232
|
value: {
|
|
71121
71233
|
initializeTracking: initializeTracking,
|
|
@@ -71125,8 +71237,11 @@
|
|
|
71125
71237
|
});
|
|
71126
71238
|
|
|
71127
71239
|
var WalletProvider = (function (props) {
|
|
71128
|
-
var _useContext = react.useContext(
|
|
71129
|
-
_useContext.
|
|
71240
|
+
var _useContext = react.useContext(ConfigurationContext),
|
|
71241
|
+
recover = _useContext.recover;
|
|
71242
|
+
|
|
71243
|
+
var _useContext2 = react.useContext(ErrorContext);
|
|
71244
|
+
_useContext2.setError;
|
|
71130
71245
|
|
|
71131
71246
|
var _useState = react.useState(),
|
|
71132
71247
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -71155,7 +71270,7 @@
|
|
|
71155
71270
|
}
|
|
71156
71271
|
};
|
|
71157
71272
|
|
|
71158
|
-
if (walletState == 'connected') {
|
|
71273
|
+
if (walletState == 'connected' || recover != undefined) {
|
|
71159
71274
|
return /*#__PURE__*/react.createElement(WalletContext.Provider, {
|
|
71160
71275
|
value: {
|
|
71161
71276
|
account: account,
|
|
@@ -71543,7 +71658,8 @@
|
|
|
71543
71658
|
|
|
71544
71659
|
var PaymentOverviewDialog = (function (props) {
|
|
71545
71660
|
var _useContext = react.useContext(ConfigurationContext),
|
|
71546
|
-
currencyCode = _useContext.currencyCode
|
|
71661
|
+
currencyCode = _useContext.currencyCode,
|
|
71662
|
+
recover = _useContext.recover;
|
|
71547
71663
|
|
|
71548
71664
|
var _useContext2 = react.useContext(PaymentContext),
|
|
71549
71665
|
payment = _useContext2.payment,
|
|
@@ -71559,7 +71675,7 @@
|
|
|
71559
71675
|
var _useContext5 = react.useContext(NavigateStackContext),
|
|
71560
71676
|
navigate = _useContext5.navigate;
|
|
71561
71677
|
|
|
71562
|
-
if (payment == undefined || paymentValue == undefined) {
|
|
71678
|
+
if (payment == undefined || recover == undefined && paymentValue == undefined) {
|
|
71563
71679
|
return /*#__PURE__*/react.createElement(PaymentOverviewSkeleton, null);
|
|
71564
71680
|
}
|
|
71565
71681
|
|
|
@@ -71610,7 +71726,7 @@
|
|
|
71610
71726
|
className: "CardImage",
|
|
71611
71727
|
title: payment.name
|
|
71612
71728
|
}, /*#__PURE__*/react.createElement(TokenImage, {
|
|
71613
|
-
blockchain: payment.
|
|
71729
|
+
blockchain: payment.blockchain,
|
|
71614
71730
|
address: payment.token
|
|
71615
71731
|
})), /*#__PURE__*/react.createElement("div", {
|
|
71616
71732
|
className: "CardBody"
|
|
@@ -71662,12 +71778,21 @@
|
|
|
71662
71778
|
|
|
71663
71779
|
var preflight$1 = /*#__PURE__*/function () {
|
|
71664
71780
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref) {
|
|
71665
|
-
var accept;
|
|
71781
|
+
var accept, recover;
|
|
71666
71782
|
return regenerator.wrap(function _callee$(_context) {
|
|
71667
71783
|
while (1) {
|
|
71668
71784
|
switch (_context.prev = _context.next) {
|
|
71669
71785
|
case 0:
|
|
71670
|
-
accept = _ref.accept;
|
|
71786
|
+
accept = _ref.accept, recover = _ref.recover;
|
|
71787
|
+
|
|
71788
|
+
if (!recover) {
|
|
71789
|
+
_context.next = 3;
|
|
71790
|
+
break;
|
|
71791
|
+
}
|
|
71792
|
+
|
|
71793
|
+
return _context.abrupt("return");
|
|
71794
|
+
|
|
71795
|
+
case 3:
|
|
71671
71796
|
accept.forEach(function (configuration) {
|
|
71672
71797
|
if (typeof configuration.blockchain === 'undefined') {
|
|
71673
71798
|
throw 'You need to set the blockchain your want to receive the payment on!';
|
|
@@ -71677,16 +71802,20 @@
|
|
|
71677
71802
|
throw 'You need to set a supported blockchain!';
|
|
71678
71803
|
}
|
|
71679
71804
|
|
|
71680
|
-
if (typeof configuration.token === 'undefined') {
|
|
71805
|
+
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
71681
71806
|
throw 'You need to set the token you want to receive as payment!';
|
|
71682
71807
|
}
|
|
71683
71808
|
|
|
71809
|
+
if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
|
|
71810
|
+
throw 'You need to set the fromToken, fromAmount and toToken!';
|
|
71811
|
+
}
|
|
71812
|
+
|
|
71684
71813
|
if (typeof configuration.receiver === 'undefined') {
|
|
71685
71814
|
throw 'You need to set the receiver address that you want to receive the payment!';
|
|
71686
71815
|
}
|
|
71687
71816
|
});
|
|
71688
71817
|
|
|
71689
|
-
case
|
|
71818
|
+
case 4:
|
|
71690
71819
|
case "end":
|
|
71691
71820
|
return _context.stop();
|
|
71692
71821
|
}
|
|
@@ -71701,16 +71830,17 @@
|
|
|
71701
71830
|
|
|
71702
71831
|
var Payment = /*#__PURE__*/function () {
|
|
71703
71832
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
|
|
71704
|
-
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, document, unmount;
|
|
71833
|
+
var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, document, unmount;
|
|
71705
71834
|
return regenerator.wrap(function _callee2$(_context2) {
|
|
71706
71835
|
while (1) {
|
|
71707
71836
|
switch (_context2.prev = _context2.next) {
|
|
71708
71837
|
case 0:
|
|
71709
|
-
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;
|
|
71838
|
+
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;
|
|
71710
71839
|
_context2.prev = 1;
|
|
71711
71840
|
_context2.next = 4;
|
|
71712
71841
|
return preflight$1({
|
|
71713
|
-
accept: accept
|
|
71842
|
+
accept: accept,
|
|
71843
|
+
recover: recover
|
|
71714
71844
|
});
|
|
71715
71845
|
|
|
71716
71846
|
case 4:
|
|
@@ -71737,7 +71867,8 @@
|
|
|
71737
71867
|
blacklist: blacklist,
|
|
71738
71868
|
providers: providers,
|
|
71739
71869
|
track: track,
|
|
71740
|
-
fee: fee
|
|
71870
|
+
fee: fee,
|
|
71871
|
+
recover: recover
|
|
71741
71872
|
}
|
|
71742
71873
|
}, /*#__PURE__*/react.createElement(UpdatableProvider, null, /*#__PURE__*/react.createElement(ClosableProvider, {
|
|
71743
71874
|
unmount: unmount
|