@matchain/matchid-sdk-react 0.1.54 → 0.1.55-alpha.0
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-ZPBHHXEE.mjs → chunk-36M5ROJI.mjs} +6543 -6897
- package/dist/chunk-36M5ROJI.mjs.map +1 -0
- package/dist/chunk-N7NX7Q7M.mjs +97 -0
- package/dist/chunk-N7NX7Q7M.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 +0 -354
- 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 +186 -203
- 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-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-D5geEbXf.d.ts → index-Es7yJi7T.d.ts} +2 -2
- package/dist/{index-DjwwXNp4.d.mts → index-G15A08DI.d.mts} +3 -40
- package/dist/{index-DSvRdAyZ.d.mts → index-MsSYZS38.d.mts} +2 -2
- 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 +0 -120
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +570 -853
- 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 +52 -69
- 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 +1 -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");
|
|
@@ -1731,85 +1731,13 @@ var useContractStore_default = useContractStore;
|
|
|
1731
1731
|
var import_react_intl18 = require("react-intl");
|
|
1732
1732
|
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
1733
1733
|
|
|
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"));
|
|
1734
|
+
// src/components/CEXBindModal/index.tsx
|
|
1798
1735
|
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
1736
|
var import_react_intl19 = require("react-intl");
|
|
1804
1737
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
1805
1738
|
|
|
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
1739
|
// src/context/BusinessProvider.tsx
|
|
1812
|
-
var
|
|
1740
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
1813
1741
|
|
|
1814
1742
|
// src/store/useStore.ts
|
|
1815
1743
|
var import_zustand4 = require("zustand");
|
|
@@ -1824,15 +1752,15 @@ var useStore = (0, import_zustand4.create)((set) => ({
|
|
|
1824
1752
|
var useStore_default = useStore;
|
|
1825
1753
|
|
|
1826
1754
|
// src/context/BusinessProvider.tsx
|
|
1827
|
-
var
|
|
1755
|
+
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
1828
1756
|
|
|
1829
1757
|
// src/context/ModalContext.tsx
|
|
1830
|
-
var
|
|
1758
|
+
var import_react29 = __toESM(require("react"));
|
|
1831
1759
|
var import_react_dom = require("react-dom");
|
|
1832
|
-
var
|
|
1833
|
-
var ModalContext = (0,
|
|
1760
|
+
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
1761
|
+
var ModalContext = (0, import_react29.createContext)(null);
|
|
1834
1762
|
function useModal() {
|
|
1835
|
-
const context = (0,
|
|
1763
|
+
const context = (0, import_react29.useContext)(ModalContext);
|
|
1836
1764
|
if (!context) {
|
|
1837
1765
|
throw new Error("useModal must be used within a ModalProvider");
|
|
1838
1766
|
}
|
|
@@ -1840,12 +1768,12 @@ function useModal() {
|
|
|
1840
1768
|
}
|
|
1841
1769
|
|
|
1842
1770
|
// src/context/ToastContext.tsx
|
|
1843
|
-
var
|
|
1771
|
+
var import_react30 = require("react");
|
|
1844
1772
|
var import_react_dom2 = require("react-dom");
|
|
1845
|
-
var
|
|
1846
|
-
var ToastContext = (0,
|
|
1773
|
+
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
1774
|
+
var ToastContext = (0, import_react30.createContext)(null);
|
|
1847
1775
|
function useToast() {
|
|
1848
|
-
const context = (0,
|
|
1776
|
+
const context = (0, import_react30.useContext)(ToastContext);
|
|
1849
1777
|
if (!context) {
|
|
1850
1778
|
throw new Error("useToast must be used within a ToastProvider");
|
|
1851
1779
|
}
|
|
@@ -1853,18 +1781,18 @@ function useToast() {
|
|
|
1853
1781
|
}
|
|
1854
1782
|
|
|
1855
1783
|
// src/context/index.tsx
|
|
1856
|
-
var
|
|
1784
|
+
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
1857
1785
|
|
|
1858
1786
|
// src/hooks/useWalletInit.ts
|
|
1859
|
-
var
|
|
1787
|
+
var import_react31 = require("react");
|
|
1860
1788
|
var AppClientId = getAppClientId();
|
|
1861
1789
|
|
|
1862
1790
|
// src/hooks/useInit.tsx
|
|
1863
|
-
var
|
|
1791
|
+
var import_react32 = require("react");
|
|
1864
1792
|
|
|
1865
1793
|
// src/MatchContext.tsx
|
|
1866
|
-
var
|
|
1867
|
-
var
|
|
1794
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
1795
|
+
var import_react_intl20 = require("react-intl");
|
|
1868
1796
|
var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
1869
1797
|
var import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
1870
1798
|
var import_chains = require("wagmi/chains");
|
|
@@ -1933,8 +1861,8 @@ var matchTest = /* @__PURE__ */ (0, import_viem6.defineChain)({
|
|
|
1933
1861
|
|
|
1934
1862
|
// src/MatchContext.tsx
|
|
1935
1863
|
var import_wagmi3 = require("wagmi");
|
|
1936
|
-
var
|
|
1937
|
-
var queryClient = new
|
|
1864
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
1865
|
+
var queryClient = new import_react_query4.QueryClient();
|
|
1938
1866
|
var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
|
|
1939
1867
|
appName: "MatchID",
|
|
1940
1868
|
projectId: "9ac6ea7e07860f04616fb311b447dee9",
|
|
@@ -1952,9 +1880,9 @@ var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
|
|
|
1952
1880
|
],
|
|
1953
1881
|
chains: [import_chains.mainnet, import_chains.polygon, import_chains.optimism, import_chains.arbitrum, import_chains.base, matchMain, matchTest, import_chains.bsc]
|
|
1954
1882
|
});
|
|
1955
|
-
var MatchContext = (0,
|
|
1883
|
+
var MatchContext = (0, import_react33.createContext)(void 0);
|
|
1956
1884
|
var useMatch = () => {
|
|
1957
|
-
const context = (0,
|
|
1885
|
+
const context = (0, import_react33.useContext)(MatchContext);
|
|
1958
1886
|
if (context === void 0) {
|
|
1959
1887
|
throw new Error("useMatch must be used within a MatchProvider");
|
|
1960
1888
|
}
|
|
@@ -1988,7 +1916,7 @@ function useUserInfo() {
|
|
|
1988
1916
|
const getRedirectUri = () => {
|
|
1989
1917
|
return encodeURIComponent(window.location.href);
|
|
1990
1918
|
};
|
|
1991
|
-
const isLogin = (0,
|
|
1919
|
+
const isLogin = (0, import_react34.useMemo)(() => !!token && !!overview, [token, overview]);
|
|
1992
1920
|
const logout = async () => {
|
|
1993
1921
|
try {
|
|
1994
1922
|
await toLogoutApi();
|
|
@@ -2259,9 +2187,9 @@ function useUserInfo() {
|
|
|
2259
2187
|
}
|
|
2260
2188
|
|
|
2261
2189
|
// src/hooks/useMatchEvents.ts
|
|
2262
|
-
var
|
|
2190
|
+
var import_react35 = require("react");
|
|
2263
2191
|
function useMatchEvents(handlers) {
|
|
2264
|
-
(0,
|
|
2192
|
+
(0, import_react35.useEffect)(() => {
|
|
2265
2193
|
Object.entries(handlers).forEach(([event, handler2]) => {
|
|
2266
2194
|
if (handler2) {
|
|
2267
2195
|
eventManager_default.on(event, handler2);
|
|
@@ -2281,7 +2209,7 @@ function useMatchEvents(handlers) {
|
|
|
2281
2209
|
var import_viem7 = require("viem");
|
|
2282
2210
|
var import_accounts = require("viem/accounts");
|
|
2283
2211
|
var import_viem8 = require("viem");
|
|
2284
|
-
var
|
|
2212
|
+
var import_react36 = require("react");
|
|
2285
2213
|
var import_viem9 = require("viem");
|
|
2286
2214
|
|
|
2287
2215
|
// src/store/useTransactionStore.ts
|
|
@@ -2315,7 +2243,7 @@ var useTransactionStore = (0, import_zustand5.create)((0, import_middleware3.dev
|
|
|
2315
2243
|
var useTransactionStore_default = useTransactionStore;
|
|
2316
2244
|
|
|
2317
2245
|
// src/hooks/useWallet.tsx
|
|
2318
|
-
var
|
|
2246
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
2319
2247
|
var AppClientId2 = "react-sdk-" + getVersion();
|
|
2320
2248
|
function useWallet() {
|
|
2321
2249
|
const { address, wallet: walletConfig } = useLocalStore_default();
|
|
@@ -2366,7 +2294,7 @@ function useWallet() {
|
|
|
2366
2294
|
throw error;
|
|
2367
2295
|
}
|
|
2368
2296
|
};
|
|
2369
|
-
const evmAccount = (0,
|
|
2297
|
+
const evmAccount = (0, import_react36.useMemo)(() => {
|
|
2370
2298
|
try {
|
|
2371
2299
|
return address ? (0, import_accounts.toAccount)({
|
|
2372
2300
|
address,
|
|
@@ -2405,7 +2333,7 @@ function useWallet() {
|
|
|
2405
2333
|
return void 0;
|
|
2406
2334
|
}
|
|
2407
2335
|
}, [address]);
|
|
2408
|
-
(0,
|
|
2336
|
+
(0, import_react36.useEffect)(() => {
|
|
2409
2337
|
matchlog_default.log("qwe-evmAccount", evmAccount);
|
|
2410
2338
|
}, [evmAccount]);
|
|
2411
2339
|
const realCreateWalletClient = (parameters) => {
|
|
@@ -2488,7 +2416,7 @@ function useWallet() {
|
|
|
2488
2416
|
address: evmAccount.address
|
|
2489
2417
|
});
|
|
2490
2418
|
modal.show((props) => {
|
|
2491
|
-
return /* @__PURE__ */ (0,
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(HashPanel_default, { isOpen: true, onClose: props.close, zIndex: props.zIndex, hash: txHash, chain: _chain });
|
|
2492
2420
|
});
|
|
2493
2421
|
clearInterval(window.matchProvider.transactionMessageIntervalMap[transactionId].interval);
|
|
2494
2422
|
delete window.matchProvider.transactionMessageIntervalMap[transactionId];
|
|
@@ -2541,14 +2469,14 @@ function useWallet() {
|
|
|
2541
2469
|
|
|
2542
2470
|
// src/hooks/useCopyClipboard.ts
|
|
2543
2471
|
var import_copy_to_clipboard = __toESM(require("copy-to-clipboard"));
|
|
2544
|
-
var
|
|
2472
|
+
var import_react37 = require("react");
|
|
2545
2473
|
function useCopyClipboard(timeout = 500) {
|
|
2546
|
-
const [isCopied, setIsCopied] = (0,
|
|
2547
|
-
const staticCopy = (0,
|
|
2474
|
+
const [isCopied, setIsCopied] = (0, import_react37.useState)(false);
|
|
2475
|
+
const staticCopy = (0, import_react37.useCallback)((text) => {
|
|
2548
2476
|
const didCopy = (0, import_copy_to_clipboard.default)(text);
|
|
2549
2477
|
setIsCopied(didCopy);
|
|
2550
2478
|
}, []);
|
|
2551
|
-
(0,
|
|
2479
|
+
(0, import_react37.useEffect)(() => {
|
|
2552
2480
|
if (isCopied) {
|
|
2553
2481
|
const hide = setTimeout(() => {
|
|
2554
2482
|
setIsCopied(false);
|
|
@@ -2562,17 +2490,72 @@ function useCopyClipboard(timeout = 500) {
|
|
|
2562
2490
|
return [isCopied, staticCopy];
|
|
2563
2491
|
}
|
|
2564
2492
|
|
|
2493
|
+
// src/hooks/api/wallet.ts
|
|
2494
|
+
var import_react_query5 = require("@tanstack/react-query");
|
|
2495
|
+
function useChainListQuery(options) {
|
|
2496
|
+
const { isLogin, token } = useUserInfo();
|
|
2497
|
+
return (0, import_react_query5.useQuery)({
|
|
2498
|
+
queryKey: ["match-user-chain-list", token],
|
|
2499
|
+
queryFn: async () => {
|
|
2500
|
+
const res = await getUserChainListApi();
|
|
2501
|
+
if (!isSuccess(res)) {
|
|
2502
|
+
return [];
|
|
2503
|
+
}
|
|
2504
|
+
return res.data;
|
|
2505
|
+
},
|
|
2506
|
+
enabled: isLogin,
|
|
2507
|
+
...options
|
|
2508
|
+
});
|
|
2509
|
+
}
|
|
2510
|
+
function useAssetListQuery({
|
|
2511
|
+
chainId,
|
|
2512
|
+
...options
|
|
2513
|
+
}) {
|
|
2514
|
+
const { isLogin, token } = useUserInfo();
|
|
2515
|
+
return (0, import_react_query5.useQuery)({
|
|
2516
|
+
queryKey: ["match-user-asset-list", token, chainId],
|
|
2517
|
+
queryFn: async () => {
|
|
2518
|
+
const res = await getUserWalletAssetApi({ chain_id: chainId.toString() });
|
|
2519
|
+
if (!isSuccess(res)) {
|
|
2520
|
+
return [];
|
|
2521
|
+
}
|
|
2522
|
+
return res.data || [];
|
|
2523
|
+
},
|
|
2524
|
+
enabled: isLogin,
|
|
2525
|
+
...options
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
var USER_IMPORT_TOKEN_LIST_KEY = "match-user-import-token-list";
|
|
2529
|
+
function useImportTokenListQuery({
|
|
2530
|
+
chainId,
|
|
2531
|
+
...options
|
|
2532
|
+
}) {
|
|
2533
|
+
const { isLogin, token } = useUserInfo();
|
|
2534
|
+
return (0, import_react_query5.useQuery)({
|
|
2535
|
+
queryKey: [USER_IMPORT_TOKEN_LIST_KEY, token, chainId],
|
|
2536
|
+
queryFn: async () => {
|
|
2537
|
+
const res = await getUserImportTokenListApi({ chain_id: chainId.toString() });
|
|
2538
|
+
if (!isSuccess(res)) {
|
|
2539
|
+
return [];
|
|
2540
|
+
}
|
|
2541
|
+
return res.data || [];
|
|
2542
|
+
},
|
|
2543
|
+
enabled: isLogin,
|
|
2544
|
+
...options
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2565
2548
|
// src/hooks/useMatchChain.tsx
|
|
2566
|
-
var
|
|
2549
|
+
var import_react38 = require("react");
|
|
2567
2550
|
var import_viem10 = require("viem");
|
|
2568
|
-
var
|
|
2569
|
-
var
|
|
2551
|
+
var import_react_intl21 = require("react-intl");
|
|
2552
|
+
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
2570
2553
|
function useMatchChain() {
|
|
2571
2554
|
const chainListQuery = useChainListQuery();
|
|
2572
2555
|
const modal = useModal();
|
|
2573
|
-
const intl = (0,
|
|
2556
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
2574
2557
|
const { chainId: storeChainId, setChainId } = useLocalStore_default();
|
|
2575
|
-
const chainId = (0,
|
|
2558
|
+
const chainId = (0, import_react38.useMemo)(() => {
|
|
2576
2559
|
if (!chainListQuery.data || !chainListQuery.data.length) {
|
|
2577
2560
|
return null;
|
|
2578
2561
|
}
|
|
@@ -2581,7 +2564,7 @@ function useMatchChain() {
|
|
|
2581
2564
|
}
|
|
2582
2565
|
return chainListQuery.data[0].id;
|
|
2583
2566
|
}, [storeChainId, chainListQuery.data]);
|
|
2584
|
-
const chain = (0,
|
|
2567
|
+
const chain = (0, import_react38.useMemo)(() => {
|
|
2585
2568
|
if (!chainListQuery.data || !chainListQuery.data.length) {
|
|
2586
2569
|
return null;
|
|
2587
2570
|
}
|
|
@@ -2595,30 +2578,30 @@ function useMatchChain() {
|
|
|
2595
2578
|
close
|
|
2596
2579
|
}) {
|
|
2597
2580
|
const { chainId: storeChainId2, setChainId: setChainId2 } = useLocalStore_default();
|
|
2598
|
-
const [selectedChainId, setSelectedChainId] = (0,
|
|
2581
|
+
const [selectedChainId, setSelectedChainId] = (0, import_react38.useState)(storeChainId2);
|
|
2599
2582
|
const isDownMd = useDownMd();
|
|
2600
|
-
return /* @__PURE__ */ (0,
|
|
2601
|
-
/* @__PURE__ */ (0,
|
|
2602
|
-
return /* @__PURE__ */ (0,
|
|
2583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: `matchid-change-network-box`, children: [
|
|
2584
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: `matchid-change-network-list`, children: chainListQuery.data?.map((item, index) => {
|
|
2585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
|
|
2603
2586
|
"div",
|
|
2604
2587
|
{
|
|
2605
2588
|
onClick: () => setSelectedChainId(item.id),
|
|
2606
2589
|
className: `matchid-change-network-item ${selectedChainId == item.id ? "matchid-change-network-selected" : ""}`,
|
|
2607
2590
|
children: [
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
/* @__PURE__ */ (0,
|
|
2610
|
-
/* @__PURE__ */ (0,
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: `matchid-change-network-item-content`, children: [
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("img", { src: item.iconUrl, className: `matchid-change-network-item-icon` }),
|
|
2593
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("span", { className: "matchid-change-network-item-name", children: item.name })
|
|
2611
2594
|
] }),
|
|
2612
|
-
/* @__PURE__ */ (0,
|
|
2595
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Radio, { checked: selectedChainId === item.id, size: isDownMd ? 18 : 24 })
|
|
2613
2596
|
]
|
|
2614
2597
|
},
|
|
2615
2598
|
index
|
|
2616
2599
|
);
|
|
2617
2600
|
}) }),
|
|
2618
|
-
/* @__PURE__ */ (0,
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Button, { size: "lg", highlight: true, onClick: () => {
|
|
2619
2602
|
setChainId2(selectedChainId || 0);
|
|
2620
2603
|
close();
|
|
2621
|
-
}, block: true, children: /* @__PURE__ */ (0,
|
|
2604
|
+
}, block: true, children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_react_intl21.FormattedMessage, { id: "confirm" }) })
|
|
2622
2605
|
] });
|
|
2623
2606
|
}
|
|
2624
2607
|
const showChangeNetwork = () => {
|
|
@@ -2627,7 +2610,7 @@ function useMatchChain() {
|
|
|
2627
2610
|
content: ChangeNetwork
|
|
2628
2611
|
});
|
|
2629
2612
|
};
|
|
2630
|
-
const publicClient = (0,
|
|
2613
|
+
const publicClient = (0, import_react38.useMemo)(() => {
|
|
2631
2614
|
if (!chain) {
|
|
2632
2615
|
return null;
|
|
2633
2616
|
}
|
|
@@ -2655,26 +2638,26 @@ function useMatchChain() {
|
|
|
2655
2638
|
|
|
2656
2639
|
// src/hooks/useMatchWallet.tsx
|
|
2657
2640
|
var import_react_qrcode = require("react-qrcode");
|
|
2658
|
-
var
|
|
2659
|
-
var
|
|
2641
|
+
var import_react40 = require("react");
|
|
2642
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
2660
2643
|
var import_viem13 = require("viem");
|
|
2661
|
-
var
|
|
2644
|
+
var import_react_intl23 = require("react-intl");
|
|
2662
2645
|
|
|
2663
2646
|
// src/components/ImportToken/index.tsx
|
|
2664
|
-
var
|
|
2665
|
-
var
|
|
2666
|
-
var
|
|
2647
|
+
var import_react39 = require("react");
|
|
2648
|
+
var import_react_intl22 = require("react-intl");
|
|
2649
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
2667
2650
|
var import_viem12 = require("viem");
|
|
2668
2651
|
|
|
2669
2652
|
// src/hooks/useIsContract.ts
|
|
2670
2653
|
var import_viem11 = require("viem");
|
|
2671
|
-
var
|
|
2654
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
2672
2655
|
function useIsContract({
|
|
2673
2656
|
address,
|
|
2674
2657
|
chain,
|
|
2675
2658
|
enabled
|
|
2676
2659
|
}) {
|
|
2677
|
-
return (0,
|
|
2660
|
+
return (0, import_react_query6.useQuery)({
|
|
2678
2661
|
queryKey: ["is_contract", chain?.id, address],
|
|
2679
2662
|
queryFn: async () => {
|
|
2680
2663
|
if (!chain) return false;
|
|
@@ -2691,14 +2674,14 @@ function useIsContract({
|
|
|
2691
2674
|
}
|
|
2692
2675
|
|
|
2693
2676
|
// src/components/ImportToken/index.tsx
|
|
2694
|
-
var
|
|
2677
|
+
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
2695
2678
|
function ImportToken({ close }) {
|
|
2696
|
-
const [status, setStatus] = (0,
|
|
2679
|
+
const [status, setStatus] = (0, import_react39.useState)("");
|
|
2697
2680
|
const { token } = useUserInfo();
|
|
2698
|
-
const [address, setAddress] = (0,
|
|
2699
|
-
const [symbol, setSymbol] = (0,
|
|
2700
|
-
const [decimals, setDecimals] = (0,
|
|
2701
|
-
const [error, setError] = (0,
|
|
2681
|
+
const [address, setAddress] = (0, import_react39.useState)("");
|
|
2682
|
+
const [symbol, setSymbol] = (0, import_react39.useState)("");
|
|
2683
|
+
const [decimals, setDecimals] = (0, import_react39.useState)("");
|
|
2684
|
+
const [error, setError] = (0, import_react39.useState)({});
|
|
2702
2685
|
const { publicClient, chainId, chain } = useMatchChain();
|
|
2703
2686
|
const getContractInfo = async () => {
|
|
2704
2687
|
if (!publicClient) return;
|
|
@@ -2731,8 +2714,8 @@ function ImportToken({ close }) {
|
|
|
2731
2714
|
});
|
|
2732
2715
|
}
|
|
2733
2716
|
};
|
|
2734
|
-
const intl = (0,
|
|
2735
|
-
(0,
|
|
2717
|
+
const intl = (0, import_react_intl22.useIntl)();
|
|
2718
|
+
(0, import_react39.useEffect)(() => {
|
|
2736
2719
|
if (address.length === 42) {
|
|
2737
2720
|
const reg = /^0x[0-9a-fA-F]{40}$/;
|
|
2738
2721
|
if (!reg.test(address)) {
|
|
@@ -2751,9 +2734,9 @@ function ImportToken({ close }) {
|
|
|
2751
2734
|
}
|
|
2752
2735
|
}
|
|
2753
2736
|
}, [address, publicClient]);
|
|
2754
|
-
const [loading, setLoading] = (0,
|
|
2737
|
+
const [loading, setLoading] = (0, import_react39.useState)(false);
|
|
2755
2738
|
const toast = useToast();
|
|
2756
|
-
const queryClient2 = (0,
|
|
2739
|
+
const queryClient2 = (0, import_react_query7.useQueryClient)();
|
|
2757
2740
|
const onImport = async () => {
|
|
2758
2741
|
setLoading(true);
|
|
2759
2742
|
try {
|
|
@@ -2779,7 +2762,7 @@ function ImportToken({ close }) {
|
|
|
2779
2762
|
setLoading(false);
|
|
2780
2763
|
}
|
|
2781
2764
|
};
|
|
2782
|
-
const canImport = (0,
|
|
2765
|
+
const canImport = (0, import_react39.useMemo)(() => {
|
|
2783
2766
|
if (!address) {
|
|
2784
2767
|
return false;
|
|
2785
2768
|
}
|
|
@@ -2802,19 +2785,19 @@ function ImportToken({ close }) {
|
|
|
2802
2785
|
enabled: canImport
|
|
2803
2786
|
});
|
|
2804
2787
|
if (status == "success" || status == "fail") {
|
|
2805
|
-
return /* @__PURE__ */ (0,
|
|
2806
|
-
/* @__PURE__ */ (0,
|
|
2807
|
-
/* @__PURE__ */ (0,
|
|
2808
|
-
/* @__PURE__ */ (0,
|
|
2788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-import-token-result matchid-flex`, children: [
|
|
2789
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-import-token-result-box matchid-flex`, children: [
|
|
2790
|
+
/* @__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` }),
|
|
2791
|
+
/* @__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
2792
|
] }),
|
|
2810
|
-
status == "success" ? /* @__PURE__ */ (0,
|
|
2793
|
+
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
2794
|
] });
|
|
2812
2795
|
}
|
|
2813
|
-
return /* @__PURE__ */ (0,
|
|
2814
|
-
/* @__PURE__ */ (0,
|
|
2815
|
-
/* @__PURE__ */ (0,
|
|
2796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-import-token`, children: [
|
|
2797
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "matchid-import-token-form", children: [
|
|
2798
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Field, { label: intl.formatMessage({
|
|
2816
2799
|
id: "tokenSmartContract"
|
|
2817
|
-
}), error: error.address ? error.address : isContractQuery.isFetched && !isContractQuery.isLoading && !isContractQuery.data && canImport ? "Address isn't a contract address" : "", children: /* @__PURE__ */ (0,
|
|
2800
|
+
}), 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
2801
|
Input,
|
|
2819
2802
|
{
|
|
2820
2803
|
placeholder: intl.formatMessage({
|
|
@@ -2825,9 +2808,9 @@ function ImportToken({ close }) {
|
|
|
2825
2808
|
maxLength: 42
|
|
2826
2809
|
}
|
|
2827
2810
|
) }),
|
|
2828
|
-
/* @__PURE__ */ (0,
|
|
2811
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Field, { label: intl.formatMessage({
|
|
2829
2812
|
id: "tokenSymbol"
|
|
2830
|
-
}), error: error.symbol, children: /* @__PURE__ */ (0,
|
|
2813
|
+
}), error: error.symbol, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2831
2814
|
Input,
|
|
2832
2815
|
{
|
|
2833
2816
|
placeholder: intl.formatMessage({
|
|
@@ -2838,9 +2821,9 @@ function ImportToken({ close }) {
|
|
|
2838
2821
|
maxLength: 16
|
|
2839
2822
|
}
|
|
2840
2823
|
) }),
|
|
2841
|
-
/* @__PURE__ */ (0,
|
|
2824
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Field, { label: intl.formatMessage({
|
|
2842
2825
|
id: "tokenDecimals"
|
|
2843
|
-
}), error: error.decimals, children: /* @__PURE__ */ (0,
|
|
2826
|
+
}), error: error.decimals, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2844
2827
|
Input,
|
|
2845
2828
|
{
|
|
2846
2829
|
placeholder: intl.formatMessage({
|
|
@@ -2852,7 +2835,7 @@ function ImportToken({ close }) {
|
|
|
2852
2835
|
}
|
|
2853
2836
|
) })
|
|
2854
2837
|
] }),
|
|
2855
|
-
/* @__PURE__ */ (0,
|
|
2838
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
2856
2839
|
Button,
|
|
2857
2840
|
{
|
|
2858
2841
|
size: "lg",
|
|
@@ -2861,20 +2844,20 @@ function ImportToken({ close }) {
|
|
|
2861
2844
|
loading: loading || isContractQuery.isLoading,
|
|
2862
2845
|
disabled: !canImport || !isContractQuery.data,
|
|
2863
2846
|
highlight: true,
|
|
2864
|
-
children: /* @__PURE__ */ (0,
|
|
2847
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "import" })
|
|
2865
2848
|
}
|
|
2866
2849
|
)
|
|
2867
2850
|
] });
|
|
2868
2851
|
}
|
|
2869
2852
|
|
|
2870
2853
|
// src/hooks/useMatchWallet.tsx
|
|
2871
|
-
var
|
|
2854
|
+
var import_jsx_runtime98 = require("react/jsx-runtime");
|
|
2872
2855
|
var ReceiveModal = () => {
|
|
2873
2856
|
const chain = useMatchChain();
|
|
2874
2857
|
const { address } = useWallet();
|
|
2875
2858
|
const [copied, setCopied] = useCopyClipboard();
|
|
2876
2859
|
const toast = useToast();
|
|
2877
|
-
const intl = (0,
|
|
2860
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
2878
2861
|
const onCopy = () => {
|
|
2879
2862
|
setCopied(address);
|
|
2880
2863
|
toast.success(intl.formatMessage({
|
|
@@ -2882,10 +2865,10 @@ var ReceiveModal = () => {
|
|
|
2882
2865
|
}));
|
|
2883
2866
|
};
|
|
2884
2867
|
const chainLink = chain.explorerLink("address/" + address);
|
|
2885
|
-
return /* @__PURE__ */ (0,
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2887
|
-
/* @__PURE__ */ (0,
|
|
2888
|
-
/* @__PURE__ */ (0,
|
|
2868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: `matchid-receive-modal`, children: [
|
|
2869
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: "matchid-receive-container", children: [
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: `matchid-receive-text`, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "receiveQrcode" }) }),
|
|
2871
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2889
2872
|
import_react_qrcode.QRCode,
|
|
2890
2873
|
{
|
|
2891
2874
|
margin: "0",
|
|
@@ -2893,7 +2876,7 @@ var ReceiveModal = () => {
|
|
|
2893
2876
|
value: address
|
|
2894
2877
|
}
|
|
2895
2878
|
) }),
|
|
2896
|
-
/* @__PURE__ */ (0,
|
|
2879
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2897
2880
|
"a",
|
|
2898
2881
|
{
|
|
2899
2882
|
href: chainLink,
|
|
@@ -2903,8 +2886,8 @@ var ReceiveModal = () => {
|
|
|
2903
2886
|
}
|
|
2904
2887
|
)
|
|
2905
2888
|
] }),
|
|
2906
|
-
/* @__PURE__ */ (0,
|
|
2907
|
-
|
|
2889
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2890
|
+
import_react_intl23.FormattedMessage,
|
|
2908
2891
|
{
|
|
2909
2892
|
id: "copyAddress"
|
|
2910
2893
|
}
|
|
@@ -2913,7 +2896,7 @@ var ReceiveModal = () => {
|
|
|
2913
2896
|
};
|
|
2914
2897
|
function useMatchWallet() {
|
|
2915
2898
|
const modal = useModal();
|
|
2916
|
-
const intl = (0,
|
|
2899
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
2917
2900
|
const showReceiveModal = () => {
|
|
2918
2901
|
modal.open({
|
|
2919
2902
|
title: intl.formatMessage({
|
|
@@ -2945,12 +2928,12 @@ function useMatchWallet() {
|
|
|
2945
2928
|
};
|
|
2946
2929
|
}
|
|
2947
2930
|
function useMatchWalletRecords() {
|
|
2948
|
-
const [hasMore, setHasMore] = (0,
|
|
2949
|
-
const [items, setItems] = (0,
|
|
2931
|
+
const [hasMore, setHasMore] = (0, import_react40.useState)(true);
|
|
2932
|
+
const [items, setItems] = (0, import_react40.useState)([]);
|
|
2950
2933
|
const { chainId, publicClient } = useMatchChain();
|
|
2951
2934
|
const { address } = useWallet();
|
|
2952
|
-
const hasMoreRef = (0,
|
|
2953
|
-
const nextPageParamsRef = (0,
|
|
2935
|
+
const hasMoreRef = (0, import_react40.useRef)(hasMore);
|
|
2936
|
+
const nextPageParamsRef = (0, import_react40.useRef)(void 0);
|
|
2954
2937
|
const { contracts, setContracts } = useContractStore_default();
|
|
2955
2938
|
const fetchMoreData = async () => {
|
|
2956
2939
|
const chainIdStr = chainId ? chainId.toString() : "";
|
|
@@ -2977,7 +2960,7 @@ function useMatchWalletRecords() {
|
|
|
2977
2960
|
hasMoreRef.current = true;
|
|
2978
2961
|
fetchMoreData();
|
|
2979
2962
|
};
|
|
2980
|
-
(0,
|
|
2963
|
+
(0, import_react40.useEffect)(() => {
|
|
2981
2964
|
if (chainId && address) {
|
|
2982
2965
|
onInit();
|
|
2983
2966
|
}
|
|
@@ -3033,7 +3016,7 @@ function useMatchWalletRecords() {
|
|
|
3033
3016
|
setContracts(contractMap);
|
|
3034
3017
|
}
|
|
3035
3018
|
};
|
|
3036
|
-
const list = (0,
|
|
3019
|
+
const list = (0, import_react40.useMemo)(() => {
|
|
3037
3020
|
const localTransactions = transactions[`${chainId}-${address}`] || [];
|
|
3038
3021
|
const removeList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
|
|
3039
3022
|
removeList.forEach((item) => {
|
|
@@ -3075,7 +3058,7 @@ function useMatchWalletAssets({
|
|
|
3075
3058
|
chainId: chainId || 0,
|
|
3076
3059
|
...assetListOptions
|
|
3077
3060
|
});
|
|
3078
|
-
const mergedAssets = (0,
|
|
3061
|
+
const mergedAssets = (0, import_react40.useMemo)(() => {
|
|
3079
3062
|
if (!assetListQuery.data && !importTokenQuery.data) return [];
|
|
3080
3063
|
const assetList = (assetListQuery.data || []).map((asset) => ({
|
|
3081
3064
|
...asset,
|
|
@@ -3143,7 +3126,7 @@ function useMatchWalletAssetList({
|
|
|
3143
3126
|
name: chain?.nativeCurrency.name,
|
|
3144
3127
|
balance: 0
|
|
3145
3128
|
};
|
|
3146
|
-
const nativeBalanceQuery = (0,
|
|
3129
|
+
const nativeBalanceQuery = (0, import_react_query8.useQuery)({
|
|
3147
3130
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
3148
3131
|
queryFn: async () => {
|
|
3149
3132
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -3162,8 +3145,8 @@ function useMatchWalletAssetList({
|
|
|
3162
3145
|
retry: 3
|
|
3163
3146
|
// Retry up to 3 times if failed
|
|
3164
3147
|
});
|
|
3165
|
-
const erc20Tokens = (0,
|
|
3166
|
-
const erc20BalanceQuery = (0,
|
|
3148
|
+
const erc20Tokens = (0, import_react40.useMemo)(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
3149
|
+
const erc20BalanceQuery = (0, import_react_query8.useQuery)({
|
|
3167
3150
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
3168
3151
|
queryFn: async () => {
|
|
3169
3152
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
@@ -3190,7 +3173,7 @@ function useMatchWalletAssetList({
|
|
|
3190
3173
|
// Refresh every 15 seconds
|
|
3191
3174
|
retry: 3
|
|
3192
3175
|
});
|
|
3193
|
-
const enrichedAssets = (0,
|
|
3176
|
+
const enrichedAssets = (0, import_react40.useMemo)(() => {
|
|
3194
3177
|
if (!list) return [];
|
|
3195
3178
|
const erc20Balances = erc20BalanceQuery.data || [];
|
|
3196
3179
|
return list.map((asset) => {
|
|
@@ -3212,7 +3195,7 @@ function useMatchWalletAssetList({
|
|
|
3212
3195
|
return { ...asset, balance, value, balanceValue };
|
|
3213
3196
|
});
|
|
3214
3197
|
}, [list, nativeBalanceQuery.data, erc20BalanceQuery.data]);
|
|
3215
|
-
(0,
|
|
3198
|
+
(0, import_react40.useEffect)(() => {
|
|
3216
3199
|
const list2 = enrichedAssets.sort((a, b) => {
|
|
3217
3200
|
if (a.address === NATIVE_TOKEN_ADDRESS) return -1;
|
|
3218
3201
|
if (b.address === NATIVE_TOKEN_ADDRESS) return 1;
|
|
@@ -3237,14 +3220,14 @@ function useMatchWalletAssetList({
|
|
|
3237
3220
|
}
|
|
3238
3221
|
|
|
3239
3222
|
// src/hooks/useReceipt.tsx
|
|
3240
|
-
var
|
|
3241
|
-
var
|
|
3223
|
+
var import_react41 = require("react");
|
|
3224
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
3242
3225
|
var import_viem14 = require("viem");
|
|
3243
3226
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
3244
3227
|
var MAX_CACHE_SIZE = 500;
|
|
3245
3228
|
var STORAGE_KEY = "match_receipt_logs";
|
|
3246
3229
|
function useReceiptCache() {
|
|
3247
|
-
const [cache, setCache] = (0,
|
|
3230
|
+
const [cache, setCache] = (0, import_react41.useState)(/* @__PURE__ */ new Map());
|
|
3248
3231
|
const isLocalStorageAvailable = (() => {
|
|
3249
3232
|
try {
|
|
3250
3233
|
const testKey = "__test__";
|
|
@@ -3255,7 +3238,7 @@ function useReceiptCache() {
|
|
|
3255
3238
|
return false;
|
|
3256
3239
|
}
|
|
3257
3240
|
})();
|
|
3258
|
-
(0,
|
|
3241
|
+
(0, import_react41.useEffect)(() => {
|
|
3259
3242
|
if (isLocalStorageAvailable) {
|
|
3260
3243
|
try {
|
|
3261
3244
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3274,7 +3257,7 @@ function useReceiptCache() {
|
|
|
3274
3257
|
}
|
|
3275
3258
|
}
|
|
3276
3259
|
}, []);
|
|
3277
|
-
const updateLocalStorage = (0,
|
|
3260
|
+
const updateLocalStorage = (0, import_react41.useCallback)((updatedCache) => {
|
|
3278
3261
|
if (isLocalStorageAvailable) {
|
|
3279
3262
|
try {
|
|
3280
3263
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3291,7 +3274,7 @@ function useReceiptCache() {
|
|
|
3291
3274
|
}
|
|
3292
3275
|
}
|
|
3293
3276
|
}, []);
|
|
3294
|
-
const set = (0,
|
|
3277
|
+
const set = (0, import_react41.useCallback)((key, value) => {
|
|
3295
3278
|
const now = Date.now();
|
|
3296
3279
|
const newCache = new Map(cache);
|
|
3297
3280
|
newCache.forEach((entry, k) => {
|
|
@@ -3309,7 +3292,7 @@ function useReceiptCache() {
|
|
|
3309
3292
|
setCache(newCache);
|
|
3310
3293
|
updateLocalStorage(newCache);
|
|
3311
3294
|
}, [cache, updateLocalStorage]);
|
|
3312
|
-
const get = (0,
|
|
3295
|
+
const get = (0, import_react41.useCallback)((key) => {
|
|
3313
3296
|
const entry = cache.get(key);
|
|
3314
3297
|
if (entry) {
|
|
3315
3298
|
if (Date.now() - entry.timestamp > CACHE_TTL) {
|
|
@@ -3323,7 +3306,7 @@ function useReceiptCache() {
|
|
|
3323
3306
|
}
|
|
3324
3307
|
return void 0;
|
|
3325
3308
|
}, [cache, updateLocalStorage]);
|
|
3326
|
-
const del = (0,
|
|
3309
|
+
const del = (0, import_react41.useCallback)((key) => {
|
|
3327
3310
|
if (cache.has(key)) {
|
|
3328
3311
|
const newCache = new Map(cache);
|
|
3329
3312
|
newCache.delete(key);
|
|
@@ -3331,7 +3314,7 @@ function useReceiptCache() {
|
|
|
3331
3314
|
updateLocalStorage(newCache);
|
|
3332
3315
|
}
|
|
3333
3316
|
}, [cache, updateLocalStorage]);
|
|
3334
|
-
const clear = (0,
|
|
3317
|
+
const clear = (0, import_react41.useCallback)(() => {
|
|
3335
3318
|
setCache(/* @__PURE__ */ new Map());
|
|
3336
3319
|
if (isLocalStorageAvailable) {
|
|
3337
3320
|
localStorage.removeItem(STORAGE_KEY);
|
|
@@ -3346,8 +3329,8 @@ function useReceipt2({
|
|
|
3346
3329
|
const { list } = useMatchChain();
|
|
3347
3330
|
const cache = useReceiptCache();
|
|
3348
3331
|
const chain = list?.find((item) => item.id === chainId);
|
|
3349
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3350
|
-
const query = (0,
|
|
3332
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react41.useState)(true);
|
|
3333
|
+
const query = (0, import_react_query9.useQuery)({
|
|
3351
3334
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
3352
3335
|
queryFn: async () => {
|
|
3353
3336
|
if (!chain || !hash) return false;
|
|
@@ -3372,7 +3355,7 @@ function useReceipt2({
|
|
|
3372
3355
|
},
|
|
3373
3356
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3374
3357
|
});
|
|
3375
|
-
(0,
|
|
3358
|
+
(0, import_react41.useEffect)(() => {
|
|
3376
3359
|
if (query.data) {
|
|
3377
3360
|
setShouldRefetch(false);
|
|
3378
3361
|
}
|
|
@@ -3381,14 +3364,14 @@ function useReceipt2({
|
|
|
3381
3364
|
}
|
|
3382
3365
|
|
|
3383
3366
|
// src/hooks/useTransaction.tsx
|
|
3384
|
-
var
|
|
3385
|
-
var
|
|
3367
|
+
var import_react42 = require("react");
|
|
3368
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
3386
3369
|
var import_viem15 = require("viem");
|
|
3387
3370
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
3388
3371
|
var MAX_CACHE_SIZE2 = 500;
|
|
3389
3372
|
var STORAGE_KEY2 = "match_transaction_logs";
|
|
3390
3373
|
function useTransactionCache() {
|
|
3391
|
-
const [cache, setCache] = (0,
|
|
3374
|
+
const [cache, setCache] = (0, import_react42.useState)(/* @__PURE__ */ new Map());
|
|
3392
3375
|
const isLocalStorageAvailable = (() => {
|
|
3393
3376
|
try {
|
|
3394
3377
|
const testKey = "__test__";
|
|
@@ -3399,7 +3382,7 @@ function useTransactionCache() {
|
|
|
3399
3382
|
return false;
|
|
3400
3383
|
}
|
|
3401
3384
|
})();
|
|
3402
|
-
(0,
|
|
3385
|
+
(0, import_react42.useEffect)(() => {
|
|
3403
3386
|
if (isLocalStorageAvailable) {
|
|
3404
3387
|
try {
|
|
3405
3388
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3418,7 +3401,7 @@ function useTransactionCache() {
|
|
|
3418
3401
|
}
|
|
3419
3402
|
}
|
|
3420
3403
|
}, []);
|
|
3421
|
-
const updateLocalStorage = (0,
|
|
3404
|
+
const updateLocalStorage = (0, import_react42.useCallback)((updatedCache) => {
|
|
3422
3405
|
if (isLocalStorageAvailable) {
|
|
3423
3406
|
try {
|
|
3424
3407
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3435,7 +3418,7 @@ function useTransactionCache() {
|
|
|
3435
3418
|
}
|
|
3436
3419
|
}
|
|
3437
3420
|
}, []);
|
|
3438
|
-
const set = (0,
|
|
3421
|
+
const set = (0, import_react42.useCallback)((key, value) => {
|
|
3439
3422
|
const now = Date.now();
|
|
3440
3423
|
const newCache = new Map(cache);
|
|
3441
3424
|
newCache.forEach((entry, k) => {
|
|
@@ -3453,7 +3436,7 @@ function useTransactionCache() {
|
|
|
3453
3436
|
setCache(newCache);
|
|
3454
3437
|
updateLocalStorage(newCache);
|
|
3455
3438
|
}, [cache, updateLocalStorage]);
|
|
3456
|
-
const get = (0,
|
|
3439
|
+
const get = (0, import_react42.useCallback)((key) => {
|
|
3457
3440
|
const entry = cache.get(key);
|
|
3458
3441
|
if (entry) {
|
|
3459
3442
|
if (Date.now() - entry.timestamp > CACHE_TTL2) {
|
|
@@ -3467,7 +3450,7 @@ function useTransactionCache() {
|
|
|
3467
3450
|
}
|
|
3468
3451
|
return void 0;
|
|
3469
3452
|
}, [cache, updateLocalStorage]);
|
|
3470
|
-
const del = (0,
|
|
3453
|
+
const del = (0, import_react42.useCallback)((key) => {
|
|
3471
3454
|
if (cache.has(key)) {
|
|
3472
3455
|
const newCache = new Map(cache);
|
|
3473
3456
|
newCache.delete(key);
|
|
@@ -3475,7 +3458,7 @@ function useTransactionCache() {
|
|
|
3475
3458
|
updateLocalStorage(newCache);
|
|
3476
3459
|
}
|
|
3477
3460
|
}, [cache, updateLocalStorage]);
|
|
3478
|
-
const clear = (0,
|
|
3461
|
+
const clear = (0, import_react42.useCallback)(() => {
|
|
3479
3462
|
setCache(/* @__PURE__ */ new Map());
|
|
3480
3463
|
if (isLocalStorageAvailable) {
|
|
3481
3464
|
localStorage.removeItem(STORAGE_KEY2);
|
|
@@ -3490,8 +3473,8 @@ function useTransaction({
|
|
|
3490
3473
|
const { list } = useMatchChain();
|
|
3491
3474
|
const cache = useTransactionCache();
|
|
3492
3475
|
const chain = list?.find((item) => item.id === chainId);
|
|
3493
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3494
|
-
const query = (0,
|
|
3476
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react42.useState)(true);
|
|
3477
|
+
const query = (0, import_react_query10.useQuery)({
|
|
3495
3478
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
3496
3479
|
queryFn: async () => {
|
|
3497
3480
|
if (!chain || !hash) return false;
|
|
@@ -3516,7 +3499,7 @@ function useTransaction({
|
|
|
3516
3499
|
},
|
|
3517
3500
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3518
3501
|
});
|
|
3519
|
-
(0,
|
|
3502
|
+
(0, import_react42.useEffect)(() => {
|
|
3520
3503
|
if (query.data) {
|
|
3521
3504
|
setShouldRefetch(false);
|
|
3522
3505
|
}
|