@depay/widgets 6.12.1 → 6.13.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/dist/umd/index.js CHANGED
@@ -1679,7 +1679,7 @@
1679
1679
  });
1680
1680
 
1681
1681
  var DialogStyle = (function (style) {
1682
- 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 ";
1682
+ 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 ";
1683
1683
  });
1684
1684
 
1685
1685
  var FontStyle = (function (style) {
@@ -2020,16 +2020,17 @@
2020
2020
  });
2021
2021
  };
2022
2022
 
2023
- var _useState = React.useState(configurationsMissAmounts(props.accept)),
2023
+ var _useContext = React.useContext(ConfigurationContext),
2024
+ amountConfiguration = _useContext.amount,
2025
+ recover = _useContext.recover;
2026
+
2027
+ var _useState = React.useState(recover == undefined ? configurationsMissAmounts(props.accept) : false),
2024
2028
  _useState2 = _slicedToArray(_useState, 2),
2025
2029
  amountsMissing = _useState2[0],
2026
2030
  setAmountsMissing = _useState2[1];
2027
2031
 
2028
- var _useContext = React.useContext(WalletContext),
2029
- account = _useContext.account;
2030
-
2031
- var _useContext2 = React.useContext(ConfigurationContext),
2032
- amountConfiguration = _useContext2.amount;
2032
+ var _useContext2 = React.useContext(WalletContext),
2033
+ account = _useContext2.account;
2033
2034
 
2034
2035
  var _useContext3 = React.useContext(ConversionRateContext),
2035
2036
  conversionRate = _useContext3.conversionRate;
@@ -2058,8 +2059,12 @@
2058
2059
  setMaxAmount = _useState10[1];
2059
2060
 
2060
2061
  React.useEffect(function () {
2062
+ if (recover) {
2063
+ return;
2064
+ }
2065
+
2061
2066
  setAmountsMissing(configurationsMissAmounts(props.accept));
2062
- }, [props.accept]);
2067
+ }, [props.accept, recover]);
2063
2068
 
2064
2069
  var getAmounts = function getAmounts() {
2065
2070
  return new Promise(function (resolve, reject) {
@@ -2095,6 +2100,10 @@
2095
2100
  };
2096
2101
 
2097
2102
  React.useEffect(function () {
2103
+ if (recover) {
2104
+ return;
2105
+ }
2106
+
2098
2107
  if (amountsMissing && account && conversionRate) {
2099
2108
  getAmounts().then(function (amounts) {
2100
2109
  setAcceptWithAmount(props.accept.map(function (configuration, index) {
@@ -2113,7 +2122,7 @@
2113
2122
  }));
2114
2123
  })["catch"](setError);
2115
2124
  }
2116
- }, [amountsMissing, account, conversionRate, amount]);
2125
+ }, [amountsMissing, account, conversionRate, amount, recover]);
2117
2126
  React.useEffect(function () {
2118
2127
  if (amountsMissing && maxRoute) {
2119
2128
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
@@ -2275,10 +2284,12 @@
2275
2284
  var _useContext2 = React.useContext(ConfigurationContext),
2276
2285
  _sent = _useContext2.sent,
2277
2286
  confirmed = _useContext2.confirmed,
2278
- failed = _useContext2.failed;
2287
+ failed = _useContext2.failed,
2288
+ recover = _useContext2.recover;
2279
2289
 
2280
2290
  var _useContext3 = React.useContext(PaymentRoutingContext),
2281
- selectedRoute = _useContext3.selectedRoute;
2291
+ selectedRoute = _useContext3.selectedRoute,
2292
+ getPaymentRoutes = _useContext3.getPaymentRoutes;
2282
2293
 
2283
2294
  var _useContext4 = React.useContext(ClosableContext),
2284
2295
  open = _useContext4.open,
@@ -2344,8 +2355,10 @@
2344
2355
  }
2345
2356
 
2346
2357
  setPaymentState('initialized');
2358
+ setPayment(null);
2347
2359
  setClosable(true);
2348
2360
  setUpdatable(true);
2361
+ getPaymentRoutes({});
2349
2362
  navigate('PaymentError');
2350
2363
  };
2351
2364
 
@@ -2431,6 +2444,39 @@
2431
2444
  setPaymentState('confirmed');
2432
2445
  }
2433
2446
  }, [release]);
2447
+ React.useEffect(function () {
2448
+ if (recover) {
2449
+ setClosable(false);
2450
+ setUpdatable(false);
2451
+ setPaymentState('paying');
2452
+ setTransaction({
2453
+ blockchain: recover.blockchain,
2454
+ id: recover.transaction,
2455
+ url: web3Blockchains.Blockchain.findByName(recover.blockchain).explorerUrlFor({
2456
+ transaction: {
2457
+ id: recover.transaction
2458
+ }
2459
+ })
2460
+ });
2461
+ var paymentToken = new web3Tokens.Token({
2462
+ blockchain: recover.blockchain,
2463
+ address: recover.token
2464
+ });
2465
+ Promise.all([paymentToken.name(), paymentToken.symbol()]).then(function (_ref2) {
2466
+ var _ref3 = _slicedToArray(_ref2, 2),
2467
+ name = _ref3[0],
2468
+ symbol = _ref3[1];
2469
+
2470
+ setPayment({
2471
+ blockchain: recover.blockchain,
2472
+ token: recover.token,
2473
+ name: name,
2474
+ symbol: symbol.toUpperCase(),
2475
+ amount: recover.amount
2476
+ });
2477
+ })["catch"](setError);
2478
+ }
2479
+ }, [recover]);
2434
2480
  React.useEffect(function () {
2435
2481
  if (foundTransaction && foundTransaction.id && foundTransaction.status) {
2436
2482
  var newTransaction;
@@ -2455,16 +2501,16 @@
2455
2501
  React.useEffect(function () {
2456
2502
  if (selectedRoute) {
2457
2503
  var fromToken = selectedRoute.fromToken;
2458
- selectedRoute.transaction.params;
2459
- Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref2) {
2460
- var _ref3 = _slicedToArray(_ref2, 3),
2461
- name = _ref3[0],
2462
- symbol = _ref3[1],
2463
- amount = _ref3[2];
2504
+ Promise.all([fromToken.name(), fromToken.symbol(), fromToken.readable(selectedRoute.fromAmount)]).then(function (_ref4) {
2505
+ var _ref5 = _slicedToArray(_ref4, 3),
2506
+ name = _ref5[0],
2507
+ symbol = _ref5[1],
2508
+ amount = _ref5[2];
2464
2509
 
2465
2510
  setPayment({
2511
+ blockchain: selectedRoute.blockchain,
2466
2512
  route: selectedRoute,
2467
- token: selectedRoute.fromToken.address,
2513
+ token: fromToken.address,
2468
2514
  name: name,
2469
2515
  symbol: symbol.toUpperCase(),
2470
2516
  amount: amount
@@ -2547,6 +2593,9 @@
2547
2593
  var _useContext2 = React.useContext(UpdatableContext),
2548
2594
  updatable = _useContext2.updatable;
2549
2595
 
2596
+ var _useContext3 = React.useContext(ConfigurationContext),
2597
+ recover = _useContext3.recover;
2598
+
2550
2599
  var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
2551
2600
  var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
2552
2601
  var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
@@ -2674,7 +2723,7 @@
2674
2723
  };
2675
2724
  }, [reloadCount, allRoutes, selectedRoute, updatable]);
2676
2725
  React.useEffect(function () {
2677
- if (account && props.accept) {
2726
+ if (account && props.accept && recover == undefined) {
2678
2727
  setAllRoutes(undefined);
2679
2728
  setSelectedRoute(undefined);
2680
2729
  getPaymentRoutes({});
@@ -2687,6 +2736,7 @@
2687
2736
  value: {
2688
2737
  selectedRoute: selectedRoute,
2689
2738
  setSelectedRoute: setSelectedRoute,
2739
+ getPaymentRoutes: getPaymentRoutes,
2690
2740
  allRoutes: allRoutes,
2691
2741
  setAllRoutes: setAllRoutes
2692
2742
  }
@@ -3329,7 +3379,7 @@
3329
3379
  };
3330
3380
 
3331
3381
  var approvalButton = function approvalButton() {
3332
- if (!payment.route.approvalRequired || payment.route.directTransfer) {
3382
+ if (payment.route == undefined || !payment.route.approvalRequired || payment.route.directTransfer) {
3333
3383
  return null;
3334
3384
  } else if (paymentState == 'initialized') {
3335
3385
  return /*#__PURE__*/React__default["default"].createElement("div", {
@@ -3366,7 +3416,7 @@
3366
3416
  displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
3367
3417
  }
3368
3418
 
3369
- if (paymentState == 'initialized' || paymentState == 'approving') {
3419
+ if ((paymentState == 'initialized' || paymentState == 'approving') && payment.route) {
3370
3420
  return /*#__PURE__*/React__default["default"].createElement("button", {
3371
3421
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
3372
3422
  onClick: function onClick() {
@@ -3515,8 +3565,11 @@
3515
3565
  var _useContext2 = React.useContext(PaymentContext),
3516
3566
  transaction = _useContext2.transaction;
3517
3567
 
3568
+ var _useContext3 = React.useContext(ConfigurationContext),
3569
+ recover = _useContext3.recover;
3570
+
3518
3571
  return /*#__PURE__*/React__default["default"].createElement(Dialog$1, {
3519
- stacked: true,
3572
+ stacked: recover ? false : true,
3520
3573
  header: /*#__PURE__*/React__default["default"].createElement("div", {
3521
3574
  className: "PaddingTopS PaddingLeftM PaddingRightM"
3522
3575
  }),
@@ -3529,7 +3582,7 @@
3529
3582
  className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
3530
3583
  }, "Payment Failed"), /*#__PURE__*/React__default["default"].createElement("div", {
3531
3584
  className: "Text PaddingTopS PaddingBottomS PaddingLeftS PaddingRightS"
3532
- }, /*#__PURE__*/React__default["default"].createElement("strong", {
3585
+ }, recover == undefined && /*#__PURE__*/React__default["default"].createElement("strong", {
3533
3586
  className: "FontSizeM"
3534
3587
  }, "Unfortunately executing your payment failed. You can go back and try again."), transaction && /*#__PURE__*/React__default["default"].createElement("div", {
3535
3588
  className: "PaddingTopS"
@@ -3542,7 +3595,7 @@
3542
3595
  }, "View on explorer")))),
3543
3596
  footer: /*#__PURE__*/React__default["default"].createElement("div", {
3544
3597
  className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
3545
- }, /*#__PURE__*/React__default["default"].createElement("button", {
3598
+ }, recover == undefined && /*#__PURE__*/React__default["default"].createElement("button", {
3546
3599
  className: "ButtonPrimary",
3547
3600
  onClick: function onClick() {
3548
3601
  return navigate('back');
@@ -3880,9 +3933,12 @@
3880
3933
  var _useContext = React.useContext(ErrorContext);
3881
3934
  _useContext.errorCallback;
3882
3935
 
3936
+ var _useContext2 = React.useContext(ConfigurationContext),
3937
+ recover = _useContext2.recover;
3938
+
3883
3939
  React.useEffect(function () {
3884
3940
  if (polling) {
3885
- var pollingInterval = setInterval(function () {
3941
+ var poll = function poll() {
3886
3942
  fetch("https://api.depay.fi/v2/transactions/".concat(givenTransaction.blockchain, "/").concat(givenTransaction.from.toLowerCase(), "/").concat(givenTransaction.nonce)).then(function (response) {
3887
3943
  if (response.status == 200) {
3888
3944
  response.json().then(function (data) {
@@ -3896,7 +3952,10 @@
3896
3952
  });
3897
3953
  }
3898
3954
  });
3899
- }, 5000);
3955
+ };
3956
+
3957
+ var pollingInterval = setInterval(poll, 5000);
3958
+ poll();
3900
3959
  return function () {
3901
3960
  clearInterval(pollingInterval);
3902
3961
  };
@@ -3976,11 +4035,25 @@
3976
4035
 
3977
4036
  var initializeTracking = function initializeTracking(transaction, afterBlock) {
3978
4037
  setGivenTransaction(transaction);
3979
- createTracking(transaction, afterBlock, 1);
4038
+
4039
+ if (recover == undefined) {
4040
+ createTracking(transaction, afterBlock, 1);
4041
+ }
4042
+
3980
4043
  openSocket(transaction);
3981
4044
  setPolling(true);
3982
4045
  };
3983
4046
 
4047
+ React.useEffect(function () {
4048
+ if (recover) {
4049
+ initializeTracking({
4050
+ blockchain: recover.blockchain,
4051
+ id: recover.transaction,
4052
+ from: recover.sender,
4053
+ nonce: recover.nonce
4054
+ }, recover.afterBlock);
4055
+ }
4056
+ }, [recover]);
3984
4057
  return /*#__PURE__*/React__default["default"].createElement(TransactionTrackingContext.Provider, {
3985
4058
  value: {
3986
4059
  initializeTracking: initializeTracking,
@@ -4408,7 +4481,8 @@
4408
4481
 
4409
4482
  var PaymentOverviewDialog = (function (props) {
4410
4483
  var _useContext = React.useContext(ConfigurationContext),
4411
- currencyCode = _useContext.currencyCode;
4484
+ currencyCode = _useContext.currencyCode,
4485
+ recover = _useContext.recover;
4412
4486
 
4413
4487
  var _useContext2 = React.useContext(PaymentContext),
4414
4488
  payment = _useContext2.payment,
@@ -4424,7 +4498,7 @@
4424
4498
  var _useContext5 = React.useContext(reactDialogStack.NavigateStackContext),
4425
4499
  navigate = _useContext5.navigate;
4426
4500
 
4427
- if (payment == undefined || paymentValue == undefined) {
4501
+ if (payment == undefined || recover == undefined && paymentValue == undefined) {
4428
4502
  return /*#__PURE__*/React__default["default"].createElement(PaymentOverviewSkeleton, null);
4429
4503
  }
4430
4504
 
@@ -4475,7 +4549,7 @@
4475
4549
  className: "CardImage",
4476
4550
  title: payment.name
4477
4551
  }, /*#__PURE__*/React__default["default"].createElement(reactTokenImage.TokenImage, {
4478
- blockchain: payment.route.blockchain,
4552
+ blockchain: payment.blockchain,
4479
4553
  address: payment.token
4480
4554
  })), /*#__PURE__*/React__default["default"].createElement("div", {
4481
4555
  className: "CardBody"
@@ -4527,12 +4601,21 @@
4527
4601
 
4528
4602
  var preflight$1 = /*#__PURE__*/function () {
4529
4603
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref) {
4530
- var accept;
4604
+ var accept, recover;
4531
4605
  return regenerator.wrap(function _callee$(_context) {
4532
4606
  while (1) {
4533
4607
  switch (_context.prev = _context.next) {
4534
4608
  case 0:
4535
- accept = _ref.accept;
4609
+ accept = _ref.accept, recover = _ref.recover;
4610
+
4611
+ if (!recover) {
4612
+ _context.next = 3;
4613
+ break;
4614
+ }
4615
+
4616
+ return _context.abrupt("return");
4617
+
4618
+ case 3:
4536
4619
  accept.forEach(function (configuration) {
4537
4620
  if (typeof configuration.blockchain === 'undefined') {
4538
4621
  throw 'You need to set the blockchain your want to receive the payment on!';
@@ -4551,7 +4634,7 @@
4551
4634
  }
4552
4635
  });
4553
4636
 
4554
- case 2:
4637
+ case 4:
4555
4638
  case "end":
4556
4639
  return _context.stop();
4557
4640
  }
@@ -4566,16 +4649,17 @@
4566
4649
 
4567
4650
  var Payment = /*#__PURE__*/function () {
4568
4651
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
4569
- var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, document, unmount;
4652
+ var accept, amount, event, sent, confirmed, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, document, unmount;
4570
4653
  return regenerator.wrap(function _callee2$(_context2) {
4571
4654
  while (1) {
4572
4655
  switch (_context2.prev = _context2.next) {
4573
4656
  case 0:
4574
- 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;
4657
+ 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;
4575
4658
  _context2.prev = 1;
4576
4659
  _context2.next = 4;
4577
4660
  return preflight$1({
4578
- accept: accept
4661
+ accept: accept,
4662
+ recover: recover
4579
4663
  });
4580
4664
 
4581
4665
  case 4:
@@ -4602,7 +4686,8 @@
4602
4686
  blacklist: blacklist,
4603
4687
  providers: providers,
4604
4688
  track: track,
4605
- fee: fee
4689
+ fee: fee,
4690
+ recover: recover
4606
4691
  }
4607
4692
  }, /*#__PURE__*/React__default["default"].createElement(UpdatableProvider, null, /*#__PURE__*/React__default["default"].createElement(ClosableProvider, {
4608
4693
  unmount: unmount
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/widgets",
3
3
  "moduleName": "DePayWidgets",
4
- "version": "6.12.1",
4
+ "version": "6.13.0",
5
5
  "description": "Web3 Payments with any token. DePay simplifies and improves Web3 Payments with the power of DeFi. Accept any token with on-the-fly conversion.",
6
6
  "main": "./dist/umd/index.js",
7
7
  "module": "./dist/esm/index.js",