tek-wallet 0.0.297 → 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];
@@ -243,22 +247,18 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
243
247
  tonTransferParam = (0, parseTonTransferUrl_1.default)(text);
244
248
  console.warn("🚀 ~ handleScanAllQrCode ~ tonTransferParam:", tonTransferParam);
245
249
  (_c = backDropRef.current) === null || _c === void 0 ? void 0 : _c.open();
246
- if (!tonTransferParam) {
247
- alert("Unsupported QR");
248
- return [2 /*return*/];
249
- }
250
250
  return [4 /*yield*/, (0, validate_wallet_address_service_1.default)({
251
251
  address: tonTransferParam === null || tonTransferParam === void 0 ? void 0 : tonTransferParam.address,
252
252
  network: (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.slug) || "ton",
253
253
  })];
254
254
  case 1:
255
- validateWalletAddress = _e.sent();
255
+ validateWalletAddress = _f.sent();
256
256
  if (!validateWalletAddress) {
257
- alert("Unsupported QR");
257
+ setInfoDialogContent("Unsupported QR");
258
258
  return [2 /*return*/];
259
259
  }
260
260
  (_d = backDropRef.current) === null || _d === void 0 ? void 0 : _d.close();
261
- 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");
262
262
  console.warn("validateWalletAddress", validateWalletAddress);
263
263
  // if(validateWalletAddress?.is_current_wallet) {
264
264
  // return
@@ -266,6 +266,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
266
266
  if (!!(validateWalletAddress === null || validateWalletAddress === void 0 ? void 0 : validateWalletAddress.master_wallet_address)) {
267
267
  //internal
268
268
  console.warn("internal");
269
+ (_e = suggestUseTransferInternalDialogRef.current) === null || _e === void 0 ? void 0 : _e.open();
269
270
  }
270
271
  else if (!!(validateWalletAddress === null || validateWalletAddress === void 0 ? void 0 : validateWalletAddress.valid)) {
271
272
  //external
@@ -275,7 +276,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
275
276
  //invalid
276
277
  console.warn("invalid");
277
278
  }
278
- _e.label = 2;
279
+ _f.label = 2;
279
280
  case 2: return [2 /*return*/];
280
281
  }
281
282
  });
@@ -329,7 +330,11 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
329
330
  placeholder: "Enter memo",
330
331
  value: memo,
331
332
  onChange: handleChangeMemo,
332
- } })] }), (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" })] }) }) })] }) }) }));
333
338
  });
334
339
  WithdrawFunction.displayName = "WithdrawFunction";
335
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;
@@ -8,5 +8,4 @@ export interface TonTransferUrlParams {
8
8
  jetton: string | undefined;
9
9
  isDeepLinkFormat: boolean;
10
10
  }
11
- export type ParseTonTransferUrlResult = TonTransferUrlParams | undefined;
12
- export default function parseTonTransferUrl(url: string): ParseTonTransferUrlResult;
11
+ export default function parseTonTransferUrl(url: string): TonTransferUrlParams;
@@ -97,6 +97,15 @@ function parseTonTransferUrl(url) {
97
97
  }
98
98
  catch (error) {
99
99
  console.error("error", error);
100
- return undefined;
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
+ };
101
110
  }
102
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.297",
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",