tek-wallet 0.0.402 → 0.0.403

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.
@@ -45,24 +45,27 @@ function Fees(props) {
45
45
  var _a;
46
46
  var result = [];
47
47
  (_a = feesData === null || feesData === void 0 ? void 0 : feesData.feeDetail) === null || _a === void 0 ? void 0 : _a.forEach(function (fee) {
48
- var _a, _b, _c, _d;
48
+ var _a, _b, _c, _d, _e;
49
49
  var index = result === null || result === void 0 ? void 0 : result.findIndex(function (feeDetail) { var _a, _b; return ((_a = feeDetail.currency) === null || _a === void 0 ? void 0 : _a.slug) === ((_b = fee === null || fee === void 0 ? void 0 : fee.currency) === null || _b === void 0 ? void 0 : _b.slug); });
50
50
  if (index === -1) {
51
51
  result.push(fee);
52
52
  }
53
53
  else {
54
- // const rate = fee.feeInUSD / fee.feeInCurrency;
54
+ var rate = fee.feeInUSD / fee.feeInCurrency;
55
55
  result[index].feeFixed += fee.feeFixed;
56
56
  result[index].feeInCurrency += fee.feeInCurrency;
57
57
  result[index].feeInUSD += fee.feeInUSD;
58
58
  result[index].feePercent += fee.feePercent;
59
59
  result[index].feePercentInCurrency =
60
60
  ((_a = result[index].feeInCurrency) !== null && _a !== void 0 ? _a : 0) + amount * (fee.feePercent / 100);
61
- var totalFeeInCurrency = ((_b = result[index].feeInCurrency) !== null && _b !== void 0 ? _b : 0) +
62
- ((_c = result[index].feePercentInCurrency) !== null && _c !== void 0 ? _c : 0);
61
+ result[index].feePercentInUSD =
62
+ ((_b = result[index].feeInUSD) !== null && _b !== void 0 ? _b : 0) +
63
+ amount * (fee.feePercent / 100) * rate;
64
+ var totalFeeInCurrency = ((_c = result[index].feeInCurrency) !== null && _c !== void 0 ? _c : 0) +
65
+ ((_d = result[index].feePercentInCurrency) !== null && _d !== void 0 ? _d : 0);
63
66
  var token = tokens === null || tokens === void 0 ? void 0 : tokens.find(function (token) { var _a; return token.currency_slug === ((_a = fee === null || fee === void 0 ? void 0 : fee.currency) === null || _a === void 0 ? void 0 : _a.slug); });
64
67
  result[index].isEnoughBalanceToPay =
65
- +((_d = token === null || token === void 0 ? void 0 : token.current_value) !== null && _d !== void 0 ? _d : 0) >= totalFeeInCurrency;
68
+ +((_e = token === null || token === void 0 ? void 0 : token.current_value) !== null && _e !== void 0 ? _e : 0) >= totalFeeInCurrency;
66
69
  }
67
70
  });
68
71
  console.warn("🚀 ~ consttokensFee:FeeDetailType[]=useMemo ~ result:", result);
@@ -78,6 +81,9 @@ function Fees(props) {
78
81
  var isEnoughBalanceToPayFee = (0, react_1.useMemo)(function () {
79
82
  return feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.some(function (fee) { return !fee.isEnoughBalanceToPay; });
80
83
  }, [feeCheckedBalance]);
84
+ var totalFeeInUSD = (0, react_1.useMemo)(function () {
85
+ return tokensFee === null || tokensFee === void 0 ? void 0 : tokensFee.reduce(function (acc, fee) { var _a, _b; return acc + ((_a = fee.feeInUSD) !== null && _a !== void 0 ? _a : 0) + ((_b = fee.feePercentInUSD) !== null && _b !== void 0 ? _b : 0); }, 0);
86
+ }, [tokensFee]);
81
87
  return ((0, jsx_runtime_1.jsxs)(material_1.Accordion, __assign({ defaultExpanded: true }, rest, { sx: __assign({ "&.MuiAccordion-root": {
82
88
  backgroundColor: "transparent",
83
89
  margin: 0,
@@ -96,7 +102,7 @@ function Fees(props) {
96
102
  }, "& .MuiAccordionDetails-root": {
97
103
  paddingLeft: theme.mixins.customPadding.p12,
98
104
  paddingRight: theme.mixins.customPadding.p12,
99
- } }, sx), children: [(0, jsx_runtime_1.jsx)(material_1.AccordionSummary, { expandIcon: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_down"), width: 20 }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Total fees" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: 1000 }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g8 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { alignItems: "stretch" }), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g8, alignItems: "center" }), children: feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.map(function (item, index) {
105
+ } }, sx), children: [(0, jsx_runtime_1.jsx)(material_1.AccordionSummary, { expandIcon: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_down"), width: 20 }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Total fees" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: totalFeeInUSD, start: "~ $" }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g8 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { alignItems: "stretch" }), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g8, alignItems: "center" }), children: feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.map(function (item, index) {
100
106
  var _a;
101
107
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_2.Fragment, { children: [index !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
102
108
  borderRight: "1px dashed ".concat(theme.palette.border.white24),
@@ -621,9 +621,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
621
621
  placeholder: "Enter memo",
622
622
  value: memo,
623
623
  onChange: handleChangeMemo,
624
- } })] })), ((_a = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeDetail) === null || _a === void 0 ? void 0 : _a.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { feesData: JSON.stringify(estimateFee), amount: +amount })), estimateReceive !== undefined && !amountError && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.row), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Estimate receive" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive }) })] })), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
625
- color: "#f00",
626
- }, children: "".concat(isValidatingAddress, " - ").concat(recipientAddressError, " - ").concat(amountError, " - ").concat(recipientAddress, " - ").concat(amount, " - ").concat(selectedToken, " - ").concat(selectedNetwork, " - ").concat(selectedMethod, " - ").concat(sendInfoGet) }), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, onClick: handleSend, status: !!amountError ||
624
+ } })] })), ((_a = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeDetail) === null || _a === void 0 ? void 0 : _a.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { feesData: JSON.stringify(estimateFee), amount: +amount })), estimateReceive !== undefined && !amountError && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.row), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Estimate receive" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive }) })] })), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, onClick: handleSend, status: !!amountError ||
627
625
  !!recipientAddressError ||
628
626
  !recipientAddress ||
629
627
  !amount ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.402",
3
+ "version": "0.0.403",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",