@matchain/matchid-sdk-react 0.1.53-alpha.25 → 0.1.53-alpha.26
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/{chunk-F7N2JPEQ.mjs → chunk-L6N4WRWG.mjs} +248 -448
- package/dist/chunk-L6N4WRWG.mjs.map +1 -0
- package/dist/components/index.d.mts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +0 -238
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +2 -4
- package/dist/hooks/api/index.js +78 -91
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +2 -2
- package/dist/hooks/index.js +140 -155
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-DromP9ET.d.mts → index-CPwcm70o.d.mts} +2 -9
- package/dist/{index-D3BHrg4-.d.ts → index-Dj1K-UdZ.d.ts} +2 -9
- package/dist/index.css +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +249 -448
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/ui/index.js +52 -65
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +2 -2
- package/example/src/App.tsx +0 -2
- package/package.json +1 -1
- package/dist/chunk-F7N2JPEQ.mjs.map +0 -1
- package/example/src/pages/Message/index.tsx +0 -5
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_react36 = require("react");
|
|
360
360
|
|
|
361
361
|
// src/MatchContext.tsx
|
|
362
|
-
var
|
|
362
|
+
var import_react35 = require("react");
|
|
363
363
|
|
|
364
364
|
// src/store/useModalStore.ts
|
|
365
365
|
var import_zustand2 = require("zustand");
|
|
@@ -1803,41 +1803,13 @@ var import_react29 = require("react");
|
|
|
1803
1803
|
var import_react_intl19 = require("react-intl");
|
|
1804
1804
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
1805
1805
|
|
|
1806
|
-
// src/
|
|
1807
|
-
var import_react_query7 = require("@tanstack/react-query");
|
|
1808
|
-
var import_last2 = __toESM(require("lodash/last"));
|
|
1806
|
+
// src/components/CEXBindModal/index.tsx
|
|
1809
1807
|
var import_react30 = require("react");
|
|
1810
|
-
|
|
1811
|
-
// src/components/MessageList/index.tsx
|
|
1812
|
-
var import_react32 = require("react");
|
|
1813
|
-
var import_react_virtuoso2 = require("react-virtuoso");
|
|
1814
1808
|
var import_react_intl20 = require("react-intl");
|
|
1815
|
-
var import_react33 = __toESM(require("react"));
|
|
1816
|
-
|
|
1817
|
-
// src/context/ModalContext.tsx
|
|
1818
|
-
var import_react31 = __toESM(require("react"));
|
|
1819
|
-
var import_react_dom = require("react-dom");
|
|
1820
1809
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
1821
|
-
var ModalContext = (0, import_react31.createContext)(null);
|
|
1822
|
-
function useModal() {
|
|
1823
|
-
const context = (0, import_react31.useContext)(ModalContext);
|
|
1824
|
-
if (!context) {
|
|
1825
|
-
throw new Error("useModal must be used within a ModalProvider");
|
|
1826
|
-
}
|
|
1827
|
-
return context;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
// src/components/MessageList/index.tsx
|
|
1831
|
-
var import_react_query8 = require("@tanstack/react-query");
|
|
1832
|
-
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
1833
|
-
|
|
1834
|
-
// src/components/CEXBindModal/index.tsx
|
|
1835
|
-
var import_react34 = require("react");
|
|
1836
|
-
var import_react_intl21 = require("react-intl");
|
|
1837
|
-
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
1838
1810
|
|
|
1839
1811
|
// src/context/BusinessProvider.tsx
|
|
1840
|
-
var
|
|
1812
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
1841
1813
|
|
|
1842
1814
|
// src/store/useStore.ts
|
|
1843
1815
|
var import_zustand4 = require("zustand");
|
|
@@ -1852,15 +1824,28 @@ var useStore = (0, import_zustand4.create)((set) => ({
|
|
|
1852
1824
|
var useStore_default = useStore;
|
|
1853
1825
|
|
|
1854
1826
|
// src/context/BusinessProvider.tsx
|
|
1855
|
-
var
|
|
1827
|
+
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
1828
|
+
|
|
1829
|
+
// src/context/ModalContext.tsx
|
|
1830
|
+
var import_react31 = __toESM(require("react"));
|
|
1831
|
+
var import_react_dom = require("react-dom");
|
|
1832
|
+
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
1833
|
+
var ModalContext = (0, import_react31.createContext)(null);
|
|
1834
|
+
function useModal() {
|
|
1835
|
+
const context = (0, import_react31.useContext)(ModalContext);
|
|
1836
|
+
if (!context) {
|
|
1837
|
+
throw new Error("useModal must be used within a ModalProvider");
|
|
1838
|
+
}
|
|
1839
|
+
return context;
|
|
1840
|
+
}
|
|
1856
1841
|
|
|
1857
1842
|
// src/context/ToastContext.tsx
|
|
1858
|
-
var
|
|
1843
|
+
var import_react32 = require("react");
|
|
1859
1844
|
var import_react_dom2 = require("react-dom");
|
|
1860
|
-
var
|
|
1861
|
-
var ToastContext = (0,
|
|
1845
|
+
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
1846
|
+
var ToastContext = (0, import_react32.createContext)(null);
|
|
1862
1847
|
function useToast() {
|
|
1863
|
-
const context = (0,
|
|
1848
|
+
const context = (0, import_react32.useContext)(ToastContext);
|
|
1864
1849
|
if (!context) {
|
|
1865
1850
|
throw new Error("useToast must be used within a ToastProvider");
|
|
1866
1851
|
}
|
|
@@ -1868,18 +1853,18 @@ function useToast() {
|
|
|
1868
1853
|
}
|
|
1869
1854
|
|
|
1870
1855
|
// src/context/index.tsx
|
|
1871
|
-
var
|
|
1856
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
1872
1857
|
|
|
1873
1858
|
// src/hooks/useWalletInit.ts
|
|
1874
|
-
var
|
|
1859
|
+
var import_react33 = require("react");
|
|
1875
1860
|
var AppClientId = getAppClientId();
|
|
1876
1861
|
|
|
1877
1862
|
// src/hooks/useInit.tsx
|
|
1878
|
-
var
|
|
1863
|
+
var import_react34 = require("react");
|
|
1879
1864
|
|
|
1880
1865
|
// src/MatchContext.tsx
|
|
1881
|
-
var
|
|
1882
|
-
var
|
|
1866
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
1867
|
+
var import_react_intl21 = require("react-intl");
|
|
1883
1868
|
var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
1884
1869
|
var import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
1885
1870
|
var import_chains = require("wagmi/chains");
|
|
@@ -1948,8 +1933,8 @@ var matchTest = /* @__PURE__ */ (0, import_viem6.defineChain)({
|
|
|
1948
1933
|
|
|
1949
1934
|
// src/MatchContext.tsx
|
|
1950
1935
|
var import_wagmi3 = require("wagmi");
|
|
1951
|
-
var
|
|
1952
|
-
var queryClient = new
|
|
1936
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
1937
|
+
var queryClient = new import_react_query8.QueryClient();
|
|
1953
1938
|
var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
|
|
1954
1939
|
appName: "MatchID",
|
|
1955
1940
|
projectId: "9ac6ea7e07860f04616fb311b447dee9",
|
|
@@ -1967,9 +1952,9 @@ var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
|
|
|
1967
1952
|
],
|
|
1968
1953
|
chains: [import_chains.mainnet, import_chains.polygon, import_chains.optimism, import_chains.arbitrum, import_chains.base, matchMain, matchTest, import_chains.bsc]
|
|
1969
1954
|
});
|
|
1970
|
-
var MatchContext = (0,
|
|
1955
|
+
var MatchContext = (0, import_react35.createContext)(void 0);
|
|
1971
1956
|
var useMatch = () => {
|
|
1972
|
-
const context = (0,
|
|
1957
|
+
const context = (0, import_react35.useContext)(MatchContext);
|
|
1973
1958
|
if (context === void 0) {
|
|
1974
1959
|
throw new Error("useMatch must be used within a MatchProvider");
|
|
1975
1960
|
}
|
|
@@ -2003,7 +1988,7 @@ function useUserInfo() {
|
|
|
2003
1988
|
const getRedirectUri = () => {
|
|
2004
1989
|
return encodeURIComponent(window.location.href);
|
|
2005
1990
|
};
|
|
2006
|
-
const isLogin = (0,
|
|
1991
|
+
const isLogin = (0, import_react36.useMemo)(() => !!token && !!overview, [token, overview]);
|
|
2007
1992
|
const logout = async () => {
|
|
2008
1993
|
try {
|
|
2009
1994
|
await toLogoutApi();
|
|
@@ -2274,9 +2259,9 @@ function useUserInfo() {
|
|
|
2274
2259
|
}
|
|
2275
2260
|
|
|
2276
2261
|
// src/hooks/useMatchEvents.ts
|
|
2277
|
-
var
|
|
2262
|
+
var import_react37 = require("react");
|
|
2278
2263
|
function useMatchEvents(handlers) {
|
|
2279
|
-
(0,
|
|
2264
|
+
(0, import_react37.useEffect)(() => {
|
|
2280
2265
|
Object.entries(handlers).forEach(([event, handler2]) => {
|
|
2281
2266
|
if (handler2) {
|
|
2282
2267
|
eventManager_default.on(event, handler2);
|
|
@@ -2296,7 +2281,7 @@ function useMatchEvents(handlers) {
|
|
|
2296
2281
|
var import_viem7 = require("viem");
|
|
2297
2282
|
var import_accounts = require("viem/accounts");
|
|
2298
2283
|
var import_viem8 = require("viem");
|
|
2299
|
-
var
|
|
2284
|
+
var import_react38 = require("react");
|
|
2300
2285
|
var import_viem9 = require("viem");
|
|
2301
2286
|
|
|
2302
2287
|
// src/store/useTransactionStore.ts
|
|
@@ -2330,7 +2315,7 @@ var useTransactionStore = (0, import_zustand5.create)((0, import_middleware3.dev
|
|
|
2330
2315
|
var useTransactionStore_default = useTransactionStore;
|
|
2331
2316
|
|
|
2332
2317
|
// src/hooks/useWallet.tsx
|
|
2333
|
-
var
|
|
2318
|
+
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
2334
2319
|
var AppClientId2 = "react-sdk-" + getVersion();
|
|
2335
2320
|
function useWallet() {
|
|
2336
2321
|
const { address, wallet: walletConfig } = useLocalStore_default();
|
|
@@ -2381,7 +2366,7 @@ function useWallet() {
|
|
|
2381
2366
|
throw error;
|
|
2382
2367
|
}
|
|
2383
2368
|
};
|
|
2384
|
-
const evmAccount = (0,
|
|
2369
|
+
const evmAccount = (0, import_react38.useMemo)(() => {
|
|
2385
2370
|
try {
|
|
2386
2371
|
return address ? (0, import_accounts.toAccount)({
|
|
2387
2372
|
address,
|
|
@@ -2420,7 +2405,7 @@ function useWallet() {
|
|
|
2420
2405
|
return void 0;
|
|
2421
2406
|
}
|
|
2422
2407
|
}, [address]);
|
|
2423
|
-
(0,
|
|
2408
|
+
(0, import_react38.useEffect)(() => {
|
|
2424
2409
|
matchlog_default.log("qwe-evmAccount", evmAccount);
|
|
2425
2410
|
}, [evmAccount]);
|
|
2426
2411
|
const realCreateWalletClient = (parameters) => {
|
|
@@ -2503,7 +2488,7 @@ function useWallet() {
|
|
|
2503
2488
|
address: evmAccount.address
|
|
2504
2489
|
});
|
|
2505
2490
|
modal.show((props) => {
|
|
2506
|
-
return /* @__PURE__ */ (0,
|
|
2491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(HashPanel_default, { isOpen: true, onClose: props.close, zIndex: props.zIndex, hash: txHash, chain: _chain });
|
|
2507
2492
|
});
|
|
2508
2493
|
clearInterval(window.matchProvider.transactionMessageIntervalMap[transactionId].interval);
|
|
2509
2494
|
delete window.matchProvider.transactionMessageIntervalMap[transactionId];
|
|
@@ -2556,14 +2541,14 @@ function useWallet() {
|
|
|
2556
2541
|
|
|
2557
2542
|
// src/hooks/useCopyClipboard.ts
|
|
2558
2543
|
var import_copy_to_clipboard = __toESM(require("copy-to-clipboard"));
|
|
2559
|
-
var
|
|
2544
|
+
var import_react39 = require("react");
|
|
2560
2545
|
function useCopyClipboard(timeout = 500) {
|
|
2561
|
-
const [isCopied, setIsCopied] = (0,
|
|
2562
|
-
const staticCopy = (0,
|
|
2546
|
+
const [isCopied, setIsCopied] = (0, import_react39.useState)(false);
|
|
2547
|
+
const staticCopy = (0, import_react39.useCallback)((text) => {
|
|
2563
2548
|
const didCopy = (0, import_copy_to_clipboard.default)(text);
|
|
2564
2549
|
setIsCopied(didCopy);
|
|
2565
2550
|
}, []);
|
|
2566
|
-
(0,
|
|
2551
|
+
(0, import_react39.useEffect)(() => {
|
|
2567
2552
|
if (isCopied) {
|
|
2568
2553
|
const hide = setTimeout(() => {
|
|
2569
2554
|
setIsCopied(false);
|
|
@@ -2578,16 +2563,16 @@ function useCopyClipboard(timeout = 500) {
|
|
|
2578
2563
|
}
|
|
2579
2564
|
|
|
2580
2565
|
// src/hooks/useMatchChain.tsx
|
|
2581
|
-
var
|
|
2566
|
+
var import_react40 = require("react");
|
|
2582
2567
|
var import_viem10 = require("viem");
|
|
2583
|
-
var
|
|
2584
|
-
var
|
|
2568
|
+
var import_react_intl22 = require("react-intl");
|
|
2569
|
+
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
2585
2570
|
function useMatchChain() {
|
|
2586
2571
|
const chainListQuery = useChainListQuery();
|
|
2587
2572
|
const modal = useModal();
|
|
2588
|
-
const intl = (0,
|
|
2573
|
+
const intl = (0, import_react_intl22.useIntl)();
|
|
2589
2574
|
const { chainId: storeChainId, setChainId } = useLocalStore_default();
|
|
2590
|
-
const chainId = (0,
|
|
2575
|
+
const chainId = (0, import_react40.useMemo)(() => {
|
|
2591
2576
|
if (!chainListQuery.data || !chainListQuery.data.length) {
|
|
2592
2577
|
return null;
|
|
2593
2578
|
}
|
|
@@ -2596,7 +2581,7 @@ function useMatchChain() {
|
|
|
2596
2581
|
}
|
|
2597
2582
|
return chainListQuery.data[0].id;
|
|
2598
2583
|
}, [storeChainId, chainListQuery.data]);
|
|
2599
|
-
const chain = (0,
|
|
2584
|
+
const chain = (0, import_react40.useMemo)(() => {
|
|
2600
2585
|
if (!chainListQuery.data || !chainListQuery.data.length) {
|
|
2601
2586
|
return null;
|
|
2602
2587
|
}
|
|
@@ -2610,30 +2595,30 @@ function useMatchChain() {
|
|
|
2610
2595
|
close
|
|
2611
2596
|
}) {
|
|
2612
2597
|
const { chainId: storeChainId2, setChainId: setChainId2 } = useLocalStore_default();
|
|
2613
|
-
const [selectedChainId, setSelectedChainId] = (0,
|
|
2598
|
+
const [selectedChainId, setSelectedChainId] = (0, import_react40.useState)(storeChainId2);
|
|
2614
2599
|
const isDownMd = useDownMd();
|
|
2615
|
-
return /* @__PURE__ */ (0,
|
|
2616
|
-
/* @__PURE__ */ (0,
|
|
2617
|
-
return /* @__PURE__ */ (0,
|
|
2600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-change-network-box`, children: [
|
|
2601
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: `matchid-change-network-list`, children: chainListQuery.data?.map((item, index) => {
|
|
2602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
|
|
2618
2603
|
"div",
|
|
2619
2604
|
{
|
|
2620
2605
|
onClick: () => setSelectedChainId(item.id),
|
|
2621
2606
|
className: `matchid-change-network-item ${selectedChainId == item.id ? "matchid-change-network-selected" : ""}`,
|
|
2622
2607
|
children: [
|
|
2623
|
-
/* @__PURE__ */ (0,
|
|
2624
|
-
/* @__PURE__ */ (0,
|
|
2625
|
-
/* @__PURE__ */ (0,
|
|
2608
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: `matchid-change-network-item-content`, children: [
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("img", { src: item.iconUrl, className: `matchid-change-network-item-icon` }),
|
|
2610
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "matchid-change-network-item-name", children: item.name })
|
|
2626
2611
|
] }),
|
|
2627
|
-
/* @__PURE__ */ (0,
|
|
2612
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Radio, { checked: selectedChainId === item.id, size: isDownMd ? 18 : 24 })
|
|
2628
2613
|
]
|
|
2629
2614
|
},
|
|
2630
2615
|
index
|
|
2631
2616
|
);
|
|
2632
2617
|
}) }),
|
|
2633
|
-
/* @__PURE__ */ (0,
|
|
2618
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Button, { size: "lg", highlight: true, onClick: () => {
|
|
2634
2619
|
setChainId2(selectedChainId || 0);
|
|
2635
2620
|
close();
|
|
2636
|
-
}, block: true, children: /* @__PURE__ */ (0,
|
|
2621
|
+
}, block: true, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_react_intl22.FormattedMessage, { id: "confirm" }) })
|
|
2637
2622
|
] });
|
|
2638
2623
|
}
|
|
2639
2624
|
const showChangeNetwork = () => {
|
|
@@ -2642,7 +2627,7 @@ function useMatchChain() {
|
|
|
2642
2627
|
content: ChangeNetwork
|
|
2643
2628
|
});
|
|
2644
2629
|
};
|
|
2645
|
-
const publicClient = (0,
|
|
2630
|
+
const publicClient = (0, import_react40.useMemo)(() => {
|
|
2646
2631
|
if (!chain) {
|
|
2647
2632
|
return null;
|
|
2648
2633
|
}
|
|
@@ -2670,26 +2655,26 @@ function useMatchChain() {
|
|
|
2670
2655
|
|
|
2671
2656
|
// src/hooks/useMatchWallet.tsx
|
|
2672
2657
|
var import_react_qrcode = require("react-qrcode");
|
|
2673
|
-
var
|
|
2674
|
-
var
|
|
2658
|
+
var import_react42 = require("react");
|
|
2659
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
2675
2660
|
var import_viem13 = require("viem");
|
|
2676
|
-
var
|
|
2661
|
+
var import_react_intl24 = require("react-intl");
|
|
2677
2662
|
|
|
2678
2663
|
// src/components/ImportToken/index.tsx
|
|
2679
|
-
var
|
|
2680
|
-
var
|
|
2681
|
-
var
|
|
2664
|
+
var import_react41 = require("react");
|
|
2665
|
+
var import_react_intl23 = require("react-intl");
|
|
2666
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
2682
2667
|
var import_viem12 = require("viem");
|
|
2683
2668
|
|
|
2684
2669
|
// src/hooks/useIsContract.ts
|
|
2685
2670
|
var import_viem11 = require("viem");
|
|
2686
|
-
var
|
|
2671
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
2687
2672
|
function useIsContract({
|
|
2688
2673
|
address,
|
|
2689
2674
|
chain,
|
|
2690
2675
|
enabled
|
|
2691
2676
|
}) {
|
|
2692
|
-
return (0,
|
|
2677
|
+
return (0, import_react_query9.useQuery)({
|
|
2693
2678
|
queryKey: ["is_contract", chain?.id, address],
|
|
2694
2679
|
queryFn: async () => {
|
|
2695
2680
|
if (!chain) return false;
|
|
@@ -2706,14 +2691,14 @@ function useIsContract({
|
|
|
2706
2691
|
}
|
|
2707
2692
|
|
|
2708
2693
|
// src/components/ImportToken/index.tsx
|
|
2709
|
-
var
|
|
2694
|
+
var import_jsx_runtime98 = require("react/jsx-runtime");
|
|
2710
2695
|
function ImportToken({ close }) {
|
|
2711
|
-
const [status, setStatus] = (0,
|
|
2696
|
+
const [status, setStatus] = (0, import_react41.useState)("");
|
|
2712
2697
|
const { token } = useUserInfo();
|
|
2713
|
-
const [address, setAddress] = (0,
|
|
2714
|
-
const [symbol, setSymbol] = (0,
|
|
2715
|
-
const [decimals, setDecimals] = (0,
|
|
2716
|
-
const [error, setError] = (0,
|
|
2698
|
+
const [address, setAddress] = (0, import_react41.useState)("");
|
|
2699
|
+
const [symbol, setSymbol] = (0, import_react41.useState)("");
|
|
2700
|
+
const [decimals, setDecimals] = (0, import_react41.useState)("");
|
|
2701
|
+
const [error, setError] = (0, import_react41.useState)({});
|
|
2717
2702
|
const { publicClient, chainId, chain } = useMatchChain();
|
|
2718
2703
|
const getContractInfo = async () => {
|
|
2719
2704
|
if (!publicClient) return;
|
|
@@ -2746,8 +2731,8 @@ function ImportToken({ close }) {
|
|
|
2746
2731
|
});
|
|
2747
2732
|
}
|
|
2748
2733
|
};
|
|
2749
|
-
const intl = (0,
|
|
2750
|
-
(0,
|
|
2734
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
2735
|
+
(0, import_react41.useEffect)(() => {
|
|
2751
2736
|
if (address.length === 42) {
|
|
2752
2737
|
const reg = /^0x[0-9a-fA-F]{40}$/;
|
|
2753
2738
|
if (!reg.test(address)) {
|
|
@@ -2766,9 +2751,9 @@ function ImportToken({ close }) {
|
|
|
2766
2751
|
}
|
|
2767
2752
|
}
|
|
2768
2753
|
}, [address, publicClient]);
|
|
2769
|
-
const [loading, setLoading] = (0,
|
|
2754
|
+
const [loading, setLoading] = (0, import_react41.useState)(false);
|
|
2770
2755
|
const toast = useToast();
|
|
2771
|
-
const queryClient2 = (0,
|
|
2756
|
+
const queryClient2 = (0, import_react_query10.useQueryClient)();
|
|
2772
2757
|
const onImport = async () => {
|
|
2773
2758
|
setLoading(true);
|
|
2774
2759
|
try {
|
|
@@ -2794,7 +2779,7 @@ function ImportToken({ close }) {
|
|
|
2794
2779
|
setLoading(false);
|
|
2795
2780
|
}
|
|
2796
2781
|
};
|
|
2797
|
-
const canImport = (0,
|
|
2782
|
+
const canImport = (0, import_react41.useMemo)(() => {
|
|
2798
2783
|
if (!address) {
|
|
2799
2784
|
return false;
|
|
2800
2785
|
}
|
|
@@ -2817,19 +2802,19 @@ function ImportToken({ close }) {
|
|
|
2817
2802
|
enabled: canImport
|
|
2818
2803
|
});
|
|
2819
2804
|
if (status == "success" || status == "fail") {
|
|
2820
|
-
return /* @__PURE__ */ (0,
|
|
2821
|
-
/* @__PURE__ */ (0,
|
|
2822
|
-
/* @__PURE__ */ (0,
|
|
2823
|
-
/* @__PURE__ */ (0,
|
|
2805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: `matchid-import-token-result matchid-flex`, children: [
|
|
2806
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: `matchid-import-token-result-box matchid-flex`, children: [
|
|
2807
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("img", { src: status == "success" ? success_default : fail_default, alt: status == "success" ? "success" : "fail", className: `matchid-import-token-result-img` }),
|
|
2808
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: `matchid-import-token-result-text matchid-import-token-result-text-${status}`, children: status == "success" ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "importSuccess" }) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "importFail" }) })
|
|
2824
2809
|
] }),
|
|
2825
|
-
status == "success" ? /* @__PURE__ */ (0,
|
|
2810
|
+
status == "success" ? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Button, { size: "lg", onClick: close, block: true, highlight: true, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "close" }) }) : /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Button, { size: "lg", onClick: () => setStatus(""), block: true, highlight: true, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "back" }) })
|
|
2826
2811
|
] });
|
|
2827
2812
|
}
|
|
2828
|
-
return /* @__PURE__ */ (0,
|
|
2829
|
-
/* @__PURE__ */ (0,
|
|
2830
|
-
/* @__PURE__ */ (0,
|
|
2813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: `matchid-import-token`, children: [
|
|
2814
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: "matchid-import-token-form", children: [
|
|
2815
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Field, { label: intl.formatMessage({
|
|
2831
2816
|
id: "tokenSmartContract"
|
|
2832
|
-
}), error: error.address ? error.address : isContractQuery.isFetched && !isContractQuery.isLoading && !isContractQuery.data && canImport ? "Address isn't a contract address" : "", children: /* @__PURE__ */ (0,
|
|
2817
|
+
}), error: error.address ? error.address : isContractQuery.isFetched && !isContractQuery.isLoading && !isContractQuery.data && canImport ? "Address isn't a contract address" : "", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2833
2818
|
Input,
|
|
2834
2819
|
{
|
|
2835
2820
|
placeholder: intl.formatMessage({
|
|
@@ -2840,9 +2825,9 @@ function ImportToken({ close }) {
|
|
|
2840
2825
|
maxLength: 42
|
|
2841
2826
|
}
|
|
2842
2827
|
) }),
|
|
2843
|
-
/* @__PURE__ */ (0,
|
|
2828
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Field, { label: intl.formatMessage({
|
|
2844
2829
|
id: "tokenSymbol"
|
|
2845
|
-
}), error: error.symbol, children: /* @__PURE__ */ (0,
|
|
2830
|
+
}), error: error.symbol, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2846
2831
|
Input,
|
|
2847
2832
|
{
|
|
2848
2833
|
placeholder: intl.formatMessage({
|
|
@@ -2853,9 +2838,9 @@ function ImportToken({ close }) {
|
|
|
2853
2838
|
maxLength: 16
|
|
2854
2839
|
}
|
|
2855
2840
|
) }),
|
|
2856
|
-
/* @__PURE__ */ (0,
|
|
2841
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Field, { label: intl.formatMessage({
|
|
2857
2842
|
id: "tokenDecimals"
|
|
2858
|
-
}), error: error.decimals, children: /* @__PURE__ */ (0,
|
|
2843
|
+
}), error: error.decimals, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2859
2844
|
Input,
|
|
2860
2845
|
{
|
|
2861
2846
|
placeholder: intl.formatMessage({
|
|
@@ -2867,7 +2852,7 @@ function ImportToken({ close }) {
|
|
|
2867
2852
|
}
|
|
2868
2853
|
) })
|
|
2869
2854
|
] }),
|
|
2870
|
-
/* @__PURE__ */ (0,
|
|
2855
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
2871
2856
|
Button,
|
|
2872
2857
|
{
|
|
2873
2858
|
size: "lg",
|
|
@@ -2876,20 +2861,20 @@ function ImportToken({ close }) {
|
|
|
2876
2861
|
loading: loading || isContractQuery.isLoading,
|
|
2877
2862
|
disabled: !canImport || !isContractQuery.data,
|
|
2878
2863
|
highlight: true,
|
|
2879
|
-
children: /* @__PURE__ */ (0,
|
|
2864
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_react_intl23.FormattedMessage, { id: "import" })
|
|
2880
2865
|
}
|
|
2881
2866
|
)
|
|
2882
2867
|
] });
|
|
2883
2868
|
}
|
|
2884
2869
|
|
|
2885
2870
|
// src/hooks/useMatchWallet.tsx
|
|
2886
|
-
var
|
|
2871
|
+
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
2887
2872
|
var ReceiveModal = () => {
|
|
2888
2873
|
const chain = useMatchChain();
|
|
2889
2874
|
const { address } = useWallet();
|
|
2890
2875
|
const [copied, setCopied] = useCopyClipboard();
|
|
2891
2876
|
const toast = useToast();
|
|
2892
|
-
const intl = (0,
|
|
2877
|
+
const intl = (0, import_react_intl24.useIntl)();
|
|
2893
2878
|
const onCopy = () => {
|
|
2894
2879
|
setCopied(address);
|
|
2895
2880
|
toast.success(intl.formatMessage({
|
|
@@ -2897,10 +2882,10 @@ var ReceiveModal = () => {
|
|
|
2897
2882
|
}));
|
|
2898
2883
|
};
|
|
2899
2884
|
const chainLink = chain.explorerLink("address/" + address);
|
|
2900
|
-
return /* @__PURE__ */ (0,
|
|
2901
|
-
/* @__PURE__ */ (0,
|
|
2902
|
-
/* @__PURE__ */ (0,
|
|
2903
|
-
/* @__PURE__ */ (0,
|
|
2885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: `matchid-receive-modal`, children: [
|
|
2886
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "matchid-receive-container", children: [
|
|
2887
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: `matchid-receive-text`, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_react_intl24.FormattedMessage, { id: "receiveQrcode" }) }),
|
|
2888
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
2904
2889
|
import_react_qrcode.QRCode,
|
|
2905
2890
|
{
|
|
2906
2891
|
margin: "0",
|
|
@@ -2908,7 +2893,7 @@ var ReceiveModal = () => {
|
|
|
2908
2893
|
value: address
|
|
2909
2894
|
}
|
|
2910
2895
|
) }),
|
|
2911
|
-
/* @__PURE__ */ (0,
|
|
2896
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
2912
2897
|
"a",
|
|
2913
2898
|
{
|
|
2914
2899
|
href: chainLink,
|
|
@@ -2918,8 +2903,8 @@ var ReceiveModal = () => {
|
|
|
2918
2903
|
}
|
|
2919
2904
|
)
|
|
2920
2905
|
] }),
|
|
2921
|
-
/* @__PURE__ */ (0,
|
|
2922
|
-
|
|
2906
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
2907
|
+
import_react_intl24.FormattedMessage,
|
|
2923
2908
|
{
|
|
2924
2909
|
id: "copyAddress"
|
|
2925
2910
|
}
|
|
@@ -2928,7 +2913,7 @@ var ReceiveModal = () => {
|
|
|
2928
2913
|
};
|
|
2929
2914
|
function useMatchWallet() {
|
|
2930
2915
|
const modal = useModal();
|
|
2931
|
-
const intl = (0,
|
|
2916
|
+
const intl = (0, import_react_intl24.useIntl)();
|
|
2932
2917
|
const showReceiveModal = () => {
|
|
2933
2918
|
modal.open({
|
|
2934
2919
|
title: intl.formatMessage({
|
|
@@ -2960,12 +2945,12 @@ function useMatchWallet() {
|
|
|
2960
2945
|
};
|
|
2961
2946
|
}
|
|
2962
2947
|
function useMatchWalletRecords() {
|
|
2963
|
-
const [hasMore, setHasMore] = (0,
|
|
2964
|
-
const [items, setItems] = (0,
|
|
2948
|
+
const [hasMore, setHasMore] = (0, import_react42.useState)(true);
|
|
2949
|
+
const [items, setItems] = (0, import_react42.useState)([]);
|
|
2965
2950
|
const { chainId, publicClient } = useMatchChain();
|
|
2966
2951
|
const { address } = useWallet();
|
|
2967
|
-
const hasMoreRef = (0,
|
|
2968
|
-
const nextPageParamsRef = (0,
|
|
2952
|
+
const hasMoreRef = (0, import_react42.useRef)(hasMore);
|
|
2953
|
+
const nextPageParamsRef = (0, import_react42.useRef)(void 0);
|
|
2969
2954
|
const { contracts, setContracts } = useContractStore_default();
|
|
2970
2955
|
const fetchMoreData = async () => {
|
|
2971
2956
|
const chainIdStr = chainId ? chainId.toString() : "";
|
|
@@ -2992,7 +2977,7 @@ function useMatchWalletRecords() {
|
|
|
2992
2977
|
hasMoreRef.current = true;
|
|
2993
2978
|
fetchMoreData();
|
|
2994
2979
|
};
|
|
2995
|
-
(0,
|
|
2980
|
+
(0, import_react42.useEffect)(() => {
|
|
2996
2981
|
if (chainId && address) {
|
|
2997
2982
|
onInit();
|
|
2998
2983
|
}
|
|
@@ -3048,7 +3033,7 @@ function useMatchWalletRecords() {
|
|
|
3048
3033
|
setContracts(contractMap);
|
|
3049
3034
|
}
|
|
3050
3035
|
};
|
|
3051
|
-
const list = (0,
|
|
3036
|
+
const list = (0, import_react42.useMemo)(() => {
|
|
3052
3037
|
const localTransactions = transactions[`${chainId}-${address}`] || [];
|
|
3053
3038
|
const removeList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
|
|
3054
3039
|
removeList.forEach((item) => {
|
|
@@ -3090,7 +3075,7 @@ function useMatchWalletAssets({
|
|
|
3090
3075
|
chainId: chainId || 0,
|
|
3091
3076
|
...assetListOptions
|
|
3092
3077
|
});
|
|
3093
|
-
const mergedAssets = (0,
|
|
3078
|
+
const mergedAssets = (0, import_react42.useMemo)(() => {
|
|
3094
3079
|
if (!assetListQuery.data && !importTokenQuery.data) return [];
|
|
3095
3080
|
const assetList = (assetListQuery.data || []).map((asset) => ({
|
|
3096
3081
|
...asset,
|
|
@@ -3158,7 +3143,7 @@ function useMatchWalletAssetList({
|
|
|
3158
3143
|
name: chain?.nativeCurrency.name,
|
|
3159
3144
|
balance: 0
|
|
3160
3145
|
};
|
|
3161
|
-
const nativeBalanceQuery = (0,
|
|
3146
|
+
const nativeBalanceQuery = (0, import_react_query11.useQuery)({
|
|
3162
3147
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
3163
3148
|
queryFn: async () => {
|
|
3164
3149
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -3177,8 +3162,8 @@ function useMatchWalletAssetList({
|
|
|
3177
3162
|
retry: 3
|
|
3178
3163
|
// Retry up to 3 times if failed
|
|
3179
3164
|
});
|
|
3180
|
-
const erc20Tokens = (0,
|
|
3181
|
-
const erc20BalanceQuery = (0,
|
|
3165
|
+
const erc20Tokens = (0, import_react42.useMemo)(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
3166
|
+
const erc20BalanceQuery = (0, import_react_query11.useQuery)({
|
|
3182
3167
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
3183
3168
|
queryFn: async () => {
|
|
3184
3169
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
@@ -3205,7 +3190,7 @@ function useMatchWalletAssetList({
|
|
|
3205
3190
|
// Refresh every 15 seconds
|
|
3206
3191
|
retry: 3
|
|
3207
3192
|
});
|
|
3208
|
-
const enrichedAssets = (0,
|
|
3193
|
+
const enrichedAssets = (0, import_react42.useMemo)(() => {
|
|
3209
3194
|
if (!list) return [];
|
|
3210
3195
|
const erc20Balances = erc20BalanceQuery.data || [];
|
|
3211
3196
|
return list.map((asset) => {
|
|
@@ -3227,7 +3212,7 @@ function useMatchWalletAssetList({
|
|
|
3227
3212
|
return { ...asset, balance, value, balanceValue };
|
|
3228
3213
|
});
|
|
3229
3214
|
}, [list, nativeBalanceQuery.data, erc20BalanceQuery.data]);
|
|
3230
|
-
(0,
|
|
3215
|
+
(0, import_react42.useEffect)(() => {
|
|
3231
3216
|
const list2 = enrichedAssets.sort((a, b) => {
|
|
3232
3217
|
if (a.address === NATIVE_TOKEN_ADDRESS) return -1;
|
|
3233
3218
|
if (b.address === NATIVE_TOKEN_ADDRESS) return 1;
|
|
@@ -3252,14 +3237,14 @@ function useMatchWalletAssetList({
|
|
|
3252
3237
|
}
|
|
3253
3238
|
|
|
3254
3239
|
// src/hooks/useReceipt.tsx
|
|
3255
|
-
var
|
|
3256
|
-
var
|
|
3240
|
+
var import_react43 = require("react");
|
|
3241
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
3257
3242
|
var import_viem14 = require("viem");
|
|
3258
3243
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
3259
3244
|
var MAX_CACHE_SIZE = 500;
|
|
3260
3245
|
var STORAGE_KEY = "match_receipt_logs";
|
|
3261
3246
|
function useReceiptCache() {
|
|
3262
|
-
const [cache, setCache] = (0,
|
|
3247
|
+
const [cache, setCache] = (0, import_react43.useState)(/* @__PURE__ */ new Map());
|
|
3263
3248
|
const isLocalStorageAvailable = (() => {
|
|
3264
3249
|
try {
|
|
3265
3250
|
const testKey = "__test__";
|
|
@@ -3270,7 +3255,7 @@ function useReceiptCache() {
|
|
|
3270
3255
|
return false;
|
|
3271
3256
|
}
|
|
3272
3257
|
})();
|
|
3273
|
-
(0,
|
|
3258
|
+
(0, import_react43.useEffect)(() => {
|
|
3274
3259
|
if (isLocalStorageAvailable) {
|
|
3275
3260
|
try {
|
|
3276
3261
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3289,7 +3274,7 @@ function useReceiptCache() {
|
|
|
3289
3274
|
}
|
|
3290
3275
|
}
|
|
3291
3276
|
}, []);
|
|
3292
|
-
const updateLocalStorage = (0,
|
|
3277
|
+
const updateLocalStorage = (0, import_react43.useCallback)((updatedCache) => {
|
|
3293
3278
|
if (isLocalStorageAvailable) {
|
|
3294
3279
|
try {
|
|
3295
3280
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3306,7 +3291,7 @@ function useReceiptCache() {
|
|
|
3306
3291
|
}
|
|
3307
3292
|
}
|
|
3308
3293
|
}, []);
|
|
3309
|
-
const set = (0,
|
|
3294
|
+
const set = (0, import_react43.useCallback)((key, value) => {
|
|
3310
3295
|
const now = Date.now();
|
|
3311
3296
|
const newCache = new Map(cache);
|
|
3312
3297
|
newCache.forEach((entry, k) => {
|
|
@@ -3324,7 +3309,7 @@ function useReceiptCache() {
|
|
|
3324
3309
|
setCache(newCache);
|
|
3325
3310
|
updateLocalStorage(newCache);
|
|
3326
3311
|
}, [cache, updateLocalStorage]);
|
|
3327
|
-
const get = (0,
|
|
3312
|
+
const get = (0, import_react43.useCallback)((key) => {
|
|
3328
3313
|
const entry = cache.get(key);
|
|
3329
3314
|
if (entry) {
|
|
3330
3315
|
if (Date.now() - entry.timestamp > CACHE_TTL) {
|
|
@@ -3338,7 +3323,7 @@ function useReceiptCache() {
|
|
|
3338
3323
|
}
|
|
3339
3324
|
return void 0;
|
|
3340
3325
|
}, [cache, updateLocalStorage]);
|
|
3341
|
-
const del = (0,
|
|
3326
|
+
const del = (0, import_react43.useCallback)((key) => {
|
|
3342
3327
|
if (cache.has(key)) {
|
|
3343
3328
|
const newCache = new Map(cache);
|
|
3344
3329
|
newCache.delete(key);
|
|
@@ -3346,7 +3331,7 @@ function useReceiptCache() {
|
|
|
3346
3331
|
updateLocalStorage(newCache);
|
|
3347
3332
|
}
|
|
3348
3333
|
}, [cache, updateLocalStorage]);
|
|
3349
|
-
const clear = (0,
|
|
3334
|
+
const clear = (0, import_react43.useCallback)(() => {
|
|
3350
3335
|
setCache(/* @__PURE__ */ new Map());
|
|
3351
3336
|
if (isLocalStorageAvailable) {
|
|
3352
3337
|
localStorage.removeItem(STORAGE_KEY);
|
|
@@ -3361,8 +3346,8 @@ function useReceipt2({
|
|
|
3361
3346
|
const { list } = useMatchChain();
|
|
3362
3347
|
const cache = useReceiptCache();
|
|
3363
3348
|
const chain = list?.find((item) => item.id === chainId);
|
|
3364
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3365
|
-
const query = (0,
|
|
3349
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react43.useState)(true);
|
|
3350
|
+
const query = (0, import_react_query12.useQuery)({
|
|
3366
3351
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
3367
3352
|
queryFn: async () => {
|
|
3368
3353
|
if (!chain || !hash) return false;
|
|
@@ -3387,7 +3372,7 @@ function useReceipt2({
|
|
|
3387
3372
|
},
|
|
3388
3373
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3389
3374
|
});
|
|
3390
|
-
(0,
|
|
3375
|
+
(0, import_react43.useEffect)(() => {
|
|
3391
3376
|
if (query.data) {
|
|
3392
3377
|
setShouldRefetch(false);
|
|
3393
3378
|
}
|
|
@@ -3396,14 +3381,14 @@ function useReceipt2({
|
|
|
3396
3381
|
}
|
|
3397
3382
|
|
|
3398
3383
|
// src/hooks/useTransaction.tsx
|
|
3399
|
-
var
|
|
3400
|
-
var
|
|
3384
|
+
var import_react44 = require("react");
|
|
3385
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
3401
3386
|
var import_viem15 = require("viem");
|
|
3402
3387
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
3403
3388
|
var MAX_CACHE_SIZE2 = 500;
|
|
3404
3389
|
var STORAGE_KEY2 = "match_transaction_logs";
|
|
3405
3390
|
function useTransactionCache() {
|
|
3406
|
-
const [cache, setCache] = (0,
|
|
3391
|
+
const [cache, setCache] = (0, import_react44.useState)(/* @__PURE__ */ new Map());
|
|
3407
3392
|
const isLocalStorageAvailable = (() => {
|
|
3408
3393
|
try {
|
|
3409
3394
|
const testKey = "__test__";
|
|
@@ -3414,7 +3399,7 @@ function useTransactionCache() {
|
|
|
3414
3399
|
return false;
|
|
3415
3400
|
}
|
|
3416
3401
|
})();
|
|
3417
|
-
(0,
|
|
3402
|
+
(0, import_react44.useEffect)(() => {
|
|
3418
3403
|
if (isLocalStorageAvailable) {
|
|
3419
3404
|
try {
|
|
3420
3405
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3433,7 +3418,7 @@ function useTransactionCache() {
|
|
|
3433
3418
|
}
|
|
3434
3419
|
}
|
|
3435
3420
|
}, []);
|
|
3436
|
-
const updateLocalStorage = (0,
|
|
3421
|
+
const updateLocalStorage = (0, import_react44.useCallback)((updatedCache) => {
|
|
3437
3422
|
if (isLocalStorageAvailable) {
|
|
3438
3423
|
try {
|
|
3439
3424
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3450,7 +3435,7 @@ function useTransactionCache() {
|
|
|
3450
3435
|
}
|
|
3451
3436
|
}
|
|
3452
3437
|
}, []);
|
|
3453
|
-
const set = (0,
|
|
3438
|
+
const set = (0, import_react44.useCallback)((key, value) => {
|
|
3454
3439
|
const now = Date.now();
|
|
3455
3440
|
const newCache = new Map(cache);
|
|
3456
3441
|
newCache.forEach((entry, k) => {
|
|
@@ -3468,7 +3453,7 @@ function useTransactionCache() {
|
|
|
3468
3453
|
setCache(newCache);
|
|
3469
3454
|
updateLocalStorage(newCache);
|
|
3470
3455
|
}, [cache, updateLocalStorage]);
|
|
3471
|
-
const get = (0,
|
|
3456
|
+
const get = (0, import_react44.useCallback)((key) => {
|
|
3472
3457
|
const entry = cache.get(key);
|
|
3473
3458
|
if (entry) {
|
|
3474
3459
|
if (Date.now() - entry.timestamp > CACHE_TTL2) {
|
|
@@ -3482,7 +3467,7 @@ function useTransactionCache() {
|
|
|
3482
3467
|
}
|
|
3483
3468
|
return void 0;
|
|
3484
3469
|
}, [cache, updateLocalStorage]);
|
|
3485
|
-
const del = (0,
|
|
3470
|
+
const del = (0, import_react44.useCallback)((key) => {
|
|
3486
3471
|
if (cache.has(key)) {
|
|
3487
3472
|
const newCache = new Map(cache);
|
|
3488
3473
|
newCache.delete(key);
|
|
@@ -3490,7 +3475,7 @@ function useTransactionCache() {
|
|
|
3490
3475
|
updateLocalStorage(newCache);
|
|
3491
3476
|
}
|
|
3492
3477
|
}, [cache, updateLocalStorage]);
|
|
3493
|
-
const clear = (0,
|
|
3478
|
+
const clear = (0, import_react44.useCallback)(() => {
|
|
3494
3479
|
setCache(/* @__PURE__ */ new Map());
|
|
3495
3480
|
if (isLocalStorageAvailable) {
|
|
3496
3481
|
localStorage.removeItem(STORAGE_KEY2);
|
|
@@ -3505,8 +3490,8 @@ function useTransaction({
|
|
|
3505
3490
|
const { list } = useMatchChain();
|
|
3506
3491
|
const cache = useTransactionCache();
|
|
3507
3492
|
const chain = list?.find((item) => item.id === chainId);
|
|
3508
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3509
|
-
const query = (0,
|
|
3493
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react44.useState)(true);
|
|
3494
|
+
const query = (0, import_react_query13.useQuery)({
|
|
3510
3495
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
3511
3496
|
queryFn: async () => {
|
|
3512
3497
|
if (!chain || !hash) return false;
|
|
@@ -3531,7 +3516,7 @@ function useTransaction({
|
|
|
3531
3516
|
},
|
|
3532
3517
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3533
3518
|
});
|
|
3534
|
-
(0,
|
|
3519
|
+
(0, import_react44.useEffect)(() => {
|
|
3535
3520
|
if (query.data) {
|
|
3536
3521
|
setShouldRefetch(false);
|
|
3537
3522
|
}
|