tek-wallet 0.0.296 → 0.0.298

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.
@@ -107,13 +107,14 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
107
107
  var _c = (0, react_1.useState)(), selectedNetwork = _c[0], setSelectedNetwork = _c[1];
108
108
  var isAuthenticated = (0, useWalletData_1.default)().isAuthenticated;
109
109
  var _d = (0, useWithdrawData_1.default)(), withdrawTokens = _d.withdrawTokens, updateWithdrawToken = _d.updateWithdrawToken;
110
- var _e = (0, react_1.useState)(), dialogContent = _e[0], setDialogContent = _e[1];
110
+ var _e = (0, react_1.useState)(), infoDialogContent = _e[0], setInfoDialogContent = _e[1];
111
111
  var _f = (0, react_1.useState)(""), amount = _f[0], setAmount = _f[1];
112
112
  var _g = (0, react_1.useState)(""), memo = _g[0], setMemo = _g[1];
113
113
  var _h = (0, react_1.useState)(""), recipientAddress = _h[0], setRecipientAddress = _h[1];
114
114
  var scannerAllQrCodeRef = (0, react_1.useRef)(null);
115
115
  var scannerAddressQrCodeRef = (0, react_1.useRef)(null);
116
116
  var backDropRef = (0, react_1.useRef)(null);
117
+ var suggestUseTransferInternalDialogRef = (0, react_1.useRef)(null);
117
118
  var _j = (0, react_1.useState)(), selectedMethod = _j[0], setSelectedMethod = _j[1];
118
119
  var networks = (0, react_1.useMemo)(function () {
119
120
  console.warn("🚀 ~ networks ~ selectedToken:", selectedToken);
@@ -140,6 +141,9 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
140
141
  open: open,
141
142
  close: close,
142
143
  }); });
144
+ var handleClearInfoDialogContent = function () {
145
+ setInfoDialogContent(undefined);
146
+ };
143
147
  var handleChangeRecipientAddress = function (e) {
144
148
  setRecipientAddress(e.target.value);
145
149
  };
@@ -232,9 +236,9 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
232
236
  // };
233
237
  var handleScanAllQrCode = function (result) { return __awaiter(void 0, void 0, void 0, function () {
234
238
  var text, tonTransferParam, validateWalletAddress;
235
- var _a, _b, _c, _d;
236
- return __generator(this, function (_e) {
237
- switch (_e.label) {
239
+ var _a, _b, _c, _d, _e;
240
+ return __generator(this, function (_f) {
241
+ switch (_f.label) {
238
242
  case 0:
239
243
  (_a = scannerAllQrCodeRef.current) === null || _a === void 0 ? void 0 : _a.close();
240
244
  if (!result) return [3 /*break*/, 2];
@@ -248,13 +252,13 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
248
252
  network: (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.slug) || "ton",
249
253
  })];
250
254
  case 1:
251
- validateWalletAddress = _e.sent();
255
+ validateWalletAddress = _f.sent();
252
256
  if (!validateWalletAddress) {
253
- alert("Unsupported QR");
257
+ setInfoDialogContent("Unsupported QR");
254
258
  return [2 /*return*/];
255
259
  }
256
260
  (_d = backDropRef.current) === null || _d === void 0 ? void 0 : _d.close();
257
- setDialogContent("Unsupported QR, please scan a valid QR code or enter the recipient address manually");
261
+ setInfoDialogContent("Unsupported QR Code, please scan a valid QR code or enter the recipient address manually");
258
262
  console.warn("validateWalletAddress", validateWalletAddress);
259
263
  // if(validateWalletAddress?.is_current_wallet) {
260
264
  // return
@@ -262,6 +266,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
262
266
  if (!!(validateWalletAddress === null || validateWalletAddress === void 0 ? void 0 : validateWalletAddress.master_wallet_address)) {
263
267
  //internal
264
268
  console.warn("internal");
269
+ (_e = suggestUseTransferInternalDialogRef.current) === null || _e === void 0 ? void 0 : _e.open();
265
270
  }
266
271
  else if (!!(validateWalletAddress === null || validateWalletAddress === void 0 ? void 0 : validateWalletAddress.valid)) {
267
272
  //external
@@ -271,7 +276,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
271
276
  //invalid
272
277
  console.warn("invalid");
273
278
  }
274
- _e.label = 2;
279
+ _f.label = 2;
275
280
  case 2: return [2 /*return*/];
276
281
  }
277
282
  });
@@ -325,7 +330,11 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
325
330
  placeholder: "Enter memo",
326
331
  value: memo,
327
332
  onChange: handleChangeMemo,
328
- } })] }), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, children: "Confirm" })] }) }, WithdrawStep.CONFIRM)] }, withdrawTokens === null || withdrawTokens === void 0 ? void 0 : withdrawTokens.length), (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: !!dialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: dialogContent, actions: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { children: "Confirm" }) }) })] }) }) }));
333
+ } })] }), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, children: "Confirm" })] }) }, WithdrawStep.CONFIRM)] }, withdrawTokens === null || withdrawTokens === void 0 ? void 0 : withdrawTokens.length), (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: infoDialogContent, actions: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsOk), { width: "100%" }), 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 transfer internal, use it for faster transaction?", actions: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
334
+ display: "grid",
335
+ gridTemplate: "1fr 1fr",
336
+ gap: theme.mixins.gaps.g8,
337
+ }, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.dialogActionsCancel), { width: "100%" }), onClick: handleClearInfoDialogContent, children: "Keep continue" }), (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: handleClearInfoDialogContent, children: "Ok" })] }) }) })] }) }) }));
329
338
  });
330
339
  WithdrawFunction.displayName = "WithdrawFunction";
331
340
  exports.default = WithdrawFunction;
@@ -272,8 +272,10 @@ var theme = (0, styles_1.createTheme)({
272
272
  },
273
273
  dialogActionsOk: {
274
274
  fontSize: typography.fontSize14,
275
- lineHeight: typography.leading140,
275
+ lineHeight: typography.leading100,
276
276
  color: "#2482ff",
277
+ textAlign: "center",
278
+ padding: "".concat(customPadding.p8, " ").concat(customPadding.p16),
277
279
  },
278
280
  dialogActionsCancel: {
279
281
  fontSize: typography.fontSize14,
@@ -1,5 +1,5 @@
1
1
  export interface TonTransferUrlParams {
2
- protocol: "ton" | "https";
2
+ protocol?: "ton" | "https";
3
3
  address: string;
4
4
  amount: string | undefined;
5
5
  text: string | undefined;
@@ -3,94 +3,109 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = parseTonTransferUrl;
4
4
  var ton_core_1 = require("ton-core");
5
5
  function parseTonTransferUrl(url) {
6
- var protocol;
7
- var address;
8
- var queryString = "";
9
- var isDeepLinkFormat = false;
10
- // Xác định loại URL
11
- if (url.startsWith("ton://transfer/")) {
12
- protocol = "ton";
13
- var _a = url.split("?"), path = _a[0], query = _a[1];
14
- address = path.split("/transfer/")[1];
15
- queryString = query || "";
16
- }
17
- else if (url.startsWith("https://app.tonkeeper.com/transfer/")) {
18
- protocol = "https";
19
- var _b = url.split("?"), path = _b[0], query = _b[1];
20
- address = path.split("/transfer/")[1];
21
- queryString = query || "";
22
- }
23
- else if (url.startsWith("ton:")) {
24
- protocol = "ton";
25
- isDeepLinkFormat = true;
26
- var _c = url.slice(4).split("?"), path = _c[0], query = _c[1];
27
- address = path;
28
- queryString = query || "";
29
- }
30
- else {
31
- throw new Error('Invalid TON transfer URL. Must start with "ton://transfer/", "https://app.tonkeeper.com/transfer/", or "ton:"');
32
- }
33
- if (!address) {
34
- throw new Error("Missing TON address in URL");
35
- }
36
- // Xác thực địa chỉ là TON address
37
6
  try {
38
- ton_core_1.Address.parse(address); // Throws nếu không hợp lệ
39
- }
40
- catch (_d) {
41
- throw new Error("Invalid TON address");
42
- }
43
- var result = {
44
- protocol: protocol,
45
- address: address,
46
- amount: undefined,
47
- text: undefined,
48
- bin: undefined,
49
- init: undefined,
50
- jetton: undefined,
51
- isDeepLinkFormat: isDeepLinkFormat,
52
- };
53
- if (queryString) {
54
- var params = new URLSearchParams(queryString);
55
- // amount
56
- var amount = params.get("amount");
57
- if (amount) {
58
- if (!/^\d+(\.\d+)?$/.test(amount)) {
59
- throw new Error("Invalid amount: must be a number");
60
- }
61
- result.amount = amount;
7
+ var protocol = void 0;
8
+ var address = void 0;
9
+ var queryString = "";
10
+ var isDeepLinkFormat = false;
11
+ // Xác định loại URL
12
+ if (url.startsWith("ton://transfer/")) {
13
+ protocol = "ton";
14
+ var _a = url.split("?"), path = _a[0], query = _a[1];
15
+ address = path.split("/transfer/")[1];
16
+ queryString = query || "";
62
17
  }
63
- // text
64
- if (params.has("text")) {
65
- result.text = decodeURIComponent(params.get("text"));
18
+ else if (url.startsWith("https://app.tonkeeper.com/transfer/")) {
19
+ protocol = "https";
20
+ var _b = url.split("?"), path = _b[0], query = _b[1];
21
+ address = path.split("/transfer/")[1];
22
+ queryString = query || "";
66
23
  }
67
- // bin
68
- var bin = params.get("bin");
69
- if (bin) {
70
- if (!/^[A-Za-z0-9-_]+={0,2}$/.test(bin)) {
71
- throw new Error("Invalid bin: must be Base64 URL-safe encoded");
72
- }
73
- result.bin = bin;
24
+ else if (url.startsWith("ton:")) {
25
+ protocol = "ton";
26
+ isDeepLinkFormat = true;
27
+ var _c = url.slice(4).split("?"), path = _c[0], query = _c[1];
28
+ address = path;
29
+ queryString = query || "";
74
30
  }
75
- // init
76
- var init = params.get("init");
77
- if (init) {
78
- if (!/^[A-Za-z0-9-_]+={0,2}$/.test(init)) {
79
- throw new Error("Invalid init: must be Base64 URL-safe encoded");
80
- }
81
- result.init = init;
31
+ else {
32
+ throw new Error('Invalid TON transfer URL. Must start with "ton://transfer/", "https://app.tonkeeper.com/transfer/", or "ton:"');
33
+ }
34
+ if (!address) {
35
+ throw new Error("Missing TON address in URL");
36
+ }
37
+ // Xác thực địa chỉ là TON address
38
+ try {
39
+ ton_core_1.Address.parse(address); // Throws nếu không hợp lệ
40
+ }
41
+ catch (_d) {
42
+ throw new Error("Invalid TON address");
82
43
  }
83
- // jetton
84
- var jetton = params.get("jetton");
85
- if (jetton) {
86
- try {
87
- ton_core_1.Address.parse(jetton); // kiểm tra hợp lệ
88
- result.jetton = jetton;
44
+ var result = {
45
+ protocol: protocol,
46
+ address: address,
47
+ amount: undefined,
48
+ text: undefined,
49
+ bin: undefined,
50
+ init: undefined,
51
+ jetton: undefined,
52
+ isDeepLinkFormat: isDeepLinkFormat,
53
+ };
54
+ if (queryString) {
55
+ var params = new URLSearchParams(queryString);
56
+ // amount
57
+ var amount = params.get("amount");
58
+ if (amount) {
59
+ if (!/^\d+(\.\d+)?$/.test(amount)) {
60
+ throw new Error("Invalid amount: must be a number");
61
+ }
62
+ result.amount = amount;
89
63
  }
90
- catch (_e) {
91
- throw new Error("Invalid jetton address");
64
+ // text
65
+ if (params.has("text")) {
66
+ result.text = decodeURIComponent(params.get("text"));
67
+ }
68
+ // bin
69
+ var bin = params.get("bin");
70
+ if (bin) {
71
+ if (!/^[A-Za-z0-9-_]+={0,2}$/.test(bin)) {
72
+ throw new Error("Invalid bin: must be Base64 URL-safe encoded");
73
+ }
74
+ result.bin = bin;
75
+ }
76
+ // init
77
+ var init = params.get("init");
78
+ if (init) {
79
+ if (!/^[A-Za-z0-9-_]+={0,2}$/.test(init)) {
80
+ throw new Error("Invalid init: must be Base64 URL-safe encoded");
81
+ }
82
+ result.init = init;
83
+ }
84
+ // jetton
85
+ var jetton = params.get("jetton");
86
+ if (jetton) {
87
+ try {
88
+ ton_core_1.Address.parse(jetton); // kiểm tra hợp lệ
89
+ result.jetton = jetton;
90
+ }
91
+ catch (_e) {
92
+ throw new Error("Invalid jetton address");
93
+ }
92
94
  }
93
95
  }
96
+ return result;
97
+ }
98
+ catch (error) {
99
+ console.error("error", error);
100
+ return {
101
+ protocol: undefined,
102
+ address: url,
103
+ amount: undefined,
104
+ text: undefined,
105
+ bin: undefined,
106
+ init: undefined,
107
+ jetton: undefined,
108
+ isDeepLinkFormat: false,
109
+ };
94
110
  }
95
- return result;
96
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.296",
3
+ "version": "0.0.298",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",