@depay/widgets 12.0.2 → 12.0.4

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/esm/index.js CHANGED
@@ -21969,7 +21969,28 @@ var ConnectWalletDialog = (function (props) {
21969
21969
  className: "Alert"
21970
21970
  }, /*#__PURE__*/React.createElement("span", {
21971
21971
  className: "FontWeightBold PaddingBottomXS"
21972
- }, "You wallet extension window is already asking to connect. It might be hidden."))), /*#__PURE__*/React.createElement("button", {
21972
+ }, "You wallet extension window is already asking to connect. It might be hidden."))), props.connectingExtension && /*#__PURE__*/React.createElement("div", {
21973
+ className: "Card disabled small PaddingTopS PaddingRightXS PaddingBottomS PaddingLeftXS",
21974
+ style: {
21975
+ height: '50px'
21976
+ }
21977
+ }, /*#__PURE__*/React.createElement("div", {
21978
+ className: "PaddingTopXS PaddingRightXS PaddingLeftS TextCenter",
21979
+ style: {
21980
+ width: "50px"
21981
+ }
21982
+ }, /*#__PURE__*/React.createElement("div", {
21983
+ className: "Loading Icon medium",
21984
+ style: {
21985
+ position: 'relative',
21986
+ top: '4px',
21987
+ left: '1px'
21988
+ }
21989
+ })), /*#__PURE__*/React.createElement("div", {
21990
+ className: "PaddingLeftS LineHeightXS"
21991
+ }, /*#__PURE__*/React.createElement("div", {
21992
+ className: "CardText FontWeightMedium"
21993
+ }, "Connecting extension"))), !props.connectingExtension && /*#__PURE__*/React.createElement("button", {
21973
21994
  onClick: function onClick() {
21974
21995
  return props.connectExtension(props.wallet);
21975
21996
  },
@@ -21995,7 +22016,28 @@ var ConnectWalletDialog = (function (props) {
21995
22016
  className: "CardText FontWeightMedium"
21996
22017
  }, "Connect extension")))), connectAppIsAvailable && /*#__PURE__*/React.createElement("div", {
21997
22018
  className: "PaddingBottomXS"
21998
- }, /*#__PURE__*/React.createElement("button", {
22019
+ }, props.connectingApp && /*#__PURE__*/React.createElement("div", {
22020
+ className: "Card disabled small PaddingTopS PaddingRightXS PaddingBottomS PaddingLeftXS",
22021
+ style: {
22022
+ height: '50px'
22023
+ }
22024
+ }, /*#__PURE__*/React.createElement("div", {
22025
+ className: "PaddingTopXS PaddingRightXS PaddingLeftS TextCenter",
22026
+ style: {
22027
+ width: "50px"
22028
+ }
22029
+ }, /*#__PURE__*/React.createElement("div", {
22030
+ className: "Loading Icon medium",
22031
+ style: {
22032
+ position: 'relative',
22033
+ top: '4px',
22034
+ left: '1px'
22035
+ }
22036
+ })), /*#__PURE__*/React.createElement("div", {
22037
+ className: "PaddingLeftS LineHeightXS"
22038
+ }, /*#__PURE__*/React.createElement("div", {
22039
+ className: "CardText FontWeightMedium"
22040
+ }, "Connecting app"))), !props.connectingApp && /*#__PURE__*/React.createElement("button", {
21999
22041
  onClick: function onClick() {
22000
22042
  return props.connectViaRedirect(props.wallet);
22001
22043
  },
@@ -22588,20 +22630,28 @@ var ConnectStack = (function (props) {
22588
22630
  _useState4 = _slicedToArray(_useState3, 2),
22589
22631
  platform = _useState4[0],
22590
22632
  setPlatform = _useState4[1];
22591
- var _useState5 = useState(),
22633
+ var _useState5 = useState(false),
22592
22634
  _useState6 = _slicedToArray(_useState5, 2),
22593
- redirectUri = _useState6[0],
22594
- setRedirectUri = _useState6[1];
22595
- var _useState7 = useState({
22596
- blockchain: undefined
22597
- }),
22635
+ connectingExtension = _useState6[0],
22636
+ setConnectingExtension = _useState6[1];
22637
+ var _useState7 = useState(false),
22598
22638
  _useState8 = _slicedToArray(_useState7, 2),
22599
- selection = _useState8[0];
22600
- _useState8[1];
22601
- var _useState9 = useState(false),
22639
+ connectingApp = _useState8[0],
22640
+ setConnectingApp = _useState8[1];
22641
+ var _useState9 = useState(),
22602
22642
  _useState10 = _slicedToArray(_useState9, 2),
22603
- showConnectExtensionWarning = _useState10[0],
22604
- setShowConnectExtensionWarning = _useState10[1];
22643
+ redirectUri = _useState10[0],
22644
+ setRedirectUri = _useState10[1];
22645
+ var _useState11 = useState({
22646
+ blockchain: undefined
22647
+ }),
22648
+ _useState12 = _slicedToArray(_useState11, 2),
22649
+ selection = _useState12[0];
22650
+ _useState12[1];
22651
+ var _useState13 = useState(false),
22652
+ _useState14 = _slicedToArray(_useState13, 2),
22653
+ showConnectExtensionWarning = _useState14[0],
22654
+ setShowConnectExtensionWarning = _useState14[1];
22605
22655
  var resolve = function resolve(account, wallet) {
22606
22656
  if (account && wallet) {
22607
22657
  var walletMeta = allWallets.find(function (walletMeta) {
@@ -22619,10 +22669,18 @@ var ConnectStack = (function (props) {
22619
22669
  };
22620
22670
  var connectExtension = function connectExtension(wallet) {
22621
22671
  setShowConnectExtensionWarning(false);
22672
+ setConnectingExtension(true);
22622
22673
  wallet = new wallets[wallet.extension]();
22674
+ var resetConnectingTimeout = setTimeout(function () {
22675
+ setConnectingExtension(false);
22676
+ }, 5000);
22623
22677
  wallet.connect().then(function (account) {
22624
22678
  resolve(account, wallet);
22679
+ setConnectingExtension(false);
22680
+ clearTimeout(resetConnectingTimeout);
22625
22681
  })["catch"](function (error) {
22682
+ setConnectingExtension(false);
22683
+ clearTimeout(resetConnectingTimeout);
22626
22684
  if ((error === null || error === void 0 ? void 0 : error.code) == -32002) {
22627
22685
  // Request of type 'wallet_requestPermissions' already pending...
22628
22686
  setShowConnectExtensionWarning(true);
@@ -22699,6 +22757,10 @@ var ConnectStack = (function (props) {
22699
22757
  if (!platform) {
22700
22758
  return;
22701
22759
  }
22760
+ setConnectingApp(true);
22761
+ setTimeout(function () {
22762
+ setConnectingApp(false);
22763
+ }, 5000);
22702
22764
  if (['WalletConnectV1', 'WalletConnectV2'].includes(platform.connect)) {
22703
22765
  localStorage[atob('ZGVwYXk6d2FsbGV0czp3YzI6cHJvamVjdElk')] = atob('YjFmYzJmMDZlYTIxMDdmY2Q5OWM2OGY0MTI3MTQxYWI=');
22704
22766
  var _wallet = new wallets[platform.connect]();
@@ -22723,7 +22785,10 @@ var ConnectStack = (function (props) {
22723
22785
  });
22724
22786
  }
22725
22787
  }).then(function (account) {
22788
+ setConnectingApp(false);
22726
22789
  resolve(account, _wallet);
22790
+ })["catch"](function () {
22791
+ setConnectingApp(false);
22727
22792
  });
22728
22793
  } else if (platform.connect === 'SolanaMobileWalletAdapter') {
22729
22794
  var _wallet2 = new wallets[platform.connect]();
@@ -22731,7 +22796,10 @@ var ConnectStack = (function (props) {
22731
22796
  name: walletMetaData.name,
22732
22797
  logo: walletMetaData.logo
22733
22798
  }).then(function (account) {
22799
+ setConnectingApp(false);
22734
22800
  resolve(account, _wallet2);
22801
+ })["catch"](function () {
22802
+ setConnectingApp(false);
22735
22803
  });
22736
22804
  }
22737
22805
  };
@@ -22774,6 +22842,8 @@ var ConnectStack = (function (props) {
22774
22842
  openInApp: openInApp,
22775
22843
  connectViaRedirect: connectViaRedirect,
22776
22844
  connectExtension: connectExtension,
22845
+ connectingExtension: connectingExtension,
22846
+ connectingApp: connectingApp,
22777
22847
  showConnectExtensionWarning: showConnectExtensionWarning,
22778
22848
  continueWithSolanaPay: props.continueWithSolanaPay
22779
22849
  })
@@ -23174,7 +23244,7 @@ var HeightStyle = (function () {
23174
23244
  });
23175
23245
 
23176
23246
  var IconStyle = (function (style) {
23177
- return "\n\n .Icon {\n fill: ".concat(style.colors.icons, ";\n stroke: ").concat(style.colors.icons, ";\n }\n\n .QuestionMarkIcon {\n fill: transparent;\n }\n\n .ChevronLeft, .ChevronRight {\n position: relative;\n top: 1px;\n }\n\n .ChevronLeft.small, .ChevronRight.small {\n height: 12px;\n width: 12px;\n }\n\n .Checkmark {\n height: 24px;\n position: relative;\n top: -1px;\n vertical-align: middle;\n width: 24px;\n }\n\n .AlertIcon {\n height: 20px;\n position: relative;\n top: -1px;\n vertical-align: middle;\n width: 20px;\n fill: #e42626;\n stroke: transparent;\n }\n\n .CheckMark.small {\n height: 16px;\n width: 16px;\n }\n\n .DigitalWalletIcon {\n height: 24px;\n position: relative;\n top: -1px;\n vertical-align: middle;\n width: 24px;\n }\n\n .ButtonPrimary .Icon {\n fill : ").concat(style.colors.buttonText, ";\n stroke : ").concat(style.colors.buttonText, ";\n }\n\n .Loading {\n border: 3px solid ").concat(style.colors.primary, ";\n border-top: 3px solid rgba(0,0,0,0.1);\n border-radius: 100%;\n position: relative;\n left: -1px;\n width: 18px;\n height: 18px;\n animation: spin 1.5s linear infinite;\n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ");
23247
+ return "\n\n .Icon {\n fill: ".concat(style.colors.icons, ";\n stroke: ").concat(style.colors.icons, ";\n }\n\n .QuestionMarkIcon {\n fill: transparent;\n }\n\n .ChevronLeft, .ChevronRight {\n position: relative;\n top: 1px;\n }\n\n .ChevronLeft.small, .ChevronRight.small {\n height: 12px;\n width: 12px;\n }\n\n .Checkmark {\n height: 24px;\n position: relative;\n top: -1px;\n vertical-align: middle;\n width: 24px;\n }\n\n .AlertIcon {\n height: 20px;\n position: relative;\n top: -1px;\n vertical-align: middle;\n width: 20px;\n fill: #e42626;\n stroke: transparent;\n }\n\n .CheckMark.small {\n height: 16px;\n width: 16px;\n }\n\n .DigitalWalletIcon {\n height: 24px;\n position: relative;\n top: -1px;\n vertical-align: middle;\n width: 24px;\n }\n\n .ButtonPrimary .Icon {\n fill : ").concat(style.colors.buttonText, ";\n stroke : ").concat(style.colors.buttonText, ";\n }\n\n .Loading {\n animation: spin 1.5s linear infinite;\n border-radius: 100%;\n border: 3px solid ").concat(style.colors.primary, ";\n border-top: 3px solid rgba(0,0,0,0.1);\n display: inline-block;\n height: 18px;\n left: -1px;\n position: relative;\n width: 18px;\n }\n\n .Loading.medium {\n border: 4px solid ").concat(style.colors.primary, ";\n border-top: 4px solid rgba(0,0,0,0.1);\n display: inline-block;\n height: 22px;\n position: relative;\n width: 22px; \n }\n\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ");
23178
23248
  });
23179
23249
 
23180
23250
  var ImageStyle = (function (style) {
@@ -23475,8 +23545,10 @@ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t
23475
23545
  var PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtqsu0wy94cpz90W4pGsJ\nSf0bfvmsq3su+R1J4AoAYz0XoAu2MXJZM8vrQvG3op7OgB3zze8pj4joaoPU2piT\ndH7kcF4Mde6QG4qKEL3VE+J8CL3qK2dUY0Umu20x/O9O792tlv8+Q/qAVv8yPfdM\nn5Je9Wc7VI5XeIBKP2AzsCkrXuzQlR48Ac5LpViNSSLu0mz5NTBoHkW2sz1sNWc6\nUpYISJkiKTvYc8Bo4p5xD6+ZmlL4hj1Ad/+26SjYcisX2Ut4QD7YKRBP2SbItVkI\nqp9mp6c6MCKNmEUkosxAr0KVfOcrk6/fcc4tI8g+KYZ32G11Ri8Xo4fgHH06DLYP\n3QIDAQAB\n-----END PUBLIC KEY-----\n";
23476
23546
  var ConfigurationProvider = (function (props) {
23477
23547
  var _props$configuration, _props$configuration5;
23478
- var currencyCode = new Currency({
23548
+ var currencyCode = typeof props.configuration.currency === 'string' ? new Currency({
23479
23549
  code: props.configuration.currency
23550
+ }).code : new Currency({
23551
+ amount: 0
23480
23552
  }).code;
23481
23553
  var _useState = useState(!((_props$configuration = props.configuration) !== null && _props$configuration !== void 0 && _props$configuration.integration) ? _objectSpread$6(_objectSpread$6({}, props.configuration), {}, {
23482
23554
  currencyCode: currencyCode
@@ -24161,10 +24233,10 @@ var ChangableAmountProvider = (function (props) {
24161
24233
  });
24162
24234
  };
24163
24235
  var _useContext = useContext(ConfigurationContext),
24164
- accept = _useContext.accept,
24165
24236
  configuredAmount = _useContext.amount;
24166
24237
  _useContext.toAmount;
24167
- var recover = _useContext.recover;
24238
+ var recover = _useContext.recover,
24239
+ accept = _useContext.accept;
24168
24240
  useContext(ConfigurationContext);
24169
24241
  var _useState = useState(recover == undefined ? configurationsMissAmounts(accept) : false),
24170
24242
  _useState2 = _slicedToArray(_useState, 2),
@@ -24782,9 +24854,12 @@ var InsufficientAmountOfTokensDialog = (function (props) {
24782
24854
  _useContext.navigate;
24783
24855
  var set = _useContext.set;
24784
24856
  var _useContext2 = useContext(ConfigurationContext),
24785
- accept = _useContext2.accept;
24786
- var _useContext3 = useContext(ClosableContext),
24787
- close = _useContext3.close;
24857
+ accept = _useContext2.accept,
24858
+ sell = _useContext2.sell;
24859
+ var _useContext3 = useContext(ChangableAmountContext),
24860
+ acceptWithAmount = _useContext3.acceptWithAmount;
24861
+ var _useContext4 = useContext(ClosableContext),
24862
+ close = _useContext4.close;
24788
24863
  var setRecommendation = function setRecommendation(_x) {
24789
24864
  return (_ref2 = _ref2 || _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(_ref) {
24790
24865
  var route, accept, nativeAvailableAsset, token, asset, _ref3, _ref4;
@@ -24995,7 +25070,7 @@ var InsufficientAmountOfTokensDialog = (function (props) {
24995
25070
  return regenerator.wrap(function _callee6$(_context6) {
24996
25071
  while (1) switch (_context6.prev = _context6.next) {
24997
25072
  case 0:
24998
- directTransfer = accept.find(function (accept) {
25073
+ directTransfer = !sell && (acceptWithAmount || accept).find(function (accept) {
24999
25074
  return props.assets.find(function (asset) {
25000
25075
  return accept.blockchain === asset.blockchain && accept.token.toLowerCase() === asset.address.toLowerCase();
25001
25076
  });
@@ -25047,7 +25122,7 @@ var InsufficientAmountOfTokensDialog = (function (props) {
25047
25122
  })) {
25048
25123
  return;
25049
25124
  } // consdier only major tokens for this
25050
- return accept.map(function (_x4) {
25125
+ return (acceptWithAmount || accept).map(function (_x4) {
25051
25126
  return (_ref6 = _ref6 || _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(accept) {
25052
25127
  return regenerator.wrap(function _callee4$(_context4) {
25053
25128
  while (1) switch (_context4.prev = _context4.next) {
@@ -25092,15 +25167,15 @@ var InsufficientAmountOfTokensDialog = (function (props) {
25092
25167
  return regenerator.wrap(function _callee5$(_context5) {
25093
25168
  while (1) switch (_context5.prev = _context5.next) {
25094
25169
  case 0:
25095
- route = (routes || []).flat().find(function (route) {
25096
- return accept.find(function (accept) {
25170
+ route = (routes.filter(Boolean) || []).flat().find(function (route) {
25171
+ return (acceptWithAmount || accept).find(function (accept) {
25097
25172
  return accept.blockchain === route.blockchain && accept.token.toLowerCase() === route.tokenOut.toLowerCase();
25098
25173
  });
25099
25174
  }) || routes.flat()[0];
25100
25175
  if (!route) {
25101
25176
  set(['NoPaymentOptionFound']);
25102
25177
  } else {
25103
- recommendedAccept = accept.find(function (accept) {
25178
+ recommendedAccept = (acceptWithAmount || accept).find(function (accept) {
25104
25179
  return accept.blockchain === route.blockchain && accept.token.toLowerCase() === route.tokenOut.toLowerCase();
25105
25180
  }) || accept.find(function (accept) {
25106
25181
  return accept.blockchain === route.blockchain;
@@ -29637,6 +29712,7 @@ var Sale = function Sale(_x2) {
29637
29712
  }, /*#__PURE__*/React.createElement(ConfigurationProvider, {
29638
29713
  configuration: {
29639
29714
  type: 'sale',
29715
+ accept: accept,
29640
29716
  tokenImage: tokenImage,
29641
29717
  amount: amount,
29642
29718
  sell: sell,
@@ -29656,9 +29732,7 @@ var Sale = function Sale(_x2) {
29656
29732
  container: container,
29657
29733
  connected: connected,
29658
29734
  unmount: unmount
29659
- }, /*#__PURE__*/React.createElement(NavigateProvider, null, /*#__PURE__*/React.createElement(ConversionRateProvider, null, /*#__PURE__*/React.createElement(ChangableAmountProvider, {
29660
- accept: accept
29661
- }, /*#__PURE__*/React.createElement(TransactionTrackingProvider, null, /*#__PURE__*/React.createElement(PaymentTrackingProvider, {
29735
+ }, /*#__PURE__*/React.createElement(NavigateProvider, null, /*#__PURE__*/React.createElement(ConversionRateProvider, null, /*#__PURE__*/React.createElement(ChangableAmountProvider, null, /*#__PURE__*/React.createElement(TransactionTrackingProvider, null, /*#__PURE__*/React.createElement(PaymentTrackingProvider, {
29662
29736
  document: ensureDocument(document)
29663
29737
  }, /*#__PURE__*/React.createElement(SaleRoutingProvider, {
29664
29738
  container: container,