@depay/widgets 6.10.0 → 6.11.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
@@ -662,6 +662,17 @@ alongside values for `start`, `min` and `step`.
662
662
 
663
663
  `step`: The number by wich to increment/decremten changes to the amount.
664
664
 
665
+ `token`: Set to `true` if you want amount selection to be denominated in the token you're selling, e.g.:
666
+
667
+ ```javascript
668
+ DePayWidgets.Sale({
669
+ sell: {...},
670
+ amount: {
671
+ token: true
672
+ }
673
+ });
674
+ ```
675
+
665
676
  #### connected
666
677
 
667
678
  `connected`
@@ -49477,7 +49477,7 @@ var ButtonPrimaryStyle = (function (style) {
49477
49477
  });
49478
49478
 
49479
49479
  var CardStyle = (function (style) {
49480
- return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.26rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
49480
+ return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.1rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
49481
49481
  });
49482
49482
 
49483
49483
  var DialogStyle = (function (style) {
@@ -61728,7 +61728,7 @@ var ChangableAmountProvider = (function (props) {
61728
61728
  account = _useContext.account;
61729
61729
 
61730
61730
  var _useContext2 = react.useContext(ConfigurationContext),
61731
- configuredAmount = _useContext2.amount;
61731
+ amountConfiguration = _useContext2.amount;
61732
61732
 
61733
61733
  var _useContext3 = react.useContext(ConversionRateContext),
61734
61734
  conversionRate = _useContext3.conversionRate;
@@ -61741,7 +61741,7 @@ var ChangableAmountProvider = (function (props) {
61741
61741
  acceptWithAmount = _useState4[0],
61742
61742
  setAcceptWithAmount = _useState4[1];
61743
61743
 
61744
- var _useState5 = react.useState(amountsMissing ? _typeof(configuredAmount) == "object" && configuredAmount.start ? configuredAmount.start : 1 : null),
61744
+ var _useState5 = react.useState(amountsMissing ? _typeof(amountConfiguration) == "object" && amountConfiguration.start ? amountConfiguration.start : 1 : null),
61745
61745
  _useState6 = _slicedToArray(_useState5, 2),
61746
61746
  amount = _useState6[0],
61747
61747
  setAmount = _useState6[1];
@@ -61759,51 +61759,83 @@ var ChangableAmountProvider = (function (props) {
61759
61759
  react.useEffect(function () {
61760
61760
  setAmountsMissing(configurationsMissAmounts(props.accept));
61761
61761
  }, [props.accept]);
61762
- react.useEffect(function () {
61763
- if (amountsMissing && account && conversionRate) {
61764
- Promise.all(props.accept.map(function (configuration) {
61765
- return route$8({
61766
- blockchain: configuration.blockchain,
61767
- tokenIn: CONSTANTS$2[configuration.blockchain].USD,
61768
- amountIn: 1.00 / conversionRate * amount,
61769
- tokenOut: configuration.token,
61770
- fromAddress: account,
61771
- toAddress: account
61772
- });
61773
- })).then(function (routes) {
61774
- Promise.all(routes.map(function (routes, index) {
61775
- if (routes[0] == undefined) {
61776
- return;
61777
- }
61778
61762
 
61779
- return Token.readable({
61780
- blockchain: props.accept[index].blockchain,
61781
- amount: routes[0].amountOut,
61782
- address: routes[0].tokenOut
61763
+ var getAmounts = function getAmounts() {
61764
+ return new Promise(function (resolve, reject) {
61765
+ if (amountConfiguration && amountConfiguration.token) {
61766
+ resolve(props.accept.map(function () {
61767
+ return amount;
61768
+ }));
61769
+ } else {
61770
+ Promise.all(props.accept.map(function (configuration) {
61771
+ return route$8({
61772
+ blockchain: configuration.blockchain,
61773
+ tokenIn: CONSTANTS$2[configuration.blockchain].USD,
61774
+ amountIn: 1.00 / conversionRate * amount,
61775
+ tokenOut: configuration.token,
61776
+ fromAddress: account,
61777
+ toAddress: account
61783
61778
  });
61784
- })).then(function (amounts) {
61785
- setAcceptWithAmount(props.accept.map(function (configuration, index) {
61786
- if (amounts[index] == undefined) {
61779
+ })).then(function (routes) {
61780
+ Promise.all(routes.map(function (routes, index) {
61781
+ if (routes[0] == undefined) {
61787
61782
  return;
61788
61783
  }
61789
61784
 
61790
- return {
61791
- blockchain: configuration.blockchain,
61792
- amount: round$1(amounts[index]),
61793
- token: configuration.token,
61794
- receiver: configuration.receiver || account
61795
- };
61796
- }).filter(function (configuration) {
61797
- return !!configuration;
61798
- }));
61785
+ return Token.readable({
61786
+ blockchain: props.accept[index].blockchain,
61787
+ amount: routes[0].amountOut,
61788
+ address: routes[0].tokenOut
61789
+ });
61790
+ })).then(resolve)["catch"](setError);
61799
61791
  })["catch"](setError);
61792
+ }
61793
+ });
61794
+ };
61795
+
61796
+ react.useEffect(function () {
61797
+ if (amountsMissing && account && conversionRate) {
61798
+ getAmounts().then(function (amounts) {
61799
+ setAcceptWithAmount(props.accept.map(function (configuration, index) {
61800
+ if (amounts[index] == undefined) {
61801
+ return;
61802
+ }
61803
+
61804
+ return {
61805
+ blockchain: configuration.blockchain,
61806
+ amount: round$1(amounts[index]),
61807
+ token: configuration.token,
61808
+ receiver: configuration.receiver || account
61809
+ };
61810
+ }).filter(function (configuration) {
61811
+ return !!configuration;
61812
+ }));
61800
61813
  })["catch"](setError);
61801
61814
  }
61802
- }, [account, conversionRate, amount]);
61815
+ }, [amountsMissing, account, conversionRate, amount]);
61803
61816
  react.useEffect(function () {
61804
61817
  if (amountsMissing && maxRoute) {
61805
61818
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
61806
- if (maxRoute.fromToken.address == CONSTANTS$2[maxRoute.blockchain].USD) {
61819
+ if (amountConfiguration && amountConfiguration.token) {
61820
+ route$8({
61821
+ blockchain: maxRoute.blockchain,
61822
+ tokenIn: maxRoute.fromToken.address,
61823
+ tokenOut: maxRoute.toToken.address,
61824
+ amountIn: parseFloat(readableMaxAmount),
61825
+ fromAddress: account,
61826
+ toAddress: account
61827
+ }).then(function (routes) {
61828
+ Token.readable({
61829
+ amount: routes[0].amountOut,
61830
+ blockchain: maxRoute.blockchain,
61831
+ address: maxRoute.toToken.address
61832
+ }).then(function (readableMaxAmount) {
61833
+ var slippage = 1.01;
61834
+ var maxAmount = parseFloat(new Decimal(readableMaxAmount).div(slippage).mul(conversionRate).toString());
61835
+ setMaxAmount(maxAmount > 10 ? Math.round(maxAmount) : round$1(maxAmount));
61836
+ })["catch"](setError);
61837
+ })["catch"](setError);
61838
+ } else if (maxRoute.fromToken.address == CONSTANTS$2[maxRoute.blockchain].USD) {
61807
61839
  var _maxAmount = parseFloat(new Decimal(readableMaxAmount).mul(conversionRate).toString());
61808
61840
 
61809
61841
  setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount) : _maxAmount);
@@ -69905,13 +69937,14 @@ var ChangeAmountDialog = (function (props) {
69905
69937
 
69906
69938
  var _useContext5 = react.useContext(ConfigurationContext),
69907
69939
  currencyCode = _useContext5.currencyCode,
69908
- configuredAmount = _useContext5.amount;
69940
+ amountConfiguration = _useContext5.amount;
69909
69941
 
69910
69942
  var _useContext6 = react.useContext(PaymentRoutingContext);
69911
69943
  _useContext6.allRoutes;
69912
69944
 
69913
- var min = _typeof(configuredAmount) == "object" && configuredAmount.min ? configuredAmount.min : 1;
69914
- var step = _typeof(configuredAmount) == "object" && configuredAmount.step ? configuredAmount.step : 1;
69945
+ var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
69946
+ var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
69947
+ var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
69915
69948
 
69916
69949
  var changeAmountAndGoBack = function changeAmountAndGoBack() {
69917
69950
  setAmount(toValidValue(parseFloat(inputAmount)));
@@ -69953,7 +69986,7 @@ var ChangeAmountDialog = (function (props) {
69953
69986
  className: "LineHeightL FontSizeL TextCenter"
69954
69987
  }, "Change Amount"), /*#__PURE__*/react.createElement("div", {
69955
69988
  className: "FontSizeL TextCenter FontWeightBold"
69956
- }, /*#__PURE__*/react.createElement("strong", null, currencyCode))),
69989
+ }, /*#__PURE__*/react.createElement("strong", null, displayedCurrencyCode))),
69957
69990
  body: /*#__PURE__*/react.createElement("div", {
69958
69991
  className: "MaxHeight PaddingTopXS"
69959
69992
  }, /*#__PURE__*/react.createElement("div", {
@@ -70256,7 +70289,8 @@ var LoadingText = (function (props) {
70256
70289
 
70257
70290
  var Footer = (function () {
70258
70291
  var _useContext = react.useContext(ConfigurationContext),
70259
- currencyCode = _useContext.currencyCode;
70292
+ currencyCode = _useContext.currencyCode,
70293
+ configuredAmount = _useContext.amount;
70260
70294
 
70261
70295
  var _useContext2 = react.useContext(ChangableAmountContext),
70262
70296
  amount = _useContext2.amount;
@@ -70410,6 +70444,19 @@ var Footer = (function () {
70410
70444
  };
70411
70445
 
70412
70446
  var mainAction = function mainAction() {
70447
+ var displayedAmount;
70448
+
70449
+ if (amount && (configuredAmount == undefined || configuredAmount.token != true)) {
70450
+ displayedAmount = new Currency({
70451
+ amount: amount.toFixed(2),
70452
+ code: currencyCode
70453
+ }).toString();
70454
+ } else if (paymentValue && paymentValue.toString().length) {
70455
+ displayedAmount = paymentValue.toString();
70456
+ } else {
70457
+ displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
70458
+ }
70459
+
70413
70460
  if (paymentState == 'initialized' || paymentState == 'approving') {
70414
70461
  return /*#__PURE__*/react.createElement("button", {
70415
70462
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
@@ -70422,10 +70469,7 @@ var Footer = (function () {
70422
70469
  navigate: navigate
70423
70470
  });
70424
70471
  }
70425
- }, "Pay ", amount ? new Currency({
70426
- amount: amount.toFixed(2),
70427
- code: currencyCode
70428
- }).toString() : paymentValue.toString().length ? paymentValue.toString() : "".concat(payment.amount));
70472
+ }, "Pay ", displayedAmount);
70429
70473
  } else if (paymentState == 'paying') {
70430
70474
  return /*#__PURE__*/react.createElement("a", {
70431
70475
  className: "ButtonPrimary",
@@ -71655,7 +71699,8 @@ var SaleOverviewDialog = (function (props) {
71655
71699
  _useContext.amount;
71656
71700
 
71657
71701
  var _useContext2 = react.useContext(ConfigurationContext),
71658
- tokenImage = _useContext2.tokenImage;
71702
+ tokenImage = _useContext2.tokenImage,
71703
+ amountConfiguration = _useContext2.amount;
71659
71704
 
71660
71705
  var _useContext3 = react.useContext(PaymentValueContext),
71661
71706
  paymentValue = _useContext3.paymentValue;
@@ -71677,7 +71722,7 @@ var SaleOverviewDialog = (function (props) {
71677
71722
  setSalePerTokenValue = _useState2[1];
71678
71723
 
71679
71724
  react.useEffect(function () {
71680
- if (paymentValue) {
71725
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
71681
71726
  setSalePerTokenValue(new Currency({
71682
71727
  amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
71683
71728
  code: paymentValue.code
package/dist/esm/index.js CHANGED
@@ -1678,7 +1678,7 @@ var ButtonPrimaryStyle = (function (style) {
1678
1678
  });
1679
1679
 
1680
1680
  var CardStyle = (function (style) {
1681
- return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.26rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
1681
+ return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.1rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
1682
1682
  });
1683
1683
 
1684
1684
  var DialogStyle = (function (style) {
@@ -2032,7 +2032,7 @@ var ChangableAmountProvider = (function (props) {
2032
2032
  account = _useContext.account;
2033
2033
 
2034
2034
  var _useContext2 = useContext(ConfigurationContext),
2035
- configuredAmount = _useContext2.amount;
2035
+ amountConfiguration = _useContext2.amount;
2036
2036
 
2037
2037
  var _useContext3 = useContext(ConversionRateContext),
2038
2038
  conversionRate = _useContext3.conversionRate;
@@ -2045,7 +2045,7 @@ var ChangableAmountProvider = (function (props) {
2045
2045
  acceptWithAmount = _useState4[0],
2046
2046
  setAcceptWithAmount = _useState4[1];
2047
2047
 
2048
- var _useState5 = useState(amountsMissing ? _typeof(configuredAmount) == "object" && configuredAmount.start ? configuredAmount.start : 1 : null),
2048
+ var _useState5 = useState(amountsMissing ? _typeof(amountConfiguration) == "object" && amountConfiguration.start ? amountConfiguration.start : 1 : null),
2049
2049
  _useState6 = _slicedToArray(_useState5, 2),
2050
2050
  amount = _useState6[0],
2051
2051
  setAmount = _useState6[1];
@@ -2063,51 +2063,83 @@ var ChangableAmountProvider = (function (props) {
2063
2063
  useEffect(function () {
2064
2064
  setAmountsMissing(configurationsMissAmounts(props.accept));
2065
2065
  }, [props.accept]);
2066
- useEffect(function () {
2067
- if (amountsMissing && account && conversionRate) {
2068
- Promise.all(props.accept.map(function (configuration) {
2069
- return route({
2070
- blockchain: configuration.blockchain,
2071
- tokenIn: CONSTANTS[configuration.blockchain].USD,
2072
- amountIn: 1.00 / conversionRate * amount,
2073
- tokenOut: configuration.token,
2074
- fromAddress: account,
2075
- toAddress: account
2076
- });
2077
- })).then(function (routes) {
2078
- Promise.all(routes.map(function (routes, index) {
2079
- if (routes[0] == undefined) {
2080
- return;
2081
- }
2082
2066
 
2083
- return Token.readable({
2084
- blockchain: props.accept[index].blockchain,
2085
- amount: routes[0].amountOut,
2086
- address: routes[0].tokenOut
2067
+ var getAmounts = function getAmounts() {
2068
+ return new Promise(function (resolve, reject) {
2069
+ if (amountConfiguration && amountConfiguration.token) {
2070
+ resolve(props.accept.map(function () {
2071
+ return amount;
2072
+ }));
2073
+ } else {
2074
+ Promise.all(props.accept.map(function (configuration) {
2075
+ return route({
2076
+ blockchain: configuration.blockchain,
2077
+ tokenIn: CONSTANTS[configuration.blockchain].USD,
2078
+ amountIn: 1.00 / conversionRate * amount,
2079
+ tokenOut: configuration.token,
2080
+ fromAddress: account,
2081
+ toAddress: account
2087
2082
  });
2088
- })).then(function (amounts) {
2089
- setAcceptWithAmount(props.accept.map(function (configuration, index) {
2090
- if (amounts[index] == undefined) {
2083
+ })).then(function (routes) {
2084
+ Promise.all(routes.map(function (routes, index) {
2085
+ if (routes[0] == undefined) {
2091
2086
  return;
2092
2087
  }
2093
2088
 
2094
- return {
2095
- blockchain: configuration.blockchain,
2096
- amount: round(amounts[index]),
2097
- token: configuration.token,
2098
- receiver: configuration.receiver || account
2099
- };
2100
- }).filter(function (configuration) {
2101
- return !!configuration;
2102
- }));
2089
+ return Token.readable({
2090
+ blockchain: props.accept[index].blockchain,
2091
+ amount: routes[0].amountOut,
2092
+ address: routes[0].tokenOut
2093
+ });
2094
+ })).then(resolve)["catch"](setError);
2103
2095
  })["catch"](setError);
2096
+ }
2097
+ });
2098
+ };
2099
+
2100
+ useEffect(function () {
2101
+ if (amountsMissing && account && conversionRate) {
2102
+ getAmounts().then(function (amounts) {
2103
+ setAcceptWithAmount(props.accept.map(function (configuration, index) {
2104
+ if (amounts[index] == undefined) {
2105
+ return;
2106
+ }
2107
+
2108
+ return {
2109
+ blockchain: configuration.blockchain,
2110
+ amount: round(amounts[index]),
2111
+ token: configuration.token,
2112
+ receiver: configuration.receiver || account
2113
+ };
2114
+ }).filter(function (configuration) {
2115
+ return !!configuration;
2116
+ }));
2104
2117
  })["catch"](setError);
2105
2118
  }
2106
- }, [account, conversionRate, amount]);
2119
+ }, [amountsMissing, account, conversionRate, amount]);
2107
2120
  useEffect(function () {
2108
2121
  if (amountsMissing && maxRoute) {
2109
2122
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
2110
- if (maxRoute.fromToken.address == CONSTANTS[maxRoute.blockchain].USD) {
2123
+ if (amountConfiguration && amountConfiguration.token) {
2124
+ route({
2125
+ blockchain: maxRoute.blockchain,
2126
+ tokenIn: maxRoute.fromToken.address,
2127
+ tokenOut: maxRoute.toToken.address,
2128
+ amountIn: parseFloat(readableMaxAmount),
2129
+ fromAddress: account,
2130
+ toAddress: account
2131
+ }).then(function (routes) {
2132
+ Token.readable({
2133
+ amount: routes[0].amountOut,
2134
+ blockchain: maxRoute.blockchain,
2135
+ address: maxRoute.toToken.address
2136
+ }).then(function (readableMaxAmount) {
2137
+ var slippage = 1.01;
2138
+ var maxAmount = parseFloat(new Decimal(readableMaxAmount).div(slippage).mul(conversionRate).toString());
2139
+ setMaxAmount(maxAmount > 10 ? Math.round(maxAmount) : round(maxAmount));
2140
+ })["catch"](setError);
2141
+ })["catch"](setError);
2142
+ } else if (maxRoute.fromToken.address == CONSTANTS[maxRoute.blockchain].USD) {
2111
2143
  var _maxAmount = parseFloat(new Decimal(readableMaxAmount).mul(conversionRate).toString());
2112
2144
 
2113
2145
  setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount) : _maxAmount);
@@ -2780,13 +2812,14 @@ var ChangeAmountDialog = (function (props) {
2780
2812
 
2781
2813
  var _useContext5 = useContext(ConfigurationContext),
2782
2814
  currencyCode = _useContext5.currencyCode,
2783
- configuredAmount = _useContext5.amount;
2815
+ amountConfiguration = _useContext5.amount;
2784
2816
 
2785
2817
  var _useContext6 = useContext(PaymentRoutingContext);
2786
2818
  _useContext6.allRoutes;
2787
2819
 
2788
- var min = _typeof(configuredAmount) == "object" && configuredAmount.min ? configuredAmount.min : 1;
2789
- var step = _typeof(configuredAmount) == "object" && configuredAmount.step ? configuredAmount.step : 1;
2820
+ var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
2821
+ var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
2822
+ var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
2790
2823
 
2791
2824
  var changeAmountAndGoBack = function changeAmountAndGoBack() {
2792
2825
  setAmount(toValidValue(parseFloat(inputAmount)));
@@ -2828,7 +2861,7 @@ var ChangeAmountDialog = (function (props) {
2828
2861
  className: "LineHeightL FontSizeL TextCenter"
2829
2862
  }, "Change Amount"), /*#__PURE__*/React.createElement("div", {
2830
2863
  className: "FontSizeL TextCenter FontWeightBold"
2831
- }, /*#__PURE__*/React.createElement("strong", null, currencyCode))),
2864
+ }, /*#__PURE__*/React.createElement("strong", null, displayedCurrencyCode))),
2832
2865
  body: /*#__PURE__*/React.createElement("div", {
2833
2866
  className: "MaxHeight PaddingTopXS"
2834
2867
  }, /*#__PURE__*/React.createElement("div", {
@@ -3131,7 +3164,8 @@ var LoadingText = (function (props) {
3131
3164
 
3132
3165
  var Footer = (function () {
3133
3166
  var _useContext = useContext(ConfigurationContext),
3134
- currencyCode = _useContext.currencyCode;
3167
+ currencyCode = _useContext.currencyCode,
3168
+ configuredAmount = _useContext.amount;
3135
3169
 
3136
3170
  var _useContext2 = useContext(ChangableAmountContext),
3137
3171
  amount = _useContext2.amount;
@@ -3285,6 +3319,19 @@ var Footer = (function () {
3285
3319
  };
3286
3320
 
3287
3321
  var mainAction = function mainAction() {
3322
+ var displayedAmount;
3323
+
3324
+ if (amount && (configuredAmount == undefined || configuredAmount.token != true)) {
3325
+ displayedAmount = new Currency({
3326
+ amount: amount.toFixed(2),
3327
+ code: currencyCode
3328
+ }).toString();
3329
+ } else if (paymentValue && paymentValue.toString().length) {
3330
+ displayedAmount = paymentValue.toString();
3331
+ } else {
3332
+ displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
3333
+ }
3334
+
3288
3335
  if (paymentState == 'initialized' || paymentState == 'approving') {
3289
3336
  return /*#__PURE__*/React.createElement("button", {
3290
3337
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
@@ -3297,10 +3344,7 @@ var Footer = (function () {
3297
3344
  navigate: navigate
3298
3345
  });
3299
3346
  }
3300
- }, "Pay ", amount ? new Currency({
3301
- amount: amount.toFixed(2),
3302
- code: currencyCode
3303
- }).toString() : paymentValue.toString().length ? paymentValue.toString() : "".concat(payment.amount));
3347
+ }, "Pay ", displayedAmount);
3304
3348
  } else if (paymentState == 'paying') {
3305
3349
  return /*#__PURE__*/React.createElement("a", {
3306
3350
  className: "ButtonPrimary",
@@ -4530,7 +4574,8 @@ var SaleOverviewDialog = (function (props) {
4530
4574
  _useContext.amount;
4531
4575
 
4532
4576
  var _useContext2 = useContext(ConfigurationContext),
4533
- tokenImage = _useContext2.tokenImage;
4577
+ tokenImage = _useContext2.tokenImage,
4578
+ amountConfiguration = _useContext2.amount;
4534
4579
 
4535
4580
  var _useContext3 = useContext(PaymentValueContext),
4536
4581
  paymentValue = _useContext3.paymentValue;
@@ -4552,7 +4597,7 @@ var SaleOverviewDialog = (function (props) {
4552
4597
  setSalePerTokenValue = _useState2[1];
4553
4598
 
4554
4599
  useEffect(function () {
4555
- if (paymentValue) {
4600
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
4556
4601
  setSalePerTokenValue(new Currency({
4557
4602
  amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
4558
4603
  code: paymentValue.code
@@ -49483,7 +49483,7 @@
49483
49483
  });
49484
49484
 
49485
49485
  var CardStyle = (function (style) {
49486
- return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.26rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
49486
+ return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.1rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
49487
49487
  });
49488
49488
 
49489
49489
  var DialogStyle = (function (style) {
@@ -61734,7 +61734,7 @@
61734
61734
  account = _useContext.account;
61735
61735
 
61736
61736
  var _useContext2 = react.useContext(ConfigurationContext),
61737
- configuredAmount = _useContext2.amount;
61737
+ amountConfiguration = _useContext2.amount;
61738
61738
 
61739
61739
  var _useContext3 = react.useContext(ConversionRateContext),
61740
61740
  conversionRate = _useContext3.conversionRate;
@@ -61747,7 +61747,7 @@
61747
61747
  acceptWithAmount = _useState4[0],
61748
61748
  setAcceptWithAmount = _useState4[1];
61749
61749
 
61750
- var _useState5 = react.useState(amountsMissing ? _typeof(configuredAmount) == "object" && configuredAmount.start ? configuredAmount.start : 1 : null),
61750
+ var _useState5 = react.useState(amountsMissing ? _typeof(amountConfiguration) == "object" && amountConfiguration.start ? amountConfiguration.start : 1 : null),
61751
61751
  _useState6 = _slicedToArray(_useState5, 2),
61752
61752
  amount = _useState6[0],
61753
61753
  setAmount = _useState6[1];
@@ -61765,51 +61765,83 @@
61765
61765
  react.useEffect(function () {
61766
61766
  setAmountsMissing(configurationsMissAmounts(props.accept));
61767
61767
  }, [props.accept]);
61768
- react.useEffect(function () {
61769
- if (amountsMissing && account && conversionRate) {
61770
- Promise.all(props.accept.map(function (configuration) {
61771
- return route$8({
61772
- blockchain: configuration.blockchain,
61773
- tokenIn: CONSTANTS$2[configuration.blockchain].USD,
61774
- amountIn: 1.00 / conversionRate * amount,
61775
- tokenOut: configuration.token,
61776
- fromAddress: account,
61777
- toAddress: account
61778
- });
61779
- })).then(function (routes) {
61780
- Promise.all(routes.map(function (routes, index) {
61781
- if (routes[0] == undefined) {
61782
- return;
61783
- }
61784
61768
 
61785
- return Token.readable({
61786
- blockchain: props.accept[index].blockchain,
61787
- amount: routes[0].amountOut,
61788
- address: routes[0].tokenOut
61769
+ var getAmounts = function getAmounts() {
61770
+ return new Promise(function (resolve, reject) {
61771
+ if (amountConfiguration && amountConfiguration.token) {
61772
+ resolve(props.accept.map(function () {
61773
+ return amount;
61774
+ }));
61775
+ } else {
61776
+ Promise.all(props.accept.map(function (configuration) {
61777
+ return route$8({
61778
+ blockchain: configuration.blockchain,
61779
+ tokenIn: CONSTANTS$2[configuration.blockchain].USD,
61780
+ amountIn: 1.00 / conversionRate * amount,
61781
+ tokenOut: configuration.token,
61782
+ fromAddress: account,
61783
+ toAddress: account
61789
61784
  });
61790
- })).then(function (amounts) {
61791
- setAcceptWithAmount(props.accept.map(function (configuration, index) {
61792
- if (amounts[index] == undefined) {
61785
+ })).then(function (routes) {
61786
+ Promise.all(routes.map(function (routes, index) {
61787
+ if (routes[0] == undefined) {
61793
61788
  return;
61794
61789
  }
61795
61790
 
61796
- return {
61797
- blockchain: configuration.blockchain,
61798
- amount: round$1(amounts[index]),
61799
- token: configuration.token,
61800
- receiver: configuration.receiver || account
61801
- };
61802
- }).filter(function (configuration) {
61803
- return !!configuration;
61804
- }));
61791
+ return Token.readable({
61792
+ blockchain: props.accept[index].blockchain,
61793
+ amount: routes[0].amountOut,
61794
+ address: routes[0].tokenOut
61795
+ });
61796
+ })).then(resolve)["catch"](setError);
61805
61797
  })["catch"](setError);
61798
+ }
61799
+ });
61800
+ };
61801
+
61802
+ react.useEffect(function () {
61803
+ if (amountsMissing && account && conversionRate) {
61804
+ getAmounts().then(function (amounts) {
61805
+ setAcceptWithAmount(props.accept.map(function (configuration, index) {
61806
+ if (amounts[index] == undefined) {
61807
+ return;
61808
+ }
61809
+
61810
+ return {
61811
+ blockchain: configuration.blockchain,
61812
+ amount: round$1(amounts[index]),
61813
+ token: configuration.token,
61814
+ receiver: configuration.receiver || account
61815
+ };
61816
+ }).filter(function (configuration) {
61817
+ return !!configuration;
61818
+ }));
61806
61819
  })["catch"](setError);
61807
61820
  }
61808
- }, [account, conversionRate, amount]);
61821
+ }, [amountsMissing, account, conversionRate, amount]);
61809
61822
  react.useEffect(function () {
61810
61823
  if (amountsMissing && maxRoute) {
61811
61824
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
61812
- if (maxRoute.fromToken.address == CONSTANTS$2[maxRoute.blockchain].USD) {
61825
+ if (amountConfiguration && amountConfiguration.token) {
61826
+ route$8({
61827
+ blockchain: maxRoute.blockchain,
61828
+ tokenIn: maxRoute.fromToken.address,
61829
+ tokenOut: maxRoute.toToken.address,
61830
+ amountIn: parseFloat(readableMaxAmount),
61831
+ fromAddress: account,
61832
+ toAddress: account
61833
+ }).then(function (routes) {
61834
+ Token.readable({
61835
+ amount: routes[0].amountOut,
61836
+ blockchain: maxRoute.blockchain,
61837
+ address: maxRoute.toToken.address
61838
+ }).then(function (readableMaxAmount) {
61839
+ var slippage = 1.01;
61840
+ var maxAmount = parseFloat(new Decimal(readableMaxAmount).div(slippage).mul(conversionRate).toString());
61841
+ setMaxAmount(maxAmount > 10 ? Math.round(maxAmount) : round$1(maxAmount));
61842
+ })["catch"](setError);
61843
+ })["catch"](setError);
61844
+ } else if (maxRoute.fromToken.address == CONSTANTS$2[maxRoute.blockchain].USD) {
61813
61845
  var _maxAmount = parseFloat(new Decimal(readableMaxAmount).mul(conversionRate).toString());
61814
61846
 
61815
61847
  setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount) : _maxAmount);
@@ -69911,13 +69943,14 @@
69911
69943
 
69912
69944
  var _useContext5 = react.useContext(ConfigurationContext),
69913
69945
  currencyCode = _useContext5.currencyCode,
69914
- configuredAmount = _useContext5.amount;
69946
+ amountConfiguration = _useContext5.amount;
69915
69947
 
69916
69948
  var _useContext6 = react.useContext(PaymentRoutingContext);
69917
69949
  _useContext6.allRoutes;
69918
69950
 
69919
- var min = _typeof(configuredAmount) == "object" && configuredAmount.min ? configuredAmount.min : 1;
69920
- var step = _typeof(configuredAmount) == "object" && configuredAmount.step ? configuredAmount.step : 1;
69951
+ var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
69952
+ var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
69953
+ var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
69921
69954
 
69922
69955
  var changeAmountAndGoBack = function changeAmountAndGoBack() {
69923
69956
  setAmount(toValidValue(parseFloat(inputAmount)));
@@ -69959,7 +69992,7 @@
69959
69992
  className: "LineHeightL FontSizeL TextCenter"
69960
69993
  }, "Change Amount"), /*#__PURE__*/react.createElement("div", {
69961
69994
  className: "FontSizeL TextCenter FontWeightBold"
69962
- }, /*#__PURE__*/react.createElement("strong", null, currencyCode))),
69995
+ }, /*#__PURE__*/react.createElement("strong", null, displayedCurrencyCode))),
69963
69996
  body: /*#__PURE__*/react.createElement("div", {
69964
69997
  className: "MaxHeight PaddingTopXS"
69965
69998
  }, /*#__PURE__*/react.createElement("div", {
@@ -70262,7 +70295,8 @@
70262
70295
 
70263
70296
  var Footer = (function () {
70264
70297
  var _useContext = react.useContext(ConfigurationContext),
70265
- currencyCode = _useContext.currencyCode;
70298
+ currencyCode = _useContext.currencyCode,
70299
+ configuredAmount = _useContext.amount;
70266
70300
 
70267
70301
  var _useContext2 = react.useContext(ChangableAmountContext),
70268
70302
  amount = _useContext2.amount;
@@ -70416,6 +70450,19 @@
70416
70450
  };
70417
70451
 
70418
70452
  var mainAction = function mainAction() {
70453
+ var displayedAmount;
70454
+
70455
+ if (amount && (configuredAmount == undefined || configuredAmount.token != true)) {
70456
+ displayedAmount = new Currency({
70457
+ amount: amount.toFixed(2),
70458
+ code: currencyCode
70459
+ }).toString();
70460
+ } else if (paymentValue && paymentValue.toString().length) {
70461
+ displayedAmount = paymentValue.toString();
70462
+ } else {
70463
+ displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
70464
+ }
70465
+
70419
70466
  if (paymentState == 'initialized' || paymentState == 'approving') {
70420
70467
  return /*#__PURE__*/react.createElement("button", {
70421
70468
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
@@ -70428,10 +70475,7 @@
70428
70475
  navigate: navigate
70429
70476
  });
70430
70477
  }
70431
- }, "Pay ", amount ? new Currency({
70432
- amount: amount.toFixed(2),
70433
- code: currencyCode
70434
- }).toString() : paymentValue.toString().length ? paymentValue.toString() : "".concat(payment.amount));
70478
+ }, "Pay ", displayedAmount);
70435
70479
  } else if (paymentState == 'paying') {
70436
70480
  return /*#__PURE__*/react.createElement("a", {
70437
70481
  className: "ButtonPrimary",
@@ -71661,7 +71705,8 @@
71661
71705
  _useContext.amount;
71662
71706
 
71663
71707
  var _useContext2 = react.useContext(ConfigurationContext),
71664
- tokenImage = _useContext2.tokenImage;
71708
+ tokenImage = _useContext2.tokenImage,
71709
+ amountConfiguration = _useContext2.amount;
71665
71710
 
71666
71711
  var _useContext3 = react.useContext(PaymentValueContext),
71667
71712
  paymentValue = _useContext3.paymentValue;
@@ -71683,7 +71728,7 @@
71683
71728
  setSalePerTokenValue = _useState2[1];
71684
71729
 
71685
71730
  react.useEffect(function () {
71686
- if (paymentValue) {
71731
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
71687
71732
  setSalePerTokenValue(new Currency({
71688
71733
  amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
71689
71734
  code: paymentValue.code
package/dist/umd/index.js CHANGED
@@ -1673,7 +1673,7 @@
1673
1673
  });
1674
1674
 
1675
1675
  var CardStyle = (function (style) {
1676
- return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.26rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
1676
+ return "\n\n .Card {\n align-items: center;\n background: rgb(255,255,255);\n border-radius: 0.8rem;\n box-shadow: 0 0 8px rgba(0,0,0,0.03);\n cursor: pointer;\n display: flex;\n flex-direction: row;\n margin-bottom: 0.5rem;\n min-height: 4.78rem;\n padding: 1rem 0.6rem;\n width: 100%;\n }\n\n .Card.Row {\n border-radius: 0;\n margin-bottom: 0;\n box-shadow: none;\n min-height: 4.3rem;\n padding: 0.4rem 1.3rem;\n border-top: 1px solid rgba(0,0,0,0.05);\n }\n\n .Card.Row .CardText {\n font-size: 1.2rem;\n }\n\n .CardTokenSymbol {\n width: 40%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n .CardTokenName {\n text-align: right;\n opacity: 0.5;\n width: 60%;\n min-width: 0;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n \n .Card.Row .CardTokenName .CardText {\n font-size: 1rem;\n }\n\n .Card.Row .CardImage {\n width: 2.5rem;\n }\n\n .Card.Row .CardImage img {\n height: 1.9rem;\n width: 1.9rem;\n }\n\n a.Card, a.Card * {\n color: inherit;\n text-decoration: none;\n }\n\n .Card.transparent {\n background: none;\n box-shadow: none;\n }\n\n .Card.small {\n min-height: auto;\n padding: 0.5rem 0.5rem;\n margin: 0;\n }\n\n .CardImage.small {\n width: 1.7rem;\n }\n\n .CardImage.small img {\n height: 1.4rem;\n width: 1.4rem;\n }\n\n .Card.disabled {\n cursor: default;\n }\n\n .Card:hover:not(.disabled) {\n background: rgb(240,240,240);\n box-shadow: 0 0 0 rgba(0,0,0,0); \n }\n\n .Card:active:not(.disabled) {\n background: rgb(235,235,235);\n box-shadow: inset 0 0 6px rgba(0,0,0,0.02);\n color: inherit;\n }\n\n .Card:hover:not(.disabled) .CardAction {\n opacity: 0.4;\n }\n\n .CardImage, .CardBody, .CardAction, .CardInfo {\n align-items: center;\n display: flex;\n min-width: 0;\n padding: 0 0.4rem;\n }\n\n .CardImage {\n flex-basis: auto;\n flex-grow: 0;\n flex-shrink: 0;\n justify-content: center;\n position: relative;\n width: 3.6rem;\n }\n\n .CardBody {\n flex-basis: auto;\n flex-grow: 1;\n flex-shrink: 1;\n line-height: 1.4rem;\n padding-left: 0.6rem;\n text-align: left;\n }\n\n .CardBodyWrapper {\n min-width: 0;\n }\n\n .CardAction {\n flex-basis: auto;\n flex-shrink: 0;\n flex-grow: 0;\n padding-right: 0;\n margin-left: auto;\n }\n\n .Card.disabled .CardAction {\n opacity: 0; \n }\n\n .CardInfo {\n display: flex;\n flex-basis: auto;\n flex-direction: column;\n flex-grow: 0;\n flex-shrink: 1;\n justify-content: center;\n margin-left: auto; \n padding-right: 0;\n }\n\n .CardImage img {\n background: white;\n border-radius: 99rem;\n border: 1px solid white;\n box-shadow: 0 2px 8px rgb(0 0 0 / 10%);\n height: 2.8rem;\n position: relative;\n vertical-align: middle;\n width: 2.8rem;\n }\n\n .CardImage img.transparent {\n border: none;\n background: none;\n box-shadow: none;\n }\n \n .CardImage .BlockchainLogo {\n position: absolute;\n bottom: 0;\n right: 0;\n }\n\n .CardTitle {\n font-size: 0.9rem;\n color: rgb(150,150,150);\n }\n \n .CardText, a .CardText {\n color: ".concat(style.colors.text, ";\n flex: 1;\n font-size: 1.3rem;\n }\n\n .CardText strong {\n font-weight: 500;\n }\n\n .CardText small {\n font-size: 1.1rem;\n color: rgb(150,150,150);\n }\n\n .CardAction {\n opacity: 0.2;\n }\n\n .Card.More {\n display: inline-block;\n text-align: center;\n }\n ");
1677
1677
  });
1678
1678
 
1679
1679
  var DialogStyle = (function (style) {
@@ -2027,7 +2027,7 @@
2027
2027
  account = _useContext.account;
2028
2028
 
2029
2029
  var _useContext2 = React.useContext(ConfigurationContext),
2030
- configuredAmount = _useContext2.amount;
2030
+ amountConfiguration = _useContext2.amount;
2031
2031
 
2032
2032
  var _useContext3 = React.useContext(ConversionRateContext),
2033
2033
  conversionRate = _useContext3.conversionRate;
@@ -2040,7 +2040,7 @@
2040
2040
  acceptWithAmount = _useState4[0],
2041
2041
  setAcceptWithAmount = _useState4[1];
2042
2042
 
2043
- var _useState5 = React.useState(amountsMissing ? _typeof(configuredAmount) == "object" && configuredAmount.start ? configuredAmount.start : 1 : null),
2043
+ var _useState5 = React.useState(amountsMissing ? _typeof(amountConfiguration) == "object" && amountConfiguration.start ? amountConfiguration.start : 1 : null),
2044
2044
  _useState6 = _slicedToArray(_useState5, 2),
2045
2045
  amount = _useState6[0],
2046
2046
  setAmount = _useState6[1];
@@ -2058,51 +2058,83 @@
2058
2058
  React.useEffect(function () {
2059
2059
  setAmountsMissing(configurationsMissAmounts(props.accept));
2060
2060
  }, [props.accept]);
2061
- React.useEffect(function () {
2062
- if (amountsMissing && account && conversionRate) {
2063
- Promise.all(props.accept.map(function (configuration) {
2064
- return web3Exchanges.route({
2065
- blockchain: configuration.blockchain,
2066
- tokenIn: web3Constants.CONSTANTS[configuration.blockchain].USD,
2067
- amountIn: 1.00 / conversionRate * amount,
2068
- tokenOut: configuration.token,
2069
- fromAddress: account,
2070
- toAddress: account
2071
- });
2072
- })).then(function (routes) {
2073
- Promise.all(routes.map(function (routes, index) {
2074
- if (routes[0] == undefined) {
2075
- return;
2076
- }
2077
2061
 
2078
- return web3Tokens.Token.readable({
2079
- blockchain: props.accept[index].blockchain,
2080
- amount: routes[0].amountOut,
2081
- address: routes[0].tokenOut
2062
+ var getAmounts = function getAmounts() {
2063
+ return new Promise(function (resolve, reject) {
2064
+ if (amountConfiguration && amountConfiguration.token) {
2065
+ resolve(props.accept.map(function () {
2066
+ return amount;
2067
+ }));
2068
+ } else {
2069
+ Promise.all(props.accept.map(function (configuration) {
2070
+ return web3Exchanges.route({
2071
+ blockchain: configuration.blockchain,
2072
+ tokenIn: web3Constants.CONSTANTS[configuration.blockchain].USD,
2073
+ amountIn: 1.00 / conversionRate * amount,
2074
+ tokenOut: configuration.token,
2075
+ fromAddress: account,
2076
+ toAddress: account
2082
2077
  });
2083
- })).then(function (amounts) {
2084
- setAcceptWithAmount(props.accept.map(function (configuration, index) {
2085
- if (amounts[index] == undefined) {
2078
+ })).then(function (routes) {
2079
+ Promise.all(routes.map(function (routes, index) {
2080
+ if (routes[0] == undefined) {
2086
2081
  return;
2087
2082
  }
2088
2083
 
2089
- return {
2090
- blockchain: configuration.blockchain,
2091
- amount: round(amounts[index]),
2092
- token: configuration.token,
2093
- receiver: configuration.receiver || account
2094
- };
2095
- }).filter(function (configuration) {
2096
- return !!configuration;
2097
- }));
2084
+ return web3Tokens.Token.readable({
2085
+ blockchain: props.accept[index].blockchain,
2086
+ amount: routes[0].amountOut,
2087
+ address: routes[0].tokenOut
2088
+ });
2089
+ })).then(resolve)["catch"](setError);
2098
2090
  })["catch"](setError);
2091
+ }
2092
+ });
2093
+ };
2094
+
2095
+ React.useEffect(function () {
2096
+ if (amountsMissing && account && conversionRate) {
2097
+ getAmounts().then(function (amounts) {
2098
+ setAcceptWithAmount(props.accept.map(function (configuration, index) {
2099
+ if (amounts[index] == undefined) {
2100
+ return;
2101
+ }
2102
+
2103
+ return {
2104
+ blockchain: configuration.blockchain,
2105
+ amount: round(amounts[index]),
2106
+ token: configuration.token,
2107
+ receiver: configuration.receiver || account
2108
+ };
2109
+ }).filter(function (configuration) {
2110
+ return !!configuration;
2111
+ }));
2099
2112
  })["catch"](setError);
2100
2113
  }
2101
- }, [account, conversionRate, amount]);
2114
+ }, [amountsMissing, account, conversionRate, amount]);
2102
2115
  React.useEffect(function () {
2103
2116
  if (amountsMissing && maxRoute) {
2104
2117
  maxRoute.fromToken.readable(maxRoute.fromBalance).then(function (readableMaxAmount) {
2105
- if (maxRoute.fromToken.address == web3Constants.CONSTANTS[maxRoute.blockchain].USD) {
2118
+ if (amountConfiguration && amountConfiguration.token) {
2119
+ web3Exchanges.route({
2120
+ blockchain: maxRoute.blockchain,
2121
+ tokenIn: maxRoute.fromToken.address,
2122
+ tokenOut: maxRoute.toToken.address,
2123
+ amountIn: parseFloat(readableMaxAmount),
2124
+ fromAddress: account,
2125
+ toAddress: account
2126
+ }).then(function (routes) {
2127
+ web3Tokens.Token.readable({
2128
+ amount: routes[0].amountOut,
2129
+ blockchain: maxRoute.blockchain,
2130
+ address: maxRoute.toToken.address
2131
+ }).then(function (readableMaxAmount) {
2132
+ var slippage = 1.01;
2133
+ var maxAmount = parseFloat(new decimal_js.Decimal(readableMaxAmount).div(slippage).mul(conversionRate).toString());
2134
+ setMaxAmount(maxAmount > 10 ? Math.round(maxAmount) : round(maxAmount));
2135
+ })["catch"](setError);
2136
+ })["catch"](setError);
2137
+ } else if (maxRoute.fromToken.address == web3Constants.CONSTANTS[maxRoute.blockchain].USD) {
2106
2138
  var _maxAmount = parseFloat(new decimal_js.Decimal(readableMaxAmount).mul(conversionRate).toString());
2107
2139
 
2108
2140
  setMaxAmount(_maxAmount > 10 ? Math.round(_maxAmount) : _maxAmount);
@@ -2775,13 +2807,14 @@
2775
2807
 
2776
2808
  var _useContext5 = React.useContext(ConfigurationContext),
2777
2809
  currencyCode = _useContext5.currencyCode,
2778
- configuredAmount = _useContext5.amount;
2810
+ amountConfiguration = _useContext5.amount;
2779
2811
 
2780
2812
  var _useContext6 = React.useContext(PaymentRoutingContext);
2781
2813
  _useContext6.allRoutes;
2782
2814
 
2783
- var min = _typeof(configuredAmount) == "object" && configuredAmount.min ? configuredAmount.min : 1;
2784
- var step = _typeof(configuredAmount) == "object" && configuredAmount.step ? configuredAmount.step : 1;
2815
+ var min = _typeof(amountConfiguration) == "object" && amountConfiguration.min ? amountConfiguration.min : 1;
2816
+ var step = _typeof(amountConfiguration) == "object" && amountConfiguration.step ? amountConfiguration.step : 1;
2817
+ var displayedCurrencyCode = amountConfiguration != undefined && amountConfiguration.token ? null : currencyCode;
2785
2818
 
2786
2819
  var changeAmountAndGoBack = function changeAmountAndGoBack() {
2787
2820
  setAmount(toValidValue(parseFloat(inputAmount)));
@@ -2823,7 +2856,7 @@
2823
2856
  className: "LineHeightL FontSizeL TextCenter"
2824
2857
  }, "Change Amount"), /*#__PURE__*/React__default["default"].createElement("div", {
2825
2858
  className: "FontSizeL TextCenter FontWeightBold"
2826
- }, /*#__PURE__*/React__default["default"].createElement("strong", null, currencyCode))),
2859
+ }, /*#__PURE__*/React__default["default"].createElement("strong", null, displayedCurrencyCode))),
2827
2860
  body: /*#__PURE__*/React__default["default"].createElement("div", {
2828
2861
  className: "MaxHeight PaddingTopXS"
2829
2862
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -3126,7 +3159,8 @@
3126
3159
 
3127
3160
  var Footer = (function () {
3128
3161
  var _useContext = React.useContext(ConfigurationContext),
3129
- currencyCode = _useContext.currencyCode;
3162
+ currencyCode = _useContext.currencyCode,
3163
+ configuredAmount = _useContext.amount;
3130
3164
 
3131
3165
  var _useContext2 = React.useContext(ChangableAmountContext),
3132
3166
  amount = _useContext2.amount;
@@ -3280,6 +3314,19 @@
3280
3314
  };
3281
3315
 
3282
3316
  var mainAction = function mainAction() {
3317
+ var displayedAmount;
3318
+
3319
+ if (amount && (configuredAmount == undefined || configuredAmount.token != true)) {
3320
+ displayedAmount = new localCurrency.Currency({
3321
+ amount: amount.toFixed(2),
3322
+ code: currencyCode
3323
+ }).toString();
3324
+ } else if (paymentValue && paymentValue.toString().length) {
3325
+ displayedAmount = paymentValue.toString();
3326
+ } else {
3327
+ displayedAmount = "".concat(payment.symbol, " ").concat(payment.amount);
3328
+ }
3329
+
3283
3330
  if (paymentState == 'initialized' || paymentState == 'approving') {
3284
3331
  return /*#__PURE__*/React__default["default"].createElement("button", {
3285
3332
  className: ["ButtonPrimary", payment.route.approvalRequired && !payment.route.directTransfer ? 'disabled' : ''].join(' '),
@@ -3292,10 +3339,7 @@
3292
3339
  navigate: navigate
3293
3340
  });
3294
3341
  }
3295
- }, "Pay ", amount ? new localCurrency.Currency({
3296
- amount: amount.toFixed(2),
3297
- code: currencyCode
3298
- }).toString() : paymentValue.toString().length ? paymentValue.toString() : "".concat(payment.amount));
3342
+ }, "Pay ", displayedAmount);
3299
3343
  } else if (paymentState == 'paying') {
3300
3344
  return /*#__PURE__*/React__default["default"].createElement("a", {
3301
3345
  className: "ButtonPrimary",
@@ -4525,7 +4569,8 @@
4525
4569
  _useContext.amount;
4526
4570
 
4527
4571
  var _useContext2 = React.useContext(ConfigurationContext),
4528
- tokenImage = _useContext2.tokenImage;
4572
+ tokenImage = _useContext2.tokenImage,
4573
+ amountConfiguration = _useContext2.amount;
4529
4574
 
4530
4575
  var _useContext3 = React.useContext(PaymentValueContext),
4531
4576
  paymentValue = _useContext3.paymentValue;
@@ -4547,7 +4592,7 @@
4547
4592
  setSalePerTokenValue = _useState2[1];
4548
4593
 
4549
4594
  React.useEffect(function () {
4550
- if (paymentValue) {
4595
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
4551
4596
  setSalePerTokenValue(new localCurrency.Currency({
4552
4597
  amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
4553
4598
  code: paymentValue.code
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/widgets",
3
3
  "moduleName": "DePayWidgets",
4
- "version": "6.10.0",
4
+ "version": "6.11.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",