@matchain/matchid-sdk-react 0.1.54 → 0.1.55-alpha.1
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 +2 -2
- package/dist/assets/icon/index.d.ts +2 -2
- package/dist/chunk-LTPXS5PV.mjs +97 -0
- package/dist/chunk-LTPXS5PV.mjs.map +1 -0
- package/dist/{chunk-ZPBHHXEE.mjs → chunk-SKA35IYC.mjs} +6547 -6893
- package/dist/chunk-SKA35IYC.mjs.map +1 -0
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +35 -381
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -6
- package/dist/hooks/api/index.d.mts +2 -2
- package/dist/hooks/api/index.d.ts +2 -2
- package/dist/hooks/api/index.js +45 -215
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +6 -6
- package/dist/hooks/index.d.mts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +220 -229
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-91BdMYDA.d.ts → index-6-oVBXRP.d.mts} +2 -5
- package/dist/{index-D5geEbXf.d.ts → index-6kXyNEXB.d.ts} +3 -2
- package/dist/{index-DSvRdAyZ.d.mts → index-CB6ZNvzn.d.mts} +3 -2
- package/dist/{index-CkHDxE7B.d.mts → index-CBQXIlWu.d.mts} +1 -1
- package/dist/{index-ChHJD4NZ.d.mts → index-CMH6Jesl.d.ts} +2 -5
- package/dist/{index-Dj1K-UdZ.d.ts → index-CNH7a3bx.d.ts} +5 -18
- package/dist/{index-CZu_8fKl.d.ts → index-CPPDmmz8.d.ts} +1 -1
- package/dist/{index-DX1vzCrM.d.mts → index-CqKohtvj.d.mts} +1 -1
- package/dist/{index-CPk553v5.d.mts → index-D0Psl8Ue.d.mts} +1 -1
- package/dist/{index-DFBrN7dx.d.ts → index-DbQn4z1l.d.ts} +1 -1
- package/dist/{index-DjwwXNp4.d.mts → index-G15A08DI.d.mts} +3 -40
- package/dist/{index-Vxvd14yW.d.ts → index-Y5WRoqzn.d.ts} +3 -40
- package/dist/{index-CPwcm70o.d.mts → index-a_Qt7NXk.d.mts} +5 -18
- package/dist/{index-SRHVQn5G.d.ts → index-agAVLGF5.d.ts} +1 -1
- package/dist/index.css +1 -121
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +603 -878
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/{types-Bi9iq57H.d.mts → types-CXzZS0eM.d.mts} +1 -20
- package/dist/{types-Bi9iq57H.d.ts → types-CXzZS0eM.d.ts} +1 -20
- package/dist/ui/index.d.mts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js +57 -72
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +2 -2
- package/example/src/App.tsx +0 -8
- package/example/src/pages/Wallet/index.tsx +4 -1
- package/package.json +1 -1
- package/dist/chunk-ZPBHHXEE.mjs.map +0 -1
- package/example/src/pages/Contact/index.tsx +0 -90
package/dist/hooks/index.js
CHANGED
|
@@ -356,10 +356,10 @@ var localStore = useLocalStore;
|
|
|
356
356
|
var useLocalStore_default = useLocalStore;
|
|
357
357
|
|
|
358
358
|
// src/hooks/useUserInfo.tsx
|
|
359
|
-
var
|
|
359
|
+
var import_react34 = require("react");
|
|
360
360
|
|
|
361
361
|
// src/MatchContext.tsx
|
|
362
|
-
var
|
|
362
|
+
var import_react33 = require("react");
|
|
363
363
|
|
|
364
364
|
// src/store/useModalStore.ts
|
|
365
365
|
var import_zustand2 = require("zustand");
|
|
@@ -1111,7 +1111,8 @@ function HashPanel({
|
|
|
1111
1111
|
chain,
|
|
1112
1112
|
isOpen,
|
|
1113
1113
|
onClose,
|
|
1114
|
-
zIndex
|
|
1114
|
+
zIndex,
|
|
1115
|
+
error
|
|
1115
1116
|
}) {
|
|
1116
1117
|
const [status, setStatus] = (0, import_react13.useState)("confirm");
|
|
1117
1118
|
const statusMaps = {
|
|
@@ -1136,7 +1137,7 @@ function HashPanel({
|
|
|
1136
1137
|
color: "#F14141"
|
|
1137
1138
|
}
|
|
1138
1139
|
};
|
|
1139
|
-
const statusValue = statusMaps[status];
|
|
1140
|
+
const statusValue = error ? statusMaps.fail : statusMaps[status];
|
|
1140
1141
|
const [shouldRefetch, setShouldRefetch] = (0, import_react13.useState)(true);
|
|
1141
1142
|
(0, import_react13.useEffect)(() => {
|
|
1142
1143
|
if (hash) {
|
|
@@ -1190,7 +1191,8 @@ function HashPanel({
|
|
|
1190
1191
|
hash && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "matchid-hashpanel-hash", children: [
|
|
1191
1192
|
"Hash:",
|
|
1192
1193
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)("a", { href: link, target: "_blank", children: hash })
|
|
1193
|
-
] })
|
|
1194
|
+
] }),
|
|
1195
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "matchid-hashpanel-text", children: error })
|
|
1194
1196
|
] }),
|
|
1195
1197
|
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Button, { onClick: onClose, size: "lg", block: true, children: "Back" })
|
|
1196
1198
|
] })
|
|
@@ -1731,85 +1733,13 @@ var useContractStore_default = useContractStore;
|
|
|
1731
1733
|
var import_react_intl18 = require("react-intl");
|
|
1732
1734
|
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
1733
1735
|
|
|
1734
|
-
// src/
|
|
1735
|
-
var import_react_query3 = require("@tanstack/react-query");
|
|
1736
|
-
|
|
1737
|
-
// src/hooks/api/poh.ts
|
|
1738
|
-
var import_react_query4 = require("@tanstack/react-query");
|
|
1739
|
-
|
|
1740
|
-
// src/hooks/api/wallet.ts
|
|
1741
|
-
var import_react_query5 = require("@tanstack/react-query");
|
|
1742
|
-
function useChainListQuery(options) {
|
|
1743
|
-
const { isLogin, token } = useUserInfo();
|
|
1744
|
-
return (0, import_react_query5.useQuery)({
|
|
1745
|
-
queryKey: ["match-user-chain-list", token],
|
|
1746
|
-
queryFn: async () => {
|
|
1747
|
-
const res = await getUserChainListApi();
|
|
1748
|
-
if (!isSuccess(res)) {
|
|
1749
|
-
return [];
|
|
1750
|
-
}
|
|
1751
|
-
return res.data;
|
|
1752
|
-
},
|
|
1753
|
-
enabled: isLogin,
|
|
1754
|
-
...options
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
function useAssetListQuery({
|
|
1758
|
-
chainId,
|
|
1759
|
-
...options
|
|
1760
|
-
}) {
|
|
1761
|
-
const { isLogin, token } = useUserInfo();
|
|
1762
|
-
return (0, import_react_query5.useQuery)({
|
|
1763
|
-
queryKey: ["match-user-asset-list", token, chainId],
|
|
1764
|
-
queryFn: async () => {
|
|
1765
|
-
const res = await getUserWalletAssetApi({ chain_id: chainId.toString() });
|
|
1766
|
-
if (!isSuccess(res)) {
|
|
1767
|
-
return [];
|
|
1768
|
-
}
|
|
1769
|
-
return res.data || [];
|
|
1770
|
-
},
|
|
1771
|
-
enabled: isLogin,
|
|
1772
|
-
...options
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
var USER_IMPORT_TOKEN_LIST_KEY = "match-user-import-token-list";
|
|
1776
|
-
function useImportTokenListQuery({
|
|
1777
|
-
chainId,
|
|
1778
|
-
...options
|
|
1779
|
-
}) {
|
|
1780
|
-
const { isLogin, token } = useUserInfo();
|
|
1781
|
-
return (0, import_react_query5.useQuery)({
|
|
1782
|
-
queryKey: [USER_IMPORT_TOKEN_LIST_KEY, token, chainId],
|
|
1783
|
-
queryFn: async () => {
|
|
1784
|
-
const res = await getUserImportTokenListApi({ chain_id: chainId.toString() });
|
|
1785
|
-
if (!isSuccess(res)) {
|
|
1786
|
-
return [];
|
|
1787
|
-
}
|
|
1788
|
-
return res.data || [];
|
|
1789
|
-
},
|
|
1790
|
-
enabled: isLogin,
|
|
1791
|
-
...options
|
|
1792
|
-
});
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
|
-
// src/hooks/api/contact.ts
|
|
1796
|
-
var import_react_query6 = require("@tanstack/react-query");
|
|
1797
|
-
var import_last = __toESM(require("lodash/last"));
|
|
1736
|
+
// src/components/CEXBindModal/index.tsx
|
|
1798
1737
|
var import_react28 = require("react");
|
|
1799
|
-
|
|
1800
|
-
// src/components/ContactList/index.tsx
|
|
1801
|
-
var import_react_virtuoso = require("react-virtuoso");
|
|
1802
|
-
var import_react29 = require("react");
|
|
1803
1738
|
var import_react_intl19 = require("react-intl");
|
|
1804
1739
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
1805
1740
|
|
|
1806
|
-
// src/components/CEXBindModal/index.tsx
|
|
1807
|
-
var import_react30 = require("react");
|
|
1808
|
-
var import_react_intl20 = require("react-intl");
|
|
1809
|
-
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
1810
|
-
|
|
1811
1741
|
// src/context/BusinessProvider.tsx
|
|
1812
|
-
var
|
|
1742
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
1813
1743
|
|
|
1814
1744
|
// src/store/useStore.ts
|
|
1815
1745
|
var import_zustand4 = require("zustand");
|
|
@@ -1824,15 +1754,15 @@ var useStore = (0, import_zustand4.create)((set) => ({
|
|
|
1824
1754
|
var useStore_default = useStore;
|
|
1825
1755
|
|
|
1826
1756
|
// src/context/BusinessProvider.tsx
|
|
1827
|
-
var
|
|
1757
|
+
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
1828
1758
|
|
|
1829
1759
|
// src/context/ModalContext.tsx
|
|
1830
|
-
var
|
|
1760
|
+
var import_react29 = __toESM(require("react"));
|
|
1831
1761
|
var import_react_dom = require("react-dom");
|
|
1832
|
-
var
|
|
1833
|
-
var ModalContext = (0,
|
|
1762
|
+
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
1763
|
+
var ModalContext = (0, import_react29.createContext)(null);
|
|
1834
1764
|
function useModal() {
|
|
1835
|
-
const context = (0,
|
|
1765
|
+
const context = (0, import_react29.useContext)(ModalContext);
|
|
1836
1766
|
if (!context) {
|
|
1837
1767
|
throw new Error("useModal must be used within a ModalProvider");
|
|
1838
1768
|
}
|
|
@@ -1840,12 +1770,12 @@ function useModal() {
|
|
|
1840
1770
|
}
|
|
1841
1771
|
|
|
1842
1772
|
// src/context/ToastContext.tsx
|
|
1843
|
-
var
|
|
1773
|
+
var import_react30 = require("react");
|
|
1844
1774
|
var import_react_dom2 = require("react-dom");
|
|
1845
|
-
var
|
|
1846
|
-
var ToastContext = (0,
|
|
1775
|
+
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
1776
|
+
var ToastContext = (0, import_react30.createContext)(null);
|
|
1847
1777
|
function useToast() {
|
|
1848
|
-
const context = (0,
|
|
1778
|
+
const context = (0, import_react30.useContext)(ToastContext);
|
|
1849
1779
|
if (!context) {
|
|
1850
1780
|
throw new Error("useToast must be used within a ToastProvider");
|
|
1851
1781
|
}
|
|
@@ -1853,18 +1783,18 @@ function useToast() {
|
|
|
1853
1783
|
}
|
|
1854
1784
|
|
|
1855
1785
|
// src/context/index.tsx
|
|
1856
|
-
var
|
|
1786
|
+
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
1857
1787
|
|
|
1858
1788
|
// src/hooks/useWalletInit.ts
|
|
1859
|
-
var
|
|
1789
|
+
var import_react31 = require("react");
|
|
1860
1790
|
var AppClientId = getAppClientId();
|
|
1861
1791
|
|
|
1862
1792
|
// src/hooks/useInit.tsx
|
|
1863
|
-
var
|
|
1793
|
+
var import_react32 = require("react");
|
|
1864
1794
|
|
|
1865
1795
|
// src/MatchContext.tsx
|
|
1866
|
-
var
|
|
1867
|
-
var
|
|
1796
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
1797
|
+
var import_react_intl20 = require("react-intl");
|
|
1868
1798
|
var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
1869
1799
|
var import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
1870
1800
|
var import_chains = require("wagmi/chains");
|
|
@@ -1933,8 +1863,8 @@ var matchTest = /* @__PURE__ */ (0, import_viem6.defineChain)({
|
|
|
1933
1863
|
|
|
1934
1864
|
// src/MatchContext.tsx
|
|
1935
1865
|
var import_wagmi3 = require("wagmi");
|
|
1936
|
-
var
|
|
1937
|
-
var queryClient = new
|
|
1866
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
1867
|
+
var queryClient = new import_react_query4.QueryClient();
|
|
1938
1868
|
var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
|
|
1939
1869
|
appName: "MatchID",
|
|
1940
1870
|
projectId: "9ac6ea7e07860f04616fb311b447dee9",
|
|
@@ -1952,9 +1882,9 @@ var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
|
|
|
1952
1882
|
],
|
|
1953
1883
|
chains: [import_chains.mainnet, import_chains.polygon, import_chains.optimism, import_chains.arbitrum, import_chains.base, matchMain, matchTest, import_chains.bsc]
|
|
1954
1884
|
});
|
|
1955
|
-
var MatchContext = (0,
|
|
1885
|
+
var MatchContext = (0, import_react33.createContext)(void 0);
|
|
1956
1886
|
var useMatch = () => {
|
|
1957
|
-
const context = (0,
|
|
1887
|
+
const context = (0, import_react33.useContext)(MatchContext);
|
|
1958
1888
|
if (context === void 0) {
|
|
1959
1889
|
throw new Error("useMatch must be used within a MatchProvider");
|
|
1960
1890
|
}
|
|
@@ -1988,7 +1918,7 @@ function useUserInfo() {
|
|
|
1988
1918
|
const getRedirectUri = () => {
|
|
1989
1919
|
return encodeURIComponent(window.location.href);
|
|
1990
1920
|
};
|
|
1991
|
-
const isLogin = (0,
|
|
1921
|
+
const isLogin = (0, import_react34.useMemo)(() => !!token && !!overview, [token, overview]);
|
|
1992
1922
|
const logout = async () => {
|
|
1993
1923
|
try {
|
|
1994
1924
|
await toLogoutApi();
|
|
@@ -2259,9 +2189,9 @@ function useUserInfo() {
|
|
|
2259
2189
|
}
|
|
2260
2190
|
|
|
2261
2191
|
// src/hooks/useMatchEvents.ts
|
|
2262
|
-
var
|
|
2192
|
+
var import_react35 = require("react");
|
|
2263
2193
|
function useMatchEvents(handlers) {
|
|
2264
|
-
(0,
|
|
2194
|
+
(0, import_react35.useEffect)(() => {
|
|
2265
2195
|
Object.entries(handlers).forEach(([event, handler2]) => {
|
|
2266
2196
|
if (handler2) {
|
|
2267
2197
|
eventManager_default.on(event, handler2);
|
|
@@ -2281,7 +2211,7 @@ function useMatchEvents(handlers) {
|
|
|
2281
2211
|
var import_viem7 = require("viem");
|
|
2282
2212
|
var import_accounts = require("viem/accounts");
|
|
2283
2213
|
var import_viem8 = require("viem");
|
|
2284
|
-
var
|
|
2214
|
+
var import_react36 = require("react");
|
|
2285
2215
|
var import_viem9 = require("viem");
|
|
2286
2216
|
|
|
2287
2217
|
// src/store/useTransactionStore.ts
|
|
@@ -2315,7 +2245,7 @@ var useTransactionStore = (0, import_zustand5.create)((0, import_middleware3.dev
|
|
|
2315
2245
|
var useTransactionStore_default = useTransactionStore;
|
|
2316
2246
|
|
|
2317
2247
|
// src/hooks/useWallet.tsx
|
|
2318
|
-
var
|
|
2248
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
2319
2249
|
var AppClientId2 = "react-sdk-" + getVersion();
|
|
2320
2250
|
function useWallet() {
|
|
2321
2251
|
const { address, wallet: walletConfig } = useLocalStore_default();
|
|
@@ -2366,7 +2296,7 @@ function useWallet() {
|
|
|
2366
2296
|
throw error;
|
|
2367
2297
|
}
|
|
2368
2298
|
};
|
|
2369
|
-
const evmAccount = (0,
|
|
2299
|
+
const evmAccount = (0, import_react36.useMemo)(() => {
|
|
2370
2300
|
try {
|
|
2371
2301
|
return address ? (0, import_accounts.toAccount)({
|
|
2372
2302
|
address,
|
|
@@ -2405,7 +2335,7 @@ function useWallet() {
|
|
|
2405
2335
|
return void 0;
|
|
2406
2336
|
}
|
|
2407
2337
|
}, [address]);
|
|
2408
|
-
(0,
|
|
2338
|
+
(0, import_react36.useEffect)(() => {
|
|
2409
2339
|
matchlog_default.log("qwe-evmAccount", evmAccount);
|
|
2410
2340
|
}, [evmAccount]);
|
|
2411
2341
|
const realCreateWalletClient = (parameters) => {
|
|
@@ -2470,34 +2400,40 @@ function useWallet() {
|
|
|
2470
2400
|
prepareTransactionRequest
|
|
2471
2401
|
}
|
|
2472
2402
|
});
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
info: {
|
|
2480
|
-
from: evmAccount.address,
|
|
2481
|
-
to: restTransaction.to,
|
|
2482
|
-
value: (restTransaction.value || 0).toString(),
|
|
2483
|
-
input: restTransaction.data,
|
|
2484
|
-
timestamp: Math.floor(Date.now() / 1e3).toString(),
|
|
2403
|
+
try {
|
|
2404
|
+
const txHash = await obj.sendRawTransaction({
|
|
2405
|
+
serializedTransaction
|
|
2406
|
+
});
|
|
2407
|
+
addTransaction({
|
|
2408
|
+
chainId,
|
|
2485
2409
|
hash: txHash,
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2410
|
+
info: {
|
|
2411
|
+
from: evmAccount.address,
|
|
2412
|
+
to: restTransaction.to,
|
|
2413
|
+
value: (restTransaction.value || 0).toString(),
|
|
2414
|
+
input: restTransaction.data,
|
|
2415
|
+
timestamp: Math.floor(Date.now() / 1e3).toString(),
|
|
2416
|
+
hash: txHash,
|
|
2417
|
+
source: "local"
|
|
2418
|
+
},
|
|
2419
|
+
address: evmAccount.address
|
|
2420
|
+
});
|
|
2421
|
+
modal.show((props) => {
|
|
2422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(HashPanel_default, { isOpen: true, onClose: props.close, zIndex: props.zIndex, hash: txHash, chain: _chain });
|
|
2423
|
+
});
|
|
2424
|
+
return txHash;
|
|
2425
|
+
} catch (error) {
|
|
2426
|
+
modal.show((props) => {
|
|
2427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(HashPanel_default, { isOpen: true, onClose: props.close, zIndex: props.zIndex, error: typeof error == "string" ? error : error.details || error.message, chain: _chain });
|
|
2428
|
+
});
|
|
2429
|
+
throw error;
|
|
2430
|
+
}
|
|
2496
2431
|
} catch (error) {
|
|
2497
|
-
console.error("
|
|
2432
|
+
console.error("matchid-send-error", error);
|
|
2433
|
+
throw error;
|
|
2434
|
+
} finally {
|
|
2498
2435
|
clearInterval(window.matchProvider.transactionMessageIntervalMap[transactionId].interval);
|
|
2499
2436
|
delete window.matchProvider.transactionMessageIntervalMap[transactionId];
|
|
2500
|
-
throw error;
|
|
2501
2437
|
}
|
|
2502
2438
|
};
|
|
2503
2439
|
const deployContract = async (parameters2) => {
|
|
@@ -2541,14 +2477,14 @@ function useWallet() {
|
|
|
2541
2477
|
|
|
2542
2478
|
// src/hooks/useCopyClipboard.ts
|
|
2543
2479
|
var import_copy_to_clipboard = __toESM(require("copy-to-clipboard"));
|
|
2544
|
-
var
|
|
2480
|
+
var import_react37 = require("react");
|
|
2545
2481
|
function useCopyClipboard(timeout = 500) {
|
|
2546
|
-
const [isCopied, setIsCopied] = (0,
|
|
2547
|
-
const staticCopy = (0,
|
|
2482
|
+
const [isCopied, setIsCopied] = (0, import_react37.useState)(false);
|
|
2483
|
+
const staticCopy = (0, import_react37.useCallback)((text) => {
|
|
2548
2484
|
const didCopy = (0, import_copy_to_clipboard.default)(text);
|
|
2549
2485
|
setIsCopied(didCopy);
|
|
2550
2486
|
}, []);
|
|
2551
|
-
(0,
|
|
2487
|
+
(0, import_react37.useEffect)(() => {
|
|
2552
2488
|
if (isCopied) {
|
|
2553
2489
|
const hide = setTimeout(() => {
|
|
2554
2490
|
setIsCopied(false);
|
|
@@ -2562,17 +2498,72 @@ function useCopyClipboard(timeout = 500) {
|
|
|
2562
2498
|
return [isCopied, staticCopy];
|
|
2563
2499
|
}
|
|
2564
2500
|
|
|
2501
|
+
// src/hooks/api/wallet.ts
|
|
2502
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
2503
|
+
function useChainListQuery(options) {
|
|
2504
|
+
const { isLogin, token } = useUserInfo();
|
|
2505
|
+
return (0, import_react_query5.useQuery)({
|
|
2506
|
+
queryKey: ["match-user-chain-list", token],
|
|
2507
|
+
queryFn: async () => {
|
|
2508
|
+
const res = await getUserChainListApi();
|
|
2509
|
+
if (!isSuccess(res)) {
|
|
2510
|
+
return [];
|
|
2511
|
+
}
|
|
2512
|
+
return res.data;
|
|
2513
|
+
},
|
|
2514
|
+
enabled: isLogin,
|
|
2515
|
+
...options
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
function useAssetListQuery({
|
|
2519
|
+
chainId,
|
|
2520
|
+
...options
|
|
2521
|
+
}) {
|
|
2522
|
+
const { isLogin, token } = useUserInfo();
|
|
2523
|
+
return (0, import_react_query5.useQuery)({
|
|
2524
|
+
queryKey: ["match-user-asset-list", token, chainId],
|
|
2525
|
+
queryFn: async () => {
|
|
2526
|
+
const res = await getUserWalletAssetApi({ chain_id: chainId.toString() });
|
|
2527
|
+
if (!isSuccess(res)) {
|
|
2528
|
+
return [];
|
|
2529
|
+
}
|
|
2530
|
+
return res.data || [];
|
|
2531
|
+
},
|
|
2532
|
+
enabled: isLogin,
|
|
2533
|
+
...options
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
var USER_IMPORT_TOKEN_LIST_KEY = "match-user-import-token-list";
|
|
2537
|
+
function useImportTokenListQuery({
|
|
2538
|
+
chainId,
|
|
2539
|
+
...options
|
|
2540
|
+
}) {
|
|
2541
|
+
const { isLogin, token } = useUserInfo();
|
|
2542
|
+
return (0, import_react_query5.useQuery)({
|
|
2543
|
+
queryKey: [USER_IMPORT_TOKEN_LIST_KEY, token, chainId],
|
|
2544
|
+
queryFn: async () => {
|
|
2545
|
+
const res = await getUserImportTokenListApi({ chain_id: chainId.toString() });
|
|
2546
|
+
if (!isSuccess(res)) {
|
|
2547
|
+
return [];
|
|
2548
|
+
}
|
|
2549
|
+
return res.data || [];
|
|
2550
|
+
},
|
|
2551
|
+
enabled: isLogin,
|
|
2552
|
+
...options
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2565
2556
|
// src/hooks/useMatchChain.tsx
|
|
2566
|
-
var
|
|
2557
|
+
var import_react38 = require("react");
|
|
2567
2558
|
var import_viem10 = require("viem");
|
|
2568
|
-
var
|
|
2569
|
-
var
|
|
2559
|
+
var import_react_intl21 = require("react-intl");
|
|
2560
|
+
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
2570
2561
|
function useMatchChain() {
|
|
2571
2562
|
const chainListQuery = useChainListQuery();
|
|
2572
2563
|
const modal = useModal();
|
|
2573
|
-
const intl = (0,
|
|
2564
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
2574
2565
|
const { chainId: storeChainId, setChainId } = useLocalStore_default();
|
|
2575
|
-
const chainId = (0,
|
|
2566
|
+
const chainId = (0, import_react38.useMemo)(() => {
|
|
2576
2567
|
if (!chainListQuery.data || !chainListQuery.data.length) {
|
|
2577
2568
|
return null;
|
|
2578
2569
|
}
|
|
@@ -2581,7 +2572,7 @@ function useMatchChain() {
|
|
|
2581
2572
|
}
|
|
2582
2573
|
return chainListQuery.data[0].id;
|
|
2583
2574
|
}, [storeChainId, chainListQuery.data]);
|
|
2584
|
-
const chain = (0,
|
|
2575
|
+
const chain = (0, import_react38.useMemo)(() => {
|
|
2585
2576
|
if (!chainListQuery.data || !chainListQuery.data.length) {
|
|
2586
2577
|
return null;
|
|
2587
2578
|
}
|
|
@@ -2595,30 +2586,30 @@ function useMatchChain() {
|
|
|
2595
2586
|
close
|
|
2596
2587
|
}) {
|
|
2597
2588
|
const { chainId: storeChainId2, setChainId: setChainId2 } = useLocalStore_default();
|
|
2598
|
-
const [selectedChainId, setSelectedChainId] = (0,
|
|
2589
|
+
const [selectedChainId, setSelectedChainId] = (0, import_react38.useState)(storeChainId2);
|
|
2599
2590
|
const isDownMd = useDownMd();
|
|
2600
|
-
return /* @__PURE__ */ (0,
|
|
2601
|
-
/* @__PURE__ */ (0,
|
|
2602
|
-
return /* @__PURE__ */ (0,
|
|
2591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: `matchid-change-network-box`, children: [
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: `matchid-change-network-list`, children: chainListQuery.data?.map((item, index) => {
|
|
2593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
|
|
2603
2594
|
"div",
|
|
2604
2595
|
{
|
|
2605
2596
|
onClick: () => setSelectedChainId(item.id),
|
|
2606
2597
|
className: `matchid-change-network-item ${selectedChainId == item.id ? "matchid-change-network-selected" : ""}`,
|
|
2607
2598
|
children: [
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
/* @__PURE__ */ (0,
|
|
2610
|
-
/* @__PURE__ */ (0,
|
|
2599
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: `matchid-change-network-item-content`, children: [
|
|
2600
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("img", { src: item.iconUrl, className: `matchid-change-network-item-icon` }),
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("span", { className: "matchid-change-network-item-name", children: item.name })
|
|
2611
2602
|
] }),
|
|
2612
|
-
/* @__PURE__ */ (0,
|
|
2603
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Radio, { checked: selectedChainId === item.id, size: isDownMd ? 18 : 24 })
|
|
2613
2604
|
]
|
|
2614
2605
|
},
|
|
2615
2606
|
index
|
|
2616
2607
|
);
|
|
2617
2608
|
}) }),
|
|
2618
|
-
/* @__PURE__ */ (0,
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Button, { size: "lg", highlight: true, onClick: () => {
|
|
2619
2610
|
setChainId2(selectedChainId || 0);
|
|
2620
2611
|
close();
|
|
2621
|
-
}, block: true, children: /* @__PURE__ */ (0,
|
|
2612
|
+
}, block: true, children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_react_intl21.FormattedMessage, { id: "confirm" }) })
|
|
2622
2613
|
] });
|
|
2623
2614
|
}
|
|
2624
2615
|
const showChangeNetwork = () => {
|
|
@@ -2627,7 +2618,7 @@ function useMatchChain() {
|
|
|
2627
2618
|
content: ChangeNetwork
|
|
2628
2619
|
});
|
|
2629
2620
|
};
|
|
2630
|
-
const publicClient = (0,
|
|
2621
|
+
const publicClient = (0, import_react38.useMemo)(() => {
|
|
2631
2622
|
if (!chain) {
|
|
2632
2623
|
return null;
|
|
2633
2624
|
}
|
|
@@ -2655,26 +2646,26 @@ function useMatchChain() {
|
|
|
2655
2646
|
|
|
2656
2647
|
// src/hooks/useMatchWallet.tsx
|
|
2657
2648
|
var import_react_qrcode = require("react-qrcode");
|
|
2658
|
-
var
|
|
2659
|
-
var
|
|
2649
|
+
var import_react40 = require("react");
|
|
2650
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
2660
2651
|
var import_viem13 = require("viem");
|
|
2661
|
-
var
|
|
2652
|
+
var import_react_intl23 = require("react-intl");
|
|
2662
2653
|
|
|
2663
2654
|
// src/components/ImportToken/index.tsx
|
|
2664
|
-
var
|
|
2665
|
-
var
|
|
2666
|
-
var
|
|
2655
|
+
var import_react39 = require("react");
|
|
2656
|
+
var import_react_intl22 = require("react-intl");
|
|
2657
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
2667
2658
|
var import_viem12 = require("viem");
|
|
2668
2659
|
|
|
2669
2660
|
// src/hooks/useIsContract.ts
|
|
2670
2661
|
var import_viem11 = require("viem");
|
|
2671
|
-
var
|
|
2662
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
2672
2663
|
function useIsContract({
|
|
2673
2664
|
address,
|
|
2674
2665
|
chain,
|
|
2675
2666
|
enabled
|
|
2676
2667
|
}) {
|
|
2677
|
-
return (0,
|
|
2668
|
+
return (0, import_react_query6.useQuery)({
|
|
2678
2669
|
queryKey: ["is_contract", chain?.id, address],
|
|
2679
2670
|
queryFn: async () => {
|
|
2680
2671
|
if (!chain) return false;
|
|
@@ -2691,14 +2682,14 @@ function useIsContract({
|
|
|
2691
2682
|
}
|
|
2692
2683
|
|
|
2693
2684
|
// src/components/ImportToken/index.tsx
|
|
2694
|
-
var
|
|
2685
|
+
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
2695
2686
|
function ImportToken({ close }) {
|
|
2696
|
-
const [status, setStatus] = (0,
|
|
2687
|
+
const [status, setStatus] = (0, import_react39.useState)("");
|
|
2697
2688
|
const { token } = useUserInfo();
|
|
2698
|
-
const [address, setAddress] = (0,
|
|
2699
|
-
const [symbol, setSymbol] = (0,
|
|
2700
|
-
const [decimals, setDecimals] = (0,
|
|
2701
|
-
const [error, setError] = (0,
|
|
2689
|
+
const [address, setAddress] = (0, import_react39.useState)("");
|
|
2690
|
+
const [symbol, setSymbol] = (0, import_react39.useState)("");
|
|
2691
|
+
const [decimals, setDecimals] = (0, import_react39.useState)("");
|
|
2692
|
+
const [error, setError] = (0, import_react39.useState)({});
|
|
2702
2693
|
const { publicClient, chainId, chain } = useMatchChain();
|
|
2703
2694
|
const getContractInfo = async () => {
|
|
2704
2695
|
if (!publicClient) return;
|
|
@@ -2731,8 +2722,8 @@ function ImportToken({ close }) {
|
|
|
2731
2722
|
});
|
|
2732
2723
|
}
|
|
2733
2724
|
};
|
|
2734
|
-
const intl = (0,
|
|
2735
|
-
(0,
|
|
2725
|
+
const intl = (0, import_react_intl22.useIntl)();
|
|
2726
|
+
(0, import_react39.useEffect)(() => {
|
|
2736
2727
|
if (address.length === 42) {
|
|
2737
2728
|
const reg = /^0x[0-9a-fA-F]{40}$/;
|
|
2738
2729
|
if (!reg.test(address)) {
|
|
@@ -2751,9 +2742,9 @@ function ImportToken({ close }) {
|
|
|
2751
2742
|
}
|
|
2752
2743
|
}
|
|
2753
2744
|
}, [address, publicClient]);
|
|
2754
|
-
const [loading, setLoading] = (0,
|
|
2745
|
+
const [loading, setLoading] = (0, import_react39.useState)(false);
|
|
2755
2746
|
const toast = useToast();
|
|
2756
|
-
const queryClient2 = (0,
|
|
2747
|
+
const queryClient2 = (0, import_react_query7.useQueryClient)();
|
|
2757
2748
|
const onImport = async () => {
|
|
2758
2749
|
setLoading(true);
|
|
2759
2750
|
try {
|
|
@@ -2779,7 +2770,7 @@ function ImportToken({ close }) {
|
|
|
2779
2770
|
setLoading(false);
|
|
2780
2771
|
}
|
|
2781
2772
|
};
|
|
2782
|
-
const canImport = (0,
|
|
2773
|
+
const canImport = (0, import_react39.useMemo)(() => {
|
|
2783
2774
|
if (!address) {
|
|
2784
2775
|
return false;
|
|
2785
2776
|
}
|
|
@@ -2802,19 +2793,19 @@ function ImportToken({ close }) {
|
|
|
2802
2793
|
enabled: canImport
|
|
2803
2794
|
});
|
|
2804
2795
|
if (status == "success" || status == "fail") {
|
|
2805
|
-
return /* @__PURE__ */ (0,
|
|
2806
|
-
/* @__PURE__ */ (0,
|
|
2807
|
-
/* @__PURE__ */ (0,
|
|
2808
|
-
/* @__PURE__ */ (0,
|
|
2796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-import-token-result matchid-flex`, children: [
|
|
2797
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-import-token-result-box matchid-flex`, children: [
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("img", { src: status == "success" ? success_default : fail_default, alt: status == "success" ? "success" : "fail", className: `matchid-import-token-result-img` }),
|
|
2799
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: `matchid-import-token-result-text matchid-import-token-result-text-${status}`, children: status == "success" ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "importSuccess" }) : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "importFail" }) })
|
|
2809
2800
|
] }),
|
|
2810
|
-
status == "success" ? /* @__PURE__ */ (0,
|
|
2801
|
+
status == "success" ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Button, { size: "lg", onClick: close, block: true, highlight: true, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "close" }) }) : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Button, { size: "lg", onClick: () => setStatus(""), block: true, highlight: true, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "back" }) })
|
|
2811
2802
|
] });
|
|
2812
2803
|
}
|
|
2813
|
-
return /* @__PURE__ */ (0,
|
|
2814
|
-
/* @__PURE__ */ (0,
|
|
2815
|
-
/* @__PURE__ */ (0,
|
|
2804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-import-token`, children: [
|
|
2805
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "matchid-import-token-form", children: [
|
|
2806
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Field, { label: intl.formatMessage({
|
|
2816
2807
|
id: "tokenSmartContract"
|
|
2817
|
-
}), error: error.address ? error.address : isContractQuery.isFetched && !isContractQuery.isLoading && !isContractQuery.data && canImport ? "Address isn't a contract address" : "", children: /* @__PURE__ */ (0,
|
|
2808
|
+
}), error: error.address ? error.address : isContractQuery.isFetched && !isContractQuery.isLoading && !isContractQuery.data && canImport ? "Address isn't a contract address" : "", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2818
2809
|
Input,
|
|
2819
2810
|
{
|
|
2820
2811
|
placeholder: intl.formatMessage({
|
|
@@ -2825,9 +2816,9 @@ function ImportToken({ close }) {
|
|
|
2825
2816
|
maxLength: 42
|
|
2826
2817
|
}
|
|
2827
2818
|
) }),
|
|
2828
|
-
/* @__PURE__ */ (0,
|
|
2819
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Field, { label: intl.formatMessage({
|
|
2829
2820
|
id: "tokenSymbol"
|
|
2830
|
-
}), error: error.symbol, children: /* @__PURE__ */ (0,
|
|
2821
|
+
}), error: error.symbol, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2831
2822
|
Input,
|
|
2832
2823
|
{
|
|
2833
2824
|
placeholder: intl.formatMessage({
|
|
@@ -2838,9 +2829,9 @@ function ImportToken({ close }) {
|
|
|
2838
2829
|
maxLength: 16
|
|
2839
2830
|
}
|
|
2840
2831
|
) }),
|
|
2841
|
-
/* @__PURE__ */ (0,
|
|
2832
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Field, { label: intl.formatMessage({
|
|
2842
2833
|
id: "tokenDecimals"
|
|
2843
|
-
}), error: error.decimals, children: /* @__PURE__ */ (0,
|
|
2834
|
+
}), error: error.decimals, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2844
2835
|
Input,
|
|
2845
2836
|
{
|
|
2846
2837
|
placeholder: intl.formatMessage({
|
|
@@ -2852,7 +2843,7 @@ function ImportToken({ close }) {
|
|
|
2852
2843
|
}
|
|
2853
2844
|
) })
|
|
2854
2845
|
] }),
|
|
2855
|
-
/* @__PURE__ */ (0,
|
|
2846
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2856
2847
|
Button,
|
|
2857
2848
|
{
|
|
2858
2849
|
size: "lg",
|
|
@@ -2861,20 +2852,20 @@ function ImportToken({ close }) {
|
|
|
2861
2852
|
loading: loading || isContractQuery.isLoading,
|
|
2862
2853
|
disabled: !canImport || !isContractQuery.data,
|
|
2863
2854
|
highlight: true,
|
|
2864
|
-
children: /* @__PURE__ */ (0,
|
|
2855
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "import" })
|
|
2865
2856
|
}
|
|
2866
2857
|
)
|
|
2867
2858
|
] });
|
|
2868
2859
|
}
|
|
2869
2860
|
|
|
2870
2861
|
// src/hooks/useMatchWallet.tsx
|
|
2871
|
-
var
|
|
2862
|
+
var import_jsx_runtime98 = require("react/jsx-runtime");
|
|
2872
2863
|
var ReceiveModal = () => {
|
|
2873
2864
|
const chain = useMatchChain();
|
|
2874
2865
|
const { address } = useWallet();
|
|
2875
2866
|
const [copied, setCopied] = useCopyClipboard();
|
|
2876
2867
|
const toast = useToast();
|
|
2877
|
-
const intl = (0,
|
|
2868
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
2878
2869
|
const onCopy = () => {
|
|
2879
2870
|
setCopied(address);
|
|
2880
2871
|
toast.success(intl.formatMessage({
|
|
@@ -2882,10 +2873,10 @@ var ReceiveModal = () => {
|
|
|
2882
2873
|
}));
|
|
2883
2874
|
};
|
|
2884
2875
|
const chainLink = chain.explorerLink("address/" + address);
|
|
2885
|
-
return /* @__PURE__ */ (0,
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2887
|
-
/* @__PURE__ */ (0,
|
|
2888
|
-
/* @__PURE__ */ (0,
|
|
2876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: `matchid-receive-modal`, children: [
|
|
2877
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: "matchid-receive-container", children: [
|
|
2878
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: `matchid-receive-text`, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "receiveQrcode" }) }),
|
|
2879
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2889
2880
|
import_react_qrcode.QRCode,
|
|
2890
2881
|
{
|
|
2891
2882
|
margin: "0",
|
|
@@ -2893,7 +2884,7 @@ var ReceiveModal = () => {
|
|
|
2893
2884
|
value: address
|
|
2894
2885
|
}
|
|
2895
2886
|
) }),
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
2887
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2897
2888
|
"a",
|
|
2898
2889
|
{
|
|
2899
2890
|
href: chainLink,
|
|
@@ -2903,8 +2894,8 @@ var ReceiveModal = () => {
|
|
|
2903
2894
|
}
|
|
2904
2895
|
)
|
|
2905
2896
|
] }),
|
|
2906
|
-
/* @__PURE__ */ (0,
|
|
2907
|
-
|
|
2897
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2898
|
+
import_react_intl23.FormattedMessage,
|
|
2908
2899
|
{
|
|
2909
2900
|
id: "copyAddress"
|
|
2910
2901
|
}
|
|
@@ -2913,7 +2904,7 @@ var ReceiveModal = () => {
|
|
|
2913
2904
|
};
|
|
2914
2905
|
function useMatchWallet() {
|
|
2915
2906
|
const modal = useModal();
|
|
2916
|
-
const intl = (0,
|
|
2907
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
2917
2908
|
const showReceiveModal = () => {
|
|
2918
2909
|
modal.open({
|
|
2919
2910
|
title: intl.formatMessage({
|
|
@@ -2945,12 +2936,12 @@ function useMatchWallet() {
|
|
|
2945
2936
|
};
|
|
2946
2937
|
}
|
|
2947
2938
|
function useMatchWalletRecords() {
|
|
2948
|
-
const [hasMore, setHasMore] = (0,
|
|
2949
|
-
const [items, setItems] = (0,
|
|
2939
|
+
const [hasMore, setHasMore] = (0, import_react40.useState)(true);
|
|
2940
|
+
const [items, setItems] = (0, import_react40.useState)([]);
|
|
2950
2941
|
const { chainId, publicClient } = useMatchChain();
|
|
2951
2942
|
const { address } = useWallet();
|
|
2952
|
-
const hasMoreRef = (0,
|
|
2953
|
-
const nextPageParamsRef = (0,
|
|
2943
|
+
const hasMoreRef = (0, import_react40.useRef)(hasMore);
|
|
2944
|
+
const nextPageParamsRef = (0, import_react40.useRef)(void 0);
|
|
2954
2945
|
const { contracts, setContracts } = useContractStore_default();
|
|
2955
2946
|
const fetchMoreData = async () => {
|
|
2956
2947
|
const chainIdStr = chainId ? chainId.toString() : "";
|
|
@@ -2977,7 +2968,7 @@ function useMatchWalletRecords() {
|
|
|
2977
2968
|
hasMoreRef.current = true;
|
|
2978
2969
|
fetchMoreData();
|
|
2979
2970
|
};
|
|
2980
|
-
(0,
|
|
2971
|
+
(0, import_react40.useEffect)(() => {
|
|
2981
2972
|
if (chainId && address) {
|
|
2982
2973
|
onInit();
|
|
2983
2974
|
}
|
|
@@ -3033,7 +3024,7 @@ function useMatchWalletRecords() {
|
|
|
3033
3024
|
setContracts(contractMap);
|
|
3034
3025
|
}
|
|
3035
3026
|
};
|
|
3036
|
-
const list = (0,
|
|
3027
|
+
const list = (0, import_react40.useMemo)(() => {
|
|
3037
3028
|
const localTransactions = transactions[`${chainId}-${address}`] || [];
|
|
3038
3029
|
const removeList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
|
|
3039
3030
|
removeList.forEach((item) => {
|
|
@@ -3075,7 +3066,7 @@ function useMatchWalletAssets({
|
|
|
3075
3066
|
chainId: chainId || 0,
|
|
3076
3067
|
...assetListOptions
|
|
3077
3068
|
});
|
|
3078
|
-
const mergedAssets = (0,
|
|
3069
|
+
const mergedAssets = (0, import_react40.useMemo)(() => {
|
|
3079
3070
|
if (!assetListQuery.data && !importTokenQuery.data) return [];
|
|
3080
3071
|
const assetList = (assetListQuery.data || []).map((asset) => ({
|
|
3081
3072
|
...asset,
|
|
@@ -3143,7 +3134,7 @@ function useMatchWalletAssetList({
|
|
|
3143
3134
|
name: chain?.nativeCurrency.name,
|
|
3144
3135
|
balance: 0
|
|
3145
3136
|
};
|
|
3146
|
-
const nativeBalanceQuery = (0,
|
|
3137
|
+
const nativeBalanceQuery = (0, import_react_query8.useQuery)({
|
|
3147
3138
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
3148
3139
|
queryFn: async () => {
|
|
3149
3140
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -3162,8 +3153,8 @@ function useMatchWalletAssetList({
|
|
|
3162
3153
|
retry: 3
|
|
3163
3154
|
// Retry up to 3 times if failed
|
|
3164
3155
|
});
|
|
3165
|
-
const erc20Tokens = (0,
|
|
3166
|
-
const erc20BalanceQuery = (0,
|
|
3156
|
+
const erc20Tokens = (0, import_react40.useMemo)(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
3157
|
+
const erc20BalanceQuery = (0, import_react_query8.useQuery)({
|
|
3167
3158
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
3168
3159
|
queryFn: async () => {
|
|
3169
3160
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
@@ -3190,7 +3181,7 @@ function useMatchWalletAssetList({
|
|
|
3190
3181
|
// Refresh every 15 seconds
|
|
3191
3182
|
retry: 3
|
|
3192
3183
|
});
|
|
3193
|
-
const enrichedAssets = (0,
|
|
3184
|
+
const enrichedAssets = (0, import_react40.useMemo)(() => {
|
|
3194
3185
|
if (!list) return [];
|
|
3195
3186
|
const erc20Balances = erc20BalanceQuery.data || [];
|
|
3196
3187
|
return list.map((asset) => {
|
|
@@ -3212,7 +3203,7 @@ function useMatchWalletAssetList({
|
|
|
3212
3203
|
return { ...asset, balance, value, balanceValue };
|
|
3213
3204
|
});
|
|
3214
3205
|
}, [list, nativeBalanceQuery.data, erc20BalanceQuery.data]);
|
|
3215
|
-
(0,
|
|
3206
|
+
(0, import_react40.useEffect)(() => {
|
|
3216
3207
|
const list2 = enrichedAssets.sort((a, b) => {
|
|
3217
3208
|
if (a.address === NATIVE_TOKEN_ADDRESS) return -1;
|
|
3218
3209
|
if (b.address === NATIVE_TOKEN_ADDRESS) return 1;
|
|
@@ -3237,14 +3228,14 @@ function useMatchWalletAssetList({
|
|
|
3237
3228
|
}
|
|
3238
3229
|
|
|
3239
3230
|
// src/hooks/useReceipt.tsx
|
|
3240
|
-
var
|
|
3241
|
-
var
|
|
3231
|
+
var import_react41 = require("react");
|
|
3232
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
3242
3233
|
var import_viem14 = require("viem");
|
|
3243
3234
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
3244
3235
|
var MAX_CACHE_SIZE = 500;
|
|
3245
3236
|
var STORAGE_KEY = "match_receipt_logs";
|
|
3246
3237
|
function useReceiptCache() {
|
|
3247
|
-
const [cache, setCache] = (0,
|
|
3238
|
+
const [cache, setCache] = (0, import_react41.useState)(/* @__PURE__ */ new Map());
|
|
3248
3239
|
const isLocalStorageAvailable = (() => {
|
|
3249
3240
|
try {
|
|
3250
3241
|
const testKey = "__test__";
|
|
@@ -3255,7 +3246,7 @@ function useReceiptCache() {
|
|
|
3255
3246
|
return false;
|
|
3256
3247
|
}
|
|
3257
3248
|
})();
|
|
3258
|
-
(0,
|
|
3249
|
+
(0, import_react41.useEffect)(() => {
|
|
3259
3250
|
if (isLocalStorageAvailable) {
|
|
3260
3251
|
try {
|
|
3261
3252
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3274,7 +3265,7 @@ function useReceiptCache() {
|
|
|
3274
3265
|
}
|
|
3275
3266
|
}
|
|
3276
3267
|
}, []);
|
|
3277
|
-
const updateLocalStorage = (0,
|
|
3268
|
+
const updateLocalStorage = (0, import_react41.useCallback)((updatedCache) => {
|
|
3278
3269
|
if (isLocalStorageAvailable) {
|
|
3279
3270
|
try {
|
|
3280
3271
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3291,7 +3282,7 @@ function useReceiptCache() {
|
|
|
3291
3282
|
}
|
|
3292
3283
|
}
|
|
3293
3284
|
}, []);
|
|
3294
|
-
const set = (0,
|
|
3285
|
+
const set = (0, import_react41.useCallback)((key, value) => {
|
|
3295
3286
|
const now = Date.now();
|
|
3296
3287
|
const newCache = new Map(cache);
|
|
3297
3288
|
newCache.forEach((entry, k) => {
|
|
@@ -3309,7 +3300,7 @@ function useReceiptCache() {
|
|
|
3309
3300
|
setCache(newCache);
|
|
3310
3301
|
updateLocalStorage(newCache);
|
|
3311
3302
|
}, [cache, updateLocalStorage]);
|
|
3312
|
-
const get = (0,
|
|
3303
|
+
const get = (0, import_react41.useCallback)((key) => {
|
|
3313
3304
|
const entry = cache.get(key);
|
|
3314
3305
|
if (entry) {
|
|
3315
3306
|
if (Date.now() - entry.timestamp > CACHE_TTL) {
|
|
@@ -3323,7 +3314,7 @@ function useReceiptCache() {
|
|
|
3323
3314
|
}
|
|
3324
3315
|
return void 0;
|
|
3325
3316
|
}, [cache, updateLocalStorage]);
|
|
3326
|
-
const del = (0,
|
|
3317
|
+
const del = (0, import_react41.useCallback)((key) => {
|
|
3327
3318
|
if (cache.has(key)) {
|
|
3328
3319
|
const newCache = new Map(cache);
|
|
3329
3320
|
newCache.delete(key);
|
|
@@ -3331,7 +3322,7 @@ function useReceiptCache() {
|
|
|
3331
3322
|
updateLocalStorage(newCache);
|
|
3332
3323
|
}
|
|
3333
3324
|
}, [cache, updateLocalStorage]);
|
|
3334
|
-
const clear = (0,
|
|
3325
|
+
const clear = (0, import_react41.useCallback)(() => {
|
|
3335
3326
|
setCache(/* @__PURE__ */ new Map());
|
|
3336
3327
|
if (isLocalStorageAvailable) {
|
|
3337
3328
|
localStorage.removeItem(STORAGE_KEY);
|
|
@@ -3346,8 +3337,8 @@ function useReceipt2({
|
|
|
3346
3337
|
const { list } = useMatchChain();
|
|
3347
3338
|
const cache = useReceiptCache();
|
|
3348
3339
|
const chain = list?.find((item) => item.id === chainId);
|
|
3349
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3350
|
-
const query = (0,
|
|
3340
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react41.useState)(true);
|
|
3341
|
+
const query = (0, import_react_query9.useQuery)({
|
|
3351
3342
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
3352
3343
|
queryFn: async () => {
|
|
3353
3344
|
if (!chain || !hash) return false;
|
|
@@ -3372,7 +3363,7 @@ function useReceipt2({
|
|
|
3372
3363
|
},
|
|
3373
3364
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3374
3365
|
});
|
|
3375
|
-
(0,
|
|
3366
|
+
(0, import_react41.useEffect)(() => {
|
|
3376
3367
|
if (query.data) {
|
|
3377
3368
|
setShouldRefetch(false);
|
|
3378
3369
|
}
|
|
@@ -3381,14 +3372,14 @@ function useReceipt2({
|
|
|
3381
3372
|
}
|
|
3382
3373
|
|
|
3383
3374
|
// src/hooks/useTransaction.tsx
|
|
3384
|
-
var
|
|
3385
|
-
var
|
|
3375
|
+
var import_react42 = require("react");
|
|
3376
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
3386
3377
|
var import_viem15 = require("viem");
|
|
3387
3378
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
3388
3379
|
var MAX_CACHE_SIZE2 = 500;
|
|
3389
3380
|
var STORAGE_KEY2 = "match_transaction_logs";
|
|
3390
3381
|
function useTransactionCache() {
|
|
3391
|
-
const [cache, setCache] = (0,
|
|
3382
|
+
const [cache, setCache] = (0, import_react42.useState)(/* @__PURE__ */ new Map());
|
|
3392
3383
|
const isLocalStorageAvailable = (() => {
|
|
3393
3384
|
try {
|
|
3394
3385
|
const testKey = "__test__";
|
|
@@ -3399,7 +3390,7 @@ function useTransactionCache() {
|
|
|
3399
3390
|
return false;
|
|
3400
3391
|
}
|
|
3401
3392
|
})();
|
|
3402
|
-
(0,
|
|
3393
|
+
(0, import_react42.useEffect)(() => {
|
|
3403
3394
|
if (isLocalStorageAvailable) {
|
|
3404
3395
|
try {
|
|
3405
3396
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3418,7 +3409,7 @@ function useTransactionCache() {
|
|
|
3418
3409
|
}
|
|
3419
3410
|
}
|
|
3420
3411
|
}, []);
|
|
3421
|
-
const updateLocalStorage = (0,
|
|
3412
|
+
const updateLocalStorage = (0, import_react42.useCallback)((updatedCache) => {
|
|
3422
3413
|
if (isLocalStorageAvailable) {
|
|
3423
3414
|
try {
|
|
3424
3415
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3435,7 +3426,7 @@ function useTransactionCache() {
|
|
|
3435
3426
|
}
|
|
3436
3427
|
}
|
|
3437
3428
|
}, []);
|
|
3438
|
-
const set = (0,
|
|
3429
|
+
const set = (0, import_react42.useCallback)((key, value) => {
|
|
3439
3430
|
const now = Date.now();
|
|
3440
3431
|
const newCache = new Map(cache);
|
|
3441
3432
|
newCache.forEach((entry, k) => {
|
|
@@ -3453,7 +3444,7 @@ function useTransactionCache() {
|
|
|
3453
3444
|
setCache(newCache);
|
|
3454
3445
|
updateLocalStorage(newCache);
|
|
3455
3446
|
}, [cache, updateLocalStorage]);
|
|
3456
|
-
const get = (0,
|
|
3447
|
+
const get = (0, import_react42.useCallback)((key) => {
|
|
3457
3448
|
const entry = cache.get(key);
|
|
3458
3449
|
if (entry) {
|
|
3459
3450
|
if (Date.now() - entry.timestamp > CACHE_TTL2) {
|
|
@@ -3467,7 +3458,7 @@ function useTransactionCache() {
|
|
|
3467
3458
|
}
|
|
3468
3459
|
return void 0;
|
|
3469
3460
|
}, [cache, updateLocalStorage]);
|
|
3470
|
-
const del = (0,
|
|
3461
|
+
const del = (0, import_react42.useCallback)((key) => {
|
|
3471
3462
|
if (cache.has(key)) {
|
|
3472
3463
|
const newCache = new Map(cache);
|
|
3473
3464
|
newCache.delete(key);
|
|
@@ -3475,7 +3466,7 @@ function useTransactionCache() {
|
|
|
3475
3466
|
updateLocalStorage(newCache);
|
|
3476
3467
|
}
|
|
3477
3468
|
}, [cache, updateLocalStorage]);
|
|
3478
|
-
const clear = (0,
|
|
3469
|
+
const clear = (0, import_react42.useCallback)(() => {
|
|
3479
3470
|
setCache(/* @__PURE__ */ new Map());
|
|
3480
3471
|
if (isLocalStorageAvailable) {
|
|
3481
3472
|
localStorage.removeItem(STORAGE_KEY2);
|
|
@@ -3490,8 +3481,8 @@ function useTransaction({
|
|
|
3490
3481
|
const { list } = useMatchChain();
|
|
3491
3482
|
const cache = useTransactionCache();
|
|
3492
3483
|
const chain = list?.find((item) => item.id === chainId);
|
|
3493
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3494
|
-
const query = (0,
|
|
3484
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react42.useState)(true);
|
|
3485
|
+
const query = (0, import_react_query10.useQuery)({
|
|
3495
3486
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
3496
3487
|
queryFn: async () => {
|
|
3497
3488
|
if (!chain || !hash) return false;
|
|
@@ -3516,7 +3507,7 @@ function useTransaction({
|
|
|
3516
3507
|
},
|
|
3517
3508
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3518
3509
|
});
|
|
3519
|
-
(0,
|
|
3510
|
+
(0, import_react42.useEffect)(() => {
|
|
3520
3511
|
if (query.data) {
|
|
3521
3512
|
setShouldRefetch(false);
|
|
3522
3513
|
}
|