tek-wallet 0.0.386 → 0.0.388

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.
@@ -1,5 +1,6 @@
1
1
  import { AccordionProps } from "@mui/material";
2
2
  export interface FeesProps extends Omit<AccordionProps, "children"> {
3
+ feesData: string;
3
4
  }
4
5
  declare function Fees(props: FeesProps): import("react/jsx-runtime").JSX.Element;
5
6
  export default Fees;
@@ -32,14 +32,12 @@ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
32
32
  var Text_1 = __importDefault(require("../Text"));
33
33
  var Formatter_1 = __importDefault(require("../Formatter"));
34
34
  var jsx_runtime_2 = require("react/jsx-runtime");
35
- var FeeDetail = function (_a) {
36
- var feeName = _a.feeName, value = _a.value;
37
- var theme = (0, material_1.useTheme)();
38
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.fieldTitle), { whiteSpace: "nowrap" }), children: feeName }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { flex: 1, width: "fit-content", alignItems: "flex-end" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: value }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: value, start: "~ " }) })] })] }));
39
- };
35
+ var parsePropsData_1 = __importDefault(require("../../../utils/parsePropsData"));
40
36
  function Fees(props) {
37
+ var _a, _b;
41
38
  var sx = props.sx, rest = __rest(props, ["sx"]);
42
39
  var theme = (0, material_1.useTheme)();
40
+ var feesData = (0, parsePropsData_1.default)(props === null || props === void 0 ? void 0 : props.feesData);
43
41
  return ((0, jsx_runtime_1.jsxs)(material_1.Accordion, __assign({ defaultExpanded: true }, rest, { sx: __assign({ "&.MuiAccordion-root": {
44
42
  backgroundColor: "transparent",
45
43
  margin: 0,
@@ -58,9 +56,20 @@ function Fees(props) {
58
56
  }, "& .MuiAccordionDetails-root": {
59
57
  paddingLeft: theme.mixins.customPadding.p12,
60
58
  paddingRight: theme.mixins.customPadding.p12,
61
- } }, 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.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: [1, 2, 3].map(function (item, index) { return ((0, jsx_runtime_1.jsxs)(jsx_runtime_2.Fragment, { children: [index !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
62
- borderRight: "1px dashed ".concat(theme.palette.border.white24),
63
- flex: 1,
64
- } })), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("timeline_dot"), width: 16 })] }, item)); }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { flex: 1 }), children: [(0, jsx_runtime_1.jsx)(FeeDetail, { feeName: "Fee 1", value: 1000 }), (0, jsx_runtime_1.jsx)(FeeDetail, { feeName: "Fee 2", value: 1000 }), (0, jsx_runtime_1.jsx)(FeeDetail, { feeName: "Fee 3", value: 1000 })] })] }) })] })));
59
+ } }, 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.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: (_a = feesData === null || feesData === void 0 ? void 0 : feesData.feeDetail) === null || _a === void 0 ? void 0 : _a.map(function (item, index) {
60
+ var _a;
61
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_2.Fragment, { children: [index !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
62
+ borderRight: "1px dashed ".concat(theme.palette.border.white24),
63
+ flex: 1,
64
+ } })), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("timeline_dot"), width: 16 })] }, (_a = item.feeType) === null || _a === void 0 ? void 0 : _a.name));
65
+ }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { flex: 1, gap: theme.mixins.gaps.g8 }), children: (_b = feesData === null || feesData === void 0 ? void 0 : feesData.feeDetail) === null || _b === void 0 ? void 0 : _b.map(function (item) {
66
+ var _a, _b;
67
+ return ((0, jsx_runtime_1.jsx)(FeeDetail, { feeName: (_a = item.feeType) === null || _a === void 0 ? void 0 : _a.name, feeInCurrency: item.feeInCurrency, feeInUSD: item.feeInUSD, currencyName: "USDT" }, (_b = item.feeType) === null || _b === void 0 ? void 0 : _b.name));
68
+ }) })] }) })] })));
65
69
  }
66
70
  exports.default = Fees;
71
+ var FeeDetail = function (_a) {
72
+ var feeName = _a.feeName, feeInCurrency = _a.feeInCurrency, feeInUSD = _a.feeInUSD, currencyName = _a.currencyName;
73
+ var theme = (0, material_1.useTheme)();
74
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.fieldTitle), { whiteSpace: "nowrap" }), children: feeName }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { flex: 1, width: "fit-content", alignItems: "flex-end" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: feeInCurrency, unit: " ".concat(currencyName) }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: feeInUSD, start: "~ $" }) })] })] }));
75
+ };
@@ -145,6 +145,7 @@ var AmountError;
145
145
  })(AmountError || (exports.AmountError = AmountError = {}));
146
146
  var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
147
147
  var swiperKey = (0, react_1.useId)();
148
+ console.warn("🚀 ~ swiperKey:", swiperKey);
148
149
  var drawerRef = (0, react_1.useRef)(null);
149
150
  var swiperRef = (0, react_1.useRef)(null);
150
151
  var theme = (0, material_1.useTheme)();
@@ -168,8 +169,8 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
168
169
  var _m = (0, react_1.useState)(), selectedMethod = _m[0], setSelectedMethod = _m[1];
169
170
  var _o = (0, react_1.useState)(), sendInfoGet = _o[0], setSendInfoGet = _o[1];
170
171
  var _p = (0, react_1.useState)(false), isLoadingEstimateFee = _p[0], setIsLoadingEstimateFee = _p[1];
171
- // const [estimateFee, setEstimateFee] = useState<number>();
172
- var _q = (0, react_1.useState)(), recipientAddressError = _q[0], setRecipientAddressError = _q[1];
172
+ var _q = (0, react_1.useState)(), estimateFee = _q[0], setEstimateFee = _q[1];
173
+ var _r = (0, react_1.useState)(), recipientAddressError = _r[0], setRecipientAddressError = _r[1];
173
174
  var onlyChangeAddress = (0, react_1.useRef)(false);
174
175
  var withdrawToken = (0, react_1.useMemo)(function () {
175
176
  return selectedMethod === SendMethods.TRANSFER_EXTERNAL
@@ -188,6 +189,11 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
188
189
  }
189
190
  return newNetWorks;
190
191
  }, [selectedToken, selectedNetwork]);
192
+ var estimateReceive = (0, react_1.useMemo)(function () {
193
+ if (!estimateFee || !amount)
194
+ return undefined;
195
+ return +amount - +(estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeInCurrency);
196
+ }, [estimateFee, amount]);
191
197
  var clearValues = function () {
192
198
  setSelectedToken(undefined);
193
199
  setSelectedNetwork(undefined);
@@ -304,12 +310,12 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
304
310
  var data = dataPromptly !== null && dataPromptly !== void 0 ? dataPromptly : sendInfoGet;
305
311
  console.warn("🚀 ~ data handleSelectContinueTransferExternal:", data);
306
312
  (_a = suggestUseTransferInternalDialogRef.current) === null || _a === void 0 ? void 0 : _a.close();
307
- var tokenSet = findWithdrawToken((data === null || data === void 0 ? void 0 : data.jetton) || "");
308
313
  setSelectedMethod(SendMethods.TRANSFER_EXTERNAL);
309
314
  setRecipientAddress(data === null || data === void 0 ? void 0 : data.address);
310
315
  if (onlyChangeAddress.current) {
311
316
  return;
312
317
  }
318
+ var tokenSet = findWithdrawToken((data === null || data === void 0 ? void 0 : data.jetton) || "");
313
319
  if (!tokenSet) {
314
320
  gotoStep(WithdrawStep.SELECT_TOKEN);
315
321
  }
@@ -357,6 +363,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
357
363
  response = _a.sent();
358
364
  console.warn("🚀 ~ handleGetEstimateFee ~ response:", response);
359
365
  setIsLoadingEstimateFee(false);
366
+ setEstimateFee(response === null || response === void 0 ? void 0 : response.data);
360
367
  return [2 /*return*/];
361
368
  }
362
369
  });
@@ -604,11 +611,11 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
604
611
  placeholder: "Enter memo",
605
612
  value: memo,
606
613
  onChange: handleChangeMemo,
607
- } })] })), (0, jsx_runtime_1.jsx)(Fees_1.default, {}), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, onClick: handleSend, status: !!amountError ||
614
+ } })] })), (0, jsx_runtime_1.jsx)(Fees_1.default, { feesData: JSON.stringify(estimateFee) }), (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)(material_1.Box, { onClick: handleReSelectNetwork, sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g6, ml: "auto", cursor: "pointer" }), children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), 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 ||
615
+ !!recipientAddressError ||
608
616
  !recipientAddress ||
609
617
  !amount ||
610
618
  !selectedToken ||
611
- !!recipientAddressError ||
612
619
  isLoadingEstimateFee
613
620
  ? Button_1.BUTTON_STATUS.DISABLED
614
621
  : Button_1.BUTTON_STATUS.ENABLED, children: "Continue" })] }) }, WithdrawStep.FORM)] }, swiperKey), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAddressQrCodeRef, onResult: handleScanAddressQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: backDropRef }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { overrideOpen: !!infoDialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
@@ -6,10 +6,10 @@ export interface GetEstimateFeeServiceQuery {
6
6
  export interface GetEstimateFeeServiceResponse {
7
7
  success: boolean;
8
8
  message: string;
9
- data: Data;
9
+ data: FeesDataType;
10
10
  timestamp: string;
11
11
  }
12
- interface Data {
12
+ export interface FeesDataType {
13
13
  feeInUSD: number;
14
14
  feeInCurrency: number;
15
15
  originalAmountInUSD: number;
@@ -17,15 +17,14 @@ interface Data {
17
17
  originalCurrency: string;
18
18
  feeDetail: FeeDetail[];
19
19
  }
20
- interface FeeDetail {
20
+ export interface FeeDetail {
21
21
  feeType: FeeType;
22
22
  feeInUSD: number;
23
23
  feeInCurrency: number;
24
24
  feePercent: number;
25
25
  feeFixed: number;
26
26
  }
27
- interface FeeType {
27
+ export interface FeeType {
28
28
  name: string;
29
29
  slug: string;
30
30
  }
31
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.386",
3
+ "version": "0.0.388",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",