@matchain/matchid-sdk-react 0.1.37-alpha.7 → 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.
- package/dist/assets/icon/index.d.mts +5 -1
- package/dist/assets/icon/index.d.ts +5 -1
- package/dist/assets/icon/index.js +59 -0
- package/dist/assets/icon/index.js.map +1 -1
- package/dist/assets/icon/index.mjs +5 -1
- package/dist/{chunk-23RO4KEG.mjs → chunk-65NEGWW3.mjs} +304 -139
- package/dist/chunk-65NEGWW3.mjs.map +1 -0
- package/dist/{chunk-2Z3EM7MH.mjs → chunk-6PWH7WZI.mjs} +59 -2
- package/dist/chunk-6PWH7WZI.mjs.map +1 -0
- package/dist/{chunk-IP3AXUIZ.mjs → chunk-X3VJMKNQ.mjs} +2 -2
- package/dist/components/index.d.mts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +601 -287
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/hooks/api/index.js +53 -42
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +3 -3
- package/dist/hooks/index.js +59 -48
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-dJi5ka2c.d.mts → index-CV5LZa9w.d.mts} +4 -4
- package/dist/{index-DTCAzQvB.d.ts → index-yEwP0nd2.d.ts} +4 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +663 -349
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/example/src/components/Login/index.tsx +1 -1
- package/example/src/pages/User.tsx +1 -1
- package/package.json +1 -1
- package/dist/chunk-23RO4KEG.mjs.map +0 -1
- package/dist/chunk-2Z3EM7MH.mjs.map +0 -1
- /package/dist/{chunk-IP3AXUIZ.mjs.map → chunk-X3VJMKNQ.mjs.map} +0 -0
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ArrowRightIcon,
|
|
5
5
|
BTCDarkIcon,
|
|
6
6
|
BTCLightIcon,
|
|
7
|
+
BitgetIcon,
|
|
7
8
|
CheckIcon,
|
|
8
9
|
CheckRoundIcon,
|
|
9
10
|
CloseEyeIcon,
|
|
@@ -22,18 +23,22 @@ import {
|
|
|
22
23
|
LinkedinIcon,
|
|
23
24
|
LoadingIcon_default,
|
|
24
25
|
LoginIcon_default,
|
|
26
|
+
OKXIcon,
|
|
25
27
|
OpenEyeIcon,
|
|
26
28
|
PasswordRoundIcon,
|
|
27
29
|
SOLDarkIcon,
|
|
28
30
|
SOLLightIcon,
|
|
31
|
+
TRXDarkIcon,
|
|
32
|
+
TRXLightIcon,
|
|
29
33
|
TelegramIcon,
|
|
34
|
+
TronLinkIcon,
|
|
30
35
|
UnLoginIcon_default,
|
|
31
36
|
UnisatIcon,
|
|
32
37
|
WalletIcon,
|
|
33
38
|
XIcon,
|
|
34
39
|
XverseIcon,
|
|
35
40
|
YoutubeIcon
|
|
36
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-6PWH7WZI.mjs";
|
|
37
42
|
import {
|
|
38
43
|
__export
|
|
39
44
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -88,7 +93,7 @@ var localStore = useLocalStore;
|
|
|
88
93
|
var useLocalStore_default = useLocalStore;
|
|
89
94
|
|
|
90
95
|
// src/hooks/useUserInfo.tsx
|
|
91
|
-
import { useMemo as
|
|
96
|
+
import { useMemo as useMemo9 } from "react";
|
|
92
97
|
|
|
93
98
|
// src/api/request.ts
|
|
94
99
|
import axios from "axios";
|
|
@@ -741,7 +746,7 @@ var useSOLModalStore = create3((set) => ({
|
|
|
741
746
|
open: (type) => set({ isOpen: true, type }),
|
|
742
747
|
close: () => set({ isOpen: false })
|
|
743
748
|
}));
|
|
744
|
-
var
|
|
749
|
+
var useTRONModalStore = create3((set) => ({
|
|
745
750
|
isOpen: false,
|
|
746
751
|
type: "",
|
|
747
752
|
open: (type) => set({ isOpen: true, type }),
|
|
@@ -777,7 +782,7 @@ __export(components_exports, {
|
|
|
777
782
|
PasswordModal: () => PasswordModal,
|
|
778
783
|
Popover: () => Popover,
|
|
779
784
|
SOLModal: () => SOLModal,
|
|
780
|
-
|
|
785
|
+
TRONModal: () => TRONModal,
|
|
781
786
|
UsernameModal: () => UsernameModal
|
|
782
787
|
});
|
|
783
788
|
|
|
@@ -1179,6 +1184,12 @@ function LoginBox({
|
|
|
1179
1184
|
activeIcon: /* @__PURE__ */ jsx11(BTCLightIcon, { size: isDownMd ? 36 : 40 }),
|
|
1180
1185
|
name: "BTC",
|
|
1181
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")
|
|
1182
1193
|
}
|
|
1183
1194
|
};
|
|
1184
1195
|
return /* @__PURE__ */ jsxs9(Fragment2, { children: [
|
|
@@ -1895,61 +1906,157 @@ function SOLModal({
|
|
|
1895
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 }) }) }) }) });
|
|
1896
1907
|
}
|
|
1897
1908
|
|
|
1898
|
-
// src/components/
|
|
1899
|
-
import React4, { useEffect as
|
|
1909
|
+
// src/components/TRONModal/index.tsx
|
|
1910
|
+
import React4, { useEffect as useEffect10, useMemo as useMemo7, useState as useState15 } from "react";
|
|
1900
1911
|
import { useIntl as useIntl11 } from "react-intl";
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
} else {
|
|
1922
|
-
setWalletAddress("");
|
|
1923
|
-
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
|
+
);
|
|
1924
1932
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
if (typeof window.tronWeb !== "undefined") {
|
|
1928
|
-
checkConnection();
|
|
1929
|
-
const interval = setInterval(() => {
|
|
1930
|
-
checkConnection();
|
|
1931
|
-
}, 1e3);
|
|
1932
|
-
return () => clearInterval(interval);
|
|
1933
|
-
} else {
|
|
1933
|
+
if (!window.tronWeb.defaultAddress.base58) {
|
|
1934
|
+
throw new Error("Your should unlink your wallet and try again");
|
|
1934
1935
|
}
|
|
1935
|
-
|
|
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);
|
|
1936
1991
|
useEffect9(() => {
|
|
1937
|
-
const
|
|
1938
|
-
|
|
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));
|
|
1939
1998
|
};
|
|
1940
|
-
|
|
1999
|
+
getInstalled();
|
|
1941
2000
|
}, []);
|
|
2001
|
+
const [wallet, chooseWallet] = useState14(null);
|
|
2002
|
+
const onConnect = async () => {
|
|
2003
|
+
setAddress(await wallet.connect());
|
|
2004
|
+
};
|
|
1942
2005
|
useEffect9(() => {
|
|
1943
|
-
if (
|
|
1944
|
-
|
|
2006
|
+
if (!wallet) {
|
|
2007
|
+
setAddress(null);
|
|
1945
2008
|
}
|
|
1946
|
-
}, [
|
|
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
|
+
};
|
|
1947
2054
|
const toLoginInWallet = async () => {
|
|
1948
|
-
if (statusRef.current) return;
|
|
2055
|
+
if (statusRef.current || !address || !wallet) return;
|
|
1949
2056
|
try {
|
|
1950
2057
|
setStatus("nonce");
|
|
1951
2058
|
statusRef.current = "nonce";
|
|
1952
|
-
const res = type == "bind" ? await getWalletInitApi({ address
|
|
2059
|
+
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
1953
2060
|
if (!isSuccess(res)) {
|
|
1954
2061
|
throw new Error(res.message);
|
|
1955
2062
|
}
|
|
@@ -1958,15 +2065,14 @@ function WalletContent2({
|
|
|
1958
2065
|
setStatus("signer");
|
|
1959
2066
|
statusRef.current = "signer";
|
|
1960
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;
|
|
1961
|
-
const
|
|
1962
|
-
const signedMessage = await window.tronWeb.trx.signMessageV2(encodedMessage);
|
|
2068
|
+
const signedMessage = await wallet.signMessage(message);
|
|
1963
2069
|
let obj = {
|
|
1964
|
-
type: "
|
|
1965
|
-
address
|
|
1966
|
-
signature:
|
|
2070
|
+
type: "TRON",
|
|
2071
|
+
address,
|
|
2072
|
+
signature: signedMessage,
|
|
1967
2073
|
message,
|
|
1968
|
-
connector_type: "
|
|
1969
|
-
wallet_client_type:
|
|
2074
|
+
connector_type: "TRON",
|
|
2075
|
+
wallet_client_type: wallet.walletKey
|
|
1970
2076
|
};
|
|
1971
2077
|
const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
1972
2078
|
if (res1) {
|
|
@@ -1998,37 +2104,75 @@ function WalletContent2({
|
|
|
1998
2104
|
statusRef.current = "";
|
|
1999
2105
|
}
|
|
2000
2106
|
};
|
|
2001
|
-
|
|
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(
|
|
2002
2130
|
WalletModalContent,
|
|
2003
2131
|
{
|
|
2004
|
-
connected,
|
|
2005
|
-
disconnect,
|
|
2006
|
-
address: walletAddress,
|
|
2007
|
-
visible,
|
|
2008
|
-
setVisible,
|
|
2009
2132
|
error,
|
|
2010
2133
|
setError,
|
|
2011
|
-
status
|
|
2134
|
+
status,
|
|
2135
|
+
disconnect,
|
|
2136
|
+
address: address || "",
|
|
2137
|
+
connected,
|
|
2138
|
+
visible: true,
|
|
2139
|
+
setVisible: () => {
|
|
2140
|
+
}
|
|
2012
2141
|
}
|
|
2013
|
-
)
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
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
|
+
] }) }) });
|
|
2028
2172
|
}
|
|
2029
2173
|
|
|
2030
2174
|
// src/components/BTCModal/index.tsx
|
|
2031
|
-
import React5, { useEffect as
|
|
2175
|
+
import React5, { useEffect as useEffect12, useMemo as useMemo8, useState as useState17 } from "react";
|
|
2032
2176
|
import { useIntl as useIntl12 } from "react-intl";
|
|
2033
2177
|
|
|
2034
2178
|
// src/lib/btc/UnisatAdapter.ts
|
|
@@ -2065,6 +2209,10 @@ var UnisatAdapter = class {
|
|
|
2065
2209
|
if (!await this.isInstalled()) throw new Error("Unisat Wallet is not installed");
|
|
2066
2210
|
return window.unisat.signMessage(message, "bip322-simple");
|
|
2067
2211
|
}
|
|
2212
|
+
async disconnet() {
|
|
2213
|
+
if (!await this.isInstalled()) throw new Error("Unisat Wallet is not installed");
|
|
2214
|
+
return window.unisat.disconnect();
|
|
2215
|
+
}
|
|
2068
2216
|
};
|
|
2069
2217
|
|
|
2070
2218
|
// src/lib/btc/XverseAdapter.ts
|
|
@@ -2148,6 +2296,10 @@ var XverseAdapter = class {
|
|
|
2148
2296
|
});
|
|
2149
2297
|
});
|
|
2150
2298
|
}
|
|
2299
|
+
async disconnet() {
|
|
2300
|
+
if (!await this.isInstalled()) throw new Error("Xverse Wallet is not installed");
|
|
2301
|
+
await request2("wallet_disconnect", null);
|
|
2302
|
+
}
|
|
2151
2303
|
};
|
|
2152
2304
|
|
|
2153
2305
|
// src/lib/btc/LeatherAdapter.ts
|
|
@@ -2175,12 +2327,12 @@ var LeatherAdapter = class {
|
|
|
2175
2327
|
};
|
|
2176
2328
|
|
|
2177
2329
|
// src/hooks/useBTCWallet.ts
|
|
2178
|
-
import { useEffect as
|
|
2330
|
+
import { useEffect as useEffect11, useState as useState16 } from "react";
|
|
2179
2331
|
var useBTCWallet = () => {
|
|
2180
2332
|
const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
|
|
2181
|
-
const [installedWallets, setInstalledWallets] =
|
|
2182
|
-
const [address, setAddress] =
|
|
2183
|
-
|
|
2333
|
+
const [installedWallets, setInstalledWallets] = useState16([]);
|
|
2334
|
+
const [address, setAddress] = useState16(null);
|
|
2335
|
+
useEffect11(() => {
|
|
2184
2336
|
const getInstalled = async () => {
|
|
2185
2337
|
const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
|
|
2186
2338
|
wallet: wallet2,
|
|
@@ -2190,11 +2342,11 @@ var useBTCWallet = () => {
|
|
|
2190
2342
|
};
|
|
2191
2343
|
getInstalled();
|
|
2192
2344
|
}, []);
|
|
2193
|
-
const [wallet, chooseWallet] =
|
|
2345
|
+
const [wallet, chooseWallet] = useState16(null);
|
|
2194
2346
|
const onConnect = async () => {
|
|
2195
2347
|
setAddress(await wallet.connect());
|
|
2196
2348
|
};
|
|
2197
|
-
|
|
2349
|
+
useEffect11(() => {
|
|
2198
2350
|
if (!wallet) {
|
|
2199
2351
|
setAddress(null);
|
|
2200
2352
|
}
|
|
@@ -2210,7 +2362,7 @@ var useBTCWallet = () => {
|
|
|
2210
2362
|
};
|
|
2211
2363
|
|
|
2212
2364
|
// src/components/BTCModal/index.tsx
|
|
2213
|
-
import { jsx as jsx22, jsxs as
|
|
2365
|
+
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2214
2366
|
function BTCModal({
|
|
2215
2367
|
type = "login",
|
|
2216
2368
|
onSuccess,
|
|
@@ -2225,15 +2377,18 @@ function BTCModal({
|
|
|
2225
2377
|
xverse: /* @__PURE__ */ jsx22(XverseIcon, { size: isDownMd ? 36 : 40 })
|
|
2226
2378
|
};
|
|
2227
2379
|
const { events, login } = useMatch();
|
|
2228
|
-
const [status, setStatus] =
|
|
2380
|
+
const [status, setStatus] = useState17("");
|
|
2229
2381
|
const statusRef = React5.useRef(status);
|
|
2230
|
-
const [error, setError] =
|
|
2231
|
-
const connected =
|
|
2382
|
+
const [error, setError] = useState17("");
|
|
2383
|
+
const connected = useMemo8(() => {
|
|
2232
2384
|
return !!address;
|
|
2233
2385
|
}, [address]);
|
|
2234
2386
|
const disconnect = async () => {
|
|
2387
|
+
wallet.disconnet();
|
|
2235
2388
|
setStatus("");
|
|
2236
2389
|
chooseWallet(null);
|
|
2390
|
+
statusRef.current = "";
|
|
2391
|
+
setError("");
|
|
2237
2392
|
};
|
|
2238
2393
|
const toLoginInWallet = async () => {
|
|
2239
2394
|
if (statusRef.current || !address || !wallet) return;
|
|
@@ -2256,7 +2411,7 @@ function BTCModal({
|
|
|
2256
2411
|
signature: signedMessage,
|
|
2257
2412
|
message,
|
|
2258
2413
|
connector_type: "BTC",
|
|
2259
|
-
wallet_client_type: wallet.
|
|
2414
|
+
wallet_client_type: wallet.walletKey
|
|
2260
2415
|
};
|
|
2261
2416
|
const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
2262
2417
|
if (res1) {
|
|
@@ -2283,37 +2438,47 @@ function BTCModal({
|
|
|
2283
2438
|
}
|
|
2284
2439
|
}
|
|
2285
2440
|
} catch (error2) {
|
|
2441
|
+
console.error("btc error", error2);
|
|
2286
2442
|
setStatus("error");
|
|
2287
2443
|
setError(error2.message);
|
|
2288
2444
|
statusRef.current = "";
|
|
2289
2445
|
}
|
|
2290
2446
|
};
|
|
2291
|
-
|
|
2447
|
+
useEffect12(() => {
|
|
2292
2448
|
if (wallet) {
|
|
2293
2449
|
console.log("onConnect");
|
|
2294
|
-
|
|
2450
|
+
try {
|
|
2451
|
+
onConnect();
|
|
2452
|
+
} catch (err) {
|
|
2453
|
+
setStatus("error");
|
|
2454
|
+
setError(err.message);
|
|
2455
|
+
}
|
|
2295
2456
|
} else {
|
|
2296
2457
|
setStatus("");
|
|
2297
2458
|
}
|
|
2298
2459
|
}, [wallet]);
|
|
2299
|
-
|
|
2460
|
+
useEffect12(() => {
|
|
2300
2461
|
if (address) {
|
|
2301
2462
|
toLoginInWallet();
|
|
2302
2463
|
}
|
|
2303
2464
|
}, [address]);
|
|
2304
|
-
|
|
2465
|
+
useEffect12(() => {
|
|
2305
2466
|
if (!props.isOpen) {
|
|
2306
|
-
setStatus("");
|
|
2307
2467
|
disconnect();
|
|
2308
2468
|
}
|
|
2309
2469
|
}, [props.isOpen]);
|
|
2470
|
+
const onBack = () => {
|
|
2471
|
+
wallet.disconnet();
|
|
2472
|
+
setStatus("");
|
|
2473
|
+
chooseWallet(null);
|
|
2474
|
+
statusRef.current = "";
|
|
2475
|
+
setError("");
|
|
2476
|
+
};
|
|
2310
2477
|
return /* @__PURE__ */ jsx22(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
2311
2478
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
2312
2479
|
}, {
|
|
2313
2480
|
name: "BTC"
|
|
2314
|
-
}), onBack: wallet ?
|
|
2315
|
-
chooseWallet(null);
|
|
2316
|
-
} : void 0, children: wallet ? /* @__PURE__ */ jsx22(
|
|
2481
|
+
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ jsx22(
|
|
2317
2482
|
WalletModalContent,
|
|
2318
2483
|
{
|
|
2319
2484
|
error,
|
|
@@ -2326,7 +2491,7 @@ function BTCModal({
|
|
|
2326
2491
|
setVisible: () => {
|
|
2327
2492
|
}
|
|
2328
2493
|
}
|
|
2329
|
-
) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */
|
|
2494
|
+
) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs18("div", { className: "matchid-login-recommend-list", children: [
|
|
2330
2495
|
installedWallets.map((wallet2) => {
|
|
2331
2496
|
return /* @__PURE__ */ jsx22(
|
|
2332
2497
|
RecommendItem,
|
|
@@ -2359,9 +2524,9 @@ function BTCModal({
|
|
|
2359
2524
|
}
|
|
2360
2525
|
|
|
2361
2526
|
// src/components/CEXBindModal/index.tsx
|
|
2362
|
-
import { useEffect as
|
|
2527
|
+
import { useEffect as useEffect13, useState as useState18 } from "react";
|
|
2363
2528
|
import { FormattedMessage as FormattedMessage10, useIntl as useIntl13 } from "react-intl";
|
|
2364
|
-
import { jsx as jsx23, jsxs as
|
|
2529
|
+
import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2365
2530
|
function CEXBindModal({
|
|
2366
2531
|
onClose,
|
|
2367
2532
|
type,
|
|
@@ -2370,13 +2535,13 @@ function CEXBindModal({
|
|
|
2370
2535
|
}) {
|
|
2371
2536
|
const intl = useIntl13();
|
|
2372
2537
|
const { events } = useMatch();
|
|
2373
|
-
const [APIPassphrase, setAPIPassphrase] =
|
|
2538
|
+
const [APIPassphrase, setAPIPassphrase] = useState18("");
|
|
2374
2539
|
const { refreshOverview } = useUserInfo();
|
|
2375
|
-
const [loading, setLoading] =
|
|
2376
|
-
const [key, setKey] =
|
|
2377
|
-
const [secret, setSecret] =
|
|
2378
|
-
const [error, setError] =
|
|
2379
|
-
|
|
2540
|
+
const [loading, setLoading] = useState18(false);
|
|
2541
|
+
const [key, setKey] = useState18("");
|
|
2542
|
+
const [secret, setSecret] = useState18("");
|
|
2543
|
+
const [error, setError] = useState18("");
|
|
2544
|
+
useEffect13(() => {
|
|
2380
2545
|
if (isOpen) {
|
|
2381
2546
|
setSecret("");
|
|
2382
2547
|
setKey("");
|
|
@@ -2417,8 +2582,8 @@ function CEXBindModal({
|
|
|
2417
2582
|
id: "CEXBindTitle"
|
|
2418
2583
|
}, {
|
|
2419
2584
|
type
|
|
2420
|
-
}), ...props, children: /* @__PURE__ */
|
|
2421
|
-
/* @__PURE__ */
|
|
2585
|
+
}), ...props, children: /* @__PURE__ */ jsxs19("div", { className: "matchid-cex-modal", children: [
|
|
2586
|
+
/* @__PURE__ */ jsxs19("div", { children: [
|
|
2422
2587
|
/* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindAttention" }) }),
|
|
2423
2588
|
/* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips1" }) }),
|
|
2424
2589
|
/* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips2" }) }),
|
|
@@ -2469,15 +2634,15 @@ function CEXBindModal({
|
|
|
2469
2634
|
}
|
|
2470
2635
|
|
|
2471
2636
|
// src/context/BusinessProvider.tsx
|
|
2472
|
-
import { Fragment as Fragment4, jsx as jsx24, jsxs as
|
|
2637
|
+
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2473
2638
|
function BusinessProvider({ children }) {
|
|
2474
2639
|
const { overview, token } = useUserInfo();
|
|
2475
2640
|
const { recoveryModal } = useStore_default();
|
|
2476
2641
|
const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
|
|
2477
|
-
const { type:
|
|
2642
|
+
const { type: TRONType, isOpen: TRONIsOpen, close: TRONClose } = useTRONModalStore();
|
|
2478
2643
|
const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
|
|
2479
2644
|
const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
|
|
2480
|
-
return /* @__PURE__ */
|
|
2645
|
+
return /* @__PURE__ */ jsxs20(Fragment4, { children: [
|
|
2481
2646
|
/* @__PURE__ */ jsx24(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
|
|
2482
2647
|
/* @__PURE__ */ jsx24(
|
|
2483
2648
|
RecoveryModal,
|
|
@@ -2498,12 +2663,12 @@ function BusinessProvider({ children }) {
|
|
|
2498
2663
|
}
|
|
2499
2664
|
),
|
|
2500
2665
|
/* @__PURE__ */ jsx24(
|
|
2501
|
-
|
|
2666
|
+
TRONModal,
|
|
2502
2667
|
{
|
|
2503
|
-
isOpen:
|
|
2504
|
-
onClose:
|
|
2505
|
-
type:
|
|
2506
|
-
onSuccess:
|
|
2668
|
+
isOpen: TRONIsOpen && (TRONType == "login" && !overview && !token || TRONType == "bind" && !!token && !!overview),
|
|
2669
|
+
onClose: TRONClose,
|
|
2670
|
+
type: TRONType,
|
|
2671
|
+
onSuccess: TRONClose,
|
|
2507
2672
|
zIndex: 199
|
|
2508
2673
|
}
|
|
2509
2674
|
),
|
|
@@ -2541,7 +2706,7 @@ var Providers = ({ children }) => {
|
|
|
2541
2706
|
var context_default = Providers;
|
|
2542
2707
|
|
|
2543
2708
|
// src/hooks/useWalletInit.ts
|
|
2544
|
-
import { useEffect as
|
|
2709
|
+
import { useEffect as useEffect14, useState as useState19 } from "react";
|
|
2545
2710
|
|
|
2546
2711
|
// src/hooks/useWallet.tsx
|
|
2547
2712
|
import { toAccount } from "viem/accounts";
|
|
@@ -2681,10 +2846,10 @@ function useWalletInit({
|
|
|
2681
2846
|
const getWalletIframe = () => {
|
|
2682
2847
|
return document.getElementById("match-wallet");
|
|
2683
2848
|
};
|
|
2684
|
-
const [walletInited, setWalletInited] =
|
|
2849
|
+
const [walletInited, setWalletInited] = useState19(false);
|
|
2685
2850
|
const { appid, token, overview } = useLocalStore_default();
|
|
2686
2851
|
const { initWallet, generateWallet } = useWallet();
|
|
2687
|
-
|
|
2852
|
+
useEffect14(() => {
|
|
2688
2853
|
if (endpoints.auth) {
|
|
2689
2854
|
if (!window.matchWalletMessageIdMap) {
|
|
2690
2855
|
window.matchWalletMessageIdMap = {};
|
|
@@ -2745,7 +2910,7 @@ function useWalletInit({
|
|
|
2745
2910
|
}
|
|
2746
2911
|
}
|
|
2747
2912
|
}, [endpoints.auth]);
|
|
2748
|
-
|
|
2913
|
+
useEffect14(() => {
|
|
2749
2914
|
const messageHandle = async (e) => {
|
|
2750
2915
|
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
2751
2916
|
return;
|
|
@@ -2778,7 +2943,7 @@ function useWalletInit({
|
|
|
2778
2943
|
window.removeEventListener("message", messageHandle);
|
|
2779
2944
|
};
|
|
2780
2945
|
}, []);
|
|
2781
|
-
|
|
2946
|
+
useEffect14(() => {
|
|
2782
2947
|
if (token && overview && overview.did && walletInited) {
|
|
2783
2948
|
const did = overview.did.split(":")[2];
|
|
2784
2949
|
const newUserInit = async () => {
|
|
@@ -2809,7 +2974,7 @@ function useWalletInit({
|
|
|
2809
2974
|
}
|
|
2810
2975
|
|
|
2811
2976
|
// src/hooks/useInit.tsx
|
|
2812
|
-
import { useEffect as
|
|
2977
|
+
import { useEffect as useEffect15, useRef as useRef2 } from "react";
|
|
2813
2978
|
function useInit({
|
|
2814
2979
|
theme,
|
|
2815
2980
|
appid,
|
|
@@ -2832,19 +2997,19 @@ function useInit({
|
|
|
2832
2997
|
const searchParams = new URLSearchParams(window.location.search);
|
|
2833
2998
|
const matchToken = searchParams.get("matchToken");
|
|
2834
2999
|
const realEndpoints = endpoints || env_default.endpoints;
|
|
2835
|
-
|
|
3000
|
+
useEffect15(() => {
|
|
2836
3001
|
setTheme(theme);
|
|
2837
3002
|
}, [theme]);
|
|
2838
|
-
|
|
3003
|
+
useEffect15(() => {
|
|
2839
3004
|
setAppid(appid);
|
|
2840
3005
|
}, [appid]);
|
|
2841
|
-
|
|
3006
|
+
useEffect15(() => {
|
|
2842
3007
|
setEndpoints(realEndpoints);
|
|
2843
3008
|
}, [realEndpoints]);
|
|
2844
|
-
|
|
3009
|
+
useEffect15(() => {
|
|
2845
3010
|
setLocale(locale || "en");
|
|
2846
3011
|
}, [locale]);
|
|
2847
|
-
|
|
3012
|
+
useEffect15(() => {
|
|
2848
3013
|
if (matchToken) {
|
|
2849
3014
|
const tokenData = JSON.parse(atob(matchToken));
|
|
2850
3015
|
if (tokenData && tokenData.mid && tokenData.token) {
|
|
@@ -2855,7 +3020,7 @@ function useInit({
|
|
|
2855
3020
|
}
|
|
2856
3021
|
}
|
|
2857
3022
|
}, [matchToken]);
|
|
2858
|
-
|
|
3023
|
+
useEffect15(() => {
|
|
2859
3024
|
const onLoginMessage = (event) => {
|
|
2860
3025
|
const res = event.data;
|
|
2861
3026
|
if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
|
|
@@ -2891,7 +3056,7 @@ function useInit({
|
|
|
2891
3056
|
overviewLoadingRef.current = false;
|
|
2892
3057
|
}
|
|
2893
3058
|
};
|
|
2894
|
-
|
|
3059
|
+
useEffect15(() => {
|
|
2895
3060
|
if (token) {
|
|
2896
3061
|
loadOverview();
|
|
2897
3062
|
}
|
|
@@ -3448,10 +3613,10 @@ function useUserInfo() {
|
|
|
3448
3613
|
} = useLocalStore_default();
|
|
3449
3614
|
const { events, login } = useMatch();
|
|
3450
3615
|
const { open: SOLOpen } = useSOLModalStore();
|
|
3451
|
-
const { open:
|
|
3616
|
+
const { open: TRONOpen } = useTRONModalStore();
|
|
3452
3617
|
const { open: BTCOpen } = useBTCModalStore();
|
|
3453
3618
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
3454
|
-
const isLogin =
|
|
3619
|
+
const isLogin = useMemo9(() => !!token, [token]);
|
|
3455
3620
|
const logout = async () => {
|
|
3456
3621
|
try {
|
|
3457
3622
|
await toLogoutApi();
|
|
@@ -3496,7 +3661,7 @@ function useUserInfo() {
|
|
|
3496
3661
|
case "sol":
|
|
3497
3662
|
return SOLOpen("login");
|
|
3498
3663
|
case "tron":
|
|
3499
|
-
return
|
|
3664
|
+
return TRONOpen("login");
|
|
3500
3665
|
case "btc":
|
|
3501
3666
|
return BTCOpen("login");
|
|
3502
3667
|
case "telegram":
|
|
@@ -3587,7 +3752,7 @@ function useUserInfo() {
|
|
|
3587
3752
|
case "sol":
|
|
3588
3753
|
return SOLOpen("bind");
|
|
3589
3754
|
case "tron":
|
|
3590
|
-
return
|
|
3755
|
+
return TRONOpen("bind");
|
|
3591
3756
|
case "btc":
|
|
3592
3757
|
return BTCOpen("bind");
|
|
3593
3758
|
case "telegram":
|
|
@@ -3640,9 +3805,9 @@ function useUserInfo() {
|
|
|
3640
3805
|
}
|
|
3641
3806
|
|
|
3642
3807
|
// src/hooks/useMatchEvents.ts
|
|
3643
|
-
import { useEffect as
|
|
3808
|
+
import { useEffect as useEffect16 } from "react";
|
|
3644
3809
|
function useMatchEvents(handlers) {
|
|
3645
|
-
|
|
3810
|
+
useEffect16(() => {
|
|
3646
3811
|
Object.entries(handlers).forEach(([event, handler2]) => {
|
|
3647
3812
|
if (handler2) {
|
|
3648
3813
|
eventManager_default.on(event, handler2);
|
|
@@ -3660,14 +3825,14 @@ function useMatchEvents(handlers) {
|
|
|
3660
3825
|
|
|
3661
3826
|
// src/hooks/useCopyClipboard.ts
|
|
3662
3827
|
import copy from "copy-to-clipboard";
|
|
3663
|
-
import { useCallback, useEffect as
|
|
3828
|
+
import { useCallback, useEffect as useEffect17, useState as useState20 } from "react";
|
|
3664
3829
|
function useCopyClipboard(timeout = 500) {
|
|
3665
|
-
const [isCopied, setIsCopied] =
|
|
3830
|
+
const [isCopied, setIsCopied] = useState20(false);
|
|
3666
3831
|
const staticCopy = useCallback((text) => {
|
|
3667
3832
|
const didCopy = copy(text);
|
|
3668
3833
|
setIsCopied(didCopy);
|
|
3669
3834
|
}, []);
|
|
3670
|
-
|
|
3835
|
+
useEffect17(() => {
|
|
3671
3836
|
if (isCopied) {
|
|
3672
3837
|
const hide = setTimeout(() => {
|
|
3673
3838
|
setIsCopied(false);
|
|
@@ -3711,10 +3876,10 @@ export {
|
|
|
3711
3876
|
LoginButton,
|
|
3712
3877
|
UsernameModal,
|
|
3713
3878
|
SOLModal,
|
|
3714
|
-
|
|
3879
|
+
TRONModal,
|
|
3715
3880
|
BTCModal,
|
|
3716
3881
|
components_exports,
|
|
3717
3882
|
MatchProvider,
|
|
3718
3883
|
useMatch
|
|
3719
3884
|
};
|
|
3720
|
-
//# sourceMappingURL=chunk-
|
|
3885
|
+
//# sourceMappingURL=chunk-65NEGWW3.mjs.map
|