@depay/widgets 11.1.0 → 11.1.1

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.
@@ -10,11 +10,11 @@ import ReactDOM from 'react-dom';
10
10
  import { ReactShadowDOM } from '@depay/react-shadow-dom';
11
11
  import { setProviderEndpoints, request } from '@depay/web3-client-evm';
12
12
  import { Currency } from '@depay/local-currency';
13
- import { route } from '@depay/web3-payments-evm';
14
- import { route as route$1 } from '@depay/web3-exchanges-evm';
13
+ import { route } from '@depay/web3-exchanges-evm';
15
14
  import { Token } from '@depay/web3-tokens-evm';
16
15
  import { ethers } from 'ethers';
17
16
  import { Decimal } from 'decimal.js';
17
+ import { route as route$1 } from '@depay/web3-payments-evm';
18
18
  import { TokenImage } from '@depay/react-token-image-evm';
19
19
 
20
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -3953,8 +3953,8 @@ var MenuIcon = (function (props) {
3953
3953
  }));
3954
3954
  });
3955
3955
 
3956
- function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3957
- function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3956
+ function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3957
+ function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3958
3958
  var SelectWalletList = (function (props) {
3959
3959
  var parentElement = React.useRef();
3960
3960
  var fuse = new Fuse(allWallets, {
@@ -4015,7 +4015,7 @@ var SelectWalletList = (function (props) {
4015
4015
  className: "Card small",
4016
4016
  title: "Connect ".concat(resultList[virtualItem.key].name),
4017
4017
  onClick: function onClick() {
4018
- props.onClickWallet(_objectSpread$6({}, resultList[virtualItem.key]));
4018
+ props.onClickWallet(_objectSpread$7({}, resultList[virtualItem.key]));
4019
4019
  }
4020
4020
  }, /*#__PURE__*/React.createElement("div", {
4021
4021
  className: "CardImage"
@@ -4032,8 +4032,8 @@ var SelectWalletList = (function (props) {
4032
4032
  })));
4033
4033
  });
4034
4034
 
4035
- function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4036
- function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4035
+ function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4036
+ function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4037
4037
  var SelectWalletDialog = (function (props) {
4038
4038
  var _useState = useState(''),
4039
4039
  _useState2 = _slicedToArray(_useState, 2),
@@ -4129,7 +4129,7 @@ var SelectWalletDialog = (function (props) {
4129
4129
  className: "Card small",
4130
4130
  title: "Connect ".concat(walletMetaData.name),
4131
4131
  onClick: function onClick() {
4132
- onClickWallet(_objectSpread$5(_objectSpread$5({}, walletMetaData), {}, {
4132
+ onClickWallet(_objectSpread$6(_objectSpread$6({}, walletMetaData), {}, {
4133
4133
  via: 'detected',
4134
4134
  connectionType: connectionType
4135
4135
  }), wallet);
@@ -4164,7 +4164,7 @@ var SelectWalletDialog = (function (props) {
4164
4164
  className: "Card small",
4165
4165
  title: "Connect ".concat(previouslyConnectedWallet.name),
4166
4166
  onClick: function onClick() {
4167
- onClickWallet(_objectSpread$5(_objectSpread$5({}, previouslyConnectedWallet), {}, {
4167
+ onClickWallet(_objectSpread$6(_objectSpread$6({}, previouslyConnectedWallet), {}, {
4168
4168
  via: 'previouslyConnected',
4169
4169
  connectionType: 'app'
4170
4170
  }));
@@ -4614,7 +4614,7 @@ class Dialog extends React.Component {
4614
4614
  const classNames = ['ReactDialog', this.state.open ? 'ReactDialogOpen' : ''];
4615
4615
  const style = ReactDialogStyle({ background: this.props.background });
4616
4616
  return (
4617
- React.createElement('div', { className: classNames.join(' '), __self: this, __source: {fileName: _jsxFileName$1, lineNumber: 55}}
4617
+ React.createElement('div', { key: this.props.dialogKey, className: classNames.join(' '), __self: this, __source: {fileName: _jsxFileName$1, lineNumber: 55}}
4618
4618
  , React.createElement('style', {__self: this, __source: {fileName: _jsxFileName$1, lineNumber: 56}}, style)
4619
4619
  , React.createElement('div', { className: "ReactDialogInner", __self: this, __source: {fileName: _jsxFileName$1, lineNumber: 57}}
4620
4620
  , React.createElement('div', { className: "ReactDialogBackground", onClick: this.onClickBackground.bind(this), __self: this, __source: {fileName: _jsxFileName$1, lineNumber: 58}} )
@@ -5116,39 +5116,6 @@ var NavigateProvider = (function (props) {
5116
5116
  }, props.children);
5117
5117
  });
5118
5118
 
5119
- function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5120
- function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5121
- var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
5122
- var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
5123
- var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
5124
- return _objectSpread$4(_objectSpread$4({}, accept), {}, {
5125
- toAddress: toAddress,
5126
- toContract: toContract
5127
- });
5128
- };
5129
- var mergeFromAccounts = function mergeFromAccounts(accept, account) {
5130
- var from = {};
5131
- accept.forEach(function (accept) {
5132
- from[accept.blockchain] = account;
5133
- });
5134
- return from;
5135
- };
5136
- var routePayments = (function (_ref) {
5137
- var accept = _ref.accept,
5138
- account = _ref.account,
5139
- whitelist = _ref.whitelist,
5140
- blacklist = _ref.blacklist,
5141
- fee = _ref.fee;
5142
- return route({
5143
- accept: accept.map(prepareAcceptedPayments),
5144
- from: mergeFromAccounts(accept, account),
5145
- whitelist: whitelist,
5146
- blacklist: blacklist,
5147
- event: 'ifRoutedAndNative',
5148
- fee: fee
5149
- });
5150
- });
5151
-
5152
5119
  var Loading = /*#__PURE__*/function () {
5153
5120
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref) {
5154
5121
  var text, style, error, critical, container, document, unmount;
@@ -5316,6 +5283,146 @@ var LoginStack = (function (props) {
5316
5283
  });
5317
5284
  });
5318
5285
 
5286
+ var round = (function (input) {
5287
+ var _digitsAfterDecimal;
5288
+ var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'up';
5289
+ var inputAsFloat = parseFloat(input);
5290
+ var digitsAfterDecimal = inputAsFloat.toString().match(/\d+\.0*(\d{4})/);
5291
+ if ((_digitsAfterDecimal = digitsAfterDecimal) !== null && _digitsAfterDecimal !== void 0 && _digitsAfterDecimal.length) {
5292
+ digitsAfterDecimal = digitsAfterDecimal[0];
5293
+ var focus = digitsAfterDecimal.match(/\d{4}$/)[0];
5294
+ var _float;
5295
+ var focusToFixed;
5296
+ if (focus.match(/^0/)) {
5297
+ if (direction == 'up') {
5298
+ _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
5299
+ } else {
5300
+ _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
5301
+ }
5302
+ focusToFixed = parseFloat(_float).toFixed(2);
5303
+ focusToFixed = "0".concat(focusToFixed).replace('.', '');
5304
+ } else {
5305
+ if (direction == 'up') {
5306
+ _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2], "9"));
5307
+ } else {
5308
+ _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2], "1"));
5309
+ }
5310
+ focusToFixed = parseFloat(_float).toFixed(2).replace('.', '');
5311
+ }
5312
+ if (focusToFixed == '0999' && parseInt(inputAsFloat.toFixed(0)) == 0) {
5313
+ focusToFixed = direction == 'up' ? '1000' : '0999';
5314
+ return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
5315
+ } else if (focusToFixed == '1000' && parseInt(inputAsFloat.toFixed(0)) == 0) {
5316
+ return parseFloat(digitsAfterDecimal.replace(/\d{5}$/, focusToFixed));
5317
+ } else if (focusToFixed.toString()[0] != "0" && focusToFixed.toString().length > 3) {
5318
+ return parseInt(inputAsFloat.toFixed(0));
5319
+ } else {
5320
+ return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
5321
+ }
5322
+ } else {
5323
+ return parseFloat(inputAsFloat.toFixed(3));
5324
+ }
5325
+ });
5326
+
5327
+ var format = (function (input) {
5328
+ var _float = round(input);
5329
+ var floatToString = _float.toString();
5330
+ if (new RegExp(/\./).test(floatToString)) {
5331
+ var exploded = floatToString.split('.');
5332
+ return new Intl.NumberFormat().format(parseInt(exploded[0])) + '.' + exploded[1];
5333
+ } else {
5334
+ return new Intl.NumberFormat().format(_float);
5335
+ }
5336
+ });
5337
+
5338
+ var PaymentBlockchainsDialog = (function () {
5339
+ var _useContext = useContext(ConfigurationContext),
5340
+ accept = _useContext.accept;
5341
+ var _useContext2 = useContext(NavigateStackContext),
5342
+ navigate = _useContext2.navigate;
5343
+ var blockchains = _toConsumableArray(new Set(accept.map(function (configuration) {
5344
+ return configuration.blockchain;
5345
+ }))).map(function (blockchainName) {
5346
+ return Blockchains[blockchainName];
5347
+ });
5348
+ return /*#__PURE__*/React.createElement(Dialog$1, {
5349
+ stacked: true,
5350
+ header: /*#__PURE__*/React.createElement("div", {
5351
+ className: "PaddingTopS PaddingLeftM PaddingRightM"
5352
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", {
5353
+ className: "LineHeightL FontSizeL"
5354
+ }, "Available blockchains"))),
5355
+ body: /*#__PURE__*/React.createElement("div", {
5356
+ className: "MaxHeight PaddingTopM PaddingBottomM"
5357
+ }, blockchains.map(function (blockchain, index) {
5358
+ return /*#__PURE__*/React.createElement("div", {
5359
+ key: index,
5360
+ className: "Card Row"
5361
+ }, /*#__PURE__*/React.createElement("div", {
5362
+ className: "CardImage"
5363
+ }, /*#__PURE__*/React.createElement("img", {
5364
+ className: "transparent",
5365
+ src: blockchain.logo
5366
+ })), /*#__PURE__*/React.createElement("div", {
5367
+ className: "CardBody"
5368
+ }, /*#__PURE__*/React.createElement("span", {
5369
+ className: "CardText"
5370
+ }, blockchain.label)));
5371
+ })),
5372
+ footer: /*#__PURE__*/React.createElement("div", {
5373
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
5374
+ }, /*#__PURE__*/React.createElement("button", {
5375
+ type: "button",
5376
+ className: "ButtonPrimary",
5377
+ onClick: function onClick() {
5378
+ return navigate('back');
5379
+ }
5380
+ }, /*#__PURE__*/React.createElement("span", {
5381
+ className: "FontSizeM"
5382
+ }, "\u276E"), " Go back"))
5383
+ });
5384
+ });
5385
+
5386
+ var WalletMissesBlockchainSupportDialog = (function (props) {
5387
+ var _useContext = useContext(NavigateStackContext),
5388
+ navigate = _useContext.navigate;
5389
+ return /*#__PURE__*/React.createElement(Dialog$1, {
5390
+ header: /*#__PURE__*/React.createElement("div", {
5391
+ className: "PaddingTopS PaddingLeftM PaddingRightM"
5392
+ }),
5393
+ body: /*#__PURE__*/React.createElement("div", {
5394
+ className: "TextCenter"
5395
+ }, /*#__PURE__*/React.createElement("div", {
5396
+ className: "GraphicWrapper"
5397
+ }, /*#__PURE__*/React.createElement("img", {
5398
+ className: "Graphic",
5399
+ src: QuestionsGraphic
5400
+ })), /*#__PURE__*/React.createElement("h1", {
5401
+ className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
5402
+ }, "Wallet Misses Blockchain Support"), /*#__PURE__*/React.createElement("div", {
5403
+ className: "Text PaddingTopS PaddingBottomS PaddingLeftM PaddingRightM"
5404
+ }, /*#__PURE__*/React.createElement("strong", {
5405
+ className: "FontSizeM"
5406
+ }, "The connected wallet does not support the blockchains required by this payment. Try to connect another wallet that does support one of the available blockchains.")), /*#__PURE__*/React.createElement("div", {
5407
+ className: "PaddingBottomM"
5408
+ }, /*#__PURE__*/React.createElement("button", {
5409
+ onClick: function onClick() {
5410
+ return navigate('PaymentBlockchains');
5411
+ },
5412
+ className: "Link FontSizeM",
5413
+ title: "Check which blockchains are available"
5414
+ }, "Check available blockchains"))),
5415
+ footer: /*#__PURE__*/React.createElement("div", {
5416
+ className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
5417
+ }, /*#__PURE__*/React.createElement("button", {
5418
+ className: "ButtonPrimary",
5419
+ onClick: function onClick() {
5420
+ return props.disconnect();
5421
+ }
5422
+ }, "Connect another wallet"))
5423
+ });
5424
+ });
5425
+
5319
5426
  /**
5320
5427
  * @license
5321
5428
  * Lodash <https://lodash.com/>
@@ -22516,26 +22623,39 @@ var lodash = createCommonjsModule(function (module, exports) {
22516
22623
  });
22517
22624
 
22518
22625
  var WalletProvider = (function (props) {
22519
- var _useContext = useContext(ConfigurationContext),
22520
- recover = _useContext.recover,
22521
- passedWallet = _useContext.wallet;
22522
- var _useContext2 = useContext(ErrorContext);
22523
- _useContext2.setError;
22626
+ var _useContext = useContext(ClosableContext),
22627
+ open = _useContext.open,
22628
+ close = _useContext.close;
22629
+ var _useContext2 = useContext(ConfigurationContext),
22630
+ accept = _useContext2.accept,
22631
+ recover = _useContext2.recover,
22632
+ passedWallet = _useContext2.wallet;
22633
+ var _useContext3 = useContext(UpdatableContext),
22634
+ setUpdatable = _useContext3.setUpdatable;
22635
+ var _useContext4 = useContext(ErrorContext);
22636
+ _useContext4.setError;
22524
22637
  var _useState = useState(passedWallet),
22525
22638
  _useState2 = _slicedToArray(_useState, 2),
22526
22639
  wallet = _useState2[0],
22527
22640
  setWallet = _useState2[1];
22528
- var _useState3 = useState(),
22641
+ var _useState3 = useState(false),
22529
22642
  _useState4 = _slicedToArray(_useState3, 2),
22530
- account = _useState4[0],
22531
- setAccount = _useState4[1];
22532
- var _useState5 = useState(passedWallet ? 'connected' : undefined),
22643
+ walletMissesBlockchainSupport = _useState4[0],
22644
+ setWalletMissesBlockchainSupport = _useState4[1];
22645
+ var _useState5 = useState(),
22533
22646
  _useState6 = _slicedToArray(_useState5, 2),
22534
- walletState = _useState6[0],
22535
- setWalletState = _useState6[1];
22647
+ account = _useState6[0],
22648
+ setAccount = _useState6[1];
22649
+ var _useState7 = useState(passedWallet ? 'connected' : undefined),
22650
+ _useState8 = _slicedToArray(_useState7, 2),
22651
+ walletState = _useState8[0],
22652
+ setWalletState = _useState8[1];
22536
22653
  var connect = useCallback(lodash.debounce(function () {
22537
22654
  wallet.connect().then(setAccount);
22538
22655
  }));
22656
+ var debounceSetWalletMissesBlockchainSupport = useCallback(lodash.debounce(function (value) {
22657
+ setWalletMissesBlockchainSupport(value);
22658
+ }));
22539
22659
  var connected = function connected(_ref) {
22540
22660
  var account = _ref.account,
22541
22661
  wallet = _ref.wallet;
@@ -22552,11 +22672,21 @@ var WalletProvider = (function (props) {
22552
22672
  setAccount();
22553
22673
  setWallet();
22554
22674
  setWalletState();
22675
+ setWalletMissesBlockchainSupport(false);
22555
22676
  };
22556
22677
  useEffect(function () {
22557
22678
  if (!wallet) {
22558
22679
  return;
22559
22680
  }
22681
+ if (accept && !accept.some(function (configuration) {
22682
+ return wallet.blockchains.includes(configuration.blockchain);
22683
+ })) {
22684
+ setUpdatable(false);
22685
+ setTimeout(function () {
22686
+ return debounceSetWalletMissesBlockchainSupport(true);
22687
+ }, 200);
22688
+ return;
22689
+ }
22560
22690
  var onAccountChanged = function onAccountChanged(account) {
22561
22691
  if (account) {
22562
22692
  setAccount(account);
@@ -22596,7 +22726,21 @@ var WalletProvider = (function (props) {
22596
22726
  }, _callee);
22597
22727
  }))();
22598
22728
  }, []);
22599
- if (walletState == 'connected' || recover != undefined) {
22729
+ if (walletMissesBlockchainSupport) {
22730
+ return /*#__PURE__*/React.createElement(ReactDialogStack, {
22731
+ open: open,
22732
+ close: close,
22733
+ start: "WalletMissesBlockchainSupport",
22734
+ container: props.container,
22735
+ document: props.document,
22736
+ dialogs: {
22737
+ WalletMissesBlockchainSupport: /*#__PURE__*/React.createElement(WalletMissesBlockchainSupportDialog, {
22738
+ disconnect: disconnect
22739
+ }),
22740
+ PaymentBlockchains: /*#__PURE__*/React.createElement(PaymentBlockchainsDialog, null)
22741
+ }
22742
+ });
22743
+ } else if (walletState == 'connected' || recover != undefined) {
22600
22744
  return /*#__PURE__*/React.createElement(WalletContext.Provider, {
22601
22745
  value: {
22602
22746
  account: account,
@@ -22712,47 +22856,8 @@ var findMaxRoute = (function (routes) {
22712
22856
  return sortedLowToHigh[sortedLowToHigh.length - 1];
22713
22857
  });
22714
22858
 
22715
- var round = (function (input) {
22716
- var _digitsAfterDecimal;
22717
- var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'up';
22718
- var inputAsFloat = parseFloat(input);
22719
- var digitsAfterDecimal = inputAsFloat.toString().match(/\d+\.0*(\d{4})/);
22720
- if ((_digitsAfterDecimal = digitsAfterDecimal) !== null && _digitsAfterDecimal !== void 0 && _digitsAfterDecimal.length) {
22721
- digitsAfterDecimal = digitsAfterDecimal[0];
22722
- var focus = digitsAfterDecimal.match(/\d{4}$/)[0];
22723
- var _float;
22724
- var focusToFixed;
22725
- if (focus.match(/^0/)) {
22726
- if (direction == 'up') {
22727
- _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
22728
- } else {
22729
- _float = parseFloat("".concat(focus[1], ".").concat(focus[2]).concat(focus[3]));
22730
- }
22731
- focusToFixed = parseFloat(_float).toFixed(2);
22732
- focusToFixed = "0".concat(focusToFixed).replace('.', '');
22733
- } else {
22734
- if (direction == 'up') {
22735
- _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2], "9"));
22736
- } else {
22737
- _float = parseFloat("".concat(focus[0], ".").concat(focus[1]).concat(focus[2], "1"));
22738
- }
22739
- focusToFixed = parseFloat(_float).toFixed(2).replace('.', '');
22740
- }
22741
- if (focusToFixed == '0999' && parseInt(inputAsFloat.toFixed(0)) == 0) {
22742
- focusToFixed = direction == 'up' ? '1000' : '0999';
22743
- return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
22744
- } else if (focusToFixed == '1000' && parseInt(inputAsFloat.toFixed(0)) == 0) {
22745
- return parseFloat(digitsAfterDecimal.replace(/\d{5}$/, focusToFixed));
22746
- } else if (focusToFixed.toString()[0] != "0" && focusToFixed.toString().length > 3) {
22747
- return parseInt(inputAsFloat.toFixed(0));
22748
- } else {
22749
- return parseFloat(digitsAfterDecimal.replace(/\d{4}$/, focusToFixed));
22750
- }
22751
- } else {
22752
- return parseFloat(inputAsFloat.toFixed(3));
22753
- }
22754
- });
22755
-
22859
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
22860
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22756
22861
  var ChangableAmountProvider = (function (props) {
22757
22862
  var configurationsMissAmounts = function configurationsMissAmounts(configurations) {
22758
22863
  return !configurations.every(function (configuration) {
@@ -22827,7 +22932,7 @@ var ChangableAmountProvider = (function (props) {
22827
22932
  if (Blockchains[configuration.blockchain].stables.usd[0] == configuration.token) {
22828
22933
  return 1.00 / fixedCurrencyConversionRate * fixedAmount;
22829
22934
  } else {
22830
- return route$1({
22935
+ return route({
22831
22936
  blockchain: configuration.blockchain,
22832
22937
  tokenIn: Blockchains[configuration.blockchain].stables.usd[0],
22833
22938
  amountIn: 1.00 / fixedCurrencyConversionRate * fixedAmount,
@@ -22840,7 +22945,7 @@ var ChangableAmountProvider = (function (props) {
22840
22945
  if (Blockchains[configuration.blockchain].stables.usd[0] == configuration.token) {
22841
22946
  return 1.00 / conversionRate * amount;
22842
22947
  } else {
22843
- return route$1({
22948
+ return route({
22844
22949
  blockchain: configuration.blockchain,
22845
22950
  tokenIn: Blockchains[configuration.blockchain].stables.usd[0],
22846
22951
  amountIn: 1.00 / conversionRate * amount,
@@ -22869,8 +22974,8 @@ var ChangableAmountProvider = (function (props) {
22869
22974
  });
22870
22975
  };
22871
22976
  var updateAmounts = useCallback(lodash.debounce(function (_ref2) {
22872
- var account = _ref2.account,
22873
- amount = _ref2.amount,
22977
+ _ref2.account;
22978
+ var amount = _ref2.amount,
22874
22979
  conversionRate = _ref2.conversionRate,
22875
22980
  fixedCurrencyConversionRate = _ref2.fixedCurrencyConversionRate;
22876
22981
  getAmounts({
@@ -22882,12 +22987,9 @@ var ChangableAmountProvider = (function (props) {
22882
22987
  if (amounts[index] == undefined) {
22883
22988
  return;
22884
22989
  }
22885
- return {
22886
- blockchain: configuration.blockchain,
22887
- amount: round(amounts[index]),
22888
- token: configuration.token,
22889
- receiver: configuration.receiver || account
22890
- };
22990
+ return _objectSpread$5(_objectSpread$5({}, configuration), {}, {
22991
+ amount: round(amounts[index])
22992
+ });
22891
22993
  }).filter(function (configuration) {
22892
22994
  return !!configuration;
22893
22995
  }));
@@ -22910,7 +23012,7 @@ var ChangableAmountProvider = (function (props) {
22910
23012
  if (amountsMissing && maxRoute) {
22911
23013
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
22912
23014
  if (configuredAmount && configuredAmount.token) {
22913
- route$1({
23015
+ route({
22914
23016
  blockchain: maxRoute.blockchain,
22915
23017
  tokenIn: maxRoute.fromToken.address,
22916
23018
  tokenOut: maxRoute.toToken.address,
@@ -22940,7 +23042,7 @@ var ChangableAmountProvider = (function (props) {
22940
23042
  var _maxAmount = parseFloat(new Decimal(readableMaxAmount).mul(conversionRate).toString());
22941
23043
  setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount - 1) : _maxAmount - 1);
22942
23044
  } else {
22943
- route$1({
23045
+ route({
22944
23046
  blockchain: maxRoute.blockchain,
22945
23047
  tokenIn: maxRoute.fromToken.address,
22946
23048
  tokenOut: Blockchains[maxRoute.blockchain].stables.usd[0],
@@ -23021,106 +23123,38 @@ var ConversionRateProvider = (function (props) {
23021
23123
 
23022
23124
  var PaymentAmountRoutingContext = /*#__PURE__*/React.createContext();
23023
23125
 
23024
- var format = (function (input) {
23025
- var _float = round(input);
23026
- var floatToString = _float.toString();
23027
- if (new RegExp(/\./).test(floatToString)) {
23028
- var exploded = floatToString.split('.');
23029
- return new Intl.NumberFormat().format(parseInt(exploded[0])) + '.' + exploded[1];
23030
- } else {
23031
- return new Intl.NumberFormat().format(_float);
23032
- }
23033
- });
23126
+ var PaymentRoutingContext = /*#__PURE__*/React.createContext();
23034
23127
 
23035
- var PaymentBlockchainsDialog = (function () {
23036
- var _useContext = useContext(ConfigurationContext),
23037
- accept = _useContext.accept;
23038
- var _useContext2 = useContext(NavigateStackContext),
23039
- navigate = _useContext2.navigate;
23040
- var blockchains = _toConsumableArray(new Set(accept.map(function (configuration) {
23041
- return configuration.blockchain;
23042
- }))).map(function (blockchainName) {
23043
- return Blockchains[blockchainName];
23128
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23129
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23130
+ var prepareAcceptedPayments = function prepareAcceptedPayments(accept) {
23131
+ var toAddress = _typeof(accept.receiver) == 'object' ? accept.receiver.address : accept.receiver;
23132
+ var toContract = _typeof(accept.receiver) == 'object' ? accept.receiver : undefined;
23133
+ return _objectSpread$4(_objectSpread$4({}, accept), {}, {
23134
+ toAddress: toAddress,
23135
+ toContract: toContract
23044
23136
  });
23045
- return /*#__PURE__*/React.createElement(Dialog$1, {
23046
- stacked: true,
23047
- header: /*#__PURE__*/React.createElement("div", {
23048
- className: "PaddingTopS PaddingLeftM PaddingRightM"
23049
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", {
23050
- className: "LineHeightL FontSizeL"
23051
- }, "Available blockchains"))),
23052
- body: /*#__PURE__*/React.createElement("div", {
23053
- className: "MaxHeight PaddingTopM PaddingBottomM"
23054
- }, blockchains.map(function (blockchain, index) {
23055
- return /*#__PURE__*/React.createElement("div", {
23056
- key: index,
23057
- className: "Card Row"
23058
- }, /*#__PURE__*/React.createElement("div", {
23059
- className: "CardImage"
23060
- }, /*#__PURE__*/React.createElement("img", {
23061
- className: "transparent",
23062
- src: blockchain.logo
23063
- })), /*#__PURE__*/React.createElement("div", {
23064
- className: "CardBody"
23065
- }, /*#__PURE__*/React.createElement("span", {
23066
- className: "CardText"
23067
- }, blockchain.label)));
23068
- })),
23069
- footer: /*#__PURE__*/React.createElement("div", {
23070
- className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
23071
- }, /*#__PURE__*/React.createElement("button", {
23072
- type: "button",
23073
- className: "ButtonPrimary",
23074
- onClick: function onClick() {
23075
- return navigate('back');
23076
- }
23077
- }, /*#__PURE__*/React.createElement("span", {
23078
- className: "FontSizeM"
23079
- }, "\u276E"), " Go back"))
23137
+ };
23138
+ var mergeFromAccounts = function mergeFromAccounts(accept, account) {
23139
+ var from = {};
23140
+ accept.forEach(function (accept) {
23141
+ from[accept.blockchain] = account;
23080
23142
  });
23081
- });
23082
-
23083
- var PaymentRoutingContext = /*#__PURE__*/React.createContext();
23084
-
23085
- var WalletMissesBlockchainSupportDialog = (function () {
23086
- var _useContext = useContext(NavigateStackContext),
23087
- navigate = _useContext.navigate;
23088
- var _useContext2 = useContext(WalletContext),
23089
- disconnect = _useContext2.disconnect;
23090
- return /*#__PURE__*/React.createElement(Dialog$1, {
23091
- header: /*#__PURE__*/React.createElement("div", {
23092
- className: "PaddingTopS PaddingLeftM PaddingRightM"
23093
- }),
23094
- body: /*#__PURE__*/React.createElement("div", {
23095
- className: "TextCenter"
23096
- }, /*#__PURE__*/React.createElement("div", {
23097
- className: "GraphicWrapper"
23098
- }, /*#__PURE__*/React.createElement("img", {
23099
- className: "Graphic",
23100
- src: QuestionsGraphic
23101
- })), /*#__PURE__*/React.createElement("h1", {
23102
- className: "LineHeightL Text FontSizeL PaddingTopS FontWeightBold"
23103
- }, "Wallet Misses Blockchain Support"), /*#__PURE__*/React.createElement("div", {
23104
- className: "Text PaddingTopS PaddingBottomS PaddingLeftM PaddingRightM"
23105
- }, /*#__PURE__*/React.createElement("strong", {
23106
- className: "FontSizeM"
23107
- }, "The connected wallet does not support the blockchains required by this payment. Try to connect another wallet that does support one of the available blockchains.")), /*#__PURE__*/React.createElement("div", {
23108
- className: "PaddingBottomM"
23109
- }, /*#__PURE__*/React.createElement("button", {
23110
- onClick: function onClick() {
23111
- return navigate('PaymentBlockchains');
23112
- },
23113
- className: "Link FontSizeM",
23114
- title: "Check which blockchains are available"
23115
- }, "Check available blockchains"))),
23116
- footer: /*#__PURE__*/React.createElement("div", {
23117
- className: "PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM"
23118
- }, /*#__PURE__*/React.createElement("button", {
23119
- className: "ButtonPrimary",
23120
- onClick: function onClick() {
23121
- return disconnect();
23122
- }
23123
- }, "Connect another wallet"))
23143
+ return from;
23144
+ };
23145
+ var routePayments = (function (_ref) {
23146
+ var accept = _ref.accept,
23147
+ account = _ref.account,
23148
+ whitelist = _ref.whitelist,
23149
+ blacklist = _ref.blacklist,
23150
+ fee = _ref.fee;
23151
+ return route$1({
23152
+ accept: accept.map(prepareAcceptedPayments),
23153
+ from: mergeFromAccounts(accept, account),
23154
+ whitelist: whitelist,
23155
+ blacklist: blacklist,
23156
+ event: 'ifRoutedAndNative',
23157
+ fee: fee
23124
23158
  });
23125
23159
  });
23126
23160
 
@@ -23147,20 +23181,12 @@ var PaymentRoutingProvider = (function (props) {
23147
23181
  _useState10 = _slicedToArray(_useState9, 2),
23148
23182
  reloadCount = _useState10[0],
23149
23183
  setReloadCount = _useState10[1];
23150
- var _useState11 = useState(false),
23151
- _useState12 = _slicedToArray(_useState11, 2),
23152
- walletMissesBlockchainSupport = _useState12[0],
23153
- setWalletMissesBlockchainSupport = _useState12[1];
23154
23184
  var _useContext = useContext(WalletContext),
23155
- wallet = _useContext.wallet,
23156
23185
  account = _useContext.account;
23157
23186
  var _useContext2 = useContext(UpdatableContext),
23158
23187
  updatable = _useContext2.updatable;
23159
23188
  var _useContext3 = useContext(ConfigurationContext),
23160
23189
  recover = _useContext3.recover;
23161
- var _useContext4 = useContext(ClosableContext),
23162
- open = _useContext4.open,
23163
- close = _useContext4.close;
23164
23190
  var onRoutesUpdate = /*#__PURE__*/function () {
23165
23191
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(routes) {
23166
23192
  return regenerator.wrap(function _callee2$(_context2) {
@@ -23235,27 +23261,19 @@ var PaymentRoutingProvider = (function (props) {
23235
23261
  }
23236
23262
  return _context3.abrupt("return");
23237
23263
  case 3:
23238
- if (props.accept.some(function (configuration) {
23239
- return wallet.blockchains.includes(configuration.blockchain);
23240
- })) {
23241
- _context3.next = 5;
23242
- break;
23243
- }
23244
- return _context3.abrupt("return", setWalletMissesBlockchainSupport(true));
23245
- case 5:
23246
23264
  slowRoutingTimeout = setTimeout(function () {
23247
23265
  setSlowRouting(true);
23248
23266
  }, 4000);
23249
- _context3.next = 8;
23267
+ _context3.next = 6;
23250
23268
  return routePayments(Object.assign({}, props, {
23251
23269
  account: account
23252
23270
  })).then(function (routes) {
23253
23271
  clearInterval(slowRoutingTimeout);
23254
23272
  onRoutesUpdate(routes);
23255
23273
  });
23256
- case 8:
23274
+ case 6:
23257
23275
  return _context3.abrupt("return", _context3.sent);
23258
- case 9:
23276
+ case 7:
23259
23277
  case "end":
23260
23278
  return _context3.stop();
23261
23279
  }
@@ -23360,32 +23378,18 @@ var PaymentRoutingProvider = (function (props) {
23360
23378
  refreshPaymentRoutes();
23361
23379
  }
23362
23380
  }, [account, props.accept]);
23363
- if (walletMissesBlockchainSupport) {
23364
- return /*#__PURE__*/React.createElement(ReactDialogStack, {
23365
- open: open,
23366
- close: close,
23367
- start: "WalletMissesBlockchainSupport",
23368
- container: props.container,
23369
- document: props.document,
23370
- dialogs: {
23371
- WalletMissesBlockchainSupport: /*#__PURE__*/React.createElement(WalletMissesBlockchainSupportDialog, null),
23372
- PaymentBlockchains: /*#__PURE__*/React.createElement(PaymentBlockchainsDialog, null)
23373
- }
23374
- });
23375
- } else {
23376
- return /*#__PURE__*/React.createElement(PaymentRoutingContext.Provider, {
23377
- value: {
23378
- selectedRoute: selectedRoute,
23379
- setSelectedRoute: setSelectedRoute,
23380
- refreshPaymentRoutes: refreshPaymentRoutes,
23381
- allRoutes: allRoutes,
23382
- setAllRoutes: setAllRoutes,
23383
- slowRouting: slowRouting,
23384
- updatedRouteWithNewPrice: updatedRouteWithNewPrice,
23385
- updateRouteWithNewPrice: updateRouteWithNewPrice
23386
- }
23387
- }, props.children);
23388
- }
23381
+ return /*#__PURE__*/React.createElement(PaymentRoutingContext.Provider, {
23382
+ value: {
23383
+ selectedRoute: selectedRoute,
23384
+ setSelectedRoute: setSelectedRoute,
23385
+ refreshPaymentRoutes: refreshPaymentRoutes,
23386
+ allRoutes: allRoutes,
23387
+ setAllRoutes: setAllRoutes,
23388
+ slowRouting: slowRouting,
23389
+ updatedRouteWithNewPrice: updatedRouteWithNewPrice,
23390
+ updateRouteWithNewPrice: updateRouteWithNewPrice
23391
+ }
23392
+ }, props.children);
23389
23393
  });
23390
23394
 
23391
23395
  var PaymentAmountRoutingProvider = (function (props) {
@@ -25477,7 +25481,7 @@ var PaymentValueProvider = (function (props) {
25477
25481
  setPaymentValue(null);
25478
25482
  setPaymentValueLoss(null);
25479
25483
  Promise.all([Promise.all(Blockchains[payment.route.blockchain].stables.usd.map(function (stable) {
25480
- return route$1({
25484
+ return route({
25481
25485
  blockchain: payment.route.blockchain,
25482
25486
  tokenIn: payment.route.fromToken.address,
25483
25487
  tokenOut: stable,
@@ -25485,7 +25489,7 @@ var PaymentValueProvider = (function (props) {
25485
25489
  fromAddress: account,
25486
25490
  toAddress: account
25487
25491
  });
25488
- })), !payment.route.directTransfer ? route$1({
25492
+ })), !payment.route.directTransfer ? route({
25489
25493
  blockchain: payment.route.blockchain,
25490
25494
  tokenIn: payment.route.toToken.address,
25491
25495
  tokenOut: payment.route.fromToken.address,
@@ -25841,11 +25845,11 @@ var preflight$1 = /*#__PURE__*/function () {
25841
25845
  }();
25842
25846
  var Payment = /*#__PURE__*/function () {
25843
25847
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref3) {
25844
- var accept, amount, sent, succeeded, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, fee, recover, closable, integration, link, container, before, wallet, title, action, document, unmount;
25848
+ var accept, amount, sent, succeeded, validated, failed, error, critical, style, whitelist, blacklist, providers, currency, connected, closed, track, recover, closable, integration, link, container, before, wallet, title, action, document, unmount;
25845
25849
  return regenerator.wrap(function _callee2$(_context2) {
25846
25850
  while (1) switch (_context2.prev = _context2.next) {
25847
25851
  case 0:
25848
- accept = _ref3.accept, amount = _ref3.amount, sent = _ref3.sent, succeeded = _ref3.succeeded, validated = _ref3.validated, 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, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, before = _ref3.before, wallet = _ref3.wallet, title = _ref3.title, action = _ref3.action, document = _ref3.document;
25852
+ accept = _ref3.accept, amount = _ref3.amount, sent = _ref3.sent, succeeded = _ref3.succeeded, validated = _ref3.validated, 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, recover = _ref3.recover, closable = _ref3.closable, integration = _ref3.integration, link = _ref3.link, container = _ref3.container, before = _ref3.before, wallet = _ref3.wallet, title = _ref3.title, action = _ref3.action, document = _ref3.document;
25849
25853
  requireReactVersion();
25850
25854
  if (currency && !SUPPORTED_CURRENCIES.includes(currency.toLowerCase())) {
25851
25855
  currency = false;
@@ -25887,7 +25891,6 @@ var Payment = /*#__PURE__*/function () {
25887
25891
  blacklist: blacklist,
25888
25892
  providers: providers,
25889
25893
  track: track,
25890
- fee: fee,
25891
25894
  recover: recover,
25892
25895
  integration: integration,
25893
25896
  link: link,
@@ -25910,7 +25913,6 @@ var Payment = /*#__PURE__*/function () {
25910
25913
  whitelist: whitelist,
25911
25914
  blacklist: blacklist,
25912
25915
  event: event,
25913
- fee: fee,
25914
25916
  container: container,
25915
25917
  document: document
25916
25918
  }, /*#__PURE__*/React.createElement(TransactionTrackingProvider, null, /*#__PURE__*/React.createElement(PaymentTrackingProvider, {
@@ -25950,13 +25952,11 @@ Payment.preload = function (_ref5) {
25950
25952
  whitelist = _ref5.whitelist,
25951
25953
  blacklist = _ref5.blacklist;
25952
25954
  _ref5.event;
25953
- var fee = _ref5.fee;
25954
25955
  routePayments({
25955
25956
  account: account,
25956
25957
  accept: accept,
25957
25958
  whitelist: whitelist,
25958
- blacklist: blacklist,
25959
- fee: fee
25959
+ blacklist: blacklist
25960
25960
  });
25961
25961
  };
25962
25962
 
@@ -27191,7 +27191,6 @@ var SelectNFTStack = (function (props) {
27191
27191
  }),
27192
27192
  SelectBlockchain: /*#__PURE__*/React.createElement(SelectBlockchainDialog, {
27193
27193
  selection: selection,
27194
- stacked: true,
27195
27194
  resolve: props.resolve,
27196
27195
  unmount: props.unmount
27197
27196
  }),
@@ -27617,7 +27616,8 @@ var SelectTokenStack = (function (props) {
27617
27616
  }),
27618
27617
  SelectBlockchain: /*#__PURE__*/React.createElement(SelectBlockchainDialog, {
27619
27618
  selection: selection,
27620
- resolve: props.resolve
27619
+ resolve: props.resolve,
27620
+ unmount: props.unmount
27621
27621
  }),
27622
27622
  ConfirmTokenSelection: /*#__PURE__*/React.createElement(ConfirmTokenSelectionDialog, {
27623
27623
  selection: selection,