@matchain/matchid-sdk-react 0.1.40-alpha.0 → 0.1.40-alpha.10

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.
Files changed (45) hide show
  1. package/dist/assets/icon/index.d.mts +6 -2
  2. package/dist/assets/icon/index.d.ts +6 -2
  3. package/dist/assets/icon/index.js +56 -0
  4. package/dist/assets/icon/index.js.map +1 -1
  5. package/dist/assets/icon/index.mjs +5 -1
  6. package/dist/{chunk-75ZLGQV7.mjs → chunk-B2HVAJPQ.mjs} +2 -2
  7. package/dist/{chunk-6PWH7WZI.mjs → chunk-DPXMCLYK.mjs} +56 -2
  8. package/dist/chunk-DPXMCLYK.mjs.map +1 -0
  9. package/dist/{chunk-XMGJLSI2.mjs → chunk-RYZFW6P6.mjs} +347 -107
  10. package/dist/chunk-RYZFW6P6.mjs.map +1 -0
  11. package/dist/components/index.d.mts +2 -2
  12. package/dist/components/index.d.ts +2 -2
  13. package/dist/components/index.js +496 -228
  14. package/dist/components/index.js.map +1 -1
  15. package/dist/components/index.mjs +4 -2
  16. package/dist/hooks/api/index.d.mts +2 -2
  17. package/dist/hooks/api/index.d.ts +2 -2
  18. package/dist/hooks/api/index.js +64 -41
  19. package/dist/hooks/api/index.js.map +1 -1
  20. package/dist/hooks/api/index.mjs +3 -3
  21. package/dist/hooks/index.d.mts +2 -2
  22. package/dist/hooks/index.d.ts +2 -2
  23. package/dist/hooks/index.js +68 -45
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/hooks/index.mjs +2 -2
  26. package/dist/{index-mEK7Lcps.d.mts → index-C3KZYrtu.d.mts} +3 -2
  27. package/dist/{index-CvCSpU8m.d.ts → index-COlsBC-b.d.mts} +9 -3
  28. package/dist/{index-BPveUnst.d.ts → index-DoF5jRoi.d.ts} +1 -1
  29. package/dist/{index-DlrDrTMk.d.ts → index-Dq9Swg8r.d.ts} +3 -2
  30. package/dist/{index-ClQl2MMF.d.mts → index-fS75Swm8.d.ts} +9 -3
  31. package/dist/{index-Dm5o2w2J.d.mts → index-fl6SNIZC.d.mts} +1 -1
  32. package/dist/index.d.mts +4 -4
  33. package/dist/index.d.ts +4 -4
  34. package/dist/index.js +589 -306
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +6 -6
  37. package/dist/{types.d-IS3DBl3p.d.mts → types.d-CLO_WLka.d.mts} +1 -1
  38. package/dist/{types.d-IS3DBl3p.d.ts → types.d-CLO_WLka.d.ts} +1 -1
  39. package/example/src/components/Login/index.tsx +2 -2
  40. package/example/src/config/index.ts +6 -1
  41. package/example/src/pages/User.tsx +4 -4
  42. package/package.json +2 -2
  43. package/dist/chunk-6PWH7WZI.mjs.map +0 -1
  44. package/dist/chunk-XMGJLSI2.mjs.map +0 -1
  45. /package/dist/{chunk-75ZLGQV7.mjs.map → chunk-B2HVAJPQ.mjs.map} +0 -0
@@ -31,6 +31,8 @@ import {
31
31
  TRXDarkIcon,
32
32
  TRXLightIcon,
33
33
  TelegramIcon,
34
+ TonLightIcon,
35
+ TonLightIcon2,
34
36
  TronLinkIcon,
35
37
  UnLoginIcon_default,
36
38
  UnisatIcon,
@@ -38,7 +40,7 @@ import {
38
40
  XIcon,
39
41
  XverseIcon,
40
42
  YoutubeIcon
41
- } from "./chunk-6PWH7WZI.mjs";
43
+ } from "./chunk-DPXMCLYK.mjs";
42
44
  import {
43
45
  __export
44
46
  } from "./chunk-J5LGTIGS.mjs";
@@ -270,11 +272,11 @@ var getBindInfoApi = () => {
270
272
  method: "GET"
271
273
  });
272
274
  };
273
- var bindCexApi = ({ cex, api_key, api_secret }) => {
275
+ var bindCexApi = (data) => {
274
276
  return request_default({
275
277
  url: `/api/v1/cex/subscribe`,
276
278
  method: "POST",
277
- data: { cex, api_key, api_secret }
279
+ data
278
280
  });
279
281
  };
280
282
  var unBindApi = ({ type }) => {
@@ -337,28 +339,42 @@ var getAuthInfoApi = () => {
337
339
  method: "GET"
338
340
  });
339
341
  };
340
- var getWalletNonceApi = ({ address }) => {
342
+ var getWalletNonceApi = (data) => {
341
343
  return request_default({
342
344
  url: `/api/v1/login/wallet/init`,
343
345
  method: "POST",
344
- data: { address }
346
+ data
345
347
  });
346
348
  };
347
- var loginByWalletApi = ({ type, address, signature, message, connector_type, wallet_client_type }) => {
349
+ var loginByWalletApi = ({
350
+ type,
351
+ address,
352
+ signature,
353
+ message,
354
+ connector_type,
355
+ wallet_client_type
356
+ }) => {
348
357
  return request_default({
349
358
  url: `/api/v1/login/wallet`,
350
359
  method: "POST",
351
360
  data: { type, address, signature, message, connector_type, wallet_client_type }
352
361
  });
353
362
  };
354
- var getWalletInitApi = ({ address }) => {
363
+ var getWalletInitApi = (data) => {
355
364
  return request_default({
356
365
  url: `/api/v1/wallet/init`,
357
366
  method: "POST",
358
- data: { address }
367
+ data
359
368
  });
360
369
  };
361
- var toBindWalletApi = ({ type, address, signature, message, connector_type, wallet_client_type }) => {
370
+ var toBindWalletApi = ({
371
+ type,
372
+ address,
373
+ signature,
374
+ message,
375
+ connector_type,
376
+ wallet_client_type
377
+ }) => {
362
378
  return request_default({
363
379
  url: `/api/v1/wallet/bind`,
364
380
  method: "POST",
@@ -752,6 +768,12 @@ var useTRONModalStore = create3((set) => ({
752
768
  open: (type) => set({ isOpen: true, type }),
753
769
  close: () => set({ isOpen: false })
754
770
  }));
771
+ var useTONModalStore = create3((set) => ({
772
+ isOpen: false,
773
+ type: "",
774
+ open: (type) => set({ isOpen: true, type }),
775
+ close: () => set({ isOpen: false })
776
+ }));
755
777
  var useBTCModalStore = create3((set) => ({
756
778
  isOpen: false,
757
779
  type: "",
@@ -782,6 +804,7 @@ __export(components_exports, {
782
804
  PasswordModal: () => PasswordModal,
783
805
  Popover: () => Popover,
784
806
  SOLModal: () => SOLModal,
807
+ TONModal: () => TONModal,
785
808
  TRONModal: () => TRONModal,
786
809
  UsernameModal: () => UsernameModal
787
810
  });
@@ -1193,6 +1216,12 @@ function LoginBox({
1193
1216
  activeIcon: /* @__PURE__ */ jsx11(TRXLightIcon, { size: isDownMd ? 36 : 40 }),
1194
1217
  name: "TRON",
1195
1218
  onClick: () => login("tron")
1219
+ },
1220
+ ton: {
1221
+ icon: /* @__PURE__ */ jsx11(TonLightIcon, { size: isDownMd ? 36 : 40 }),
1222
+ activeIcon: /* @__PURE__ */ jsx11(TonLightIcon2, { size: isDownMd ? 36 : 40 }),
1223
+ name: "TON",
1224
+ onClick: () => login("ton")
1196
1225
  }
1197
1226
  };
1198
1227
  return /* @__PURE__ */ jsxs9(Fragment2, { children: [
@@ -1704,8 +1733,13 @@ function WalletModalContent({
1704
1733
  text: error,
1705
1734
  btnText: "Reconnect Wallet",
1706
1735
  btnClick: async () => {
1736
+ console.log("click error");
1707
1737
  setError("");
1708
- await disconnect();
1738
+ try {
1739
+ await disconnect();
1740
+ } catch (error2) {
1741
+ console.error(error2);
1742
+ }
1709
1743
  setVisible(true);
1710
1744
  },
1711
1745
  statusImage: walletErrorImage,
@@ -1792,7 +1826,7 @@ function WalletContent({
1792
1826
  try {
1793
1827
  setStatus("nonce");
1794
1828
  statusRef.current = "nonce";
1795
- const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
1829
+ const res = type == "bind" ? await getWalletInitApi({ address, type: "SOL" }) : await getWalletNonceApi({ address, type: "SOL" });
1796
1830
  if (!isSuccess(res)) {
1797
1831
  throw new Error(res.message);
1798
1832
  }
@@ -2059,7 +2093,7 @@ function TRONModal({
2059
2093
  try {
2060
2094
  setStatus("nonce");
2061
2095
  statusRef.current = "nonce";
2062
- const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
2096
+ const res = type == "bind" ? await getWalletInitApi({ address, type: "TRON" }) : await getWalletNonceApi({ address, type: "TRON" });
2063
2097
  if (!isSuccess(res)) {
2064
2098
  throw new Error(res.message);
2065
2099
  }
@@ -2174,9 +2208,193 @@ function TRONModal({
2174
2208
  ] }) }) });
2175
2209
  }
2176
2210
 
2177
- // src/components/BTCModal/index.tsx
2178
- import React5, { useEffect as useEffect12, useMemo as useMemo8, useState as useState17 } from "react";
2211
+ // src/components/TONModal/index.tsx
2212
+ import React5, { useEffect as useEffect11, useState as useState16 } from "react";
2179
2213
  import { useIntl as useIntl12 } from "react-intl";
2214
+ import {
2215
+ TonConnectUIProvider,
2216
+ useTonAddress,
2217
+ useTonConnectModal,
2218
+ useTonConnectUI,
2219
+ useTonWallet
2220
+ } from "@tonconnect/ui-react";
2221
+ import { jsx as jsx22 } from "react/jsx-runtime";
2222
+ function WalletContent2({
2223
+ onSuccess,
2224
+ type
2225
+ }) {
2226
+ const { events, login } = useMatch();
2227
+ const [connected, setConnected] = useState16(false);
2228
+ const wallet = useTonWallet();
2229
+ const userFriendlyAddress = useTonAddress();
2230
+ const [tonConnectUI] = useTonConnectUI();
2231
+ const { state, open, close } = useTonConnectModal();
2232
+ const [status, setStatus] = useState16("");
2233
+ const statusRef = React5.useRef(status);
2234
+ const [error, setError] = useState16("");
2235
+ useEffect11(() => {
2236
+ const init = async () => {
2237
+ if (wallet) {
2238
+ await tonConnectUI.disconnect();
2239
+ }
2240
+ open();
2241
+ };
2242
+ init();
2243
+ tonConnectUI.onStatusChange((wallet2) => {
2244
+ matchlog_default.log("onStatusChange:", wallet2, wallet2?.connectItems?.tonProof, JSON.stringify(wallet2?.connectItems?.tonProof));
2245
+ if (wallet2?.connectItems?.tonProof && "proof" in wallet2.connectItems.tonProof) {
2246
+ matchlog_default.log(wallet2?.connectItems.tonProof.proof, wallet2?.account);
2247
+ const toLoginInWallet = async () => {
2248
+ if (statusRef.current || !wallet2) return;
2249
+ setStatus("signer");
2250
+ statusRef.current = "signer";
2251
+ try {
2252
+ const signature = {
2253
+ "address": wallet2?.account?.address,
2254
+ "network": wallet2?.account?.chain,
2255
+ "public_key": wallet2?.account?.publicKey,
2256
+ "proof": {
2257
+ //@ts-ignore
2258
+ ...wallet2?.connectItems?.tonProof?.proof,
2259
+ "state_init": wallet2?.account?.walletStateInit
2260
+ }
2261
+ };
2262
+ let obj = {
2263
+ type: "TON",
2264
+ address: wallet2?.account?.publicKey,
2265
+ signature: JSON.stringify(signature),
2266
+ //@ts-ignore
2267
+ message: wallet2?.connectItems?.tonProof?.proof.payload,
2268
+ connector_type: "TON",
2269
+ wallet_client_type: wallet2?.name
2270
+ };
2271
+ console.log("signature", {
2272
+ signature,
2273
+ obj
2274
+ });
2275
+ const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
2276
+ if (res1) {
2277
+ if (!isSuccess(res1)) {
2278
+ throw new Error(res1.message);
2279
+ }
2280
+ matchlog_default.log(res1);
2281
+ setStatus("success");
2282
+ statusRef.current = "success";
2283
+ if (type == "bind") {
2284
+ events.onBind && events.onBind({
2285
+ type: "ton"
2286
+ });
2287
+ eventManager_default.emit("onBind", {
2288
+ type: "ton"
2289
+ });
2290
+ } else {
2291
+ await login({
2292
+ mid: res1.data.mid,
2293
+ token: `${res1.data.token_type} ${res1.data.access_token}`
2294
+ });
2295
+ }
2296
+ onSuccess && onSuccess();
2297
+ }
2298
+ } catch (error2) {
2299
+ setStatus("error");
2300
+ setError(error2.message);
2301
+ statusRef.current = "";
2302
+ }
2303
+ };
2304
+ toLoginInWallet();
2305
+ }
2306
+ });
2307
+ }, []);
2308
+ useEffect11(() => {
2309
+ if (wallet) {
2310
+ setConnected(true);
2311
+ console.log("Wallet connected:", wallet);
2312
+ } else {
2313
+ setConnected(false);
2314
+ open();
2315
+ statusRef.current = "";
2316
+ setStatus("");
2317
+ }
2318
+ }, [wallet]);
2319
+ useEffect11(() => {
2320
+ console.log({
2321
+ state,
2322
+ wallet
2323
+ });
2324
+ if (state.status == "opened") {
2325
+ const init = async () => {
2326
+ tonConnectUI.setConnectRequestParameters({ state: "loading" });
2327
+ const res = type == "bind" ? await getWalletInitApi({
2328
+ address: "tonconnect",
2329
+ type: "TON"
2330
+ }) : await getWalletNonceApi({ address: "tonconnect", type: "TON" });
2331
+ if (!isSuccess(res)) {
2332
+ tonConnectUI.setConnectRequestParameters(null);
2333
+ throw new Error(res.message);
2334
+ }
2335
+ tonConnectUI.setConnectRequestParameters({
2336
+ state: "ready",
2337
+ value: { tonProof: res.data.nonce }
2338
+ });
2339
+ };
2340
+ init();
2341
+ } else {
2342
+ if (!wallet) {
2343
+ setStatus("");
2344
+ statusRef.current = "";
2345
+ }
2346
+ }
2347
+ }, [state]);
2348
+ return /* @__PURE__ */ jsx22(
2349
+ WalletModalContent,
2350
+ {
2351
+ connected,
2352
+ disconnect: tonConnectUI.disconnect,
2353
+ address: userFriendlyAddress,
2354
+ visible: state.status == "opened",
2355
+ setVisible: async (v) => {
2356
+ console.log("setVisible", v);
2357
+ if (v) {
2358
+ if (wallet) {
2359
+ await tonConnectUI.disconnect();
2360
+ }
2361
+ setStatus("");
2362
+ statusRef.current = "";
2363
+ open();
2364
+ } else {
2365
+ close();
2366
+ }
2367
+ },
2368
+ error,
2369
+ setError,
2370
+ status
2371
+ }
2372
+ );
2373
+ }
2374
+ function TONModal({
2375
+ type = "login",
2376
+ onSuccess,
2377
+ ...props
2378
+ }) {
2379
+ const intl = useIntl12();
2380
+ const { endpoints, appid } = useLocalStore_default();
2381
+ const manifestUrl = `${endpoints.back}api/v1/wallet/ton?appid=${appid}&url=` + encodeURIComponent(window.location.origin);
2382
+ return /* @__PURE__ */ jsx22(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
2383
+ id: type == "bind" ? "bindWith" : "loginWith"
2384
+ }, {
2385
+ name: "TON"
2386
+ }), children: /* @__PURE__ */ jsx22(
2387
+ TonConnectUIProvider,
2388
+ {
2389
+ manifestUrl,
2390
+ children: /* @__PURE__ */ jsx22(WalletContent2, { onSuccess, type })
2391
+ }
2392
+ ) });
2393
+ }
2394
+
2395
+ // src/components/BTCModal/index.tsx
2396
+ import React6, { useEffect as useEffect13, useMemo as useMemo8, useState as useState18 } from "react";
2397
+ import { useIntl as useIntl13 } from "react-intl";
2180
2398
 
2181
2399
  // src/lib/btc/UnisatAdapter.ts
2182
2400
  var UnisatAdapter = class {
@@ -2330,12 +2548,12 @@ var LeatherAdapter = class {
2330
2548
  };
2331
2549
 
2332
2550
  // src/hooks/useBTCWallet.ts
2333
- import { useEffect as useEffect11, useState as useState16 } from "react";
2551
+ import { useEffect as useEffect12, useState as useState17 } from "react";
2334
2552
  var useBTCWallet = () => {
2335
2553
  const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
2336
- const [installedWallets, setInstalledWallets] = useState16([]);
2337
- const [address, setAddress] = useState16(null);
2338
- useEffect11(() => {
2554
+ const [installedWallets, setInstalledWallets] = useState17([]);
2555
+ const [address, setAddress] = useState17(null);
2556
+ useEffect12(() => {
2339
2557
  const getInstalled = async () => {
2340
2558
  const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
2341
2559
  wallet: wallet2,
@@ -2345,11 +2563,11 @@ var useBTCWallet = () => {
2345
2563
  };
2346
2564
  getInstalled();
2347
2565
  }, []);
2348
- const [wallet, chooseWallet] = useState16(null);
2566
+ const [wallet, chooseWallet] = useState17(null);
2349
2567
  const onConnect = async () => {
2350
2568
  setAddress(await wallet.connect());
2351
2569
  };
2352
- useEffect11(() => {
2570
+ useEffect12(() => {
2353
2571
  if (!wallet) {
2354
2572
  setAddress(null);
2355
2573
  }
@@ -2365,24 +2583,24 @@ var useBTCWallet = () => {
2365
2583
  };
2366
2584
 
2367
2585
  // src/components/BTCModal/index.tsx
2368
- import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
2586
+ import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
2369
2587
  function BTCModal({
2370
2588
  type = "login",
2371
2589
  onSuccess,
2372
2590
  ...props
2373
2591
  }) {
2374
2592
  const isDownMd = useDownMd();
2375
- const intl = useIntl12();
2593
+ const intl = useIntl13();
2376
2594
  const { wallets: wallets2, installedWallets, chooseWallet, wallet, address, onConnect } = useBTCWallet();
2377
2595
  const iconMaps = {
2378
- leather: /* @__PURE__ */ jsx22(LeatherIcon, { size: isDownMd ? 36 : 40 }),
2379
- unisat: /* @__PURE__ */ jsx22(UnisatIcon, { size: isDownMd ? 36 : 40 }),
2380
- xverse: /* @__PURE__ */ jsx22(XverseIcon, { size: isDownMd ? 36 : 40 })
2596
+ leather: /* @__PURE__ */ jsx23(LeatherIcon, { size: isDownMd ? 36 : 40 }),
2597
+ unisat: /* @__PURE__ */ jsx23(UnisatIcon, { size: isDownMd ? 36 : 40 }),
2598
+ xverse: /* @__PURE__ */ jsx23(XverseIcon, { size: isDownMd ? 36 : 40 })
2381
2599
  };
2382
2600
  const { events, login } = useMatch();
2383
- const [status, setStatus] = useState17("");
2384
- const statusRef = React5.useRef(status);
2385
- const [error, setError] = useState17("");
2601
+ const [status, setStatus] = useState18("");
2602
+ const statusRef = React6.useRef(status);
2603
+ const [error, setError] = useState18("");
2386
2604
  const connected = useMemo8(() => {
2387
2605
  return !!address;
2388
2606
  }, [address]);
@@ -2398,7 +2616,7 @@ function BTCModal({
2398
2616
  try {
2399
2617
  setStatus("nonce");
2400
2618
  statusRef.current = "nonce";
2401
- const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
2619
+ const res = type == "bind" ? await getWalletInitApi({ address, type: "BTC" }) : await getWalletNonceApi({ address, type: "BTC" });
2402
2620
  if (!isSuccess(res)) {
2403
2621
  throw new Error(res.message);
2404
2622
  }
@@ -2447,7 +2665,7 @@ function BTCModal({
2447
2665
  statusRef.current = "";
2448
2666
  }
2449
2667
  };
2450
- useEffect12(() => {
2668
+ useEffect13(() => {
2451
2669
  if (wallet) {
2452
2670
  console.log("onConnect");
2453
2671
  try {
@@ -2460,12 +2678,12 @@ function BTCModal({
2460
2678
  setStatus("");
2461
2679
  }
2462
2680
  }, [wallet]);
2463
- useEffect12(() => {
2681
+ useEffect13(() => {
2464
2682
  if (address) {
2465
2683
  toLoginInWallet();
2466
2684
  }
2467
2685
  }, [address]);
2468
- useEffect12(() => {
2686
+ useEffect13(() => {
2469
2687
  if (!props.isOpen) {
2470
2688
  disconnect();
2471
2689
  }
@@ -2477,11 +2695,11 @@ function BTCModal({
2477
2695
  statusRef.current = "";
2478
2696
  setError("");
2479
2697
  };
2480
- return /* @__PURE__ */ jsx22(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
2698
+ return /* @__PURE__ */ jsx23(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
2481
2699
  id: type == "bind" ? "bindWith" : "loginWith"
2482
2700
  }, {
2483
2701
  name: "BTC"
2484
- }), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ jsx22(
2702
+ }), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ jsx23(
2485
2703
  WalletModalContent,
2486
2704
  {
2487
2705
  error,
@@ -2494,9 +2712,9 @@ function BTCModal({
2494
2712
  setVisible: () => {
2495
2713
  }
2496
2714
  }
2497
- ) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs18("div", { className: "matchid-login-recommend-list", children: [
2715
+ ) : /* @__PURE__ */ jsx23("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs18("div", { className: "matchid-login-recommend-list", children: [
2498
2716
  installedWallets.map((wallet2) => {
2499
- return /* @__PURE__ */ jsx22(
2717
+ return /* @__PURE__ */ jsx23(
2500
2718
  RecommendItem,
2501
2719
  {
2502
2720
  icon: iconMaps[wallet2.walletKey],
@@ -2509,14 +2727,14 @@ function BTCModal({
2509
2727
  );
2510
2728
  }),
2511
2729
  wallets2.filter((wallet2) => !installedWallets.find((installedWallet) => installedWallet.walletKey == wallet2.walletKey)).map((wallet2) => {
2512
- return /* @__PURE__ */ jsx22(
2730
+ return /* @__PURE__ */ jsx23(
2513
2731
  RecommendItem,
2514
2732
  {
2515
2733
  icon: iconMaps[wallet2.walletKey],
2516
2734
  name: wallet2.name,
2517
2735
  onClick: () => {
2518
2736
  },
2519
- footer: /* @__PURE__ */ jsx22(Button, { size: "sm", onClick: () => {
2737
+ footer: /* @__PURE__ */ jsx23(Button, { size: "sm", onClick: () => {
2520
2738
  window.open(wallet2.website);
2521
2739
  }, children: "Install" })
2522
2740
  },
@@ -2527,27 +2745,27 @@ function BTCModal({
2527
2745
  }
2528
2746
 
2529
2747
  // src/components/CEXBindModal/index.tsx
2530
- import { useEffect as useEffect13, useMemo as useMemo9, useState as useState18 } from "react";
2531
- import { FormattedMessage as FormattedMessage10, useIntl as useIntl13 } from "react-intl";
2532
- import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
2748
+ import { useEffect as useEffect14, useMemo as useMemo9, useState as useState19 } from "react";
2749
+ import { FormattedMessage as FormattedMessage10, useIntl as useIntl14 } from "react-intl";
2750
+ import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
2533
2751
  function CEXBindModal({
2534
2752
  onClose,
2535
2753
  type,
2536
2754
  isOpen = false,
2537
2755
  ...props
2538
2756
  }) {
2539
- const intl = useIntl13();
2757
+ const intl = useIntl14();
2540
2758
  const { events } = useMatch();
2541
- const [APIPassphrase, setAPIPassphrase] = useState18("");
2759
+ const [APIPassphrase, setAPIPassphrase] = useState19("");
2542
2760
  const { refreshOverview } = useUserInfo();
2543
- const [loading, setLoading] = useState18(false);
2544
- const [key, setKey] = useState18("");
2545
- const [secret, setSecret] = useState18("");
2546
- const [error, setError] = useState18("");
2761
+ const [loading, setLoading] = useState19(false);
2762
+ const [key, setKey] = useState19("");
2763
+ const [secret, setSecret] = useState19("");
2764
+ const [error, setError] = useState19("");
2547
2765
  const needPassphrase = useMemo9(() => {
2548
2766
  return ["bitget", "okx"].includes(type.toLowerCase());
2549
2767
  }, [type]);
2550
- useEffect13(() => {
2768
+ useEffect14(() => {
2551
2769
  if (isOpen) {
2552
2770
  setSecret("");
2553
2771
  setKey("");
@@ -2584,20 +2802,20 @@ function CEXBindModal({
2584
2802
  setLoading(false);
2585
2803
  }
2586
2804
  };
2587
- return /* @__PURE__ */ jsx23(ModalWithHeader, { showClose: true, isOpen, onClose, title: intl.formatMessage({
2805
+ return /* @__PURE__ */ jsx24(ModalWithHeader, { showClose: true, isOpen, onClose, title: intl.formatMessage({
2588
2806
  id: "CEXBindTitle"
2589
2807
  }, {
2590
2808
  type
2591
2809
  }), ...props, children: /* @__PURE__ */ jsxs19("div", { className: "matchid-cex-modal", children: [
2592
2810
  /* @__PURE__ */ jsxs19("div", { children: [
2593
- /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindAttention" }) }),
2594
- /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips1" }) }),
2595
- /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips2" }) }),
2596
- /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips3" }) })
2811
+ /* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(FormattedMessage10, { id: "CEXBindAttention" }) }),
2812
+ /* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(FormattedMessage10, { id: "CEXBindTips1" }) }),
2813
+ /* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(FormattedMessage10, { id: "CEXBindTips2" }) }),
2814
+ /* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(FormattedMessage10, { id: "CEXBindTips3" }) })
2597
2815
  ] }),
2598
- /* @__PURE__ */ jsx23(Field, { label: intl.formatMessage({
2816
+ /* @__PURE__ */ jsx24(Field, { label: intl.formatMessage({
2599
2817
  id: "CEXBindApiKey"
2600
- }), children: /* @__PURE__ */ jsx23(
2818
+ }), children: /* @__PURE__ */ jsx24(
2601
2819
  Input,
2602
2820
  {
2603
2821
  value: key,
@@ -2605,9 +2823,9 @@ function CEXBindModal({
2605
2823
  placeholder: "**** **** ****"
2606
2824
  }
2607
2825
  ) }),
2608
- /* @__PURE__ */ jsx23(Field, { label: intl.formatMessage({
2826
+ /* @__PURE__ */ jsx24(Field, { label: intl.formatMessage({
2609
2827
  id: "CEXBindApiSecretKey"
2610
- }), error: type != "OKX" && error, children: /* @__PURE__ */ jsx23(
2828
+ }), error: !needPassphrase && error, children: /* @__PURE__ */ jsx24(
2611
2829
  Input,
2612
2830
  {
2613
2831
  value: secret,
@@ -2615,9 +2833,9 @@ function CEXBindModal({
2615
2833
  placeholder: "**** **** ****"
2616
2834
  }
2617
2835
  ) }),
2618
- needPassphrase && /* @__PURE__ */ jsx23(Field, { error, label: intl.formatMessage({
2836
+ needPassphrase && /* @__PURE__ */ jsx24(Field, { error, label: intl.formatMessage({
2619
2837
  id: "CEXBindApiPassphrase"
2620
- }), children: /* @__PURE__ */ jsx23(
2838
+ }), children: /* @__PURE__ */ jsx24(
2621
2839
  Input,
2622
2840
  {
2623
2841
  value: APIPassphrase,
@@ -2625,7 +2843,7 @@ function CEXBindModal({
2625
2843
  placeholder: "**** **** ****"
2626
2844
  }
2627
2845
  ) }),
2628
- /* @__PURE__ */ jsx23(
2846
+ /* @__PURE__ */ jsx24(
2629
2847
  Button,
2630
2848
  {
2631
2849
  onClick: SubmitApi,
@@ -2633,24 +2851,25 @@ function CEXBindModal({
2633
2851
  block: true,
2634
2852
  loading,
2635
2853
  disabled: !key || !secret,
2636
- children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "continue" })
2854
+ children: /* @__PURE__ */ jsx24(FormattedMessage10, { id: "continue" })
2637
2855
  }
2638
2856
  )
2639
2857
  ] }) });
2640
2858
  }
2641
2859
 
2642
2860
  // src/context/BusinessProvider.tsx
2643
- import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
2861
+ import { Fragment as Fragment4, jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
2644
2862
  function BusinessProvider({ children }) {
2645
2863
  const { overview, token } = useUserInfo();
2646
2864
  const { recoveryModal } = useStore_default();
2647
2865
  const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
2866
+ const { type: TONType, isOpen: TONIsOpen, close: TONClose } = useTONModalStore();
2648
2867
  const { type: TRONType, isOpen: TRONIsOpen, close: TRONClose } = useTRONModalStore();
2649
2868
  const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
2650
2869
  const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
2651
2870
  return /* @__PURE__ */ jsxs20(Fragment4, { children: [
2652
- /* @__PURE__ */ jsx24(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
2653
- /* @__PURE__ */ jsx24(
2871
+ /* @__PURE__ */ jsx25(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
2872
+ /* @__PURE__ */ jsx25(
2654
2873
  RecoveryModal,
2655
2874
  {
2656
2875
  isOpen: !!token && !!overview && !!overview.address && recoveryModal.open,
@@ -2658,7 +2877,7 @@ function BusinessProvider({ children }) {
2658
2877
  onSuccess: recoveryModal.success
2659
2878
  }
2660
2879
  ),
2661
- /* @__PURE__ */ jsx24(
2880
+ /* @__PURE__ */ jsx25(
2662
2881
  SOLModal,
2663
2882
  {
2664
2883
  isOpen: SOLIsOpen && (SOLType == "login" && !overview && !token || SOLType == "bind" && !!token && !!overview),
@@ -2668,7 +2887,7 @@ function BusinessProvider({ children }) {
2668
2887
  zIndex: 199
2669
2888
  }
2670
2889
  ),
2671
- /* @__PURE__ */ jsx24(
2890
+ /* @__PURE__ */ jsx25(
2672
2891
  TRONModal,
2673
2892
  {
2674
2893
  isOpen: TRONIsOpen && (TRONType == "login" && !overview && !token || TRONType == "bind" && !!token && !!overview),
@@ -2678,7 +2897,17 @@ function BusinessProvider({ children }) {
2678
2897
  zIndex: 199
2679
2898
  }
2680
2899
  ),
2681
- /* @__PURE__ */ jsx24(
2900
+ /* @__PURE__ */ jsx25(
2901
+ TONModal,
2902
+ {
2903
+ isOpen: TONIsOpen && (TONType == "login" && !overview && !token || TONType == "bind" && !!token && !!overview),
2904
+ onClose: TONClose,
2905
+ type: TONType,
2906
+ onSuccess: TONClose,
2907
+ zIndex: 199
2908
+ }
2909
+ ),
2910
+ /* @__PURE__ */ jsx25(
2682
2911
  BTCModal,
2683
2912
  {
2684
2913
  isOpen: BTCIsOpen && (BTCType == "login" && !overview && !token || BTCType == "bind" && !!token && !!overview),
@@ -2688,7 +2917,7 @@ function BusinessProvider({ children }) {
2688
2917
  zIndex: 199
2689
2918
  }
2690
2919
  ),
2691
- /* @__PURE__ */ jsx24(
2920
+ /* @__PURE__ */ jsx25(
2692
2921
  CEXBindModal,
2693
2922
  {
2694
2923
  isOpen: CEXIsOpen && (!!token && !!overview),
@@ -2702,17 +2931,17 @@ function BusinessProvider({ children }) {
2702
2931
  }
2703
2932
 
2704
2933
  // src/context/index.tsx
2705
- import { jsx as jsx25 } from "react/jsx-runtime";
2934
+ import { jsx as jsx26 } from "react/jsx-runtime";
2706
2935
  var Providers = ({ children }) => {
2707
2936
  return (
2708
2937
  // <MpcWalletProvider>
2709
- /* @__PURE__ */ jsx25(BusinessProvider, { children })
2938
+ /* @__PURE__ */ jsx26(BusinessProvider, { children })
2710
2939
  );
2711
2940
  };
2712
2941
  var context_default = Providers;
2713
2942
 
2714
2943
  // src/hooks/useWalletInit.ts
2715
- import { useEffect as useEffect14, useState as useState19 } from "react";
2944
+ import { useEffect as useEffect15, useState as useState20 } from "react";
2716
2945
 
2717
2946
  // src/hooks/useWallet.tsx
2718
2947
  import { toAccount } from "viem/accounts";
@@ -2852,17 +3081,17 @@ function useWalletInit({
2852
3081
  const getWalletIframe = () => {
2853
3082
  return document.getElementById("match-wallet");
2854
3083
  };
2855
- const [walletInited, setWalletInited] = useState19(false);
3084
+ const [walletInited, setWalletInited] = useState20(false);
2856
3085
  const { appid, token, overview } = useLocalStore_default();
2857
3086
  const { initWallet, generateWallet } = useWallet();
2858
- const [iframeLoaded, setIframeLoaded] = useState19(false);
2859
- useEffect14(() => {
3087
+ const [iframeLoaded, setIframeLoaded] = useState20(false);
3088
+ useEffect15(() => {
2860
3089
  console.log("wallet status", {
2861
3090
  iframeLoaded,
2862
3091
  walletInited
2863
3092
  });
2864
3093
  }, [iframeLoaded, walletInited]);
2865
- useEffect14(() => {
3094
+ useEffect15(() => {
2866
3095
  if (endpoints.auth) {
2867
3096
  if (!window.matchWalletMessageIdMap) {
2868
3097
  window.matchWalletMessageIdMap = {};
@@ -2883,7 +3112,21 @@ function useWalletInit({
2883
3112
  setIframeLoaded(true);
2884
3113
  });
2885
3114
  document.body.insertBefore(iframe, document.body.firstChild);
2886
- window.sendMatchWalletMessage = (method, data) => {
3115
+ window.sendMatchWalletMessage = (method, data, retry = 5, times = 0) => {
3116
+ try {
3117
+ if (!document.getElementById("match-wallet")) {
3118
+ throw new Error("Wallet not found");
3119
+ }
3120
+ } catch (error) {
3121
+ console.error(`wallet init[${times}/${retry}]`, error);
3122
+ if (times < retry) {
3123
+ setTimeout(() => {
3124
+ window.sendMatchWalletMessage(method, data, retry, times + 1);
3125
+ }, 1e3);
3126
+ } else {
3127
+ throw error;
3128
+ }
3129
+ }
2887
3130
  const messageId = Date.now().toString() + Math.random().toString().slice(6);
2888
3131
  const message = {
2889
3132
  method,
@@ -2891,18 +3134,9 @@ function useWalletInit({
2891
3134
  messageId,
2892
3135
  source: "matchid"
2893
3136
  };
2894
- if (!iframeLoaded) {
2895
- throw new Error("Wallet not ready");
2896
- }
2897
- if (!walletInited) {
2898
- throw new Error("Wallet not inited");
2899
- }
2900
- if (document.getElementById("match-wallet")) {
2901
- matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
2902
- getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
2903
- return messageId;
2904
- }
2905
- throw new Error("Wallet not found");
3137
+ matchlog_default.log("matchid.sdk.sendMatchWalletMessage", message, endpoints.auth);
3138
+ getWalletIframe()?.contentWindow?.postMessage(message, endpoints.auth);
3139
+ return messageId;
2906
3140
  };
2907
3141
  window.waitMatchUntilWalletMessage = async (method, data, timeout = 3e4) => {
2908
3142
  return new Promise((resolve, reject) => {
@@ -2931,7 +3165,7 @@ function useWalletInit({
2931
3165
  }
2932
3166
  }
2933
3167
  }, [endpoints.auth]);
2934
- useEffect14(() => {
3168
+ useEffect15(() => {
2935
3169
  const messageHandle = async (e) => {
2936
3170
  if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
2937
3171
  return;
@@ -2964,7 +3198,7 @@ function useWalletInit({
2964
3198
  window.removeEventListener("message", messageHandle);
2965
3199
  };
2966
3200
  }, []);
2967
- useEffect14(() => {
3201
+ useEffect15(() => {
2968
3202
  if (token && overview && overview.did && walletInited) {
2969
3203
  const did = overview.did.split(":")[2];
2970
3204
  const newUserInit = async () => {
@@ -2995,7 +3229,7 @@ function useWalletInit({
2995
3229
  }
2996
3230
 
2997
3231
  // src/hooks/useInit.tsx
2998
- import { useEffect as useEffect15, useRef as useRef2 } from "react";
3232
+ import { useEffect as useEffect16, useRef as useRef2 } from "react";
2999
3233
  function useInit({
3000
3234
  theme,
3001
3235
  appid,
@@ -3018,19 +3252,19 @@ function useInit({
3018
3252
  const searchParams = new URLSearchParams(window.location.search);
3019
3253
  const matchToken = searchParams.get("matchToken");
3020
3254
  const realEndpoints = endpoints || env_default.endpoints;
3021
- useEffect15(() => {
3255
+ useEffect16(() => {
3022
3256
  setTheme(theme);
3023
3257
  }, [theme]);
3024
- useEffect15(() => {
3258
+ useEffect16(() => {
3025
3259
  setAppid(appid);
3026
3260
  }, [appid]);
3027
- useEffect15(() => {
3261
+ useEffect16(() => {
3028
3262
  setEndpoints(realEndpoints);
3029
3263
  }, [realEndpoints]);
3030
- useEffect15(() => {
3264
+ useEffect16(() => {
3031
3265
  setLocale(locale || "en");
3032
3266
  }, [locale]);
3033
- useEffect15(() => {
3267
+ useEffect16(() => {
3034
3268
  if (matchToken) {
3035
3269
  const tokenData = JSON.parse(atob(matchToken));
3036
3270
  if (tokenData && tokenData.mid && tokenData.token) {
@@ -3041,7 +3275,7 @@ function useInit({
3041
3275
  }
3042
3276
  }
3043
3277
  }, [matchToken]);
3044
- useEffect15(() => {
3278
+ useEffect16(() => {
3045
3279
  const onLoginMessage = (event) => {
3046
3280
  const res = event.data;
3047
3281
  if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
@@ -3077,7 +3311,7 @@ function useInit({
3077
3311
  overviewLoadingRef.current = false;
3078
3312
  }
3079
3313
  };
3080
- useEffect15(() => {
3314
+ useEffect16(() => {
3081
3315
  if (token) {
3082
3316
  loadOverview();
3083
3317
  }
@@ -3584,7 +3818,7 @@ var messages = {
3584
3818
  };
3585
3819
 
3586
3820
  // src/MatchContext.tsx
3587
- import { jsx as jsx26 } from "react/jsx-runtime";
3821
+ import { jsx as jsx27 } from "react/jsx-runtime";
3588
3822
  var queryClient = new QueryClient();
3589
3823
  var MatchContext = createContext(void 0);
3590
3824
  var MatchProvider = ({ children, appid, events, theme = "light", endpoints, locale }) => {
@@ -3605,7 +3839,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints, loca
3605
3839
  useWalletInit({
3606
3840
  refreshOverview: loadOverview
3607
3841
  });
3608
- return /* @__PURE__ */ jsx26(IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ jsx26(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx26(
3842
+ return /* @__PURE__ */ jsx27(IntlProvider, { locale: realLocale, messages: messages[realLocale], children: /* @__PURE__ */ jsx27(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx27(
3609
3843
  MatchContext.Provider,
3610
3844
  {
3611
3845
  value: {
@@ -3616,7 +3850,7 @@ var MatchProvider = ({ children, appid, events, theme = "light", endpoints, loca
3616
3850
  theme,
3617
3851
  locale: realLocale
3618
3852
  },
3619
- children: /* @__PURE__ */ jsx26(context_default, { children })
3853
+ children: /* @__PURE__ */ jsx27(context_default, { children })
3620
3854
  }
3621
3855
  ) }) });
3622
3856
  };
@@ -3644,6 +3878,7 @@ function useUserInfo() {
3644
3878
  const { events, login } = useMatch();
3645
3879
  const { open: SOLOpen } = useSOLModalStore();
3646
3880
  const { open: TRONOpen } = useTRONModalStore();
3881
+ const { open: TONOpen } = useTONModalStore();
3647
3882
  const { open: BTCOpen } = useBTCModalStore();
3648
3883
  const { open: CEXBindOpen } = useCEXBindModalStore();
3649
3884
  const isLogin = useMemo10(() => !!token, [token]);
@@ -3692,6 +3927,8 @@ function useUserInfo() {
3692
3927
  return SOLOpen("login");
3693
3928
  case "tron":
3694
3929
  return TRONOpen("login");
3930
+ case "ton":
3931
+ return TONOpen("login");
3695
3932
  case "btc":
3696
3933
  return BTCOpen("login");
3697
3934
  case "telegram":
@@ -3783,6 +4020,8 @@ function useUserInfo() {
3783
4020
  return SOLOpen("bind");
3784
4021
  case "tron":
3785
4022
  return TRONOpen("bind");
4023
+ case "ton":
4024
+ return TONOpen("bind");
3786
4025
  case "btc":
3787
4026
  return BTCOpen("bind");
3788
4027
  case "telegram":
@@ -3835,9 +4074,9 @@ function useUserInfo() {
3835
4074
  }
3836
4075
 
3837
4076
  // src/hooks/useMatchEvents.ts
3838
- import { useEffect as useEffect16 } from "react";
4077
+ import { useEffect as useEffect17 } from "react";
3839
4078
  function useMatchEvents(handlers) {
3840
- useEffect16(() => {
4079
+ useEffect17(() => {
3841
4080
  Object.entries(handlers).forEach(([event, handler2]) => {
3842
4081
  if (handler2) {
3843
4082
  eventManager_default.on(event, handler2);
@@ -3855,14 +4094,14 @@ function useMatchEvents(handlers) {
3855
4094
 
3856
4095
  // src/hooks/useCopyClipboard.ts
3857
4096
  import copy from "copy-to-clipboard";
3858
- import { useCallback, useEffect as useEffect17, useState as useState20 } from "react";
4097
+ import { useCallback, useEffect as useEffect18, useState as useState21 } from "react";
3859
4098
  function useCopyClipboard(timeout = 500) {
3860
- const [isCopied, setIsCopied] = useState20(false);
4099
+ const [isCopied, setIsCopied] = useState21(false);
3861
4100
  const staticCopy = useCallback((text) => {
3862
4101
  const didCopy = copy(text);
3863
4102
  setIsCopied(didCopy);
3864
4103
  }, []);
3865
- useEffect17(() => {
4104
+ useEffect18(() => {
3866
4105
  if (isCopied) {
3867
4106
  const hide = setTimeout(() => {
3868
4107
  setIsCopied(false);
@@ -3907,9 +4146,10 @@ export {
3907
4146
  UsernameModal,
3908
4147
  SOLModal,
3909
4148
  TRONModal,
4149
+ TONModal,
3910
4150
  BTCModal,
3911
4151
  components_exports,
3912
4152
  MatchProvider,
3913
4153
  useMatch
3914
4154
  };
3915
- //# sourceMappingURL=chunk-XMGJLSI2.mjs.map
4155
+ //# sourceMappingURL=chunk-RYZFW6P6.mjs.map