@matchain/matchid-sdk-react 0.1.37-alpha.12 → 0.1.37-alpha.3
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 +1 -7
- package/dist/assets/icon/index.d.ts +1 -7
- package/dist/assets/icon/index.js +0 -78
- package/dist/assets/icon/index.js.map +1 -1
- package/dist/assets/icon/index.mjs +1 -7
- package/dist/chunk-J6EA7OSJ.mjs +992 -0
- package/dist/chunk-J6EA7OSJ.mjs.map +1 -0
- package/dist/{chunk-IHRQKSSO.mjs → chunk-MZB76VOE.mjs} +2 -2
- package/dist/chunk-MZB76VOE.mjs.map +1 -0
- package/dist/{chunk-F5CJROWH.mjs → chunk-YCRZLAOS.mjs} +173 -358
- package/dist/chunk-YCRZLAOS.mjs.map +1 -0
- package/dist/components/index.d.mts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +300 -663
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/hooks/api/index.d.mts +1 -1
- package/dist/hooks/api/index.d.ts +1 -1
- package/dist/hooks/api/index.js +42 -56
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +3 -3
- package/dist/hooks/index.js +48 -62
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-BICt0DjJ.d.ts → index-BFn-HCRJ.d.ts} +3 -3
- package/dist/{index-CzAaZV-2.d.mts → index-BdeWio3u.d.mts} +3 -3
- package/dist/{index-B89X65ox.d.ts → index-CfipOX1C.d.ts} +5 -5
- package/dist/{index-CAvsdgJw.d.mts → index-Dq1vYJ0E.d.mts} +5 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +377 -752
- 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-6PWH7WZI.mjs +0 -1067
- package/dist/chunk-6PWH7WZI.mjs.map +0 -1
- package/dist/chunk-F5CJROWH.mjs.map +0 -1
- package/dist/chunk-IHRQKSSO.mjs.map +0 -1
|
@@ -2,9 +2,6 @@ import {
|
|
|
2
2
|
ArrowDownIcon,
|
|
3
3
|
ArrowLeftIcon,
|
|
4
4
|
ArrowRightIcon,
|
|
5
|
-
BTCDarkIcon,
|
|
6
|
-
BTCLightIcon,
|
|
7
|
-
BitgetIcon,
|
|
8
5
|
CheckIcon,
|
|
9
6
|
CheckRoundIcon,
|
|
10
7
|
CloseEyeIcon,
|
|
@@ -23,22 +20,18 @@ import {
|
|
|
23
20
|
LinkedinIcon,
|
|
24
21
|
LoadingIcon_default,
|
|
25
22
|
LoginIcon_default,
|
|
26
|
-
OKXIcon,
|
|
27
23
|
OpenEyeIcon,
|
|
28
24
|
PasswordRoundIcon,
|
|
29
25
|
SOLDarkIcon,
|
|
30
26
|
SOLLightIcon,
|
|
31
|
-
TRXDarkIcon,
|
|
32
|
-
TRXLightIcon,
|
|
33
27
|
TelegramIcon,
|
|
34
|
-
TronLinkIcon,
|
|
35
28
|
UnLoginIcon_default,
|
|
36
29
|
UnisatIcon,
|
|
37
30
|
WalletIcon,
|
|
38
31
|
XIcon,
|
|
39
32
|
XverseIcon,
|
|
40
33
|
YoutubeIcon
|
|
41
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-J6EA7OSJ.mjs";
|
|
42
35
|
import {
|
|
43
36
|
__export
|
|
44
37
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -93,7 +86,7 @@ var localStore = useLocalStore;
|
|
|
93
86
|
var useLocalStore_default = useLocalStore;
|
|
94
87
|
|
|
95
88
|
// src/hooks/useUserInfo.tsx
|
|
96
|
-
import { useMemo as
|
|
89
|
+
import { useMemo as useMemo8 } from "react";
|
|
97
90
|
|
|
98
91
|
// src/api/request.ts
|
|
99
92
|
import axios from "axios";
|
|
@@ -565,9 +558,14 @@ function PasswordModal({
|
|
|
565
558
|
return "";
|
|
566
559
|
}, [rePassword, password]);
|
|
567
560
|
useEffect2(() => {
|
|
568
|
-
if (isOpen) {
|
|
561
|
+
if (isOpen && overview) {
|
|
569
562
|
setPassword("");
|
|
570
563
|
setRePassword("");
|
|
564
|
+
const did2 = overview.did.split(":")[2];
|
|
565
|
+
initWallet({
|
|
566
|
+
did: did2,
|
|
567
|
+
address: ""
|
|
568
|
+
});
|
|
571
569
|
}
|
|
572
570
|
}, [isOpen, overview]);
|
|
573
571
|
const [isSubmitting, setIsSubmitting] = useState3(false);
|
|
@@ -575,13 +573,8 @@ function PasswordModal({
|
|
|
575
573
|
if (isSubmitting) return;
|
|
576
574
|
try {
|
|
577
575
|
setIsSubmitting(true);
|
|
578
|
-
const did2 = overview ? overview.did.split(":")[2] : "";
|
|
579
|
-
await initWallet({
|
|
580
|
-
did: did2,
|
|
581
|
-
address: ""
|
|
582
|
-
});
|
|
583
576
|
const address = await generateWallet({
|
|
584
|
-
did:
|
|
577
|
+
did: did.split(":")[2],
|
|
585
578
|
userPasscode: password
|
|
586
579
|
});
|
|
587
580
|
await refreshOverview();
|
|
@@ -667,6 +660,11 @@ function RecoveryModal({
|
|
|
667
660
|
useEffect3(() => {
|
|
668
661
|
if (isOpen && overview) {
|
|
669
662
|
setPassword("");
|
|
663
|
+
const did = overview.did.split(":")[2];
|
|
664
|
+
initWallet({
|
|
665
|
+
did,
|
|
666
|
+
address: overview.address
|
|
667
|
+
});
|
|
670
668
|
}
|
|
671
669
|
}, [isOpen, overview]);
|
|
672
670
|
const [isSubmitting, setIsSubmitting] = useState4(false);
|
|
@@ -674,11 +672,6 @@ function RecoveryModal({
|
|
|
674
672
|
if (isSubmitting) return;
|
|
675
673
|
try {
|
|
676
674
|
setIsSubmitting(true);
|
|
677
|
-
const did = overview ? overview.did.split(":")[2] : "";
|
|
678
|
-
await initWallet({
|
|
679
|
-
did,
|
|
680
|
-
address: overview?.address || ""
|
|
681
|
-
});
|
|
682
675
|
await recoveryWallet("ethereum", "user_passcode_recovery_key", password);
|
|
683
676
|
await refreshOverview();
|
|
684
677
|
onSuccess && onSuccess();
|
|
@@ -746,7 +739,7 @@ var useSOLModalStore = create3((set) => ({
|
|
|
746
739
|
open: (type) => set({ isOpen: true, type }),
|
|
747
740
|
close: () => set({ isOpen: false })
|
|
748
741
|
}));
|
|
749
|
-
var
|
|
742
|
+
var useTronModalStore = create3((set) => ({
|
|
750
743
|
isOpen: false,
|
|
751
744
|
type: "",
|
|
752
745
|
open: (type) => set({ isOpen: true, type }),
|
|
@@ -782,7 +775,7 @@ __export(components_exports, {
|
|
|
782
775
|
PasswordModal: () => PasswordModal,
|
|
783
776
|
Popover: () => Popover,
|
|
784
777
|
SOLModal: () => SOLModal,
|
|
785
|
-
|
|
778
|
+
TronModal: () => TronModal,
|
|
786
779
|
UsernameModal: () => UsernameModal
|
|
787
780
|
});
|
|
788
781
|
|
|
@@ -1031,7 +1024,7 @@ function Popover({
|
|
|
1031
1024
|
gap = "20px"
|
|
1032
1025
|
}) {
|
|
1033
1026
|
const [active, setActive] = useState8(false);
|
|
1034
|
-
return
|
|
1027
|
+
return /* @__PURE__ */ jsxs8(
|
|
1035
1028
|
"div",
|
|
1036
1029
|
{
|
|
1037
1030
|
onClick: () => {
|
|
@@ -1103,7 +1096,7 @@ function LoginBox({
|
|
|
1103
1096
|
"telegram",
|
|
1104
1097
|
"twitter"
|
|
1105
1098
|
],
|
|
1106
|
-
walletMethods = ["evm"
|
|
1099
|
+
walletMethods = ["evm"],
|
|
1107
1100
|
inModal = false
|
|
1108
1101
|
}) {
|
|
1109
1102
|
const [emailOpen, setEmailOpen] = useState9(false);
|
|
@@ -1178,18 +1171,6 @@ function LoginBox({
|
|
|
1178
1171
|
activeIcon: /* @__PURE__ */ jsx11(SOLLightIcon, { size: isDownMd ? 36 : 40 }),
|
|
1179
1172
|
name: "SOL",
|
|
1180
1173
|
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")
|
|
1193
1174
|
}
|
|
1194
1175
|
};
|
|
1195
1176
|
return /* @__PURE__ */ jsxs9(Fragment2, { children: [
|
|
@@ -1575,7 +1556,7 @@ function UsernameModal({
|
|
|
1575
1556
|
}, onClick: onSubmit, size: "lg", block: true, highlight: true, children: /* @__PURE__ */ jsx18(FormattedMessage9, { id: "confirm" }) }),
|
|
1576
1557
|
/* @__PURE__ */ jsx18(Button, { style: {
|
|
1577
1558
|
marginTop: isDownMd ? "12px" : "24px"
|
|
1578
|
-
}, onClick: props.onClose, size: "lg", block: true, children: /* @__PURE__ */ jsx18(FormattedMessage9, { id: "
|
|
1559
|
+
}, onClick: props.onClose, size: "lg", block: true, children: /* @__PURE__ */ jsx18(FormattedMessage9, { id: "nextTime" }) })
|
|
1579
1560
|
] }) });
|
|
1580
1561
|
}
|
|
1581
1562
|
|
|
@@ -1906,157 +1887,61 @@ function SOLModal({
|
|
|
1906
1887
|
}), children: /* @__PURE__ */ jsx20(ConnectionProvider, { endpoint: clusterApiUrl("devnet"), children: /* @__PURE__ */ jsx20(WalletProvider, { wallets, autoConnect: true, children: /* @__PURE__ */ jsx20(WalletModalProvider, { children: /* @__PURE__ */ jsx20(WalletContent, { onSuccess, type }) }) }) }) });
|
|
1907
1888
|
}
|
|
1908
1889
|
|
|
1909
|
-
// src/components/
|
|
1910
|
-
import React4, { useEffect as
|
|
1890
|
+
// src/components/TronModal/index.tsx
|
|
1891
|
+
import React4, { useEffect as useEffect9, useState as useState14 } from "react";
|
|
1911
1892
|
import { useIntl as useIntl11 } from "react-intl";
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
);
|
|
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);
|
|
1932
1916
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
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 {
|
|
1935
1926
|
}
|
|
1936
|
-
|
|
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);
|
|
1927
|
+
}, []);
|
|
1991
1928
|
useEffect9(() => {
|
|
1992
|
-
const
|
|
1993
|
-
|
|
1994
|
-
wallet: wallet2,
|
|
1995
|
-
isInstalled
|
|
1996
|
-
}))));
|
|
1997
|
-
setInstalledWallets(installed.filter(({ isInstalled }) => isInstalled).map(({ wallet: wallet2 }) => wallet2));
|
|
1929
|
+
const init = async () => {
|
|
1930
|
+
setVisible(true);
|
|
1998
1931
|
};
|
|
1999
|
-
|
|
1932
|
+
init();
|
|
2000
1933
|
}, []);
|
|
2001
|
-
const [wallet, chooseWallet] = useState14(null);
|
|
2002
|
-
const onConnect = async () => {
|
|
2003
|
-
setAddress(await wallet.connect());
|
|
2004
|
-
};
|
|
2005
1934
|
useEffect9(() => {
|
|
2006
|
-
if (
|
|
2007
|
-
|
|
1935
|
+
if (connected) {
|
|
1936
|
+
toLoginInWallet();
|
|
2008
1937
|
}
|
|
2009
|
-
}, [
|
|
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
|
-
};
|
|
1938
|
+
}, [connected]);
|
|
2054
1939
|
const toLoginInWallet = async () => {
|
|
2055
|
-
if (statusRef.current
|
|
1940
|
+
if (statusRef.current) return;
|
|
2056
1941
|
try {
|
|
2057
1942
|
setStatus("nonce");
|
|
2058
1943
|
statusRef.current = "nonce";
|
|
2059
|
-
const res = type == "bind" ? await getWalletInitApi({ address }) : await getWalletNonceApi({ address });
|
|
1944
|
+
const res = type == "bind" ? await getWalletInitApi({ address: walletAddress }) : await getWalletNonceApi({ address: walletAddress });
|
|
2060
1945
|
if (!isSuccess(res)) {
|
|
2061
1946
|
throw new Error(res.message);
|
|
2062
1947
|
}
|
|
@@ -2065,14 +1950,15 @@ function TRONModal({
|
|
|
2065
1950
|
setStatus("signer");
|
|
2066
1951
|
statusRef.current = "signer";
|
|
2067
1952
|
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;
|
|
2068
|
-
const
|
|
1953
|
+
const encodedMessage = new TextEncoder().encode(message);
|
|
1954
|
+
const signedMessage = await window.tronWeb.trx.signMessageV2(encodedMessage);
|
|
2069
1955
|
let obj = {
|
|
2070
|
-
type: "
|
|
2071
|
-
address,
|
|
2072
|
-
signature: signedMessage,
|
|
1956
|
+
type: "Tron",
|
|
1957
|
+
address: walletAddress,
|
|
1958
|
+
signature: Buffer.from(signedMessage).toString("base64"),
|
|
2073
1959
|
message,
|
|
2074
|
-
connector_type: "
|
|
2075
|
-
wallet_client_type:
|
|
1960
|
+
connector_type: "Tron",
|
|
1961
|
+
wallet_client_type: "TronLink"
|
|
2076
1962
|
};
|
|
2077
1963
|
const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
2078
1964
|
if (res1) {
|
|
@@ -2104,75 +1990,37 @@ function TRONModal({
|
|
|
2104
1990
|
statusRef.current = "";
|
|
2105
1991
|
}
|
|
2106
1992
|
};
|
|
2107
|
-
|
|
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(
|
|
1993
|
+
return /* @__PURE__ */ jsx21(
|
|
2130
1994
|
WalletModalContent,
|
|
2131
1995
|
{
|
|
1996
|
+
connected,
|
|
1997
|
+
disconnect,
|
|
1998
|
+
address: walletAddress,
|
|
1999
|
+
visible,
|
|
2000
|
+
setVisible,
|
|
2132
2001
|
error,
|
|
2133
2002
|
setError,
|
|
2134
|
-
status
|
|
2135
|
-
disconnect,
|
|
2136
|
-
address: address || "",
|
|
2137
|
-
connected,
|
|
2138
|
-
visible: true,
|
|
2139
|
-
setVisible: () => {
|
|
2140
|
-
}
|
|
2003
|
+
status
|
|
2141
2004
|
}
|
|
2142
|
-
)
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
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
|
-
] }) }) });
|
|
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 }) });
|
|
2172
2020
|
}
|
|
2173
2021
|
|
|
2174
2022
|
// src/components/BTCModal/index.tsx
|
|
2175
|
-
import React5, { useEffect as
|
|
2023
|
+
import React5, { useEffect as useEffect11, useMemo as useMemo7, useState as useState16 } from "react";
|
|
2176
2024
|
import { useIntl as useIntl12 } from "react-intl";
|
|
2177
2025
|
|
|
2178
2026
|
// src/lib/btc/UnisatAdapter.ts
|
|
@@ -2196,10 +2044,10 @@ var UnisatAdapter = class {
|
|
|
2196
2044
|
window.unisat.disconnect();
|
|
2197
2045
|
await this.checkChain();
|
|
2198
2046
|
const accounts = await window.unisat.getAccounts();
|
|
2199
|
-
|
|
2047
|
+
console.log("accounts", accounts);
|
|
2200
2048
|
if (accounts.length === 0) {
|
|
2201
2049
|
const accounts2 = await window.unisat.requestAccounts();
|
|
2202
|
-
|
|
2050
|
+
console.log("accounts", accounts2);
|
|
2203
2051
|
if (!accounts2 || accounts2.length === 0) throw new Error("No accounts found in Unisat Wallet");
|
|
2204
2052
|
return accounts2[0];
|
|
2205
2053
|
}
|
|
@@ -2209,10 +2057,6 @@ var UnisatAdapter = class {
|
|
|
2209
2057
|
if (!await this.isInstalled()) throw new Error("Unisat Wallet is not installed");
|
|
2210
2058
|
return window.unisat.signMessage(message, "bip322-simple");
|
|
2211
2059
|
}
|
|
2212
|
-
async disconnet() {
|
|
2213
|
-
if (!await this.isInstalled()) throw new Error("Unisat Wallet is not installed");
|
|
2214
|
-
return window.unisat.disconnect();
|
|
2215
|
-
}
|
|
2216
2060
|
};
|
|
2217
2061
|
|
|
2218
2062
|
// src/lib/btc/XverseAdapter.ts
|
|
@@ -2237,7 +2081,7 @@ var XverseAdapter = class {
|
|
|
2237
2081
|
try {
|
|
2238
2082
|
await getCapabilities({
|
|
2239
2083
|
onFinish: (response) => {
|
|
2240
|
-
|
|
2084
|
+
console.log(response);
|
|
2241
2085
|
this.capabilities = new Set(response);
|
|
2242
2086
|
resolve(true);
|
|
2243
2087
|
},
|
|
@@ -2250,7 +2094,7 @@ var XverseAdapter = class {
|
|
|
2250
2094
|
}
|
|
2251
2095
|
});
|
|
2252
2096
|
} catch (err) {
|
|
2253
|
-
console.
|
|
2097
|
+
console.log(err);
|
|
2254
2098
|
resolve(false);
|
|
2255
2099
|
}
|
|
2256
2100
|
});
|
|
@@ -2261,7 +2105,7 @@ var XverseAdapter = class {
|
|
|
2261
2105
|
purposes: [AddressPurpose.Ordinals],
|
|
2262
2106
|
message: "SATS Connect Demo"
|
|
2263
2107
|
});
|
|
2264
|
-
|
|
2108
|
+
console.log("getAccounts ~ response:", response);
|
|
2265
2109
|
if (response.status === "success") {
|
|
2266
2110
|
const ordinalsAddressItem = response.result.find(
|
|
2267
2111
|
(address) => address.purpose === AddressPurpose.Ordinals
|
|
@@ -2296,10 +2140,6 @@ var XverseAdapter = class {
|
|
|
2296
2140
|
});
|
|
2297
2141
|
});
|
|
2298
2142
|
}
|
|
2299
|
-
async disconnet() {
|
|
2300
|
-
if (!await this.isInstalled()) throw new Error("Xverse Wallet is not installed");
|
|
2301
|
-
await request2("wallet_disconnect", null);
|
|
2302
|
-
}
|
|
2303
2143
|
};
|
|
2304
2144
|
|
|
2305
2145
|
// src/lib/btc/LeatherAdapter.ts
|
|
@@ -2315,24 +2155,24 @@ var LeatherAdapter = class {
|
|
|
2315
2155
|
async connect() {
|
|
2316
2156
|
if (!await this.isInstalled()) throw new Error("Leather Wallet is not installed");
|
|
2317
2157
|
const response = await window.LeatherProvider?.request("getAddresses");
|
|
2318
|
-
|
|
2158
|
+
console.log("Addresses:", response.result.addresses);
|
|
2319
2159
|
return response.result.addresses[0].address;
|
|
2320
2160
|
}
|
|
2321
2161
|
async signMessage(message) {
|
|
2322
2162
|
if (!await this.isInstalled()) throw new Error("Hiro Wallet is not installed");
|
|
2323
2163
|
const response = await window.LeatherProvider?.request("signMessage", { message });
|
|
2324
|
-
|
|
2164
|
+
console.log("response", response);
|
|
2325
2165
|
return response.result.signature;
|
|
2326
2166
|
}
|
|
2327
2167
|
};
|
|
2328
2168
|
|
|
2329
2169
|
// src/hooks/useBTCWallet.ts
|
|
2330
|
-
import { useEffect as
|
|
2170
|
+
import { useEffect as useEffect10, useState as useState15 } from "react";
|
|
2331
2171
|
var useBTCWallet = () => {
|
|
2332
2172
|
const wallets2 = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter()];
|
|
2333
|
-
const [installedWallets, setInstalledWallets] =
|
|
2334
|
-
const [address, setAddress] =
|
|
2335
|
-
|
|
2173
|
+
const [installedWallets, setInstalledWallets] = useState15([]);
|
|
2174
|
+
const [address, setAddress] = useState15(null);
|
|
2175
|
+
useEffect10(() => {
|
|
2336
2176
|
const getInstalled = async () => {
|
|
2337
2177
|
const installed = await Promise.all(wallets2.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
|
|
2338
2178
|
wallet: wallet2,
|
|
@@ -2342,11 +2182,11 @@ var useBTCWallet = () => {
|
|
|
2342
2182
|
};
|
|
2343
2183
|
getInstalled();
|
|
2344
2184
|
}, []);
|
|
2345
|
-
const [wallet, chooseWallet] =
|
|
2185
|
+
const [wallet, chooseWallet] = useState15(null);
|
|
2346
2186
|
const onConnect = async () => {
|
|
2347
2187
|
setAddress(await wallet.connect());
|
|
2348
2188
|
};
|
|
2349
|
-
|
|
2189
|
+
useEffect10(() => {
|
|
2350
2190
|
if (!wallet) {
|
|
2351
2191
|
setAddress(null);
|
|
2352
2192
|
}
|
|
@@ -2362,7 +2202,7 @@ var useBTCWallet = () => {
|
|
|
2362
2202
|
};
|
|
2363
2203
|
|
|
2364
2204
|
// src/components/BTCModal/index.tsx
|
|
2365
|
-
import { jsx as jsx22, jsxs as
|
|
2205
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2366
2206
|
function BTCModal({
|
|
2367
2207
|
type = "login",
|
|
2368
2208
|
onSuccess,
|
|
@@ -2377,18 +2217,15 @@ function BTCModal({
|
|
|
2377
2217
|
xverse: /* @__PURE__ */ jsx22(XverseIcon, { size: isDownMd ? 36 : 40 })
|
|
2378
2218
|
};
|
|
2379
2219
|
const { events, login } = useMatch();
|
|
2380
|
-
const [status, setStatus] =
|
|
2220
|
+
const [status, setStatus] = useState16("");
|
|
2381
2221
|
const statusRef = React5.useRef(status);
|
|
2382
|
-
const [error, setError] =
|
|
2383
|
-
const connected =
|
|
2222
|
+
const [error, setError] = useState16("");
|
|
2223
|
+
const connected = useMemo7(() => {
|
|
2384
2224
|
return !!address;
|
|
2385
2225
|
}, [address]);
|
|
2386
2226
|
const disconnect = async () => {
|
|
2387
|
-
wallet && wallet.disconnet && wallet.disconnet();
|
|
2388
2227
|
setStatus("");
|
|
2389
2228
|
chooseWallet(null);
|
|
2390
|
-
statusRef.current = "";
|
|
2391
|
-
setError("");
|
|
2392
2229
|
};
|
|
2393
2230
|
const toLoginInWallet = async () => {
|
|
2394
2231
|
if (statusRef.current || !address || !wallet) return;
|
|
@@ -2411,7 +2248,7 @@ function BTCModal({
|
|
|
2411
2248
|
signature: signedMessage,
|
|
2412
2249
|
message,
|
|
2413
2250
|
connector_type: "BTC",
|
|
2414
|
-
wallet_client_type: wallet.
|
|
2251
|
+
wallet_client_type: wallet.name
|
|
2415
2252
|
};
|
|
2416
2253
|
const res1 = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
2417
2254
|
if (res1) {
|
|
@@ -2438,47 +2275,37 @@ function BTCModal({
|
|
|
2438
2275
|
}
|
|
2439
2276
|
}
|
|
2440
2277
|
} catch (error2) {
|
|
2441
|
-
console.error("btc error", error2);
|
|
2442
2278
|
setStatus("error");
|
|
2443
2279
|
setError(error2.message);
|
|
2444
2280
|
statusRef.current = "";
|
|
2445
2281
|
}
|
|
2446
2282
|
};
|
|
2447
|
-
|
|
2283
|
+
useEffect11(() => {
|
|
2448
2284
|
if (wallet) {
|
|
2449
2285
|
console.log("onConnect");
|
|
2450
|
-
|
|
2451
|
-
onConnect();
|
|
2452
|
-
} catch (err) {
|
|
2453
|
-
setStatus("error");
|
|
2454
|
-
setError(err.message);
|
|
2455
|
-
}
|
|
2286
|
+
onConnect();
|
|
2456
2287
|
} else {
|
|
2457
2288
|
setStatus("");
|
|
2458
2289
|
}
|
|
2459
2290
|
}, [wallet]);
|
|
2460
|
-
|
|
2291
|
+
useEffect11(() => {
|
|
2461
2292
|
if (address) {
|
|
2462
2293
|
toLoginInWallet();
|
|
2463
2294
|
}
|
|
2464
2295
|
}, [address]);
|
|
2465
|
-
|
|
2296
|
+
useEffect11(() => {
|
|
2466
2297
|
if (!props.isOpen) {
|
|
2298
|
+
setStatus("");
|
|
2467
2299
|
disconnect();
|
|
2468
2300
|
}
|
|
2469
2301
|
}, [props.isOpen]);
|
|
2470
|
-
const onBack = () => {
|
|
2471
|
-
wallet && wallet.disconnet && wallet.disconnet();
|
|
2472
|
-
setStatus("");
|
|
2473
|
-
chooseWallet(null);
|
|
2474
|
-
statusRef.current = "";
|
|
2475
|
-
setError("");
|
|
2476
|
-
};
|
|
2477
2302
|
return /* @__PURE__ */ jsx22(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
2478
2303
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
2479
2304
|
}, {
|
|
2480
2305
|
name: "BTC"
|
|
2481
|
-
}), onBack: wallet ?
|
|
2306
|
+
}), onBack: wallet ? () => {
|
|
2307
|
+
chooseWallet(null);
|
|
2308
|
+
} : void 0, children: wallet ? /* @__PURE__ */ jsx22(
|
|
2482
2309
|
WalletModalContent,
|
|
2483
2310
|
{
|
|
2484
2311
|
error,
|
|
@@ -2491,7 +2318,7 @@ function BTCModal({
|
|
|
2491
2318
|
setVisible: () => {
|
|
2492
2319
|
}
|
|
2493
2320
|
}
|
|
2494
|
-
) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */
|
|
2321
|
+
) : /* @__PURE__ */ jsx22("div", { className: "matchid-login-box", children: /* @__PURE__ */ jsxs17("div", { className: "matchid-login-recommend-list", children: [
|
|
2495
2322
|
installedWallets.map((wallet2) => {
|
|
2496
2323
|
return /* @__PURE__ */ jsx22(
|
|
2497
2324
|
RecommendItem,
|
|
@@ -2524,9 +2351,9 @@ function BTCModal({
|
|
|
2524
2351
|
}
|
|
2525
2352
|
|
|
2526
2353
|
// src/components/CEXBindModal/index.tsx
|
|
2527
|
-
import { useEffect as
|
|
2354
|
+
import { useEffect as useEffect12, useState as useState17 } from "react";
|
|
2528
2355
|
import { FormattedMessage as FormattedMessage10, useIntl as useIntl13 } from "react-intl";
|
|
2529
|
-
import { jsx as jsx23, jsxs as
|
|
2356
|
+
import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2530
2357
|
function CEXBindModal({
|
|
2531
2358
|
onClose,
|
|
2532
2359
|
type,
|
|
@@ -2535,13 +2362,13 @@ function CEXBindModal({
|
|
|
2535
2362
|
}) {
|
|
2536
2363
|
const intl = useIntl13();
|
|
2537
2364
|
const { events } = useMatch();
|
|
2538
|
-
const [APIPassphrase, setAPIPassphrase] =
|
|
2365
|
+
const [APIPassphrase, setAPIPassphrase] = useState17("");
|
|
2539
2366
|
const { refreshOverview } = useUserInfo();
|
|
2540
|
-
const [loading, setLoading] =
|
|
2541
|
-
const [key, setKey] =
|
|
2542
|
-
const [secret, setSecret] =
|
|
2543
|
-
const [error, setError] =
|
|
2544
|
-
|
|
2367
|
+
const [loading, setLoading] = useState17(false);
|
|
2368
|
+
const [key, setKey] = useState17("");
|
|
2369
|
+
const [secret, setSecret] = useState17("");
|
|
2370
|
+
const [error, setError] = useState17("");
|
|
2371
|
+
useEffect12(() => {
|
|
2545
2372
|
if (isOpen) {
|
|
2546
2373
|
setSecret("");
|
|
2547
2374
|
setKey("");
|
|
@@ -2568,22 +2395,19 @@ function CEXBindModal({
|
|
|
2568
2395
|
type: "cex_" + type
|
|
2569
2396
|
});
|
|
2570
2397
|
onClose();
|
|
2571
|
-
} else {
|
|
2572
|
-
throw new Error(res.message);
|
|
2573
2398
|
}
|
|
2399
|
+
setLoading(false);
|
|
2574
2400
|
} catch (error2) {
|
|
2575
2401
|
console.error(error2);
|
|
2576
2402
|
setError(error2.message);
|
|
2577
|
-
} finally {
|
|
2578
|
-
setLoading(false);
|
|
2579
2403
|
}
|
|
2580
2404
|
};
|
|
2581
2405
|
return /* @__PURE__ */ jsx23(ModalWithHeader, { showClose: true, isOpen, onClose, title: intl.formatMessage({
|
|
2582
2406
|
id: "CEXBindTitle"
|
|
2583
2407
|
}, {
|
|
2584
2408
|
type
|
|
2585
|
-
}), ...props, children: /* @__PURE__ */
|
|
2586
|
-
/* @__PURE__ */
|
|
2409
|
+
}), ...props, children: /* @__PURE__ */ jsxs18("div", { className: "matchid-cex-modal", children: [
|
|
2410
|
+
/* @__PURE__ */ jsxs18("div", { children: [
|
|
2587
2411
|
/* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindAttention" }) }),
|
|
2588
2412
|
/* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips1" }) }),
|
|
2589
2413
|
/* @__PURE__ */ jsx23("p", { children: /* @__PURE__ */ jsx23(FormattedMessage10, { id: "CEXBindTips2" }) }),
|
|
@@ -2601,7 +2425,7 @@ function CEXBindModal({
|
|
|
2601
2425
|
) }),
|
|
2602
2426
|
/* @__PURE__ */ jsx23(Field, { label: intl.formatMessage({
|
|
2603
2427
|
id: "CEXBindApiSecretKey"
|
|
2604
|
-
}),
|
|
2428
|
+
}), children: /* @__PURE__ */ jsx23(
|
|
2605
2429
|
Input,
|
|
2606
2430
|
{
|
|
2607
2431
|
value: secret,
|
|
@@ -2609,7 +2433,7 @@ function CEXBindModal({
|
|
|
2609
2433
|
placeholder: "**** **** ****"
|
|
2610
2434
|
}
|
|
2611
2435
|
) }),
|
|
2612
|
-
type == "OKX" && /* @__PURE__ */ jsx23(Field, {
|
|
2436
|
+
type == "OKX" && /* @__PURE__ */ jsx23(Field, { label: intl.formatMessage({
|
|
2613
2437
|
id: "CEXBindApiPassphrase"
|
|
2614
2438
|
}), children: /* @__PURE__ */ jsx23(
|
|
2615
2439
|
Input,
|
|
@@ -2634,15 +2458,15 @@ function CEXBindModal({
|
|
|
2634
2458
|
}
|
|
2635
2459
|
|
|
2636
2460
|
// src/context/BusinessProvider.tsx
|
|
2637
|
-
import { Fragment as Fragment4, jsx as jsx24, jsxs as
|
|
2461
|
+
import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2638
2462
|
function BusinessProvider({ children }) {
|
|
2639
2463
|
const { overview, token } = useUserInfo();
|
|
2640
2464
|
const { recoveryModal } = useStore_default();
|
|
2641
2465
|
const { type: SOLType, isOpen: SOLIsOpen, close: SOLClose } = useSOLModalStore();
|
|
2642
|
-
const { type:
|
|
2466
|
+
const { type: TronType, isOpen: TronIsOpen, close: TronClose } = useTronModalStore();
|
|
2643
2467
|
const { type: BTCType, isOpen: BTCIsOpen, close: BTCClose } = useBTCModalStore();
|
|
2644
2468
|
const { type: CEXType, isOpen: CEXIsOpen, close: CEXClose } = useCEXBindModalStore();
|
|
2645
|
-
return /* @__PURE__ */
|
|
2469
|
+
return /* @__PURE__ */ jsxs19(Fragment4, { children: [
|
|
2646
2470
|
/* @__PURE__ */ jsx24(PasswordModal, { isOpen: !!token && !!overview && !overview.address && !!overview.did, showClose: false }),
|
|
2647
2471
|
/* @__PURE__ */ jsx24(
|
|
2648
2472
|
RecoveryModal,
|
|
@@ -2663,12 +2487,12 @@ function BusinessProvider({ children }) {
|
|
|
2663
2487
|
}
|
|
2664
2488
|
),
|
|
2665
2489
|
/* @__PURE__ */ jsx24(
|
|
2666
|
-
|
|
2490
|
+
TronModal,
|
|
2667
2491
|
{
|
|
2668
|
-
isOpen:
|
|
2669
|
-
onClose:
|
|
2670
|
-
type:
|
|
2671
|
-
onSuccess:
|
|
2492
|
+
isOpen: TronIsOpen && (TronType == "login" && !overview && !token || TronType == "bind" && !!token && !!overview),
|
|
2493
|
+
onClose: TronClose,
|
|
2494
|
+
type: TronType,
|
|
2495
|
+
onSuccess: TronClose,
|
|
2672
2496
|
zIndex: 199
|
|
2673
2497
|
}
|
|
2674
2498
|
),
|
|
@@ -2706,7 +2530,7 @@ var Providers = ({ children }) => {
|
|
|
2706
2530
|
var context_default = Providers;
|
|
2707
2531
|
|
|
2708
2532
|
// src/hooks/useWalletInit.ts
|
|
2709
|
-
import { useEffect as
|
|
2533
|
+
import { useEffect as useEffect13, useState as useState18 } from "react";
|
|
2710
2534
|
|
|
2711
2535
|
// src/hooks/useWallet.tsx
|
|
2712
2536
|
import { toAccount } from "viem/accounts";
|
|
@@ -2846,10 +2670,10 @@ function useWalletInit({
|
|
|
2846
2670
|
const getWalletIframe = () => {
|
|
2847
2671
|
return document.getElementById("match-wallet");
|
|
2848
2672
|
};
|
|
2849
|
-
const [walletInited, setWalletInited] =
|
|
2673
|
+
const [walletInited, setWalletInited] = useState18(false);
|
|
2850
2674
|
const { appid, token, overview } = useLocalStore_default();
|
|
2851
2675
|
const { initWallet, generateWallet } = useWallet();
|
|
2852
|
-
|
|
2676
|
+
useEffect13(() => {
|
|
2853
2677
|
if (endpoints.auth) {
|
|
2854
2678
|
if (!window.matchWalletMessageIdMap) {
|
|
2855
2679
|
window.matchWalletMessageIdMap = {};
|
|
@@ -2910,7 +2734,7 @@ function useWalletInit({
|
|
|
2910
2734
|
}
|
|
2911
2735
|
}
|
|
2912
2736
|
}, [endpoints.auth]);
|
|
2913
|
-
|
|
2737
|
+
useEffect13(() => {
|
|
2914
2738
|
const messageHandle = async (e) => {
|
|
2915
2739
|
if (e.origin !== endpoints.auth.substring(0, endpoints.auth.length - 1)) {
|
|
2916
2740
|
return;
|
|
@@ -2943,7 +2767,7 @@ function useWalletInit({
|
|
|
2943
2767
|
window.removeEventListener("message", messageHandle);
|
|
2944
2768
|
};
|
|
2945
2769
|
}, []);
|
|
2946
|
-
|
|
2770
|
+
useEffect13(() => {
|
|
2947
2771
|
if (token && overview && overview.did && walletInited) {
|
|
2948
2772
|
const did = overview.did.split(":")[2];
|
|
2949
2773
|
const newUserInit = async () => {
|
|
@@ -2974,7 +2798,7 @@ function useWalletInit({
|
|
|
2974
2798
|
}
|
|
2975
2799
|
|
|
2976
2800
|
// src/hooks/useInit.tsx
|
|
2977
|
-
import { useEffect as
|
|
2801
|
+
import { useEffect as useEffect14, useRef as useRef2 } from "react";
|
|
2978
2802
|
function useInit({
|
|
2979
2803
|
theme,
|
|
2980
2804
|
appid,
|
|
@@ -2997,19 +2821,19 @@ function useInit({
|
|
|
2997
2821
|
const searchParams = new URLSearchParams(window.location.search);
|
|
2998
2822
|
const matchToken = searchParams.get("matchToken");
|
|
2999
2823
|
const realEndpoints = endpoints || env_default.endpoints;
|
|
3000
|
-
|
|
2824
|
+
useEffect14(() => {
|
|
3001
2825
|
setTheme(theme);
|
|
3002
2826
|
}, [theme]);
|
|
3003
|
-
|
|
2827
|
+
useEffect14(() => {
|
|
3004
2828
|
setAppid(appid);
|
|
3005
2829
|
}, [appid]);
|
|
3006
|
-
|
|
2830
|
+
useEffect14(() => {
|
|
3007
2831
|
setEndpoints(realEndpoints);
|
|
3008
2832
|
}, [realEndpoints]);
|
|
3009
|
-
|
|
2833
|
+
useEffect14(() => {
|
|
3010
2834
|
setLocale(locale || "en");
|
|
3011
2835
|
}, [locale]);
|
|
3012
|
-
|
|
2836
|
+
useEffect14(() => {
|
|
3013
2837
|
if (matchToken) {
|
|
3014
2838
|
const tokenData = JSON.parse(atob(matchToken));
|
|
3015
2839
|
if (tokenData && tokenData.mid && tokenData.token) {
|
|
@@ -3020,7 +2844,7 @@ function useInit({
|
|
|
3020
2844
|
}
|
|
3021
2845
|
}
|
|
3022
2846
|
}, [matchToken]);
|
|
3023
|
-
|
|
2847
|
+
useEffect14(() => {
|
|
3024
2848
|
const onLoginMessage = (event) => {
|
|
3025
2849
|
const res = event.data;
|
|
3026
2850
|
if (res.event === "login" && res.data && (res.data.token || res.data.token_type && res.data.access_token)) {
|
|
@@ -3056,7 +2880,7 @@ function useInit({
|
|
|
3056
2880
|
overviewLoadingRef.current = false;
|
|
3057
2881
|
}
|
|
3058
2882
|
};
|
|
3059
|
-
|
|
2883
|
+
useEffect14(() => {
|
|
3060
2884
|
if (token) {
|
|
3061
2885
|
loadOverview();
|
|
3062
2886
|
}
|
|
@@ -3137,8 +2961,7 @@ var en_default = {
|
|
|
3137
2961
|
CEXBindTips3: "3. Only one API can be bound to the same exchange at the same time.",
|
|
3138
2962
|
CEXBindApiKey: "API Key",
|
|
3139
2963
|
CEXBindApiSecretKey: "API Secret Key",
|
|
3140
|
-
CEXBindApiPassphrase: "API Passphrase"
|
|
3141
|
-
cancel: "Cancel"
|
|
2964
|
+
CEXBindApiPassphrase: "API Passphrase"
|
|
3142
2965
|
};
|
|
3143
2966
|
|
|
3144
2967
|
// src/i18n/zh.json
|
|
@@ -3188,8 +3011,7 @@ var zh_default = {
|
|
|
3188
3011
|
CEXBindTips3: "3. \u540C\u4E00\u65F6\u95F4\u53EA\u80FD\u7ED1\u5B9A\u4E00\u4E2A API \u5230\u76F8\u540C\u7684\u4EA4\u6613\u6240\u3002",
|
|
3189
3012
|
CEXBindApiKey: "API \u5BC6\u94A5",
|
|
3190
3013
|
CEXBindApiSecretKey: "API \u79D8\u94A5",
|
|
3191
|
-
CEXBindApiPassphrase: "API \u5BC6\u7801\u77ED\u8BED"
|
|
3192
|
-
cancel: "\u53D6\u6D88"
|
|
3014
|
+
CEXBindApiPassphrase: "API \u5BC6\u7801\u77ED\u8BED"
|
|
3193
3015
|
};
|
|
3194
3016
|
|
|
3195
3017
|
// src/i18n/tw.json
|
|
@@ -3239,8 +3061,7 @@ var tw_default = {
|
|
|
3239
3061
|
CEXBindTips3: "3. \u540C\u4E00\u6642\u9593\u53EA\u80FD\u7D81\u5B9A\u4E00\u500B API \u5230\u76F8\u540C\u7684\u4EA4\u6613\u6240\u3002",
|
|
3240
3062
|
CEXBindApiKey: "API \u91D1\u9470",
|
|
3241
3063
|
CEXBindApiSecretKey: "API \u5BC6\u9470",
|
|
3242
|
-
CEXBindApiPassphrase: "API \u5BC6\u78BC\u77ED\u8A9E"
|
|
3243
|
-
cancel: "\u53D6\u6D88"
|
|
3064
|
+
CEXBindApiPassphrase: "API \u5BC6\u78BC\u77ED\u8A9E"
|
|
3244
3065
|
};
|
|
3245
3066
|
|
|
3246
3067
|
// src/i18n/fr.json
|
|
@@ -3290,8 +3111,7 @@ var fr_default = {
|
|
|
3290
3111
|
CEXBindTips3: "3. Une seule API peut \xEAtre li\xE9e au m\xEAme \xE9change \xE0 la fois.",
|
|
3291
3112
|
CEXBindApiKey: "Cl\xE9 API",
|
|
3292
3113
|
CEXBindApiSecretKey: "Cl\xE9 Secr\xE8te API",
|
|
3293
|
-
CEXBindApiPassphrase: "Phrase secr\xE8te API"
|
|
3294
|
-
cancel: "Annuler"
|
|
3114
|
+
CEXBindApiPassphrase: "Phrase secr\xE8te API"
|
|
3295
3115
|
};
|
|
3296
3116
|
|
|
3297
3117
|
// src/i18n/ja.json
|
|
@@ -3341,8 +3161,7 @@ var ja_default = {
|
|
|
3341
3161
|
CEXBindTips3: "3. \u540C\u3058\u53D6\u5F15\u6240\u306B\u540C\u6642\u306B\u30D0\u30A4\u30F3\u30C9\u3067\u304D\u308B API \u306F1\u3064\u3060\u3051\u3067\u3059\u3002",
|
|
3342
3162
|
CEXBindApiKey: "API \u30AD\u30FC",
|
|
3343
3163
|
CEXBindApiSecretKey: "API \u30B7\u30FC\u30AF\u30EC\u30C3\u30C8\u30AD\u30FC",
|
|
3344
|
-
CEXBindApiPassphrase: "API \u30D1\u30B9\u30D5\u30EC\u30FC\u30BA"
|
|
3345
|
-
cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB"
|
|
3164
|
+
CEXBindApiPassphrase: "API \u30D1\u30B9\u30D5\u30EC\u30FC\u30BA"
|
|
3346
3165
|
};
|
|
3347
3166
|
|
|
3348
3167
|
// src/i18n/ko.json
|
|
@@ -3392,8 +3211,7 @@ var ko_default = {
|
|
|
3392
3211
|
CEXBindTips3: "3. \uB3D9\uC77C\uD55C \uAC70\uB798\uC18C\uC5D0 \uB3D9\uC2DC\uC5D0 \uC5F0\uACB0\uD560 \uC218 \uC788\uB294 API\uB294 \uD558\uB098\uBFD0\uC785\uB2C8\uB2E4.",
|
|
3393
3212
|
CEXBindApiKey: "API \uD0A4",
|
|
3394
3213
|
CEXBindApiSecretKey: "API \uBE44\uBC00 \uD0A4",
|
|
3395
|
-
CEXBindApiPassphrase: "API \uC554\uD638 \uAD6C\uBB38"
|
|
3396
|
-
cancel: "\uCDE8\uC18C"
|
|
3214
|
+
CEXBindApiPassphrase: "API \uC554\uD638 \uAD6C\uBB38"
|
|
3397
3215
|
};
|
|
3398
3216
|
|
|
3399
3217
|
// src/i18n/vi.json
|
|
@@ -3443,8 +3261,7 @@ var vi_default = {
|
|
|
3443
3261
|
CEXBindTips3: "3. Ch\u1EC9 c\xF3 th\u1EC3 li\xEAn k\u1EBFt m\u1ED9t API v\u1EDBi c\xF9ng m\u1ED9t s\xE0n giao d\u1ECBch t\u1EA1i m\u1ED9t th\u1EDDi \u0111i\u1EC3m.",
|
|
3444
3262
|
CEXBindApiKey: "Kh\xF3a API",
|
|
3445
3263
|
CEXBindApiSecretKey: "Kh\xF3a b\xED m\u1EADt API",
|
|
3446
|
-
CEXBindApiPassphrase: "C\u1EE5m m\u1EADt kh\u1EA9u API"
|
|
3447
|
-
cancel: "H\u1EE7y"
|
|
3264
|
+
CEXBindApiPassphrase: "C\u1EE5m m\u1EADt kh\u1EA9u API"
|
|
3448
3265
|
};
|
|
3449
3266
|
|
|
3450
3267
|
// src/i18n/es.json
|
|
@@ -3494,8 +3311,7 @@ var es_default = {
|
|
|
3494
3311
|
CEXBindTips3: "3. Solo se puede vincular una API al mismo intercambio a la vez.",
|
|
3495
3312
|
CEXBindApiKey: "Clave API",
|
|
3496
3313
|
CEXBindApiSecretKey: "Clave Secreta API",
|
|
3497
|
-
CEXBindApiPassphrase: "Frase de contrase\xF1a API"
|
|
3498
|
-
cancel: "Cancelar"
|
|
3314
|
+
CEXBindApiPassphrase: "Frase de contrase\xF1a API"
|
|
3499
3315
|
};
|
|
3500
3316
|
|
|
3501
3317
|
// src/i18n/pt.json
|
|
@@ -3545,8 +3361,7 @@ var pt_default = {
|
|
|
3545
3361
|
CEXBindTips3: "3. Apenas uma API pode ser vinculada ao mesmo c\xE2mbio ao mesmo tempo.",
|
|
3546
3362
|
CEXBindApiKey: "Chave API",
|
|
3547
3363
|
CEXBindApiSecretKey: "Chave Secreta API",
|
|
3548
|
-
CEXBindApiPassphrase: "Senha de API"
|
|
3549
|
-
cancel: "Cancelar"
|
|
3364
|
+
CEXBindApiPassphrase: "Senha de API"
|
|
3550
3365
|
};
|
|
3551
3366
|
|
|
3552
3367
|
// src/i18n/index.ts
|
|
@@ -3622,10 +3437,10 @@ function useUserInfo() {
|
|
|
3622
3437
|
} = useLocalStore_default();
|
|
3623
3438
|
const { events, login } = useMatch();
|
|
3624
3439
|
const { open: SOLOpen } = useSOLModalStore();
|
|
3625
|
-
const { open:
|
|
3440
|
+
const { open: TronOpen } = useTronModalStore();
|
|
3626
3441
|
const { open: BTCOpen } = useBTCModalStore();
|
|
3627
3442
|
const { open: CEXBindOpen } = useCEXBindModalStore();
|
|
3628
|
-
const isLogin =
|
|
3443
|
+
const isLogin = useMemo8(() => !!token, [token]);
|
|
3629
3444
|
const logout = async () => {
|
|
3630
3445
|
try {
|
|
3631
3446
|
await toLogoutApi();
|
|
@@ -3670,7 +3485,7 @@ function useUserInfo() {
|
|
|
3670
3485
|
case "sol":
|
|
3671
3486
|
return SOLOpen("login");
|
|
3672
3487
|
case "tron":
|
|
3673
|
-
return
|
|
3488
|
+
return TronOpen("login");
|
|
3674
3489
|
case "btc":
|
|
3675
3490
|
return BTCOpen("login");
|
|
3676
3491
|
case "telegram":
|
|
@@ -3761,7 +3576,7 @@ function useUserInfo() {
|
|
|
3761
3576
|
case "sol":
|
|
3762
3577
|
return SOLOpen("bind");
|
|
3763
3578
|
case "tron":
|
|
3764
|
-
return
|
|
3579
|
+
return TronOpen("bind");
|
|
3765
3580
|
case "btc":
|
|
3766
3581
|
return BTCOpen("bind");
|
|
3767
3582
|
case "telegram":
|
|
@@ -3814,9 +3629,9 @@ function useUserInfo() {
|
|
|
3814
3629
|
}
|
|
3815
3630
|
|
|
3816
3631
|
// src/hooks/useMatchEvents.ts
|
|
3817
|
-
import { useEffect as
|
|
3632
|
+
import { useEffect as useEffect15 } from "react";
|
|
3818
3633
|
function useMatchEvents(handlers) {
|
|
3819
|
-
|
|
3634
|
+
useEffect15(() => {
|
|
3820
3635
|
Object.entries(handlers).forEach(([event, handler2]) => {
|
|
3821
3636
|
if (handler2) {
|
|
3822
3637
|
eventManager_default.on(event, handler2);
|
|
@@ -3834,14 +3649,14 @@ function useMatchEvents(handlers) {
|
|
|
3834
3649
|
|
|
3835
3650
|
// src/hooks/useCopyClipboard.ts
|
|
3836
3651
|
import copy from "copy-to-clipboard";
|
|
3837
|
-
import { useCallback, useEffect as
|
|
3652
|
+
import { useCallback, useEffect as useEffect16, useState as useState19 } from "react";
|
|
3838
3653
|
function useCopyClipboard(timeout = 500) {
|
|
3839
|
-
const [isCopied, setIsCopied] =
|
|
3654
|
+
const [isCopied, setIsCopied] = useState19(false);
|
|
3840
3655
|
const staticCopy = useCallback((text) => {
|
|
3841
3656
|
const didCopy = copy(text);
|
|
3842
3657
|
setIsCopied(didCopy);
|
|
3843
3658
|
}, []);
|
|
3844
|
-
|
|
3659
|
+
useEffect16(() => {
|
|
3845
3660
|
if (isCopied) {
|
|
3846
3661
|
const hide = setTimeout(() => {
|
|
3847
3662
|
setIsCopied(false);
|
|
@@ -3885,10 +3700,10 @@ export {
|
|
|
3885
3700
|
LoginButton,
|
|
3886
3701
|
UsernameModal,
|
|
3887
3702
|
SOLModal,
|
|
3888
|
-
|
|
3703
|
+
TronModal,
|
|
3889
3704
|
BTCModal,
|
|
3890
3705
|
components_exports,
|
|
3891
3706
|
MatchProvider,
|
|
3892
3707
|
useMatch
|
|
3893
3708
|
};
|
|
3894
|
-
//# sourceMappingURL=chunk-
|
|
3709
|
+
//# sourceMappingURL=chunk-YCRZLAOS.mjs.map
|