@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 CHANGED
@@ -194,6 +194,25 @@ DePayWidgets.Payment({
194
194
  });
195
195
  ```
196
196
 
197
+ #### fromToken, fromAmount + toToken
198
+
199
+ In case where you want to configure payments based on the source token + amount, rather than target token and amount, you can pass `fromToken`, `fromAmount` and `toToken` to `accept`.
200
+
201
+ In those cases make sure to NOT configure `token` nor `amount`!
202
+
203
+ ```javascript
204
+ DePayWidgets.Payment({
205
+ accept: [{
206
+ blockchain: 'bsc',
207
+ fromToken: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
208
+ fromAmount: 0.1,
209
+ toToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
210
+ receiver: '0x08B277154218CCF3380CAE48d630DA13462E3950'
211
+ }]
212
+ });
213
+
214
+ // This will open a payment widget to send 0.1 BUSD to the receiver, converting it to BNB along the way.
215
+ ```
197
216
 
198
217
  #### track
199
218
 
@@ -586,6 +605,29 @@ let { unmount } = await DePayWidgets.Payment({})
586
605
  unmount()
587
606
  ```
588
607
 
608
+ #### recover
609
+
610
+ `recover`
611
+
612
+ Allows you to recover a previous made payment. E.g. useful if you need to continue to show a pending payment progress if user rearrives or reloads a payment page:
613
+
614
+ ```javascript
615
+ DePayWidgets.Payment({
616
+ recover: {
617
+ blockchain: 'ethereum',
618
+ transaction: '0x081ae81229b2c7df586835e9e4c16aa89f8a15dc118fac31b7521477c53ed2a9',
619
+ sender: '0x317d875ca3b9f8d14f960486c0d1d1913be74e90',
620
+ nonce: 2865,
621
+ afterBlock: 14088130,
622
+ token: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
623
+ amount: 0.0001
624
+ }
625
+ })
626
+
627
+ A recovered payment still results in a confirmed or failed payment, and also calls one of those callbacks also when created with recover.
628
+
629
+ ```
630
+
589
631
  ## DePay Sales
590
632
 
591
633
  DePay Sales allows you to sell tokens directly from your website or dApp with automatic any-to-any payment conversion (so people can use any token when buying your token directly off your website or dApp).
@@ -1599,6 +1599,8 @@ class Dialog$1 extends react.Component {
1599
1599
  constructor(props) {
1600
1600
  super(props);
1601
1601
 
1602
+ this.handler = this.onKeyDown.bind(this);
1603
+
1602
1604
  this.state = {
1603
1605
  open: true,
1604
1606
  };
@@ -1632,22 +1634,22 @@ class Dialog$1 extends react.Component {
1632
1634
  this.setState({ open: true });
1633
1635
  }, 10);
1634
1636
  });
1635
- this.props.document.addEventListener('keydown', this.onKeyDown.bind(this), false);
1637
+ this.props.document.addEventListener('keydown', this.handler, true);
1636
1638
  }
1637
1639
 
1638
1640
  componentWillUnmount() {
1639
- this.props.document.addEventListener('keydown', this.onKeyDown.bind(this), false);
1641
+ this.props.document.removeEventListener('keydown', this.handler, true);
1640
1642
  }
1641
1643
 
1642
1644
  render() {
1643
1645
  const classNames = ['ReactDialog', this.state.open ? 'ReactDialogOpen' : ''];
1644
1646
  const style = ReactDialogStyle({ background: this.props.background });
1645
1647
  return (
1646
- react.createElement('div', { className: classNames.join(' '), __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 54}}
1647
- , react.createElement('style', {__self: this, __source: {fileName: _jsxFileName$2, lineNumber: 55}}, style)
1648
- , react.createElement('div', { className: "ReactDialogRow", __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 56}}
1649
- , react.createElement('div', { className: "ReactDialogCell", __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 57}}
1650
- , react.createElement('div', { className: "ReactDialogBackground", onClick: this.onClickBackground.bind(this), __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 58}} )
1648
+ react.createElement('div', { className: classNames.join(' '), __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 56}}
1649
+ , react.createElement('style', {__self: this, __source: {fileName: _jsxFileName$2, lineNumber: 57}}, style)
1650
+ , react.createElement('div', { className: "ReactDialogRow", __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 58}}
1651
+ , react.createElement('div', { className: "ReactDialogCell", __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 59}}
1652
+ , react.createElement('div', { className: "ReactDialogBackground", onClick: this.onClickBackground.bind(this), __self: this, __source: {fileName: _jsxFileName$2, lineNumber: 60}} )
1651
1653
  , this.props.children
1652
1654
  )
1653
1655
  )
@@ -49482,7 +49484,7 @@ var CardStyle = (function (style) {
49482
49484
  });
49483
49485
 
49484
49486
  var DialogStyle = (function (style) {
49485
- 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 height: 100%;\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 ";
49487
+ 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 ";
49486
49488
  });
49487
49489
 
49488
49490
  var FontStyle = (function (style) {
@@ -61716,20 +61718,22 @@ let route$8 = ({
61716
61718
  var ChangableAmountProvider = (function (props) {
61717
61719
  var configurationsMissAmounts = function configurationsMissAmounts(configurations) {
61718
61720
  return !configurations.every(function (configuration) {
61719
- return typeof configuration.amount != 'undefined';
61721
+ return typeof configuration.amount != 'undefined' || typeof configuration.fromAmount != 'undefined';
61720
61722
  });
61721
61723
  };
61722
61724
 
61723
- var _useState = react.useState(configurationsMissAmounts(props.accept)),
61725
+ var _useContext = react.useContext(ConfigurationContext),
61726
+ amountConfiguration = _useContext.amount;
61727
+ _useContext.toAmount;
61728
+ var recover = _useContext.recover;
61729
+
61730
+ var _useState = react.useState(recover == undefined ? configurationsMissAmounts(props.accept) : false),
61724
61731
  _useState2 = _slicedToArray(_useState, 2),
61725
61732
  amountsMissing = _useState2[0],
61726
61733
  setAmountsMissing = _useState2[1];
61727
61734
 
61728
- var _useContext = react.useContext(WalletContext),
61729
- account = _useContext.account;
61730
-
61731
- var _useContext2 = react.useContext(ConfigurationContext),
61732
- amountConfiguration = _useContext2.amount;
61735
+ var _useContext2 = react.useContext(WalletContext),
61736
+ account = _useContext2.account;
61733
61737
 
61734
61738
  var _useContext3 = react.useContext(ConversionRateContext),
61735
61739
  conversionRate = _useContext3.conversionRate;
@@ -61758,8 +61762,12 @@ var ChangableAmountProvider = (function (props) {
61758
61762
  setMaxAmount = _useState10[1];
61759
61763
 
61760
61764
  react.useEffect(function () {
61765
+ if (recover) {
61766
+ return;
61767
+ }
61768
+
61761
61769
  setAmountsMissing(configurationsMissAmounts(props.accept));
61762
- }, [props.accept]);
61770
+ }, [props.accept, recover]);
61763
61771
 
61764
61772
  var getAmounts = function getAmounts() {
61765
61773
  return new Promise(function (resolve, reject) {
@@ -61795,6 +61803,10 @@ var ChangableAmountProvider = (function (props) {
61795
61803
  };
61796
61804
 
61797
61805
  react.useEffect(function () {
61806
+ if (recover) {
61807
+ return;
61808
+ }
61809
+
61798
61810
  if (amountsMissing && account && conversionRate) {
61799
61811
  getAmounts().then(function (amounts) {
61800
61812
  setAcceptWithAmount(props.accept.map(function (configuration, index) {
@@ -61813,7 +61825,7 @@ var ChangableAmountProvider = (function (props) {
61813
61825
  }));
61814
61826
  })["catch"](setError);
61815
61827
  }
61816
- }, [amountsMissing, account, conversionRate, amount]);
61828
+ }, [amountsMissing, account, conversionRate, amount, recover]);
61817
61829
  react.useEffect(function () {
61818
61830
  if (amountsMissing && maxRoute) {
61819
61831
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
@@ -62432,10 +62444,12 @@ var PaymentProvider = (function (props) {
62432
62444
  var _useContext2 = react.useContext(ConfigurationContext),
62433
62445
  _sent = _useContext2.sent,
62434
62446
  confirmed = _useContext2.confirmed,
62435
- failed = _useContext2.failed;
62447
+ failed = _useContext2.failed,
62448
+ recover = _useContext2.recover;
62436
62449
 
62437
62450
  var _useContext3 = react.useContext(PaymentRoutingContext),
62438
- selectedRoute = _useContext3.selectedRoute;
62451
+ selectedRoute = _useContext3.selectedRoute,
62452
+ getPaymentRoutes = _useContext3.getPaymentRoutes;
62439
62453
 
62440
62454
  var _useContext4 = react.useContext(ClosableContext),
62441
62455
  open = _useContext4.open,
@@ -62501,8 +62515,10 @@ var PaymentProvider = (function (props) {
62501
62515
  }
62502
62516
 
62503
62517
  setPaymentState('initialized');
62518
+ setPayment(null);
62504
62519
  setClosable(true);
62505
62520
  setUpdatable(true);
62521
+ getPaymentRoutes({});
62506
62522
  navigate('PaymentError');
62507
62523
  };
62508
62524
 
@@ -62588,6 +62604,39 @@ var PaymentProvider = (function (props) {
62588
62604
  setPaymentState('confirmed');
62589
62605
  }
62590
62606
  }, [release]);
62607
+ react.useEffect(function () {
62608
+ if (recover) {
62609
+ setClosable(false);
62610
+ setUpdatable(false);
62611
+ setPaymentState('paying');
62612
+ setTransaction({
62613
+ blockchain: recover.blockchain,
62614
+ id: recover.transaction,
62615
+ url: Blockchain.findByName(recover.blockchain).explorerUrlFor({
62616
+ transaction: {
62617
+ id: recover.transaction
62618
+ }
62619
+ })
62620
+ });
62621
+ var paymentToken = new Token({
62622
+ blockchain: recover.blockchain,
62623
+ address: recover.token
62624
+ });
62625
+ Promise.all([paymentToken.name(), paymentToken.symbol()]).then(function (_ref2) {
62626
+ var _ref3 = _slicedToArray(_ref2, 2),
62627
+ name = _ref3[0],
62628
+ symbol = _ref3[1];
62629
+
62630
+ setPayment({
62631
+ blockchain: recover.blockchain,
62632
+ token: recover.token,
62633
+ name: name,
62634
+ symbol: symbol.toUpperCase(),
62635
+ amount: recover.amount
62636
+ });
62637
+ })["catch"](setError);
62638
+ }
62639
+ }, [recover]);
62591
62640
  react.useEffect(function () {
62592
62641
  if (foundTransaction && foundTransaction.id && foundTransaction.status) {
62593
62642
  var newTransaction;
@@ -62612,16 +62661,16 @@ var PaymentProvider = (function (props) {
62612
62661
  react.useEffect(function () {
62613
62662
  if (selectedRoute) {
62614
62663
  var fromToken = selectedRoute.fromToken;
62615
- selectedRoute.transaction.params;
62616
- Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref2) {
62617
- var _ref3 = _slicedToArray(_ref2, 3),
62618
- name = _ref3[0],
62619
- symbol = _ref3[1],
62620
- amount = _ref3[2];
62664
+ Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref4) {
62665
+ var _ref5 = _slicedToArray(_ref4, 3),
62666
+ name = _ref5[0],
62667
+ symbol = _ref5[1],
62668
+ amount = _ref5[2];
62621
62669
 
62622
62670
  setPayment({
62671
+ blockchain: selectedRoute.blockchain,
62623
62672
  route: selectedRoute,
62624
- token: selectedRoute.fromToken.address,
62673
+ token: fromToken.address,
62625
62674
  name: name,
62626
62675
  symbol: symbol.toUpperCase(),
62627
62676
  amount: amount
@@ -67633,14 +67682,16 @@ let transactionValue = ({ paymentRoute, exchangeRoute })=> {
67633
67682
 
67634
67683
  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; }
67635
67684
  class PaymentRoute {
67636
- constructor({ blockchain, fromToken, toToken, toDecimals, toAmount, fromAddress, toAddress, toContract }) {
67685
+ constructor({ blockchain, fromAddress, fromToken, fromDecimals, fromAmount, toToken, toDecimals, toAmount, toAddress, toContract }) {
67637
67686
  this.blockchain = blockchain;
67687
+ this.fromAddress = fromAddress;
67638
67688
  this.fromToken = fromToken;
67689
+ this.fromAmount = _optionalChain([fromAmount, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
67690
+ this.fromDecimals = _optionalChain([fromDecimals, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
67639
67691
  this.fromBalance = 0;
67640
67692
  this.toToken = toToken;
67693
+ this.toAmount = _optionalChain([toAmount, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()]);
67641
67694
  this.toDecimals = toDecimals;
67642
- this.toAmount = _optionalChain([toAmount, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]);
67643
- this.fromAddress = fromAddress;
67644
67695
  this.toAddress = toAddress;
67645
67696
  this.toContract = toContract;
67646
67697
  this.exchangeRoutes = [];
@@ -67700,22 +67751,43 @@ function convertToRoutes({ tokens, accept }) {
67700
67751
  return Promise.all(tokens.map(async (fromToken)=>{
67701
67752
  let relevantConfigurations = accept.filter((configuration)=>(configuration.blockchain == fromToken.blockchain));
67702
67753
  return Promise.all(relevantConfigurations.map(async (configuration)=>{
67703
- let blockchain = configuration.blockchain;
67704
- let toToken = new Token({ blockchain, address: configuration.token });
67705
- let toDecimals = await toToken.decimals();
67706
- let toAmount = (await toToken.BigNumber(configuration.amount)).toString();
67707
- return new PaymentRoute({
67708
- blockchain,
67709
- fromToken: fromToken,
67710
- toToken: toToken,
67711
- toAmount: toAmount,
67712
- toDecimals: toDecimals,
67713
- fromAddress: configuration.fromAddress,
67714
- toAddress: configuration.toAddress,
67715
- toContract: configuration.toContract
67716
- })
67754
+ if(configuration.token && configuration.amount) {
67755
+ let blockchain = configuration.blockchain;
67756
+ let toToken = new Token({ blockchain, address: configuration.token });
67757
+ let toDecimals = await toToken.decimals();
67758
+ let toAmount = (await toToken.BigNumber(configuration.amount)).toString();
67759
+
67760
+ return new PaymentRoute({
67761
+ blockchain,
67762
+ fromToken,
67763
+ toToken,
67764
+ toAmount,
67765
+ toDecimals,
67766
+ fromAddress: configuration.fromAddress,
67767
+ toAddress: configuration.toAddress,
67768
+ toContract: configuration.toContract
67769
+ })
67770
+ } else if(configuration.fromToken && configuration.fromAmount && fromToken.address.toLowerCase() == configuration.fromToken.toLowerCase()) {
67771
+ let blockchain = configuration.blockchain;
67772
+ let fromAmount = (await fromToken.BigNumber(configuration.fromAmount)).toString();
67773
+ let fromDecimals = await fromToken.decimals();
67774
+ let toToken = new Token({ blockchain, address: configuration.toToken });
67775
+ let toDecimals = await toToken.decimals();
67776
+
67777
+ return new PaymentRoute({
67778
+ blockchain,
67779
+ fromToken,
67780
+ fromAmount,
67781
+ fromDecimals,
67782
+ toToken,
67783
+ toDecimals,
67784
+ fromAddress: configuration.fromAddress,
67785
+ toAddress: configuration.toAddress,
67786
+ toContract: configuration.toContract
67787
+ })
67788
+ }
67717
67789
  }))
67718
- })).then((routes)=> routes.flat())
67790
+ })).then((routes)=> routes.flat().filter(el => el))
67719
67791
  }
67720
67792
 
67721
67793
  async function route({ accept, whitelist, blacklist, apiKey, event, fee }) {
@@ -67771,14 +67843,25 @@ let addExchangeRoutes = async (routes) => {
67771
67843
  return await Promise.all(
67772
67844
  routes.map((route) => {
67773
67845
  if(route.directTransfer) { return [] }
67774
- return route$8({
67775
- blockchain: route.blockchain,
67776
- tokenIn: route.fromToken.address,
67777
- tokenOut: route.toToken.address,
67778
- amountOutMin: route.toAmount,
67779
- fromAddress: route.fromAddress,
67780
- toAddress: route.toAddress
67781
- })
67846
+ if(route.toToken && route.toAmount) {
67847
+ return route$8({
67848
+ blockchain: route.blockchain,
67849
+ tokenIn: route.fromToken.address,
67850
+ tokenOut: route.toToken.address,
67851
+ amountOutMin: route.toAmount,
67852
+ fromAddress: route.fromAddress,
67853
+ toAddress: route.toAddress
67854
+ })
67855
+ } else if(route.fromToken && route.fromAmount) {
67856
+ return route$8({
67857
+ blockchain: route.blockchain,
67858
+ tokenIn: route.fromToken.address,
67859
+ tokenOut: route.toToken.address,
67860
+ amountIn: route.fromAmount,
67861
+ fromAddress: route.fromAddress,
67862
+ toAddress: route.toAddress
67863
+ })
67864
+ }
67782
67865
  }),
67783
67866
  ).then((exchangeRoutes) => {
67784
67867
  return routes.map((route, index) => {
@@ -67808,8 +67891,10 @@ let filterInsufficientBalance = async(routes) => {
67808
67891
  return routes.filter((route) => {
67809
67892
  if (route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase()) {
67810
67893
  return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.toAmount))
67811
- } else {
67894
+ } else if(route.fromAmount && route.toAmount) {
67812
67895
  return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.exchangeRoutes[0].amountInMax))
67896
+ } else if(route.exchangeRoutes[0] && route.exchangeRoutes[0].amountIn) {
67897
+ return BigNumber.from(route.fromBalance).gte(BigNumber.from(route.exchangeRoutes[0].amountIn))
67813
67898
  }
67814
67899
  })
67815
67900
  };
@@ -67962,6 +68047,9 @@ var PaymentRoutingProvider = (function (props) {
67962
68047
  var _useContext2 = react.useContext(UpdatableContext),
67963
68048
  updatable = _useContext2.updatable;
67964
68049
 
68050
+ var _useContext3 = react.useContext(ConfigurationContext),
68051
+ recover = _useContext3.recover;
68052
+
67965
68053
  var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
67966
68054
  var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
67967
68055
  var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
@@ -68089,7 +68177,7 @@ var PaymentRoutingProvider = (function (props) {
68089
68177
  };
68090
68178
  }, [reloadCount, allRoutes, selectedRoute, updatable]);
68091
68179
  react.useEffect(function () {
68092
- if (account && props.accept) {
68180
+ if (account && props.accept && recover == undefined) {
68093
68181
  setAllRoutes(undefined);
68094
68182
  setSelectedRoute(undefined);
68095
68183
  getPaymentRoutes({});
@@ -68102,6 +68190,7 @@ var PaymentRoutingProvider = (function (props) {
68102
68190
  value: {
68103
68191
  selectedRoute: selectedRoute,
68104
68192
  setSelectedRoute: setSelectedRoute,
68193
+ getPaymentRoutes: getPaymentRoutes,
68105
68194
  allRoutes: allRoutes,
68106
68195
  setAllRoutes: setAllRoutes
68107
68196
  }
@@ -70458,7 +70547,7 @@ var Footer = (function () {
70458
70547
  };
70459
70548
 
70460
70549
  var approvalButton = function approvalButton() {
70461
- if (!payment.route.approvalRequired || payment.route.directTransfer) {
70550
+ if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
70462
70551
  return null;
70463
70552
  } else if (paymentState == 'initialized') {
70464
70553
  return /*#__PURE__*/react.createElement("div", {
@@ -70495,7 +70584,7 @@ var Footer = (function () {
70495
70584
  displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
70496
70585
  }
70497
70586
 
70498
- if (paymentState == 'initialized' || paymentState == 'approving') {
70587
+ if ((paymentState == 'initialized' || paymentState == 'approving') && payment.route) {
70499
70588
  return /*#__PURE__*/react.createElement("button", {
70500
70589
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
70501
70590
  onClick: function onClick() {
@@ -70644,8 +70733,11 @@ var PaymentErrorDialog = (function () {
70644
70733
  var _useContext2 = react.useContext(PaymentContext),
70645
70734
  transaction = _useContext2.transaction;
70646
70735
 
70736
+ var _useContext3 = react.useContext(ConfigurationContext),
70737
+ recover = _useContext3.recover;
70738
+
70647
70739
  return /*#__PURE__*/react.createElement(Dialog, {
70648
- stacked: true,
70740
+ stacked: recover ? false : true,
70649
70741
  header: /*#__PURE__*/react.createElement("div", {
70650
70742
  className: "PaddingTopS PaddingLeftM PaddingRightM"
70651
70743
  }),
@@ -70658,7 +70750,7 @@ var PaymentErrorDialog = (function () {
70658
70750
  className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
70659
70751
  }, "Payment Failed"), /*#__PURE__*/react.createElement("div", {
70660
70752
  className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
70661
- }, /*#__PURE__*/react.createElement("strong", {
70753
+ }, recover == undefined && /*#__PURE__*/react.createElement("strong", {
70662
70754
  className: "FontSizeM"
70663
70755
  }, "Unfortunately executing your payment failed. You can go back and try again."), transaction && /*#__PURE__*/react.createElement("div", {
70664
70756
  className: "PaddingTopS"
@@ -70671,7 +70763,7 @@ var PaymentErrorDialog = (function () {
70671
70763
  }, "View on explorer")))),
70672
70764
  footer: /*#__PURE__*/react.createElement("div", {
70673
70765
  className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
70674
- }, /*#__PURE__*/react.createElement("button", {
70766
+ }, recover == undefined && /*#__PURE__*/react.createElement("button", {
70675
70767
  className: "ButtonPrimary",
70676
70768
  onClick: function onClick() {
70677
70769
  return navigate('back');
@@ -71009,9 +71101,12 @@ var TransactionTrackingProvider = (function (props) {
71009
71101
  var _useContext = react.useContext(ErrorContext);
71010
71102
  _useContext.errorCallback;
71011
71103
 
71104
+ var _useContext2 = react.useContext(ConfigurationContext),
71105
+ recover = _useContext2.recover;
71106
+
71012
71107
  react.useEffect(function () {
71013
71108
  if (polling) {
71014
- var pollingInterval = setInterval(function () {
71109
+ var poll = function poll() {
71015
71110
  fetch("https://api.depay.fi/v2/transactions/".concat(givenTransaction.blockchain, "/").concat(givenTransaction.from.toLowerCase(), "/").concat(givenTransaction.nonce)).then(function (response) {
71016
71111
  if (response.status == 200) {
71017
71112
  response.json().then(function (data) {
@@ -71025,7 +71120,10 @@ var TransactionTrackingProvider = (function (props) {
71025
71120
  });
71026
71121
  }
71027
71122
  });
71028
- }, 5000);
71123
+ };
71124
+
71125
+ var pollingInterval = setInterval(poll, 5000);
71126
+ poll();
71029
71127
  return function () {
71030
71128
  clearInterval(pollingInterval);
71031
71129
  };
@@ -71105,11 +71203,25 @@ var TransactionTrackingProvider = (function (props) {
71105
71203
 
71106
71204
  var initializeTracking = function initializeTracking(transaction, afterBlock) {
71107
71205
  setGivenTransaction(transaction);
71108
- createTracking(transaction, afterBlock, 1);
71206
+
71207
+ if (recover == undefined) {
71208
+ createTracking(transaction, afterBlock, 1);
71209
+ }
71210
+
71109
71211
  openSocket(transaction);
71110
71212
  setPolling(true);
71111
71213
  };
71112
71214
 
71215
+ react.useEffect(function () {
71216
+ if (recover) {
71217
+ initializeTracking({
71218
+ blockchain: recover.blockchain,
71219
+ id: recover.transaction,
71220
+ from: recover.sender,
71221
+ nonce: recover.nonce
71222
+ }, recover.afterBlock);
71223
+ }
71224
+ }, [recover]);
71113
71225
  return /*#__PURE__*/react.createElement(TransactionTrackingContext.Provider, {
71114
71226
  value: {
71115
71227
  initializeTracking: initializeTracking,
@@ -71119,8 +71231,11 @@ var TransactionTrackingProvider = (function (props) {
71119
71231
  });
71120
71232
 
71121
71233
  var WalletProvider = (function (props) {
71122
- var _useContext = react.useContext(ErrorContext);
71123
- _useContext.setError;
71234
+ var _useContext = react.useContext(ConfigurationContext),
71235
+ recover = _useContext.recover;
71236
+
71237
+ var _useContext2 = react.useContext(ErrorContext);
71238
+ _useContext2.setError;
71124
71239
 
71125
71240
  var _useState = react.useState(),
71126
71241
  _useState2 = _slicedToArray(_useState, 2),
@@ -71149,7 +71264,7 @@ var WalletProvider = (function (props) {
71149
71264
  }
71150
71265
  };
71151
71266
 
71152
- if (walletState == 'connected') {
71267
+ if (walletState == 'connected' || recover != undefined) {
71153
71268
  return /*#__PURE__*/react.createElement(WalletContext.Provider, {
71154
71269
  value: {
71155
71270
  account: account,
@@ -71537,7 +71652,8 @@ var PaymentOverviewSkeleton = (function (props) {
71537
71652
 
71538
71653
  var PaymentOverviewDialog = (function (props) {
71539
71654
  var _useContext = react.useContext(ConfigurationContext),
71540
- currencyCode = _useContext.currencyCode;
71655
+ currencyCode = _useContext.currencyCode,
71656
+ recover = _useContext.recover;
71541
71657
 
71542
71658
  var _useContext2 = react.useContext(PaymentContext),
71543
71659
  payment = _useContext2.payment,
@@ -71553,7 +71669,7 @@ var PaymentOverviewDialog = (function (props) {
71553
71669
  var _useContext5 = react.useContext(NavigateStackContext),
71554
71670
  navigate = _useContext5.navigate;
71555
71671
 
71556
- if (payment == undefined || paymentValue == undefined) {
71672
+ if (payment == undefined || recover == undefined && paymentValue == undefined) {
71557
71673
  return /*#__PURE__*/react.createElement(PaymentOverviewSkeleton, null);
71558
71674
  }
71559
71675
 
@@ -71604,7 +71720,7 @@ var PaymentOverviewDialog = (function (props) {
71604
71720
  className: "CardImage",
71605
71721
  title: payment.name
71606
71722
  }, /*#__PURE__*/react.createElement(TokenImage, {
71607
- blockchain: payment.route.blockchain,
71723
+ blockchain: payment.blockchain,
71608
71724
  address: payment.token
71609
71725
  })), /*#__PURE__*/react.createElement("div", {
71610
71726
  className: "CardBody"
@@ -71656,12 +71772,21 @@ var PaymentStack = (function (props) {
71656
71772
 
71657
71773
  var preflight$1 = /*#__PURE__*/function () {
71658
71774
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref) {
71659
- var accept;
71775
+ var accept, recover;
71660
71776
  return regenerator.wrap(function _callee$(_context) {
71661
71777
  while (1) {
71662
71778
  switch (_context.prev = _context.next) {
71663
71779
  case 0:
71664
- accept = _ref.accept;
71780
+ accept = _ref.accept, recover = _ref.recover;
71781
+
71782
+ if (!recover) {
71783
+ _context.next = 3;
71784
+ break;
71785
+ }
71786
+
71787
+ return _context.abrupt("return");
71788
+
71789
+ case 3:
71665
71790
  accept.forEach(function (configuration) {
71666
71791
  if (typeof configuration.blockchain === 'undefined') {
71667
71792
  throw 'You need to set the blockchain your want to receive the payment on!';
@@ -71671,16 +71796,20 @@ var preflight$1 = /*#__PURE__*/function () {
71671
71796
  throw 'You need to set a supported blockchain!';
71672
71797
  }
71673
71798
 
71674
- if (typeof configuration.token === 'undefined') {
71799
+ if (typeof configuration.token === 'undefined' && typeof configuration.fromToken === 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
71675
71800
  throw 'You need to set the token you want to receive as payment!';
71676
71801
  }
71677
71802
 
71803
+ if (typeof configuration.token === 'undefined' && typeof configuration.fromToken !== 'undefined' && typeof configuration.fromAmount === 'undefined' && typeof configuration.toToken === 'undefined') {
71804
+ throw 'You need to set the fromToken, fromAmount and toToken!';
71805
+ }
71806
+
71678
71807
  if (typeof configuration.receiver === 'undefined') {
71679
71808
  throw 'You need to set the receiver address that you want to receive the payment!';
71680
71809
  }
71681
71810
  });
71682
71811
 
71683
- case 2:
71812
+ case 4:
71684
71813
  case "end":
71685
71814
  return _context.stop();
71686
71815
  }
@@ -71695,16 +71824,17 @@ var preflight$1 = /*#__PURE__*/function () {
71695
71824
 
71696
71825
  var Payment = /*#__PURE__*/function () {
71697
71826
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
71698
- var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, document, unmount;
71827
+ var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, document, unmount;
71699
71828
  return regenerator.wrap(function _callee2$(_context2) {
71700
71829
  while (1) {
71701
71830
  switch (_context2.prev = _context2.next) {
71702
71831
  case 0:
71703
- 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;
71832
+ 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;
71704
71833
  _context2.prev = 1;
71705
71834
  _context2.next = 4;
71706
71835
  return preflight$1({
71707
- accept: accept
71836
+ accept: accept,
71837
+ recover: recover
71708
71838
  });
71709
71839
 
71710
71840
  case 4:
@@ -71731,7 +71861,8 @@ var Payment = /*#__PURE__*/function () {
71731
71861
  blacklist: blacklist,
71732
71862
  providers: providers,
71733
71863
  track: track,
71734
- fee: fee
71864
+ fee: fee,
71865
+ recover: recover
71735
71866
  }
71736
71867
  }, /*#__PURE__*/react.createElement(UpdatableProvider, null, /*#__PURE__*/react.createElement(ClosableProvider, {
71737
71868
  unmount: unmount