@depay/widgets 6.28.0 → 6.28.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62159,6 +62159,10 @@ var ChangableAmountProvider = (function (props) {
62159
62159
  }));
62160
62160
  } else {
62161
62161
  Promise.all(props.accept.map(function (configuration) {
62162
+ if (CONSTANTS$2[configuration.blockchain].USD.toLowerCase() == configuration.token.toLowerCase()) {
62163
+ return 1.00 / conversionRate;
62164
+ }
62165
+
62162
62166
  return route$8({
62163
62167
  blockchain: configuration.blockchain,
62164
62168
  tokenIn: CONSTANTS$2[configuration.blockchain].USD,
@@ -62167,17 +62171,19 @@ var ChangableAmountProvider = (function (props) {
62167
62171
  fromAddress: account,
62168
62172
  toAddress: account
62169
62173
  });
62170
- })).then(function (routes) {
62171
- Promise.all(routes.map(function (routes, index) {
62172
- if (routes[0] == undefined) {
62174
+ })).then(function (results) {
62175
+ Promise.all(results.map(function (result, index) {
62176
+ if (typeof result == 'number') {
62177
+ return result;
62178
+ } else if (result[0] == undefined) {
62173
62179
  return;
62180
+ } else {
62181
+ return Token.readable({
62182
+ blockchain: props.accept[index].blockchain,
62183
+ amount: result[0].amountOut,
62184
+ address: result[0].tokenOut
62185
+ });
62174
62186
  }
62175
-
62176
- return Token.readable({
62177
- blockchain: props.accept[index].blockchain,
62178
- amount: routes[0].amountOut,
62179
- address: routes[0].tokenOut
62180
- });
62181
62187
  })).then(resolve)["catch"](setError);
62182
62188
  })["catch"](setError);
62183
62189
  }
@@ -68147,7 +68153,7 @@ let subtractFee = ({ amount, paymentRoute, fee })=> {
68147
68153
 
68148
68154
  let transactionFeeAmount = ({ paymentRoute, fee })=> {
68149
68155
  if(typeof fee.amount == 'string' && fee.amount.match('%')) {
68150
- return BigNumber.from(paymentRoute.toAmount).div(100).mul(parseFloat(fee.amount)).toString()
68156
+ return BigNumber.from(paymentRoute.toAmount).div(1000).mul(parseFloat(fee.amount)*10).toString()
68151
68157
  } else if(typeof fee.amount == 'string') {
68152
68158
  return fee.amount
68153
68159
  } else if(typeof fee.amount == 'number') {
@@ -85485,7 +85491,7 @@ function convertToRoutes({ assets, accept, from }) {
85485
85491
  function assetsToRoutes({ assets, blacklist, accept, from, event, fee }) {
85486
85492
  return Promise.resolve(filterBlacklistedAssets({ assets, blacklist }))
85487
85493
  .then((assets) => convertToRoutes({ assets, accept, from }))
85488
- .then(addDirectTransferStatus)
85494
+ .then((routes) => addDirectTransferStatus({ routes, fee }))
85489
85495
  .then(addExchangeRoutes)
85490
85496
  .then(filterExchangeRoutesWithoutPlugin)
85491
85497
  .then(filterNotRoutable)
@@ -85498,6 +85504,10 @@ function assetsToRoutes({ assets, blacklist, accept, from, event, fee }) {
85498
85504
  }
85499
85505
 
85500
85506
  function route({ accept, from, whitelist, blacklist, event, fee, update }) {
85507
+ if(fee && fee.amount && typeof(fee.amount) == 'string' && fee.amount.match(/\.\d\d+\%/)) {
85508
+ throw('Only up to 1 decimal is supported for fee amounts!')
85509
+ }
85510
+
85501
85511
  return new Promise(async (resolveAll, rejectAll)=>{
85502
85512
 
85503
85513
  let priority = [];
@@ -85646,9 +85656,9 @@ let addApproval = (routes) => {
85646
85656
  )
85647
85657
  };
85648
85658
 
85649
- let addDirectTransferStatus = (routes) => {
85659
+ let addDirectTransferStatus = ({ routes, fee }) => {
85650
85660
  return routes.map((route)=>{
85651
- route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined;
85661
+ route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined && fee == undefined;
85652
85662
  return route
85653
85663
  })
85654
85664
  };
@@ -89522,7 +89532,7 @@ var PaymentOverviewSkeleton = (function (props) {
89522
89532
  className: "SkeletonBackground"
89523
89533
  }))), selectedRoute == undefined && slowRouting && /*#__PURE__*/react.createElement("div", {
89524
89534
  className: "TextCenter Opacity05 PaddingTopS"
89525
- }, /*#__PURE__*/react.createElement("strong", null, "Still loading your wallet balances...")))
89535
+ }, /*#__PURE__*/react.createElement("strong", null, "Loading payment routes...")))
89526
89536
  });
89527
89537
  });
89528
89538
 
@@ -89953,13 +89963,22 @@ var SaleOverviewDialog = (function (props) {
89953
89963
  setSalePerTokenValue = _useState2[1];
89954
89964
 
89955
89965
  react.useEffect(function () {
89956
- if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
89957
- setSalePerTokenValue(new Currency({
89958
- amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
89966
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
89967
+ var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
89968
+ var readableLocalizedAmountPerToken = new Currency({
89969
+ amount: UsdAmountPerToken,
89970
+ code: paymentValue.code
89971
+ }).toString();
89972
+ var zero = new Currency({
89973
+ amount: 0,
89959
89974
  code: paymentValue.code
89960
- }).toString());
89975
+ }).toString();
89976
+
89977
+ if (readableLocalizedAmountPerToken != zero) {
89978
+ setSalePerTokenValue(readableLocalizedAmountPerToken);
89979
+ }
89961
89980
  }
89962
- }, [paymentValue]);
89981
+ }, [paymentValue, toTokenReadableAmount]);
89963
89982
 
89964
89983
  if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
89965
89984
  return /*#__PURE__*/react.createElement(SaleOverviewSkeleton, null);
@@ -107853,7 +107872,7 @@ var SelectTokenDialog = (function (props) {
107853
107872
  className: "Tooltip"
107854
107873
  }, /*#__PURE__*/react.createElement("span", {
107855
107874
  className: "TooltipArrowUp"
107856
- }), "Paste or enter token address here!")))),
107875
+ }), "Enter token address here")))),
107857
107876
  bodyClassName: "ScrollHeight",
107858
107877
  body: /*#__PURE__*/react.createElement("div", {
107859
107878
  className: ""
package/dist/esm/index.js CHANGED
@@ -2107,6 +2107,10 @@ var ChangableAmountProvider = (function (props) {
2107
2107
  }));
2108
2108
  } else {
2109
2109
  Promise.all(props.accept.map(function (configuration) {
2110
+ if (CONSTANTS[configuration.blockchain].USD.toLowerCase() == configuration.token.toLowerCase()) {
2111
+ return 1.00 / conversionRate;
2112
+ }
2113
+
2110
2114
  return route({
2111
2115
  blockchain: configuration.blockchain,
2112
2116
  tokenIn: CONSTANTS[configuration.blockchain].USD,
@@ -2115,17 +2119,19 @@ var ChangableAmountProvider = (function (props) {
2115
2119
  fromAddress: account,
2116
2120
  toAddress: account
2117
2121
  });
2118
- })).then(function (routes) {
2119
- Promise.all(routes.map(function (routes, index) {
2120
- if (routes[0] == undefined) {
2122
+ })).then(function (results) {
2123
+ Promise.all(results.map(function (result, index) {
2124
+ if (typeof result == 'number') {
2125
+ return result;
2126
+ } else if (result[0] == undefined) {
2121
2127
  return;
2128
+ } else {
2129
+ return Token.readable({
2130
+ blockchain: props.accept[index].blockchain,
2131
+ amount: result[0].amountOut,
2132
+ address: result[0].tokenOut
2133
+ });
2122
2134
  }
2123
-
2124
- return Token.readable({
2125
- blockchain: props.accept[index].blockchain,
2126
- amount: routes[0].amountOut,
2127
- address: routes[0].tokenOut
2128
- });
2129
2135
  })).then(resolve)["catch"](setError);
2130
2136
  })["catch"](setError);
2131
2137
  }
@@ -4671,7 +4677,7 @@ var PaymentOverviewSkeleton = (function (props) {
4671
4677
  className: "SkeletonBackground"
4672
4678
  }))), selectedRoute == undefined && slowRouting && /*#__PURE__*/React.createElement("div", {
4673
4679
  className: "TextCenter Opacity05 PaddingTopS"
4674
- }, /*#__PURE__*/React.createElement("strong", null, "Still loading your wallet balances...")))
4680
+ }, /*#__PURE__*/React.createElement("strong", null, "Loading payment routes...")))
4675
4681
  });
4676
4682
  });
4677
4683
 
@@ -5102,13 +5108,22 @@ var SaleOverviewDialog = (function (props) {
5102
5108
  setSalePerTokenValue = _useState2[1];
5103
5109
 
5104
5110
  useEffect(function () {
5105
- if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
5106
- setSalePerTokenValue(new Currency({
5107
- amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
5111
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
5112
+ var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
5113
+ var readableLocalizedAmountPerToken = new Currency({
5114
+ amount: UsdAmountPerToken,
5115
+ code: paymentValue.code
5116
+ }).toString();
5117
+ var zero = new Currency({
5118
+ amount: 0,
5108
5119
  code: paymentValue.code
5109
- }).toString());
5120
+ }).toString();
5121
+
5122
+ if (readableLocalizedAmountPerToken != zero) {
5123
+ setSalePerTokenValue(readableLocalizedAmountPerToken);
5124
+ }
5110
5125
  }
5111
- }, [paymentValue]);
5126
+ }, [paymentValue, toTokenReadableAmount]);
5112
5127
 
5113
5128
  if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
5114
5129
  return /*#__PURE__*/React.createElement(SaleOverviewSkeleton, null);
@@ -23002,7 +23017,7 @@ var SelectTokenDialog = (function (props) {
23002
23017
  className: "Tooltip"
23003
23018
  }, /*#__PURE__*/React.createElement("span", {
23004
23019
  className: "TooltipArrowUp"
23005
- }), "Paste or enter token address here!")))),
23020
+ }), "Enter token address here")))),
23006
23021
  bodyClassName: "ScrollHeight",
23007
23022
  body: /*#__PURE__*/React.createElement("div", {
23008
23023
  className: ""
@@ -62165,6 +62165,10 @@
62165
62165
  }));
62166
62166
  } else {
62167
62167
  Promise.all(props.accept.map(function (configuration) {
62168
+ if (CONSTANTS$2[configuration.blockchain].USD.toLowerCase() == configuration.token.toLowerCase()) {
62169
+ return 1.00 / conversionRate;
62170
+ }
62171
+
62168
62172
  return route$8({
62169
62173
  blockchain: configuration.blockchain,
62170
62174
  tokenIn: CONSTANTS$2[configuration.blockchain].USD,
@@ -62173,17 +62177,19 @@
62173
62177
  fromAddress: account,
62174
62178
  toAddress: account
62175
62179
  });
62176
- })).then(function (routes) {
62177
- Promise.all(routes.map(function (routes, index) {
62178
- if (routes[0] == undefined) {
62180
+ })).then(function (results) {
62181
+ Promise.all(results.map(function (result, index) {
62182
+ if (typeof result == 'number') {
62183
+ return result;
62184
+ } else if (result[0] == undefined) {
62179
62185
  return;
62186
+ } else {
62187
+ return Token.readable({
62188
+ blockchain: props.accept[index].blockchain,
62189
+ amount: result[0].amountOut,
62190
+ address: result[0].tokenOut
62191
+ });
62180
62192
  }
62181
-
62182
- return Token.readable({
62183
- blockchain: props.accept[index].blockchain,
62184
- amount: routes[0].amountOut,
62185
- address: routes[0].tokenOut
62186
- });
62187
62193
  })).then(resolve)["catch"](setError);
62188
62194
  })["catch"](setError);
62189
62195
  }
@@ -68153,7 +68159,7 @@
68153
68159
 
68154
68160
  let transactionFeeAmount = ({ paymentRoute, fee })=> {
68155
68161
  if(typeof fee.amount == 'string' && fee.amount.match('%')) {
68156
- return BigNumber.from(paymentRoute.toAmount).div(100).mul(parseFloat(fee.amount)).toString()
68162
+ return BigNumber.from(paymentRoute.toAmount).div(1000).mul(parseFloat(fee.amount)*10).toString()
68157
68163
  } else if(typeof fee.amount == 'string') {
68158
68164
  return fee.amount
68159
68165
  } else if(typeof fee.amount == 'number') {
@@ -85491,7 +85497,7 @@
85491
85497
  function assetsToRoutes({ assets, blacklist, accept, from, event, fee }) {
85492
85498
  return Promise.resolve(filterBlacklistedAssets({ assets, blacklist }))
85493
85499
  .then((assets) => convertToRoutes({ assets, accept, from }))
85494
- .then(addDirectTransferStatus)
85500
+ .then((routes) => addDirectTransferStatus({ routes, fee }))
85495
85501
  .then(addExchangeRoutes)
85496
85502
  .then(filterExchangeRoutesWithoutPlugin)
85497
85503
  .then(filterNotRoutable)
@@ -85504,6 +85510,10 @@
85504
85510
  }
85505
85511
 
85506
85512
  function route({ accept, from, whitelist, blacklist, event, fee, update }) {
85513
+ if(fee && fee.amount && typeof(fee.amount) == 'string' && fee.amount.match(/\.\d\d+\%/)) {
85514
+ throw('Only up to 1 decimal is supported for fee amounts!')
85515
+ }
85516
+
85507
85517
  return new Promise(async (resolveAll, rejectAll)=>{
85508
85518
 
85509
85519
  let priority = [];
@@ -85652,9 +85662,9 @@
85652
85662
  )
85653
85663
  };
85654
85664
 
85655
- let addDirectTransferStatus = (routes) => {
85665
+ let addDirectTransferStatus = ({ routes, fee }) => {
85656
85666
  return routes.map((route)=>{
85657
- route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined;
85667
+ route.directTransfer = route.fromToken.address.toLowerCase() == route.toToken.address.toLowerCase() && route.toContract == undefined && fee == undefined;
85658
85668
  return route
85659
85669
  })
85660
85670
  };
@@ -89528,7 +89538,7 @@
89528
89538
  className: "SkeletonBackground"
89529
89539
  }))), selectedRoute == undefined && slowRouting && /*#__PURE__*/react.createElement("div", {
89530
89540
  className: "TextCenter Opacity05 PaddingTopS"
89531
- }, /*#__PURE__*/react.createElement("strong", null, "Still loading your wallet balances...")))
89541
+ }, /*#__PURE__*/react.createElement("strong", null, "Loading payment routes...")))
89532
89542
  });
89533
89543
  });
89534
89544
 
@@ -89959,13 +89969,22 @@
89959
89969
  setSalePerTokenValue = _useState2[1];
89960
89970
 
89961
89971
  react.useEffect(function () {
89962
- if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
89963
- setSalePerTokenValue(new Currency({
89964
- amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
89972
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
89973
+ var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
89974
+ var readableLocalizedAmountPerToken = new Currency({
89975
+ amount: UsdAmountPerToken,
89976
+ code: paymentValue.code
89977
+ }).toString();
89978
+ var zero = new Currency({
89979
+ amount: 0,
89965
89980
  code: paymentValue.code
89966
- }).toString());
89981
+ }).toString();
89982
+
89983
+ if (readableLocalizedAmountPerToken != zero) {
89984
+ setSalePerTokenValue(readableLocalizedAmountPerToken);
89985
+ }
89967
89986
  }
89968
- }, [paymentValue]);
89987
+ }, [paymentValue, toTokenReadableAmount]);
89969
89988
 
89970
89989
  if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
89971
89990
  return /*#__PURE__*/react.createElement(SaleOverviewSkeleton, null);
@@ -107859,7 +107878,7 @@
107859
107878
  className: "Tooltip"
107860
107879
  }, /*#__PURE__*/react.createElement("span", {
107861
107880
  className: "TooltipArrowUp"
107862
- }), "Paste or enter token address here!")))),
107881
+ }), "Enter token address here")))),
107863
107882
  bodyClassName: "ScrollHeight",
107864
107883
  body: /*#__PURE__*/react.createElement("div", {
107865
107884
  className: ""
package/dist/umd/index.js CHANGED
@@ -2102,6 +2102,10 @@
2102
2102
  }));
2103
2103
  } else {
2104
2104
  Promise.all(props.accept.map(function (configuration) {
2105
+ if (web3Constants.CONSTANTS[configuration.blockchain].USD.toLowerCase() == configuration.token.toLowerCase()) {
2106
+ return 1.00 / conversionRate;
2107
+ }
2108
+
2105
2109
  return web3Exchanges.route({
2106
2110
  blockchain: configuration.blockchain,
2107
2111
  tokenIn: web3Constants.CONSTANTS[configuration.blockchain].USD,
@@ -2110,17 +2114,19 @@
2110
2114
  fromAddress: account,
2111
2115
  toAddress: account
2112
2116
  });
2113
- })).then(function (routes) {
2114
- Promise.all(routes.map(function (routes, index) {
2115
- if (routes[0] == undefined) {
2117
+ })).then(function (results) {
2118
+ Promise.all(results.map(function (result, index) {
2119
+ if (typeof result == 'number') {
2120
+ return result;
2121
+ } else if (result[0] == undefined) {
2116
2122
  return;
2123
+ } else {
2124
+ return web3Tokens.Token.readable({
2125
+ blockchain: props.accept[index].blockchain,
2126
+ amount: result[0].amountOut,
2127
+ address: result[0].tokenOut
2128
+ });
2117
2129
  }
2118
-
2119
- return web3Tokens.Token.readable({
2120
- blockchain: props.accept[index].blockchain,
2121
- amount: routes[0].amountOut,
2122
- address: routes[0].tokenOut
2123
- });
2124
2130
  })).then(resolve)["catch"](setError);
2125
2131
  })["catch"](setError);
2126
2132
  }
@@ -4666,7 +4672,7 @@
4666
4672
  className: "SkeletonBackground"
4667
4673
  }))), selectedRoute == undefined && slowRouting && /*#__PURE__*/React__default["default"].createElement("div", {
4668
4674
  className: "TextCenter Opacity05 PaddingTopS"
4669
- }, /*#__PURE__*/React__default["default"].createElement("strong", null, "Still loading your wallet balances...")))
4675
+ }, /*#__PURE__*/React__default["default"].createElement("strong", null, "Loading payment routes...")))
4670
4676
  });
4671
4677
  });
4672
4678
 
@@ -5097,13 +5103,22 @@
5097
5103
  setSalePerTokenValue = _useState2[1];
5098
5104
 
5099
5105
  React.useEffect(function () {
5100
- if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true)) {
5101
- setSalePerTokenValue(new localCurrency.Currency({
5102
- amount: (paymentValue.amount / parseFloat(toTokenReadableAmount)).toFixed(2),
5106
+ if (paymentValue && (amountConfiguration == undefined || amountConfiguration.token != true) && toTokenReadableAmount) {
5107
+ var UsdAmountPerToken = paymentValue.amount / parseFloat(toTokenReadableAmount);
5108
+ var readableLocalizedAmountPerToken = new localCurrency.Currency({
5109
+ amount: UsdAmountPerToken,
5110
+ code: paymentValue.code
5111
+ }).toString();
5112
+ var zero = new localCurrency.Currency({
5113
+ amount: 0,
5103
5114
  code: paymentValue.code
5104
- }).toString());
5115
+ }).toString();
5116
+
5117
+ if (readableLocalizedAmountPerToken != zero) {
5118
+ setSalePerTokenValue(readableLocalizedAmountPerToken);
5119
+ }
5105
5120
  }
5106
- }, [paymentValue]);
5121
+ }, [paymentValue, toTokenReadableAmount]);
5107
5122
 
5108
5123
  if (toToken == undefined || toTokenReadableAmount == undefined || payment == undefined || paymentValue == undefined) {
5109
5124
  return /*#__PURE__*/React__default["default"].createElement(SaleOverviewSkeleton, null);
@@ -22997,7 +23012,7 @@
22997
23012
  className: "Tooltip"
22998
23013
  }, /*#__PURE__*/React__default["default"].createElement("span", {
22999
23014
  className: "TooltipArrowUp"
23000
- }), "Paste or enter token address here!")))),
23015
+ }), "Enter token address here")))),
23001
23016
  bodyClassName: "ScrollHeight",
23002
23017
  body: /*#__PURE__*/React__default["default"].createElement("div", {
23003
23018
  className: ""
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/widgets",
3
3
  "moduleName": "DePayWidgets",
4
- "version": "6.28.0",
4
+ "version": "6.28.4",
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",
@@ -44,7 +44,7 @@
44
44
  "@depay/web3-client": "^8.0.0",
45
45
  "@depay/web3-constants": "^5.0.0",
46
46
  "@depay/web3-exchanges": "^8.2.1",
47
- "@depay/web3-payments": "^10.1.1",
47
+ "@depay/web3-payments": "^10.1.3",
48
48
  "@depay/web3-tokens": "^8.0.1",
49
49
  "@depay/web3-wallets": "^10.0.3",
50
50
  "decimal.js": "^10.3.1",