tek-wallet 0.0.694 → 0.0.696

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.
@@ -39,7 +39,7 @@ var AppBackDrop = (0, react_1.forwardRef)(function (props, ref) {
39
39
  open: function () { return setIsOpen(true); },
40
40
  close: function () { return setIsOpen(false); },
41
41
  }); });
42
- return ((0, jsx_runtime_1.jsx)(material_2.Backdrop, __assign({ sx: __assign({ color: "text.white", zIndex: theme.zIndex.drawer + 1, "& .MuiBackdrop-root": {
42
+ return ((0, jsx_runtime_1.jsx)(material_2.Backdrop, __assign({ sx: __assign({ color: theme.palette.text.white, zIndex: theme.zIndex.drawer + 1, "& .MuiBackdrop-root": {
43
43
  backdropFilter: "blur(12px)",
44
44
  } }, sx) }, rest, { open: open !== null && open !== void 0 ? open : isOpen, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", alignItems: "center", color: "white", gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 28, color: "inherit", value: 50, thickness: 4 }), message && (0, jsx_runtime_1.jsx)(Text_1.default, { children: message })] }) })));
45
45
  });
@@ -25,15 +25,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  var jsx_runtime_1 = require("react/jsx-runtime");
26
26
  var material_1 = require("@mui/material");
27
27
  var react_1 = require("react");
28
+ var ThemeProvider_1 = require("../../../providers/ThemeProvider");
28
29
  var AppDialog = (0, react_1.forwardRef)(function (props, ref) {
29
30
  var _a = (0, react_1.useState)(false), isOpen = _a[0], setIsOpen = _a[1];
30
31
  var sx = props.sx, children = props.children, overrideOpen = props.overrideOpen, rest = __rest(props, ["sx", "children", "overrideOpen"]);
32
+ var theme = (0, ThemeProvider_1.useTheme)();
31
33
  (0, react_1.useImperativeHandle)(ref, function () { return ({
32
34
  open: function () { return setIsOpen(true); },
33
35
  close: function () { return setIsOpen(false); },
34
36
  }); });
35
37
  return ((0, jsx_runtime_1.jsx)(material_1.Dialog, __assign({ open: overrideOpen !== null && overrideOpen !== void 0 ? overrideOpen : isOpen, "aria-labelledby": "alert-dialog-title", "aria-describedby": "alert-dialog-description", sx: __assign({ "& .MuiPaper-root": {
36
38
  backgroundColor: "transparent",
39
+ borderRadius: theme.mixins.customRadius.r12,
40
+ overflow: "hidden",
37
41
  } }, sx) }, rest, { children: children })));
38
42
  });
39
43
  AppDialog.displayName = "AppDialog";
@@ -53,16 +53,13 @@ var QrCodeReader = (0, react_1.forwardRef)(function (props, ref) {
53
53
  if (video) {
54
54
  var stream = video.srcObject;
55
55
  var track = stream === null || stream === void 0 ? void 0 : stream.getTracks()[0];
56
- console.warn("🚀 ~ toggleFlash ~ track:", track.getCapabilities());
57
56
  var torch = track.getCapabilities().torch;
58
- console.warn("🚀 ~ toggleFlash ~ torch:", torch);
59
57
  if (torch) {
60
58
  track
61
59
  .applyConstraints({
62
60
  advanced: [{ torch: !flashEnabled }],
63
61
  })
64
62
  .then(function () {
65
- console.warn("🚀 ~ toggleFlash ~ flashEnabled:", flashEnabled);
66
63
  setFlashEnabled(!flashEnabled);
67
64
  })
68
65
  .catch(function (err) { return console.error("Error toggling flash:", err); });
@@ -79,18 +76,22 @@ var QrCodeReader = (0, react_1.forwardRef)(function (props, ref) {
79
76
  };
80
77
  }
81
78
  }, [isOpen]);
82
- // Thêm CSS animation vào document khi component được mount
83
- (0, react_1.useEffect)(function () {
84
- var animationStyle = "\n @keyframes move-up-down {\n 0% {\n top: 0%;\n } \n 50% {\n top: 100%;\n }\n 100% {\n top: 0%;\n }\n }\n ";
85
- // Thêm animation vào stylesheet đầu tiên của trang
86
- document.styleSheets[0].insertRule(animationStyle, 0);
87
- }, []); // Chỉ chạy một lần khi component mount
88
- return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { trigger: props.children, ref: drawerRef, onClose: onClose, onOpen: onOpen, children: (0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { header: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { hideBack: true, title: "Scan QR code", sx: {
79
+ (0, react_1.useLayoutEffect)(function () {
80
+ var styleTag = document.createElement("style");
81
+ styleTag.innerHTML = "\n @keyframes move-up-down {\n 0% {\n top: 0%;\n } \n 50% {\n top: 100%;\n }\n 100% {\n top: 0%;\n }\n }\n\n .move-up-down-animation {\n animation: move-up-down 5s infinite linear;\n }\n ";
82
+ document.head.appendChild(styleTag);
83
+ return function () {
84
+ styleTag.remove();
85
+ };
86
+ }, []);
87
+ return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { trigger: props.children, ref: drawerRef, onClose: onClose, onOpen: onOpen, children: (0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { sx: {
88
+ backgroundColor: "transparent !important",
89
+ }, header: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { hideBack: true, title: "Scan QR code", sx: {
89
90
  position: "absolute",
90
91
  top: 0,
91
92
  left: 0,
92
93
  right: 0,
93
- zIndex: 1000,
94
+ zIndex: 1001,
94
95
  height: "fit-content",
95
96
  fontWeight: 700,
96
97
  }, children: (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: {
@@ -98,82 +99,83 @@ var QrCodeReader = (0, react_1.forwardRef)(function (props, ref) {
98
99
  height: "1.5rem",
99
100
  cursor: "pointer",
100
101
  ml: "auto",
101
- }, onClick: close, children: (0, jsx_runtime_1.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 15L15 5M5 5L15 15", stroke: "white", "stroke-width": "1.25", "stroke-linecap": "round", "stroke-linejoin": "round" }) }) }) }), children: (0, jsx_runtime_1.jsx)("div", { ref: qrReaderContainer, children: isOpen && ((0, jsx_runtime_1.jsxs)(react_qr_scanner_1.Scanner, { components: {
102
- audio: false,
103
- finder: false,
104
- }, styles: {
105
- container: {
106
- width: "100%",
107
- height: "100dvh",
108
- position: "relative",
109
- },
110
- video: {
111
- width: "100%",
112
- height: "100%",
113
- objectFit: "cover",
114
- },
115
- }, onScan: props.onResult, children: [!isReaderReady && ((0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { open: !isReaderReady, message: "Starting the camera..." })), isReaderReady && ((0, jsx_runtime_1.jsxs)("div", { style: {
116
- width: "60%",
117
- aspectRatio: "1",
118
- position: "absolute",
119
- top: "40%",
120
- left: "50%",
121
- transform: "translateX(-50%) translateY(-50%)",
122
- display: "relative",
123
- boxShadow: "0 0 2px max(50vw, 50dvh) rgba(0, 0, 0, 0.36)",
124
- color: "#C5E99F",
125
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
126
- position: "absolute",
127
- left: 0,
128
- width: "100%",
129
- height: "2px",
130
- backgroundImage: "linear-gradient(to right, transparent, currentColor, transparent)",
131
- // animation: "move-up-down 4s infinite linear",
132
- } }), (0, jsx_runtime_1.jsx)("div", { style: {
133
- position: "absolute",
134
- borderTopLeftRadius: STYLES.borderRadius,
135
- top: "-".concat(STYLES.borderWidth),
136
- left: "-".concat(STYLES.borderWidth),
137
- width: STYLES.nodeSize,
138
- height: STYLES.nodeSize,
139
- borderTop: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
140
- borderLeft: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
141
- } }), (0, jsx_runtime_1.jsx)("div", { style: {
142
- position: "absolute",
143
- borderTopRightRadius: STYLES.borderRadius,
144
- top: "-".concat(STYLES.borderWidth),
145
- right: "-".concat(STYLES.borderWidth),
146
- width: STYLES.nodeSize,
147
- height: STYLES.nodeSize,
148
- borderTop: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
149
- borderRight: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
150
- } }), (0, jsx_runtime_1.jsx)("div", { style: {
151
- position: "absolute",
152
- borderBottomLeftRadius: STYLES.borderRadius,
153
- bottom: "-".concat(STYLES.borderWidth),
154
- left: "-".concat(STYLES.borderWidth),
155
- width: STYLES.nodeSize,
156
- height: STYLES.nodeSize,
157
- borderBottom: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
158
- borderLeft: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
159
- } }), (0, jsx_runtime_1.jsx)("div", { style: {
160
- position: "absolute",
161
- borderBottomRightRadius: STYLES.borderRadius,
162
- bottom: "-".concat(STYLES.borderWidth),
163
- right: "-".concat(STYLES.borderWidth),
164
- width: STYLES.nodeSize,
165
- height: STYLES.nodeSize,
166
- borderBottom: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
167
- borderRight: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
168
- } }), (0, jsx_runtime_1.jsx)("div", { onClick: toggleFlash, style: {
169
- position: "absolute",
170
- top: "100%",
102
+ }, onClick: close, children: (0, jsx_runtime_1.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 15L15 5M5 5L15 15", stroke: "white", "stroke-width": "1.25", "stroke-linecap": "round", "stroke-linejoin": "round" }) }) }) }), children: (0, jsx_runtime_1.jsx)("div", { ref: qrReaderContainer, children: isOpen && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
103
+ opacity: isReaderReady ? 0 : 1,
104
+ transition: "opacity 0.3s ease-in-out",
105
+ }, children: (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { open: true, message: "Starting the camera..." }) }), (0, jsx_runtime_1.jsxs)("div", { style: { transition: "opacity 0.3s ease-in-out", opacity: isReaderReady ? 1 : 0 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
106
+ width: "60%",
107
+ aspectRatio: "1",
108
+ position: "fixed",
109
+ top: "50%",
171
110
  left: "50%",
172
- transform: "translateX(-50%) translateY(0.75rem)",
173
- fontSize: "1rem",
174
- fontWeight: 500,
175
- color: "#fff",
176
- }, children: "Scan QR code" })] }))] })) }) }) }));
111
+ zIndex: 1000,
112
+ transform: "translateX(-50%) translateY(-50%)",
113
+ boxShadow: "0 0 2px max(50vw, 50dvh) rgba(0, 0, 0, 0.36)",
114
+ color: "#C5E99F",
115
+ }, children: [(0, jsx_runtime_1.jsx)("div", { className: "move-up-down-animation", style: {
116
+ position: "absolute",
117
+ left: 0,
118
+ width: "100%",
119
+ height: "2px",
120
+ backgroundImage: "linear-gradient(to right, transparent, currentColor, transparent)",
121
+ } }), (0, jsx_runtime_1.jsx)("div", { style: {
122
+ position: "absolute",
123
+ borderTopLeftRadius: STYLES.borderRadius,
124
+ top: "-".concat(STYLES.borderWidth),
125
+ left: "-".concat(STYLES.borderWidth),
126
+ width: STYLES.nodeSize,
127
+ height: STYLES.nodeSize,
128
+ borderTop: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
129
+ borderLeft: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
130
+ } }), (0, jsx_runtime_1.jsx)("div", { style: {
131
+ position: "absolute",
132
+ borderTopRightRadius: STYLES.borderRadius,
133
+ top: "-".concat(STYLES.borderWidth),
134
+ right: "-".concat(STYLES.borderWidth),
135
+ width: STYLES.nodeSize,
136
+ height: STYLES.nodeSize,
137
+ borderTop: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
138
+ borderRight: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
139
+ } }), (0, jsx_runtime_1.jsx)("div", { style: {
140
+ position: "absolute",
141
+ borderBottomLeftRadius: STYLES.borderRadius,
142
+ bottom: "-".concat(STYLES.borderWidth),
143
+ left: "-".concat(STYLES.borderWidth),
144
+ width: STYLES.nodeSize,
145
+ height: STYLES.nodeSize,
146
+ borderBottom: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
147
+ borderLeft: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
148
+ } }), (0, jsx_runtime_1.jsx)("div", { style: {
149
+ position: "absolute",
150
+ borderBottomRightRadius: STYLES.borderRadius,
151
+ bottom: "-".concat(STYLES.borderWidth),
152
+ right: "-".concat(STYLES.borderWidth),
153
+ width: STYLES.nodeSize,
154
+ height: STYLES.nodeSize,
155
+ borderBottom: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
156
+ borderRight: "".concat(STYLES.borderWidth, " solid ").concat(STYLES.borderColor),
157
+ } }), (0, jsx_runtime_1.jsx)("div", { onClick: toggleFlash, style: {
158
+ position: "absolute",
159
+ top: "100%",
160
+ left: "50%",
161
+ transform: "translateX(-50%) translateY(0.75rem)",
162
+ fontSize: "1rem",
163
+ fontWeight: 500,
164
+ color: "#fff",
165
+ } })] }), (0, jsx_runtime_1.jsx)(react_qr_scanner_1.Scanner, { components: {
166
+ audio: false,
167
+ finder: false,
168
+ }, styles: {
169
+ container: {
170
+ width: "100%",
171
+ height: "100dvh",
172
+ },
173
+ video: {
174
+ width: "100%",
175
+ height: "100%",
176
+ objectFit: "cover",
177
+ },
178
+ }, onScan: props.onResult })] })] })) }) }) }));
177
179
  });
178
180
  QrCodeReader.displayName = "QrCodeReader";
179
181
  exports.default = QrCodeReader;
@@ -177,23 +177,23 @@ exports.ScanQRToSend = (0, react_1.forwardRef)(function (props, ref) {
177
177
  }
178
178
  });
179
179
  }); };
180
- return ((0, jsx_runtime_1.jsxs)(RequireConnect_1.default, { sx: sx, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { onClick: openCanner, className: className, sx: sx, children: children }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: loadingDropRef }), (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: {
181
- textAlign: "center",
182
- display: "inline-block",
183
- width: "100%",
184
- }, children: infoDialogContent }), actions: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsOk), { width: "100%", display: "inline-block" }), onClick: handleClearInfoDialogContent, children: "Ok" }) }) }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { ref: suggestUseTransferInternalDialogRef, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: "This wallet is supported send internally, use it for faster transaction?", actions: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
185
- display: "grid",
186
- gridTemplateColumns: "1fr auto 1fr",
187
- gap: theme.mixins.gaps.g8,
188
- }, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsCancel), { width: "100%" }), onClick: function () {
189
- var _a;
190
- gotoTransferExternal();
191
- (_a = suggestUseTransferInternalDialogRef.current) === null || _a === void 0 ? void 0 : _a.close();
192
- }, children: "Keep external" }), (0, jsx_runtime_1.jsx)(material_1.Divider, { orientation: "vertical", variant: "middle", flexItem: true }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsOk), { width: "100%" }), onClick: function () {
193
- var _a;
194
- gotoTransferInternal();
195
- (_a = suggestUseTransferInternalDialogRef.current) === null || _a === void 0 ? void 0 : _a.close();
196
- }, children: "Ok" })] }) }) })] }));
180
+ return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { sx: sx, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { onClick: openCanner, className: className, sx: sx, children: children }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: loadingDropRef }), (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: {
181
+ textAlign: "center",
182
+ display: "inline-block",
183
+ width: "100%",
184
+ }, children: infoDialogContent }), actions: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsOk), { width: "100%", display: "inline-block" }), onClick: handleClearInfoDialogContent, children: "Ok" }) }) }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { ref: suggestUseTransferInternalDialogRef, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: "This wallet is supported send internally, use it for faster transaction?", actions: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
185
+ display: "grid",
186
+ gridTemplateColumns: "1fr auto 1fr",
187
+ gap: theme.mixins.gaps.g8,
188
+ }, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsCancel), { width: "100%" }), onClick: function () {
189
+ var _a;
190
+ gotoTransferExternal();
191
+ (_a = suggestUseTransferInternalDialogRef.current) === null || _a === void 0 ? void 0 : _a.close();
192
+ }, children: "Keep external" }), (0, jsx_runtime_1.jsx)(material_1.Divider, { orientation: "vertical", variant: "middle", flexItem: true }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsOk), { width: "100%" }), onClick: function () {
193
+ var _a;
194
+ gotoTransferInternal();
195
+ (_a = suggestUseTransferInternalDialogRef.current) === null || _a === void 0 ? void 0 : _a.close();
196
+ }, children: "Ok" })] }) }) })] }) }));
197
197
  });
198
198
  exports.ScanQRToSend.displayName = "ScanQRToSend";
199
199
  exports.default = exports.ScanQRToSend;
@@ -17,11 +17,11 @@ export interface TransferConfirmationTokenRef {
17
17
  close: () => void;
18
18
  }
19
19
  export declare enum TransferConfirmationError {
20
- TOKEN_NOT_FOUND = "Token not found",
21
- NOT_ENOUGH_BALANCE = "Not enough balance",
22
- MAX_AMOUNT = "Max amount",
23
- MIN_AMOUNT = "Min amount",
24
- FAILED = "Failed"
20
+ TOKEN_NOT_FOUND = "\u24D8 Token not found",
21
+ NOT_ENOUGH_BALANCE = "\u24D8 Not enough balance",
22
+ MAX_AMOUNT = "\u24D8 Max amount",
23
+ MIN_AMOUNT = "\u24D8 Min amount",
24
+ FAILED = "\u24D8 Failed"
25
25
  }
26
26
  export declare const TransferConfirmation: import("react").ForwardRefExoticComponent<Omit<TransferConfirmationProps, "ref"> & import("react").RefAttributes<TransferConfirmationTokenRef>>;
27
27
  export default TransferConfirmation;
@@ -97,31 +97,31 @@ var RequireConnect_1 = __importDefault(require("../RequireConnect"));
97
97
  var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
98
98
  var type_1 = require("../../../services/axios/get-activities-service/type");
99
99
  var useWithdrawData_1 = __importDefault(require("../../../hooks/useWithdrawData"));
100
- var material_1 = require("@mui/material");
101
100
  var validate_wallet_address_service_1 = __importDefault(require("../../../services/axios/validate-wallet-address-service"));
102
101
  var type_2 = require("../../../services/axios/validate-wallet-address-service/type");
103
102
  var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
104
103
  var instructions_service_1 = __importDefault(require("../../../services/axios/instructions-service"));
104
+ var providers_1 = require("../../../providers");
105
105
  var TransferConfirmationError;
106
106
  (function (TransferConfirmationError) {
107
- TransferConfirmationError["TOKEN_NOT_FOUND"] = "Token not found";
108
- TransferConfirmationError["NOT_ENOUGH_BALANCE"] = "Not enough balance";
109
- TransferConfirmationError["MAX_AMOUNT"] = "Max amount";
110
- TransferConfirmationError["MIN_AMOUNT"] = "Min amount";
111
- TransferConfirmationError["FAILED"] = "Failed";
107
+ TransferConfirmationError["TOKEN_NOT_FOUND"] = "\u24D8 Token not found";
108
+ TransferConfirmationError["NOT_ENOUGH_BALANCE"] = "\u24D8 Not enough balance";
109
+ TransferConfirmationError["MAX_AMOUNT"] = "\u24D8 Max amount";
110
+ TransferConfirmationError["MIN_AMOUNT"] = "\u24D8 Min amount";
111
+ TransferConfirmationError["FAILED"] = "\u24D8 Failed";
112
112
  })(TransferConfirmationError || (exports.TransferConfirmationError = TransferConfirmationError = {}));
113
113
  exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
114
- var _a;
115
- var theme = (0, material_1.useTheme)();
114
+ var _a, _b;
115
+ var theme = (0, providers_1.useTheme)();
116
116
  var transferData = props.transferData, transferContent = props.transferContent;
117
- var _b = (0, useWithdrawData_1.default)(), sendInternalTokens = _b.sendInternalTokens, updateSendInternalToken = _b.updateSendInternalToken;
117
+ var _c = (0, useWithdrawData_1.default)(), sendInternalTokens = _c.sendInternalTokens, updateSendInternalToken = _c.updateSendInternalToken;
118
118
  var isInitPasscode = (0, useWalletData_1.default)().isInitPasscode;
119
119
  var confirmLayoutDrawerRef = (0, react_1.useRef)(null);
120
- var _c = (0, react_1.useState)(undefined), error = _c[0], setError = _c[1];
121
- var _d = (0, react_1.useState)(undefined), errorAmount = _d[0], setErrorAmount = _d[1];
122
- var _e = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), buttonStatus = _e[0], setButtonStatus = _e[1];
123
- var _f = (0, react_1.useState)(false), isValidatingAddress = _f[0], setIsValidatingAddress = _f[1];
124
- var _g = (0, react_1.useState)(undefined), errorAddress = _g[0], setErrorAddress = _g[1];
120
+ var _d = (0, react_1.useState)(undefined), error = _d[0], setError = _d[1];
121
+ var _e = (0, react_1.useState)(undefined), errorAmount = _e[0], setErrorAmount = _e[1];
122
+ var _f = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), buttonStatus = _f[0], setButtonStatus = _f[1];
123
+ var _g = (0, react_1.useState)(false), isValidatingAddress = _g[0], setIsValidatingAddress = _g[1];
124
+ var _h = (0, react_1.useState)(undefined), errorAddress = _h[0], setErrorAddress = _h[1];
125
125
  var toAddress = transferData.to_address;
126
126
  var amount = transferData.amount;
127
127
  var currencySlug = transferData.currency_slug;
@@ -165,7 +165,7 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
165
165
  message = (_a.sent()).message;
166
166
  setIsValidatingAddress(false);
167
167
  if (message !== type_2.ValidateWalletAddressResultMessage.INTERNAL_WALLET) {
168
- setErrorAddress("Invalid wallet address");
168
+ setErrorAddress(" This address is not a valid internal wallet address");
169
169
  return [2 /*return*/, false];
170
170
  }
171
171
  setErrorAddress(undefined);
@@ -200,7 +200,7 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
200
200
  (_b = props.onTransferSuccess) === null || _b === void 0 ? void 0 : _b.call(props, response);
201
201
  }
202
202
  else {
203
- throw new Error("Send internal failed");
203
+ throw new Error("Send internal failed");
204
204
  }
205
205
  return [3 /*break*/, 3];
206
206
  case 2:
@@ -241,7 +241,7 @@ exports.TransferConfirmation = (0, react_1.forwardRef)(function (props, ref) {
241
241
  ? DrawerComponent_1.DRAWER_TRIGGER_STATUS.DISABLED
242
242
  : DrawerComponent_1.DRAWER_TRIGGER_STATUS.ENABLED, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isValidatingAddress || errorAddress
243
243
  ? Button_1.BUTTON_STATUS.DISABLED
244
- : buttonStatus, sx: { width: "100%" }, children: "Confirm" }) }), children: [transferContent, !!error && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: (_a = theme.mixins.gaps) === null || _a === void 0 ? void 0 : _a.g6 }), children: [error, " ", !!errorAmount && (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: errorAmount, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) })] }))] }) }));
244
+ : buttonStatus, sx: { width: "100%" }, children: "Confirm" }) }), children: [transferContent, !!error && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: (_a = theme.mixins.gaps) === null || _a === void 0 ? void 0 : _a.g6 }), children: [error, " ", !!errorAmount && (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: errorAmount, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) })] })), !!errorAddress && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: (_b = theme.mixins.gaps) === null || _b === void 0 ? void 0 : _b.g6 }), children: errorAddress }))] }) }));
245
245
  });
246
246
  exports.TransferConfirmation.displayName = "TransferInternal";
247
247
  exports.default = exports.TransferConfirmation;
@@ -93,7 +93,6 @@ var PageHeader_1 = __importDefault(require("../../ui/PageHeader"));
93
93
  var OTP_1 = __importStar(require("../../ui/OTP"));
94
94
  var react_2 = require("react");
95
95
  var Text_1 = __importDefault(require("../../ui/Text"));
96
- var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
97
96
  var material_1 = require("@mui/material");
98
97
  var ThemeProvider_1 = require("../../../providers/ThemeProvider");
99
98
  var authentication_by_passcode_service_1 = __importDefault(require("../../../services/axios/authentication-by-passcode-service"));
@@ -122,7 +121,6 @@ var ChangePasscodeView = function (props) {
122
121
  var childPageLayoutRef = (0, react_2.useRef)(null);
123
122
  var _f = (0, react_2.useState)(initStep.current), currentStep = _f[0], setCurrentStep = _f[1];
124
123
  var _g = (0, react_2.useState)(null), error = _g[0], setError = _g[1];
125
- var updateWalletDetail = (0, useWalletData_1.default)().updateWalletDetail;
126
124
  var resetValue = function () {
127
125
  var _a;
128
126
  setError(null);
@@ -254,7 +252,6 @@ var ChangePasscodeView = function (props) {
254
252
  res = _e.sent();
255
253
  (_c = childPageLayoutRef.current) === null || _c === void 0 ? void 0 : _c.showNormal();
256
254
  if (res.success) {
257
- updateWalletDetail();
258
255
  (_d = childPageLayoutRef.current) === null || _d === void 0 ? void 0 : _d.showSuccess();
259
256
  setTimeout(function () {
260
257
  handleDone();
@@ -3,7 +3,8 @@ import { Transaction } from "../services/axios/get-activities-service/type";
3
3
  type ShowActivities = () => void;
4
4
  export type EventHandler = (messageEvent: Transaction, showActivities?: ShowActivities) => NotificationType | undefined;
5
5
  export type EventHandlerHookType = {
6
- eventHandler: EventHandler;
6
+ transactionHandler: EventHandler;
7
+ walletInfoHandler: EventHandler;
7
8
  };
8
9
  export declare const useEventHandler: () => EventHandlerHookType;
9
10
  export {};
@@ -7,13 +7,11 @@ exports.useEventHandler = void 0;
7
7
  var jsx_runtime_1 = require("react/jsx-runtime");
8
8
  var react_1 = require("react");
9
9
  var type_1 = require("../services/axios/get-activities-service/type");
10
- var useActivities_1 = __importDefault(require("./useActivities"));
11
10
  var useWalletData_1 = __importDefault(require("./useWalletData"));
12
11
  var useWithdrawData_1 = __importDefault(require("./useWithdrawData"));
13
12
  var Formatter_1 = __importDefault(require("../components/ui/Formatter"));
14
13
  var Text_1 = __importDefault(require("../components/ui/Text"));
15
14
  var useEventHandler = function () {
16
- var updateActivities = (0, useActivities_1.default)().updateActivities;
17
15
  var updateWalletDetail = (0, useWalletData_1.default)().updateWalletDetail;
18
16
  var _a = (0, useWithdrawData_1.default)(), updateWithdrawToken = _a.updateWithdrawToken, updateSendInternalToken = _a.updateSendInternalToken;
19
17
  var updateData = (0, react_1.useCallback)(function (transactionType, showActivities) {
@@ -44,8 +42,8 @@ var useEventHandler = function () {
44
42
  updateWalletDetail();
45
43
  break;
46
44
  }
47
- }, [updateActivities, updateWalletDetail, updateWithdrawToken, updateSendInternalToken]);
48
- var handler = function (messageEvent, showActivities) {
45
+ }, [updateWalletDetail, updateWithdrawToken, updateSendInternalToken]);
46
+ var transactionHandler = function (messageEvent, showActivities) {
49
47
  var _a, _b, _c;
50
48
  if (!messageEvent)
51
49
  return undefined;
@@ -85,6 +83,13 @@ var useEventHandler = function () {
85
83
  id: "".concat(transactionId, "-").concat(status),
86
84
  };
87
85
  };
88
- return { eventHandler: handler };
86
+ var walletInfoHandler = function (messageEvent) {
87
+ if (!messageEvent)
88
+ return undefined;
89
+ var type = messageEvent.transaction_type || "unknown";
90
+ console.warn("🚀 ~ useEventHandler ~ type:", type);
91
+ updateData(type);
92
+ };
93
+ return { transactionHandler: transactionHandler, walletInfoHandler: walletInfoHandler };
89
94
  };
90
95
  exports.useEventHandler = useEventHandler;
@@ -11,8 +11,8 @@ var useEventHandler_1 = require("../../hooks/useEventHandler");
11
11
  var useRealtime_1 = __importDefault(require("../../hooks/useRealtime"));
12
12
  var Activities_1 = __importDefault(require("../../components/ui/Activities"));
13
13
  function EventHandlerProvider(props) {
14
- var eventHandler = (0, useEventHandler_1.useEventHandler)().eventHandler;
15
- var _a = (0, useRealtime_1.default)(), pushNotification = _a.pushNotification, transaction = _a.transaction;
14
+ var _a = (0, useEventHandler_1.useEventHandler)(), transactionHandler = _a.transactionHandler, walletInfoHandler = _a.walletInfoHandler;
15
+ var _b = (0, useRealtime_1.default)(), pushNotification = _b.pushNotification, transaction = _b.transaction, walletHandlerInfo = _b.walletHandlerInfo;
16
16
  var activitiesRef = (0, react_1.useRef)(null);
17
17
  var options = props.options;
18
18
  var hideDefaultActivities = options === null || options === void 0 ? void 0 : options.hideDefaultActivities;
@@ -23,13 +23,16 @@ function EventHandlerProvider(props) {
23
23
  (_a = activitiesRef.current) === null || _a === void 0 ? void 0 : _a.openTab(0);
24
24
  }, [hideDefaultActivities]);
25
25
  (0, react_1.useEffect)(function () {
26
- if (!eventHandler || !transaction)
26
+ if (!transactionHandler || !transaction)
27
27
  return;
28
- var theMessage = eventHandler(transaction, showActivities);
28
+ var theMessage = transactionHandler(transaction, showActivities);
29
29
  if (theMessage) {
30
30
  pushNotification(theMessage);
31
31
  }
32
32
  }, [transaction]);
33
+ (0, react_1.useEffect)(function () {
34
+ walletInfoHandler === null || walletInfoHandler === void 0 ? void 0 : walletInfoHandler(walletHandlerInfo);
35
+ }, [walletHandlerInfo]);
33
36
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [props.children, !hideDefaultActivities && false && (0, jsx_runtime_1.jsx)(Activities_1.default, { ref: activitiesRef })] }));
34
37
  }
35
38
  exports.default = EventHandlerProvider;
@@ -68,6 +68,7 @@ var notistack_1 = require("notistack");
68
68
  var ThemeProvider_1 = require("../ThemeProvider");
69
69
  exports.initialRealtime = {
70
70
  transaction: undefined,
71
+ walletHandlerInfo: undefined,
71
72
  isConnected: false,
72
73
  pushNotification: function () { },
73
74
  };
@@ -81,7 +82,8 @@ function RealtimeProvider(_a) {
81
82
  var masterWallet = (0, useWalletData_1.default)().masterWallet;
82
83
  var _b = (0, react_1.useState)(exports.initialRealtime.isConnected), isConnected = _b[0], setIsConnected = _b[1];
83
84
  var _c = (0, react_1.useState)(exports.initialRealtime.transaction), transaction = _c[0], setTransaction = _c[1];
84
- var _d = (0, react_1.useState)([]), notifications = _d[0], setNotifications = _d[1];
85
+ var _d = (0, react_1.useState)(exports.initialRealtime.walletHandlerInfo), walletHandlerInfo = _d[0], setWalletHandlerInfo = _d[1];
86
+ var _e = (0, react_1.useState)([]), notifications = _e[0], setNotifications = _e[1];
85
87
  var pushNotification = function (notification) {
86
88
  if (!(options === null || options === void 0 ? void 0 : options.useDefaultToastMessage))
87
89
  return;
@@ -92,13 +94,20 @@ function RealtimeProvider(_a) {
92
94
  if (!masterWallet)
93
95
  return;
94
96
  var ablyService = new ably_service_1.AblyService();
95
- ablyService.listenMessage(masterWallet, function (message) {
97
+ var handleHasTransaction = function (message) {
96
98
  // eslint-disable-next-line no-console
97
- console.log("🚀 ~ ablyService.listenMessage ~ message:", message);
99
+ console.log("🚀 ~ ablyService.listenMessage ~ transaction:", message);
98
100
  var eventData = message.data;
99
101
  setIsConnected(true);
100
102
  setTransaction(eventData);
101
- });
103
+ };
104
+ var handleHasWalletEvent = function (message) {
105
+ // eslint-disable-next-line no-console
106
+ console.log("🚀 ~ ablyService.listenMessage ~ wallet event:", message);
107
+ var eventData = message.data;
108
+ setWalletHandlerInfo(eventData);
109
+ };
110
+ ablyService.listenMessage(masterWallet, handleHasTransaction, handleHasWalletEvent);
102
111
  }
103
112
  catch (error) {
104
113
  console.error("🚀 ~ TEK-WALLET: Error connecting to realtime", error);
@@ -110,6 +119,7 @@ function RealtimeProvider(_a) {
110
119
  return ((0, jsx_runtime_1.jsxs)(exports.RealtimeContext.Provider, { value: {
111
120
  isConnected: isConnected,
112
121
  transaction: transaction,
122
+ walletHandlerInfo: walletHandlerInfo,
113
123
  pushNotification: pushNotification,
114
124
  }, children: [children, (options === null || options === void 0 ? void 0 : options.useDefaultToastMessage) && ((0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { maxSnack: 2, children: notifications.map(function (notification) {
115
125
  var _a, _b, _c, _d, _e, _f;
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  export interface RealtimeProviderDataType {
3
3
  transaction: any;
4
+ walletHandlerInfo: any;
4
5
  isConnected: boolean;
5
6
  pushNotification: (notification: NotificationType) => void;
6
7
  }
@@ -6,7 +6,7 @@ export declare class AblyService {
6
6
  constructor();
7
7
  getChannels(): Map<string, Ably.RealtimeChannel>;
8
8
  getClient(): Ably.Realtime;
9
- listenMessage(walletAddress: string, onMessage: (message: Message) => void): Promise<void>;
9
+ listenMessage(walletAddress: string, onHasTransaction: (message: Message) => void, onHasWalletEvent: (message: Message) => void): Promise<void>;
10
10
  publish(channel: string, event: string, data: any): Promise<void>;
11
11
  subscribe(channel: string, event: string, callback: (message: any) => void): Promise<void>;
12
12
  cleanup(walletAddress: string): Promise<void>;
@@ -86,25 +86,30 @@ var AblyService = /** @class */ (function () {
86
86
  AblyService.prototype.getClient = function () {
87
87
  return this.ably;
88
88
  };
89
- AblyService.prototype.listenMessage = function (walletAddress, onMessage) {
89
+ AblyService.prototype.listenMessage = function (walletAddress, onHasTransaction, onHasWalletEvent) {
90
90
  return __awaiter(this, void 0, void 0, function () {
91
91
  var channel, error_1;
92
92
  return __generator(this, function (_a) {
93
93
  switch (_a.label) {
94
94
  case 0:
95
- _a.trys.push([0, 2, , 3]);
95
+ _a.trys.push([0, 3, , 4]);
96
96
  channel = this.ably.channels.get(walletAddress);
97
97
  return [4 /*yield*/, channel.subscribe(type_1.ABLY_CHANNELS_NAME.TRANSACTION, function (message) {
98
- onMessage(message);
98
+ onHasTransaction(message);
99
99
  })];
100
100
  case 1:
101
101
  _a.sent();
102
- return [3 /*break*/, 3];
102
+ return [4 /*yield*/, channel.subscribe(type_1.ABLY_CHANNELS_NAME.WALLET_HANDLER_INFO, function (message) {
103
+ onHasWalletEvent(message);
104
+ })];
103
105
  case 2:
106
+ _a.sent();
107
+ return [3 /*break*/, 4];
108
+ case 3:
104
109
  error_1 = _a.sent();
105
110
  console.error("Test failed for wallet ".concat(walletAddress, ":"), error_1);
106
- return [3 /*break*/, 3];
107
- case 3: return [2 /*return*/];
111
+ return [3 /*break*/, 4];
112
+ case 4: return [2 /*return*/];
108
113
  }
109
114
  });
110
115
  });
@@ -1,3 +1,4 @@
1
1
  export declare enum ABLY_CHANNELS_NAME {
2
- TRANSACTION = "transaction"
2
+ TRANSACTION = "transaction",
3
+ WALLET_HANDLER_INFO = "wallet_handler_info"
3
4
  }
@@ -4,4 +4,5 @@ exports.ABLY_CHANNELS_NAME = void 0;
4
4
  var ABLY_CHANNELS_NAME;
5
5
  (function (ABLY_CHANNELS_NAME) {
6
6
  ABLY_CHANNELS_NAME["TRANSACTION"] = "transaction";
7
+ ABLY_CHANNELS_NAME["WALLET_HANDLER_INFO"] = "wallet_handler_info";
7
8
  })(ABLY_CHANNELS_NAME || (exports.ABLY_CHANNELS_NAME = ABLY_CHANNELS_NAME = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.694",
3
+ "version": "0.0.696",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",