@matchain/matchid-sdk-react 0.1.37-alpha.6 → 0.1.37-alpha.8

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 (35) hide show
  1. package/dist/assets/icon/index.d.mts +7 -1
  2. package/dist/assets/icon/index.d.ts +7 -1
  3. package/dist/assets/icon/index.js +78 -0
  4. package/dist/assets/icon/index.js.map +1 -1
  5. package/dist/assets/icon/index.mjs +7 -1
  6. package/dist/{chunk-FLEEMUIJ.mjs → chunk-65NEGWW3.mjs} +313 -140
  7. package/dist/chunk-65NEGWW3.mjs.map +1 -0
  8. package/dist/chunk-6PWH7WZI.mjs +1067 -0
  9. package/dist/chunk-6PWH7WZI.mjs.map +1 -0
  10. package/dist/{chunk-OZ3WBUHE.mjs → chunk-X3VJMKNQ.mjs} +2 -2
  11. package/dist/components/index.d.mts +1 -1
  12. package/dist/components/index.d.ts +1 -1
  13. package/dist/components/index.js +649 -286
  14. package/dist/components/index.js.map +1 -1
  15. package/dist/components/index.mjs +4 -4
  16. package/dist/hooks/api/index.js +56 -42
  17. package/dist/hooks/api/index.js.map +1 -1
  18. package/dist/hooks/api/index.mjs +3 -3
  19. package/dist/hooks/index.js +62 -48
  20. package/dist/hooks/index.js.map +1 -1
  21. package/dist/hooks/index.mjs +2 -2
  22. package/dist/{index-dJi5ka2c.d.mts → index-CV5LZa9w.d.mts} +4 -4
  23. package/dist/{index-DTCAzQvB.d.ts → index-yEwP0nd2.d.ts} +4 -4
  24. package/dist/index.d.mts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +711 -348
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +3 -3
  29. package/example/src/components/Login/index.tsx +1 -1
  30. package/example/src/pages/User.tsx +1 -1
  31. package/package.json +1 -1
  32. package/dist/chunk-FLEEMUIJ.mjs.map +0 -1
  33. package/dist/chunk-J6EA7OSJ.mjs +0 -992
  34. package/dist/chunk-J6EA7OSJ.mjs.map +0 -1
  35. /package/dist/{chunk-OZ3WBUHE.mjs.map → chunk-X3VJMKNQ.mjs.map} +0 -0
@@ -2,6 +2,9 @@ import {
2
2
  ArrowDownIcon,
3
3
  ArrowLeftIcon,
4
4
  ArrowRightIcon,
5
+ BTCDarkIcon,
6
+ BTCLightIcon,
7
+ BitgetIcon,
5
8
  CheckIcon,
6
9
  CheckRoundIcon,
7
10
  CloseEyeIcon,
@@ -20,18 +23,22 @@ import {
20
23
  LinkedinIcon,
21
24
  LoadingIcon_default,
22
25
  LoginIcon_default,
26
+ OKXIcon,
23
27
  OpenEyeIcon,
24
28
  PasswordRoundIcon,
25
29
  SOLDarkIcon,
26
30
  SOLLightIcon,
31
+ TRXDarkIcon,
32
+ TRXLightIcon,
27
33
  TelegramIcon,
34
+ TronLinkIcon,
28
35
  UnLoginIcon_default,
29
36
  UnisatIcon,
30
37
  WalletIcon,
31
38
  XIcon,
32
39
  XverseIcon,
33
40
  YoutubeIcon
34
- } from "./chunk-J6EA7OSJ.mjs";
41
+ } from "./chunk-6PWH7WZI.mjs";
35
42
  import {
36
43
  __export
37
44
  } from "./chunk-J5LGTIGS.mjs";
@@ -86,7 +93,7 @@ var localStore = useLocalStore;
86
93
  var useLocalStore_default = useLocalStore;
87
94
 
88
95
  // src/hooks/useUserInfo.tsx
89
- import { useMemo as useMemo8 } from "react";
96
+ import { useMemo as useMemo9 } from "react";
90
97
 
91
98
  // src/api/request.ts
92
99
  import axios from "axios";
@@ -739,7 +746,7 @@ var useSOLModalStore = create3((set) => ({
739
746
  open: (type) => set({ isOpen: true, type }),
740
747
  close: () => set({ isOpen: false })
741
748
  }));
742
- var useTronModalStore = create3((set) => ({
749
+ var useTRONModalStore = create3((set) => ({
743
750
  isOpen: false,
744
751
  type: "",
745
752
  open: (type) => set({ isOpen: true, type }),
@@ -775,7 +782,7 @@ __export(components_exports, {
775
782
  PasswordModal: () => PasswordModal,
776
783
  Popover: () => Popover,
777
784
  SOLModal: () => SOLModal,
778
- TronModal: () => TronModal,
785
+ TRONModal: () => TRONModal,
779
786
  UsernameModal: () => UsernameModal
780
787
  });
781
788
 
@@ -1096,7 +1103,7 @@ function LoginBox({
1096
1103
  "telegram",
1097
1104
  "twitter"
1098
1105
  ],
1099
- walletMethods = ["evm"],
1106
+ walletMethods = ["evm", "sol"],
1100
1107
  inModal = false
1101
1108
  }) {
1102
1109
  const [emailOpen, setEmailOpen] = useState9(false);
@@ -1171,6 +1178,18 @@ function LoginBox({
1171
1178
  activeIcon: /* @__PURE__ */ jsx11(SOLLightIcon, { size: isDownMd ? 36 : 40 }),
1172
1179
  name: "SOL",
1173
1180
  onClick: () => login("sol")
1181
+ },
1182
+ btc: {
1183
+ icon: /* @__PURE__ */ jsx11(BTCDarkIcon, { size: isDownMd ? 36 : 40 }),
1184
+ activeIcon: /* @__PURE__ */ jsx11(BTCLightIcon, { size: isDownMd ? 36 : 40 }),
1185
+ name: "BTC",
1186
+ onClick: () => login("btc")
1187
+ },
1188
+ tron: {
1189
+ icon: /* @__PURE__ */ jsx11(TRXDarkIcon, { size: isDownMd ? 36 : 40 }),
1190
+ activeIcon: /* @__PURE__ */ jsx11(TRXLightIcon, { size: isDownMd ? 36 : 40 }),
1191
+ name: "TRON",
1192
+ onClick: () => login("tron")
1174
1193
  }
1175
1194
  };
1176
1195
  return /* @__PURE__ */ jsxs9(Fragment2, { children: [
@@ -1887,61 +1906,157 @@ function SOLModal({
1887
1906
  }), children: /* @__PURE__ */ jsx20(ConnectionProvider, { endpoint: clusterApiUrl("devnet"), children: /* @__PURE__ */ jsx20(WalletProvider, { wallets, autoConnect: true, children: /* @__PURE__ */ jsx20(WalletModalProvider, { children: /* @__PURE__ */ jsx20(WalletContent, { onSuccess, type }) }) }) }) });
1888
1907
  }
1889
1908
 
1890
- // src/components/TronModal/index.tsx
1891
- import React4, { useEffect as useEffect9, useState as useState14 } from "react";
1909
+ // src/components/TRONModal/index.tsx
1910
+ import React4, { useEffect as useEffect10, useMemo as useMemo7, useState as useState15 } from "react";
1892
1911
  import { useIntl as useIntl11 } from "react-intl";
1893
- import { jsx as jsx21 } from "react/jsx-runtime";
1894
- function WalletContent2({
1895
- onSuccess,
1896
- type
1897
- }) {
1898
- const { events, login } = useMatch();
1899
- const disconnect = async () => {
1900
- };
1901
- const [status, setStatus] = useState14("");
1902
- const statusRef = React4.useRef(status);
1903
- const [error, setError] = useState14("");
1904
- const [visible, setVisible] = useState14(false);
1905
- const [walletAddress, setWalletAddress] = useState14("");
1906
- const [connected, setConnected] = useState14(false);
1907
- const checkConnection = () => {
1908
- if (window.tronWeb && window.tronWeb.defaultAddress && window.tronWeb.defaultAddress.base58) {
1909
- const address = window.tronWeb.defaultAddress.base58;
1910
- matchlog_default.log("tron address", address);
1911
- setWalletAddress(address);
1912
- setConnected(true);
1913
- } else {
1914
- setWalletAddress("");
1915
- setConnected(false);
1912
+
1913
+ // src/lib/tron/TronLinkAdapter.ts
1914
+ var TronLinkAdapter = class {
1915
+ constructor() {
1916
+ this.name = "TronLink Wallet";
1917
+ this.website = "https://www.tronlink.org/";
1918
+ this.walletKey = "tronlink";
1919
+ }
1920
+ async isInstalled() {
1921
+ return typeof window.tronWeb !== "undefined" && typeof window.tronLink !== "undefined";
1922
+ }
1923
+ async connect() {
1924
+ if (!await this.isInstalled()) throw new Error("TronLink Wallet is not installed");
1925
+ if (!window.tronWeb.defaultAddress.base58) {
1926
+ await window.tronWeb.request(
1927
+ {
1928
+ method: "tron_requestAccounts",
1929
+ params: window.tronLink.tronlinkParams
1930
+ }
1931
+ );
1916
1932
  }
1917
- };
1918
- useEffect9(() => {
1919
- if (typeof window.tronWeb !== "undefined") {
1920
- checkConnection();
1921
- const interval = setInterval(() => {
1922
- checkConnection();
1923
- }, 1e3);
1924
- return () => clearInterval(interval);
1925
- } else {
1933
+ if (!window.tronWeb.defaultAddress.base58) {
1934
+ throw new Error("Your should unlink your wallet and try again");
1926
1935
  }
1927
- }, []);
1936
+ return window.tronWeb.defaultAddress.base58;
1937
+ }
1938
+ async signMessage(message) {
1939
+ return await window.tronWeb.trx.signMessageV2(message);
1940
+ }
1941
+ };
1942
+
1943
+ // src/hooks/useTRONWallet.ts
1944
+ import { useEffect as useEffect9, useState as useState14 } from "react";
1945
+
1946
+ // src/lib/tron/BitgetAdapter.ts
1947
+ var BitgetAdapter = class {
1948
+ constructor() {
1949
+ this.name = "Bitget Wallet";
1950
+ this.website = "https://web3.bitget.com/zh-CN/wallet-download";
1951
+ this.walletKey = "bitget";
1952
+ }
1953
+ async isInstalled() {
1954
+ return typeof window.bitkeep !== "undefined" && typeof window.bitkeep.tronWeb !== "undefined" && typeof window.bitkeep.tronLink !== "undefined";
1955
+ }
1956
+ async connect() {
1957
+ if (!await this.isInstalled()) throw new Error("Bitkeep Wallet is not installed");
1958
+ await window.bitkeep.tronLink.request({ method: "tron_requestAccounts" });
1959
+ return window.bitkeep.tronWeb.defaultAddress.base58;
1960
+ }
1961
+ async signMessage(message) {
1962
+ return await window.bitkeep.tronWeb.trx.signMessageV2(message);
1963
+ }
1964
+ };
1965
+
1966
+ // src/lib/tron/OKXAdapter.ts
1967
+ var OKXAdapter = class {
1968
+ constructor() {
1969
+ this.name = "OKX Wallet";
1970
+ this.website = "https://www.okx.com/zh-hans/download";
1971
+ this.walletKey = "okx";
1972
+ }
1973
+ async isInstalled() {
1974
+ return typeof window.okxwallet !== "undefined" && typeof window.okxwallet.tronWeb !== "undefined" && typeof window.okxwallet.tronLink !== "undefined";
1975
+ }
1976
+ async connect() {
1977
+ if (!await this.isInstalled()) throw new Error("OKX Wallet is not installed");
1978
+ await window.okxwallet.tronLink.request({ method: "tron_requestAccounts" });
1979
+ return window.okxwallet.tronWeb.defaultAddress.base58;
1980
+ }
1981
+ async signMessage(message) {
1982
+ return await window.okxwallet.tronWeb.trx.signMessageV2(message);
1983
+ }
1984
+ };
1985
+
1986
+ // src/hooks/useTRONWallet.ts
1987
+ var useTRONWallet = () => {
1988
+ const wallets2 = [new TronLinkAdapter(), new BitgetAdapter(), new OKXAdapter()];
1989
+ const [installedWallets, setInstalledWallets] = useState14([]);
1990
+ const [address, setAddress] = useState14(null);
1928
1991
  useEffect9(() => {
1929
- const init = async () => {
1930
- setVisible(true);
1992
+ const getInstalled = async () => {
1993
+ const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
1994
+ wallet: wallet2,
1995
+ isInstalled
1996
+ }))));
1997
+ setInstalledWallets(installed.filter(({ isInstalled }) => isInstalled).map(({ wallet: wallet2 }) => wallet2));
1931
1998
  };
1932
- init();
1999
+ getInstalled();
1933
2000
  }, []);
2001
+ const [wallet, chooseWallet] = useState14(null);
2002
+ const onConnect = async () => {
2003
+ setAddress(await wallet.connect());
2004
+ };
1934
2005
  useEffect9(() => {
1935
- if (connected) {
1936
- toLoginInWallet();
2006
+ if (!wallet) {
2007
+ setAddress(null);
1937
2008
  }
1938
- }, [connected]);
2009
+ }, [wallet]);
2010
+ return {
2011
+ installedWallets,
2012
+ wallets: wallets2,
2013
+ chooseWallet,
2014
+ wallet,
2015
+ address,
2016
+ onConnect
2017
+ };
2018
+ };
2019
+
2020
+ // src/components/TRONModal/index.tsx
2021
+ import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
2022
+ function TRONModal({
2023
+ type = "login",
2024
+ onSuccess,
2025
+ ...props
2026
+ }) {
2027
+ const isDownMd = useDownMd();
2028
+ const intl = useIntl11();
2029
+ const { wallets: wallets2, installedWallets, chooseWallet, wallet, address, onConnect } = useTRONWallet();
2030
+ const iconMaps = {
2031
+ tronlink: /* @__PURE__ */ jsx21(TronLinkIcon, { size: isDownMd ? 36 : 40 }),
2032
+ bitget: /* @__PURE__ */ jsx21(BitgetIcon, { size: isDownMd ? 36 : 40 }),
2033
+ okx: /* @__PURE__ */ jsx21(OKXIcon, { size: isDownMd ? 36 : 40 })
2034
+ };
2035
+ const { events, login } = useMatch();
2036
+ const [status, setStatus] = useState15("");
2037
+ const statusRef = React4.useRef(status);
2038
+ const [error, setError] = useState15("");
2039
+ const connected = useMemo7(() => {
2040
+ return !!address;
2041
+ }, [address]);
2042
+ const disconnect = async () => {
2043
+ setStatus("");
2044
+ chooseWallet(null);
2045
+ statusRef.current = "";
2046
+ setError("");
2047
+ };
2048
+ const onBack = () => {
2049
+ setStatus("");
2050
+ chooseWallet(null);
2051
+ statusRef.current = "";
2052
+ setError("");
2053
+ };
1939
2054
  const toLoginInWallet = async () => {
1940
- if (statusRef.current) return;
2055
+ if (statusRef.current || !address || !wallet) return;
1941
2056
  try {
1942
2057
  setStatus("nonce");
1943
2058
  statusRef.current = "nonce";
1944
- const res = type == "bind" ? await getWalletInitApi({ address: walletAddress }) : await getWalletNonceApi({ address: walletAddress });
2059
+ const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
1945
2060
  if (!isSuccess(res)) {
1946
2061
  throw new Error(res.message);
1947
2062
  }
@@ -1950,15 +2065,14 @@ function WalletContent2({
1950
2065
  setStatus("signer");
1951
2066
  statusRef.current = "signer";
1952
2067
  const message = "By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.Nonce:" + res.data.nonce;
1953
- const encodedMessage = new TextEncoder().encode(message);
1954
- const signedMessage = await window.tronWeb.trx.signMessageV2(encodedMessage);
2068
+ const signedMessage = await wallet.signMessage(message);
1955
2069
  let obj = {
1956
- type: "Tron",
1957
- address: walletAddress,
1958
- signature: Buffer.from(signedMessage).toString("base64"),
2070
+ type: "TRON",
2071
+ address,
2072
+ signature: signedMessage,
1959
2073
  message,
1960
- connector_type: "Tron",
1961
- wallet_client_type: "TronLink"
2074
+ connector_type: "TRON",
2075
+ wallet_client_type: wallet.walletKey
1962
2076
  };
1963
2077
  const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
1964
2078
  if (res1) {
@@ -1990,37 +2104,75 @@ function WalletContent2({
1990
2104
  statusRef.current = "";
1991
2105
  }
1992
2106
  };
1993
- return /* @__PURE__ */ jsx21(
2107
+ useEffect10(() => {
2108
+ if (wallet) {
2109
+ console.log("onConnect");
2110
+ onConnect();
2111
+ } else {
2112
+ setStatus("");
2113
+ }
2114
+ }, [wallet]);
2115
+ useEffect10(() => {
2116
+ if (address) {
2117
+ toLoginInWallet();
2118
+ }
2119
+ }, [address]);
2120
+ useEffect10(() => {
2121
+ if (!props.isOpen) {
2122
+ disconnect();
2123
+ }
2124
+ }, [props.isOpen]);
2125
+ return /* @__PURE__ */ jsx21(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
2126
+ id: type == "bind" ? "bindWith" : "loginWith"
2127
+ }, {
2128
+ name: "TRON"
2129
+ }), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ jsx21(
1994
2130
  WalletModalContent,
1995
2131
  {
1996
- connected,
1997
- disconnect,
1998
- address: walletAddress,
1999
- visible,
2000
- setVisible,
2001
2132
  error,
2002
2133
  setError,
2003
- status
2134
+ status,
2135
+ disconnect,
2136
+ address: address || "",
2137
+ connected,
2138
+ visible: true,
2139
+ setVisible: () => {
2140
+ }
2004
2141
  }
2005
- );
2006
- }
2007
- function TronModal({
2008
- type = "login",
2009
- onSuccess,
2010
- ...props
2011
- }) {
2012
- const intl = useIntl11();
2013
- return /* @__PURE__ */ jsx21(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
2014
- id: type == "bind" ? "bindWith" : "loginWith"
2015
- }, {
2016
- name: "Tron"
2017
- }), children: typeof window.tronWeb === "undefined" ? /* @__PURE__ */ jsx21(Button, { onClick: () => {
2018
- window.open("https://chromewebstore.google.com/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec");
2019
- }, children: "Install TronLink extension" }) : /* @__PURE__ */ jsx21(WalletContent2, { onSuccess, type }) });
2142
+ ) : /* @__PURE__ */ jsx21("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs17("div", { className: "matchid-login-recommend-list", children: [
2143
+ installedWallets.map((wallet2) => {
2144
+ return /* @__PURE__ */ jsx21(
2145
+ RecommendItem,
2146
+ {
2147
+ icon: iconMaps[wallet2.walletKey],
2148
+ name: wallet2.name,
2149
+ onClick: () => {
2150
+ chooseWallet(wallet2);
2151
+ }
2152
+ },
2153
+ wallet2.walletKey
2154
+ );
2155
+ }),
2156
+ wallets2.filter((wallet2) => !installedWallets.find((installedWallet) => installedWallet.walletKey == wallet2.walletKey)).map((wallet2) => {
2157
+ return /* @__PURE__ */ jsx21(
2158
+ RecommendItem,
2159
+ {
2160
+ icon: iconMaps[wallet2.walletKey],
2161
+ name: wallet2.name,
2162
+ onClick: () => {
2163
+ },
2164
+ footer: /* @__PURE__ */ jsx21(Button, { size: "sm", onClick: () => {
2165
+ window.open(wallet2.website);
2166
+ }, children: "Install" })
2167
+ },
2168
+ wallet2.walletKey
2169
+ );
2170
+ })
2171
+ ] }) }) });
2020
2172
  }
2021
2173
 
2022
2174
  // src/components/BTCModal/index.tsx
2023
- import React5, { useEffect as useEffect11, useMemo as useMemo7, useState as useState16 } from "react";
2175
+ import React5, { useEffect as useEffect12, useMemo as useMemo8, useState as useState17 } from "react";
2024
2176
  import { useIntl as useIntl12 } from "react-intl";
2025
2177
 
2026
2178
  // src/lib/btc/UnisatAdapter.ts
@@ -2057,6 +2209,10 @@ var UnisatAdapter = class {
2057
2209
  if (!await this.isInstalled()) throw new Error("Unisat Wallet is not installed");
2058
2210
  return window.unisat.signMessage(message, "bip322-simple");
2059
2211
  }
2212
+ async disconnet() {
2213
+ if (!await this.isInstalled()) throw new Error("Unisat Wallet is not installed");
2214
+ return window.unisat.disconnect();
2215
+ }
2060
2216
  };
2061
2217
 
2062
2218
  // src/lib/btc/XverseAdapter.ts
@@ -2140,6 +2296,10 @@ var XverseAdapter = class {
2140
2296
  });
2141
2297
  });
2142
2298
  }
2299
+ async disconnet() {
2300
+ if (!await this.isInstalled()) throw new Error("Xverse Wallet is not installed");
2301
+ await request2("wallet_disconnect", null);
2302
+ }
2143
2303
  };
2144
2304
 
2145
2305
  // src/lib/btc/LeatherAdapter.ts
@@ -2167,12 +2327,12 @@ var LeatherAdapter = class {
2167
2327
  };
2168
2328
 
2169
2329
  // src/hooks/useBTCWallet.ts
2170
- import { useEffect as useEffect10, useState as useState15 } from "react";
2330
+ import { useEffect as useEffect11, useState as useState16 } from "react";
2171
2331
  var useBTCWallet = () => {
2172
2332
  const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
2173
- const [installedWallets, setInstalledWallets] = useState15([]);
2174
- const [address, setAddress] = useState15(null);
2175
- useEffect10(() => {
2333
+ const [installedWallets, setInstalledWallets] = useState16([]);
2334
+ const [address, setAddress] = useState16(null);
2335
+ useEffect11(() => {
2176
2336
  const getInstalled = async () => {
2177
2337
  const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
2178
2338
  wallet: wallet2,
@@ -2182,11 +2342,11 @@ var useBTCWallet = () => {
2182
2342
  };
2183
2343
  getInstalled();
2184
2344
  }, []);
2185
- const [wallet, chooseWallet] = useState15(null);
2345
+ const [wallet, chooseWallet] = useState16(null);
2186
2346
  const onConnect = async () => {
2187
2347
  setAddress(await wallet.connect());
2188
2348
  };
2189
- useEffect10(() => {
2349
+ useEffect11(() => {
2190
2350
  if (!wallet) {
2191
2351
  setAddress(null);
2192
2352
  }
@@ -2202,7 +2362,7 @@ var useBTCWallet = () => {
2202
2362
  };
2203
2363
 
2204
2364
  // src/components/BTCModal/index.tsx
2205
- import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
2365
+ import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
2206
2366
  function BTCModal({
2207
2367
  type = "login",
2208
2368
  onSuccess,
@@ -2217,15 +2377,18 @@ function BTCModal({
2217
2377
  xverse: /* @__PURE__ */ jsx22(XverseIcon, { size: isDownMd ? 36 : 40 })
2218
2378
  };
2219
2379
  const { events, login } = useMatch();
2220
- const [status, setStatus] = useState16("");
2380
+ const [status, setStatus] = useState17("");
2221
2381
  const statusRef = React5.useRef(status);
2222
- const [error, setError] = useState16("");
2223
- const connected = useMemo7(() => {
2382
+ const [error, setError] = useState17("");
2383
+ const connected = useMemo8(() => {
2224
2384
  return !!address;
2225
2385
  }, [address]);
2226
2386
  const disconnect = async () => {
2387
+ wallet.disconnet();
2227
2388
  setStatus("");
2228
2389
  chooseWallet(null);
2390
+ statusRef.current = "";
2391
+ setError("");
2229
2392
  };
2230
2393
  const toLoginInWallet = async () => {
2231
2394
  if (statusRef.current || !address || !wallet) return;
@@ -2248,7 +2411,7 @@ function BTCModal({
2248
2411
  signature: signedMessage,
2249
2412
  message,
2250
2413
  connector_type: "BTC",
2251
- wallet_client_type: wallet.name
2414
+ wallet_client_type: wallet.walletKey
2252
2415
  };
2253
2416
  const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
2254
2417
  if (res1) {
@@ -2275,37 +2438,47 @@ function BTCModal({
2275
2438
  }
2276
2439
  }
2277
2440
  } catch (error2) {
2441
+ console.error("btc error", error2);
2278
2442
  setStatus("error");
2279
2443
  setError(error2.message);
2280
2444
  statusRef.current = "";
2281
2445
  }
2282
2446
  };
2283
- useEffect11(() => {
2447
+ useEffect12(() => {
2284
2448
  if (wallet) {
2285
2449
  console.log("onConnect");
2286
- onConnect();
2450
+ try {
2451
+ onConnect();
2452
+ } catch (err) {
2453
+ setStatus("error");
2454
+ setError(err.message);
2455
+ }
2287
2456
  } else {
2288
2457
  setStatus("");
2289
2458
  }
2290
2459
  }, [wallet]);
2291
- useEffect11(() => {
2460
+ useEffect12(() => {
2292
2461
  if (address) {
2293
2462
  toLoginInWallet();
2294
2463
  }
2295
2464
  }, [address]);
2296
- useEffect11(() => {
2465
+ useEffect12(() => {
2297
2466
  if (!props.isOpen) {
2298
- setStatus("");
2299
2467
  disconnect();
2300
2468
  }
2301
2469
  }, [props.isOpen]);
2470
+ const onBack = () => {
2471
+ wallet.disconnet();
2472
+ setStatus("");
2473
+ chooseWallet(null);
2474
+ statusRef.current = "";
2475
+ setError("");
2476
+ };
2302
2477
  return /* @__PURE__ */ jsx22(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
2303
2478
  id: type == "bind" ? "bindWith" : "loginWith"
2304
2479
  }, {
2305
2480
  name: "BTC"
2306
- }), onBack: wallet ? () => {
2307
- chooseWallet(null);
2308
- } : void 0, children: wallet ? /* @__PURE__ */ jsx22(
2481
+ }), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ jsx22(
2309
2482
  WalletModalContent,
2310
2483
  {
2311
2484
  error,
@@ -2318,7 +2491,7 @@ function BTCModal({
2318
2491
  setVisible: () => {
2319
2492
  }
2320
2493
  }
2321
- ) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs17("div", { className: "matchid-login-recommend-list", children: [
2494
+ ) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs18("div", { className: "matchid-login-recommend-list", children: [
2322
2495
  installedWallets.map((wallet2) => {
2323
2496
  return /* @__PURE__ */ jsx22(
2324
2497
  RecommendItem,
@@ -2351,9 +2524,9 @@ function BTCModal({
2351
2524
  }
2352
2525
 
2353
2526
  // src/components/CEXBindModal/index.tsx
2354
- import { useEffect as useEffect12, useState as useState17 } from "react";
2527
+ import { useEffect as useEffect13, useState as useState18 } from "react";
2355
2528
  import { FormattedMessage as FormattedMessage10, useIntl as useIntl13 } from "react-intl";
2356
- import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
2529
+ import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
2357
2530
  function CEXBindModal({
2358
2531
  onClose,
2359
2532
  type,
@@ -2362,13 +2535,13 @@ function CEXBindModal({
2362
2535
  }) {
2363
2536
  const intl = useIntl13();
2364
2537
  const { events } = useMatch();
2365
- const [APIPassphrase, setAPIPassphrase] = useState17("");
2538
+ const [APIPassphrase, setAPIPassphrase] = useState18("");
2366
2539
  const { refreshOverview } = useUserInfo();
2367
- const [loading, setLoading] = useState17(false);
2368
- const [key, setKey] = useState17("");
2369
- const [secret, setSecret] = useState17("");
2370
- const [error, setError] = useState17("");
2371
- useEffect12(() => {
2540
+ const [loading, setLoading] = useState18(false);
2541
+ const [key, setKey] = useState18("");
2542
+ const [secret, setSecret] = useState18("");
2543
+ const [error, setError] = useState18("");
2544
+ useEffect13(() => {
2372
2545
  if (isOpen) {
2373
2546
  setSecret("");
2374
2547
  setKey("");
@@ -2409,8 +2582,8 @@ function CEXBindModal({
2409
2582
  id: "CEXBindTitle"
2410
2583
  }, {
2411
2584
  type
2412
- }), ...props, children: /* @__PURE__ */ jsxs18("div", { className: "matchid-cex-modal", children: [
2413
- /* @__PURE__ */ jsxs18("div", { children: [
2585
+ }), ...props, children: /* @__PURE__ */ jsxs19("div", { className: "matchid-cex-modal", children: [
2586
+ /* @__PURE__ */ jsxs19("div", { children: [
2414
2587
  /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindAttention" }) }),
2415
2588
  /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips1" }) }),
2416
2589
  /* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips2" }) }),
@@ -2461,15 +2634,15 @@ function CEXBindModal({
2461
2634
  }
2462
2635
 
2463
2636
  // src/context/BusinessProvider.tsx
2464
- import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
2637
+ import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
2465
2638
  function BusinessProvider({ children }) {
2466
2639
  const { overview, token } = useUserInfo();
2467
2640
  const { recoveryModal } = useStore_default();
2468
2641
  const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
2469
- const { type: TronType, isOpen: TronIsOpen, close: TronClose } = useTronModalStore();
2642
+ const { type: TRONType, isOpen: TRONIsOpen, close: TRONClose } = useTRONModalStore();
2470
2643
  const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
2471
2644
  const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
2472
- return /* @__PURE__ */ jsxs19(Fragment4, { children: [
2645
+ return /* @__PURE__ */ jsxs20(Fragment4, { children: [
2473
2646
  /* @__PURE__ */ jsx24(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
2474
2647
  /* @__PURE__ */ jsx24(
2475
2648
  RecoveryModal,
@@ -2490,12 +2663,12 @@ function BusinessProvider({ children }) {
2490
2663
  }
2491
2664
  ),
2492
2665
  /* @__PURE__ */ jsx24(
2493
- TronModal,
2666
+ TRONModal,
2494
2667
  {
2495
- isOpen: TronIsOpen && (TronType == "login" && !overview && !token || TronType == "bind" && !!token && !!overview),
2496
- onClose: TronClose,
2497
- type: TronType,
2498
- onSuccess: TronClose,
2668
+ isOpen: TRONIsOpen && (TRONType == "login" && !overview && !token || TRONType == "bind" && !!token && !!overview),
2669
+ onClose: TRONClose,
2670
+ type: TRONType,
2671
+ onSuccess: TRONClose,
2499
2672
  zIndex: 199
2500
2673
  }
2501
2674
  ),
@@ -2533,7 +2706,7 @@ var Providers = ({ children }) => {
2533
2706
  var context_default = Providers;
2534
2707
 
2535
2708
  // src/hooks/useWalletInit.ts
2536
- import { useEffect as useEffect13, useState as useState18 } from "react";
2709
+ import { useEffect as useEffect14, useState as useState19 } from "react";
2537
2710
 
2538
2711
  // src/hooks/useWallet.tsx
2539
2712
  import { toAccount } from "viem/accounts";
@@ -2673,10 +2846,10 @@ function useWalletInit({
2673
2846
  const getWalletIframe = () => {
2674
2847
  return document.getElementById("match-wallet");
2675
2848
  };
2676
- const [walletInited, setWalletInited] = useState18(false);
2849
+ const [walletInited, setWalletInited] = useState19(false);
2677
2850
  const { appid, token, overview } = useLocalStore_default();
2678
2851
  const { initWallet, generateWallet } = useWallet();
2679
- useEffect13(() => {
2852
+ useEffect14(() => {
2680
2853
  if (endpoints.auth) {
2681
2854
  if (!window.matchWalletMessageIdMap) {
2682
2855
  window.matchWalletMessageIdMap = {};
@@ -2737,7 +2910,7 @@ function useWalletInit({
2737
2910
  }
2738
2911
  }
2739
2912
  }, [endpoints.auth]);
2740
- useEffect13(() => {
2913
+ useEffect14(() => {
2741
2914
  const messageHandle = async (e) => {
2742
2915
  if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
2743
2916
  return;
@@ -2770,7 +2943,7 @@ function useWalletInit({
2770
2943
  window.removeEventListener("message", messageHandle);
2771
2944
  };
2772
2945
  }, []);
2773
- useEffect13(() => {
2946
+ useEffect14(() => {
2774
2947
  if (token && overview && overview.did && walletInited) {
2775
2948
  const did = overview.did.split(":")[2];
2776
2949
  const newUserInit = async () => {
@@ -2801,7 +2974,7 @@ function useWalletInit({
2801
2974
  }
2802
2975
 
2803
2976
  // src/hooks/useInit.tsx
2804
- import { useEffect as useEffect14, useRef as useRef2 } from "react";
2977
+ import { useEffect as useEffect15, useRef as useRef2 } from "react";
2805
2978
  function useInit({
2806
2979
  theme,
2807
2980
  appid,
@@ -2824,19 +2997,19 @@ function useInit({
2824
2997
  const searchParams = new URLSearchParams(window.location.search);
2825
2998
  const matchToken = searchParams.get("matchToken");
2826
2999
  const realEndpoints = endpoints || env_default.endpoints;
2827
- useEffect14(() => {
3000
+ useEffect15(() => {
2828
3001
  setTheme(theme);
2829
3002
  }, [theme]);
2830
- useEffect14(() => {
3003
+ useEffect15(() => {
2831
3004
  setAppid(appid);
2832
3005
  }, [appid]);
2833
- useEffect14(() => {
3006
+ useEffect15(() => {
2834
3007
  setEndpoints(realEndpoints);
2835
3008
  }, [realEndpoints]);
2836
- useEffect14(() => {
3009
+ useEffect15(() => {
2837
3010
  setLocale(locale || "en");
2838
3011
  }, [locale]);
2839
- useEffect14(() => {
3012
+ useEffect15(() => {
2840
3013
  if (matchToken) {
2841
3014
  const tokenData = JSON.parse(atob(matchToken));
2842
3015
  if (tokenData && tokenData.mid && tokenData.token) {
@@ -2847,7 +3020,7 @@ function useInit({
2847
3020
  }
2848
3021
  }
2849
3022
  }, [matchToken]);
2850
- useEffect14(() => {
3023
+ useEffect15(() => {
2851
3024
  const onLoginMessage = (event) => {
2852
3025
  const res = event.data;
2853
3026
  if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
@@ -2883,7 +3056,7 @@ function useInit({
2883
3056
  overviewLoadingRef.current = false;
2884
3057
  }
2885
3058
  };
2886
- useEffect14(() => {
3059
+ useEffect15(() => {
2887
3060
  if (token) {
2888
3061
  loadOverview();
2889
3062
  }
@@ -3440,10 +3613,10 @@ function useUserInfo() {
3440
3613
  } = useLocalStore_default();
3441
3614
  const { events, login } = useMatch();
3442
3615
  const { open: SOLOpen } = useSOLModalStore();
3443
- const { open: TronOpen } = useTronModalStore();
3616
+ const { open: TRONOpen } = useTRONModalStore();
3444
3617
  const { open: BTCOpen } = useBTCModalStore();
3445
3618
  const { open: CEXBindOpen } = useCEXBindModalStore();
3446
- const isLogin = useMemo8(() => !!token, [token]);
3619
+ const isLogin = useMemo9(() => !!token, [token]);
3447
3620
  const logout = async () => {
3448
3621
  try {
3449
3622
  await toLogoutApi();
@@ -3488,7 +3661,7 @@ function useUserInfo() {
3488
3661
  case "sol":
3489
3662
  return SOLOpen("login");
3490
3663
  case "tron":
3491
- return TronOpen("login");
3664
+ return TRONOpen("login");
3492
3665
  case "btc":
3493
3666
  return BTCOpen("login");
3494
3667
  case "telegram":
@@ -3579,7 +3752,7 @@ function useUserInfo() {
3579
3752
  case "sol":
3580
3753
  return SOLOpen("bind");
3581
3754
  case "tron":
3582
- return TronOpen("bind");
3755
+ return TRONOpen("bind");
3583
3756
  case "btc":
3584
3757
  return BTCOpen("bind");
3585
3758
  case "telegram":
@@ -3632,9 +3805,9 @@ function useUserInfo() {
3632
3805
  }
3633
3806
 
3634
3807
  // src/hooks/useMatchEvents.ts
3635
- import { useEffect as useEffect15 } from "react";
3808
+ import { useEffect as useEffect16 } from "react";
3636
3809
  function useMatchEvents(handlers) {
3637
- useEffect15(() => {
3810
+ useEffect16(() => {
3638
3811
  Object.entries(handlers).forEach(([event, handler2]) => {
3639
3812
  if (handler2) {
3640
3813
  eventManager_default.on(event, handler2);
@@ -3652,14 +3825,14 @@ function useMatchEvents(handlers) {
3652
3825
 
3653
3826
  // src/hooks/useCopyClipboard.ts
3654
3827
  import copy from "copy-to-clipboard";
3655
- import { useCallback, useEffect as useEffect16, useState as useState19 } from "react";
3828
+ import { useCallback, useEffect as useEffect17, useState as useState20 } from "react";
3656
3829
  function useCopyClipboard(timeout = 500) {
3657
- const [isCopied, setIsCopied] = useState19(false);
3830
+ const [isCopied, setIsCopied] = useState20(false);
3658
3831
  const staticCopy = useCallback((text) => {
3659
3832
  const didCopy = copy(text);
3660
3833
  setIsCopied(didCopy);
3661
3834
  }, []);
3662
- useEffect16(() => {
3835
+ useEffect17(() => {
3663
3836
  if (isCopied) {
3664
3837
  const hide = setTimeout(() => {
3665
3838
  setIsCopied(false);
@@ -3703,10 +3876,10 @@ export {
3703
3876
  LoginButton,
3704
3877
  UsernameModal,
3705
3878
  SOLModal,
3706
- TronModal,
3879
+ TRONModal,
3707
3880
  BTCModal,
3708
3881
  components_exports,
3709
3882
  MatchProvider,
3710
3883
  useMatch
3711
3884
  };
3712
- //# sourceMappingURL=chunk-FLEEMUIJ.mjs.map
3885
+ //# sourceMappingURL=chunk-65NEGWW3.mjs.map