tek-wallet 0.0.460 → 0.0.461

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.
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ // "use client";
3
+ // import { Box, useTheme } from "@mui/material";
4
+ // import Button, { BUTTON_STATUS } from "../../ui/Button";
5
+ // import { DrawerComponentRef } from "../DrawerComponent";
6
+ // import ConfirmLayout, { ConfirmLayoutProps } from "../ConfirmLayout";
7
+ // import { ActionConfirm } from "../ConfirmLayout/type";
8
+ // import LineValue from "../LineValue";
9
+ // import Formatter from "../Formatter";
10
+ // import ConfirmByPasscode from "../ConfirmByPasscode";
11
+ // import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
12
+ // import Text from "../Text";
13
+ // import { LockCurrency } from "../../../services/axios/get-lock-tokens-list-service/type";
14
+ // import RequireConnect from "../RequireConnect";
15
+ // import useWalletData from "../../../hooks/useWalletData";
16
+ // import { SendExternalBody, SendExternalResponse } from "../../../services/axios/send-external-service/type";
17
+ // import useWithdrawData from "../../../hooks/useWithdrawData";
18
+ // import sendExternalService from "../../../services/axios/send-external-service";
19
+ // import Icon from "../Icon";
20
+ // import Fees from "../Fees";
21
+ // import { FeesDataType } from "../../../services/axios/get-est-fee-service/type";
22
+ // interface SendExternalTokenProps extends Omit<ConfirmLayoutProps, "action"> {
23
+ // sendExternalData: SendExternalBody;
24
+ // onSuccess?: (data: SendExternalResponse) => any;
25
+ // }
26
+ // export interface SendExternalTokenRef {
27
+ // open: () => void;
28
+ // close: () => void;
29
+ // }
30
+ // export enum SendExternalTokenError {
31
+ // TOKEN_NOT_FOUND = "Token not found",
32
+ // NOT_ENOUGH_BALANCE = "Not enough balance",
33
+ // MAX_AMOUNT = "Max amount",
34
+ // MIN_AMOUNT = "Min amount",
35
+ // FAILED = "Failed",
36
+ // }
37
+ // const SendExternalToken = forwardRef<SendExternalTokenRef, SendExternalTokenProps>((props, ref) => {
38
+ // const theme = useTheme();
39
+ // const { withdrawTokens } = useWithdrawData();
40
+ // const { isAuthenticated } = useWalletData();
41
+ // const confirmLayoutDrawerRef = useRef<DrawerComponentRef>(null);
42
+ // const [token, setToken] = useState<LockCurrency | undefined>(undefined);
43
+ // const [error, setError] = useState<SendExternalTokenError | undefined>(undefined);
44
+ // const [errorAmount, setErrorAmount] = useState<string | number | undefined>(undefined);
45
+ // const [buttonStatus, setButtonStatus] = useState<BUTTON_STATUS>(BUTTON_STATUS.ENABLED);
46
+ // const [estimateFee, setEstimateFee] = useState<FeesDataType>();
47
+ // const amount = props.sendExternalData.amount;
48
+ // const network = props.sendExternalData.network;
49
+ // const memo = props.sendExternalData.memo;
50
+ // const toAddress = props.sendExternalData.to_address;
51
+ // const validateAmount = useCallback(
52
+ // (sendExternalData: SendExternalBody) => {
53
+ // const token = withdrawTokens?.find((token) => token.slug === sendExternalData.currency_slug);
54
+ // console.warn("🚀 ~ validateAmount ~ lockData:", sendExternalData, withdrawTokens, token);
55
+ // setToken(token);
56
+ // if (!token) {
57
+ // setError(SendExternalTokenError.TOKEN_NOT_FOUND);
58
+ // return;
59
+ // }
60
+ // if (+sendExternalData.amount > token.max_value) {
61
+ // setError(SendExternalTokenError.MAX_AMOUNT);
62
+ // setErrorAmount(token.max_value);
63
+ // return;
64
+ // }
65
+ // if (+sendExternalData.amount < token.min_value) {
66
+ // setError(SendExternalTokenError.MIN_AMOUNT);
67
+ // setErrorAmount(token.min_value);
68
+ // return;
69
+ // }
70
+ // if (+sendExternalData.amount > +token.balance) {
71
+ // setError(SendExternalTokenError.NOT_ENOUGH_BALANCE);
72
+ // setErrorAmount(token.balance);
73
+ // return;
74
+ // }
75
+ // setError(undefined);
76
+ // setErrorAmount(undefined);
77
+ // },
78
+ // [withdrawTokens]
79
+ // );
80
+ // const handleSendExternalToken = async (passcode: string) => {
81
+ // try {
82
+ // console.warn("🚀 ~ handleSendExternalToken ~ sendExternalData:", props.sendExternalData, passcode);
83
+ // setButtonStatus(BUTTON_STATUS.LOADING);
84
+ // const response = await sendExternalService(props.sendExternalData);
85
+ // console.warn("🚀 ~ handleSendExternalToken ~ response:", response);
86
+ // if (response.success) {
87
+ // confirmLayoutDrawerRef.current?.close();
88
+ // setButtonStatus(BUTTON_STATUS.ENABLED);
89
+ // props.onSuccess?.(response);
90
+ // } else {
91
+ // throw new Error("Send external failed");
92
+ // }
93
+ // } catch (err) {
94
+ // console.error(err);
95
+ // setButtonStatus(BUTTON_STATUS.ERROR);
96
+ // setTimeout(() => {
97
+ // setButtonStatus(BUTTON_STATUS.ENABLED);
98
+ // }, 1200);
99
+ // }
100
+ // };
101
+ // const handleOpen = () => {
102
+ // if (!isAuthenticated) throw new Error("Please connect your wallet");
103
+ // confirmLayoutDrawerRef.current?.open();
104
+ // };
105
+ // const handleClose = () => {
106
+ // if (!isAuthenticated) throw new Error("Please connect your wallet");
107
+ // confirmLayoutDrawerRef.current?.close();
108
+ // };
109
+ // useImperativeHandle(ref, () => ({
110
+ // open: handleOpen,
111
+ // close: handleClose,
112
+ // }));
113
+ // useEffect(() => {
114
+ // validateAmount(props.sendExternalData);
115
+ // }, [validateAmount, props.sendExternalData]);
116
+ // return (
117
+ // <RequireConnect>
118
+ // <ConfirmLayout ref={confirmLayoutDrawerRef} action={ActionConfirm.LOCK} trigger={props.children}>
119
+ // <Box sx={{ ...theme.mixins.column, gap: theme.mixins.gaps.g12 }}>
120
+ // <Box
121
+ // sx={{
122
+ // ...theme.mixins.paper,
123
+ // }}
124
+ // >
125
+ // <LineValue
126
+ // field="Recipient address"
127
+ // value={
128
+ // <Text
129
+ // sx={{
130
+ // wordBreak: "break-all",
131
+ // }}
132
+ // >
133
+ // {toAddress}
134
+ // </Text>
135
+ // }
136
+ // />
137
+ // <LineValue
138
+ // field="Network"
139
+ // value={
140
+ // <Box
141
+ // sx={{
142
+ // ...theme.mixins.row,
143
+ // gap: theme.mixins.gaps.g6,
144
+ // ml: "auto",
145
+ // }}
146
+ // >
147
+ // {/* <Icon width={20} src={props.sendExternalData.network?.icon} /> */}
148
+ // <Text sx={{ ...theme.mixins.value }}>{props.sendExternalData.network}</Text>
149
+ // </Box>
150
+ // }
151
+ // />
152
+ // <LineValue field="Amount" value={<Formatter value={amount} unit={` ${token?.name}`} />} />
153
+ // {!!memo && <LineValue field="Memo" value={memo} />}
154
+ // {estimateFee?.feeDetail?.length && !!amount && (
155
+ // <Fees feesData={JSON.stringify(estimateFee)} amount={+amount} />
156
+ // )}
157
+ // <LineValue
158
+ // field="Receive amount estimated"
159
+ // value={
160
+ // <Text
161
+ // sx={{
162
+ // fontWeight: theme.typography.fontWeight600,
163
+ // fontSize: theme.typography.fontSize16,
164
+ // }}
165
+ // >
166
+ // <Formatter value={estimateReceive} unit={` ${selectedToken?.name}`} />
167
+ // </Text>
168
+ // }
169
+ // />
170
+ // </Box>
171
+ // <ConfirmByPasscode action={ActionConfirm.LOCK} onConfirmSuccess={handleSendExternalToken}>
172
+ // <Button.Primary status={!!error ? BUTTON_STATUS.DISABLED : buttonStatus} sx={{ width: "100%" }}>
173
+ // Confirm
174
+ // </Button.Primary>
175
+ // </ConfirmByPasscode>
176
+ // </Box>
177
+ // </ConfirmLayout>
178
+ // </RequireConnect>
179
+ // );
180
+ // });
181
+ // SendExternalToken.displayName = "SendExternalToken";
182
+ // export default SendExternalToken;
@@ -0,0 +1,4 @@
1
+ export interface LockData {
2
+ amount: number;
3
+ tokenSlug: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -121,7 +121,6 @@ var type_1 = require("../ConfirmLayout/type");
121
121
  var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
122
122
  var LineValue_1 = __importDefault(require("../LineValue"));
123
123
  var send_external_service_1 = __importDefault(require("../../../services/axios/send-external-service"));
124
- var useRealtime_1 = __importDefault(require("../../../hooks/useRealtime"));
125
124
  var SendMethods;
126
125
  (function (SendMethods) {
127
126
  SendMethods["SCAN_QR_CODE"] = "scan qr code";
@@ -151,7 +150,6 @@ var AmountError;
151
150
  })(AmountError || (exports.AmountError = AmountError = {}));
152
151
  var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
153
152
  var _a, _b;
154
- var pushNotification = (0, useRealtime_1.default)().pushNotification;
155
153
  var drawerRef = (0, react_1.useRef)(null);
156
154
  var swiperRef = (0, react_1.useRef)(null);
157
155
  var confirmLayoutDrawerRef = (0, react_1.useRef)(null);
@@ -201,13 +199,6 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
201
199
  return undefined;
202
200
  return +amount - +(estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeInCurrency);
203
201
  }, [estimateFee, amount]);
204
- var testPushNotification = function () {
205
- pushNotification({
206
- message: "Test notification",
207
- type: "success",
208
- id: new Date().getTime().toString(),
209
- });
210
- };
211
202
  (0, react_1.useEffect)(function () {
212
203
  setTimeout(function () {
213
204
  var _a;
@@ -572,6 +563,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
572
563
  if (response.success) {
573
564
  close();
574
565
  (_a = confirmLayoutDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
566
+ setSendButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
575
567
  (_b = props.onSendSuccess) === null || _b === void 0 ? void 0 : _b.call(props, response);
576
568
  }
577
569
  else {
@@ -627,11 +619,11 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
627
619
  : WITHDRAW_STEP_NAME[currentStep], children: (0, jsx_runtime_1.jsx)(CloseModal_1.default, { sx: { marginLeft: "auto" }, onClick: close }) }), children: [(0, jsx_runtime_1.jsxs)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: {
628
620
  autoHeight: true,
629
621
  spaceBetween: 32,
630
- }, disableSwipe: true, children: [(0, jsx_runtime_1.jsxs)(react_2.SwiperSlide, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.Primary, { onClick: testPushNotification, children: " Push" }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { height: "fit-content" }), children: Object.values(SendMethods).map(function (item, index) {
631
- return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index !== 0 && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(ListItemCustom_1.default, { title: item, description: item, icon: (0, getIcon_1.default)(item + "_icon"), onClick: function () { return handleSelectMethod(item); }, sx: {
632
- py: theme.mixins.customPadding.p12,
633
- } })] }, item));
634
- }) })] }, WithdrawStep.SELECT_METHOD), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children: withdrawToken === null || withdrawToken === void 0 ? void 0 : withdrawToken.map(function (item) {
622
+ }, disableSwipe: true, children: [(0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { height: "fit-content" }), children: Object.values(SendMethods).map(function (item, index) {
623
+ return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [index !== 0 && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(ListItemCustom_1.default, { title: item, description: item, icon: (0, getIcon_1.default)(item + "_icon"), onClick: function () { return handleSelectMethod(item); }, sx: {
624
+ py: theme.mixins.customPadding.p12,
625
+ } })] }, item));
626
+ }) }) }, WithdrawStep.SELECT_METHOD), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children: withdrawToken === null || withdrawToken === void 0 ? void 0 : withdrawToken.map(function (item) {
635
627
  var stringifiedTokenData = JSON.stringify(item);
636
628
  if (!item)
637
629
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.460",
3
+ "version": "0.0.461",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",