@matchain/matchid-sdk-react 0.1.48-alpha.20 → 0.1.48-alpha.22
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-WXPVHKGJ.mjs → chunk-FB5MHLWX.mjs} +3 -1
- package/dist/{chunk-3UVHHJP6.mjs → chunk-MUEDDGKX.mjs} +2 -2
- package/dist/{chunk-WHZ3HI4R.mjs → chunk-WPXA4QPX.mjs} +613 -562
- package/dist/chunk-WPXA4QPX.mjs.map +1 -0
- package/dist/components/index.js +456 -446
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -3
- package/dist/hooks/api/index.js +38 -28
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +3 -3
- package/dist/hooks/index.js +136 -132
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +3 -3
- package/dist/index.css +33 -0
- package/dist/index.js +267 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/ui/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-WHZ3HI4R.mjs.map +0 -1
- /package/dist/{chunk-WXPVHKGJ.mjs.map → chunk-FB5MHLWX.mjs.map} +0 -0
- /package/dist/{chunk-3UVHHJP6.mjs.map → chunk-MUEDDGKX.mjs.map} +0 -0
package/dist/hooks/api/index.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
bind_exports,
|
|
3
3
|
poh_exports,
|
|
4
4
|
user_exports
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-MUEDDGKX.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isSuccess,
|
|
8
8
|
wallet_exports
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-WPXA4QPX.mjs";
|
|
10
10
|
import "../../chunk-UA6XHZHX.mjs";
|
|
11
|
-
import "../../chunk-WXPVHKGJ.mjs";
|
|
12
11
|
import "../../chunk-5JHHHLG4.mjs";
|
|
12
|
+
import "../../chunk-FB5MHLWX.mjs";
|
|
13
13
|
import "../../chunk-LHNKZISB.mjs";
|
|
14
14
|
import "../../chunk-J5LGTIGS.mjs";
|
|
15
15
|
export {
|
package/dist/hooks/index.js
CHANGED
|
@@ -1759,11 +1759,12 @@ var useContractStore = (0, import_zustand3.create)((0, import_middleware2.devtoo
|
|
|
1759
1759
|
var useContractStore_default = useContractStore;
|
|
1760
1760
|
|
|
1761
1761
|
// src/components/TransactionList/index.tsx
|
|
1762
|
+
var import_react_intl17 = require("react-intl");
|
|
1762
1763
|
var import_jsx_runtime84 = require("react/jsx-runtime");
|
|
1763
1764
|
|
|
1764
1765
|
// src/components/CEXBindModal/index.tsx
|
|
1765
1766
|
var import_react26 = require("react");
|
|
1766
|
-
var
|
|
1767
|
+
var import_react_intl18 = require("react-intl");
|
|
1767
1768
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
1768
1769
|
|
|
1769
1770
|
// src/context/BusinessProvider.tsx
|
|
@@ -1817,7 +1818,7 @@ var import_react30 = require("react");
|
|
|
1817
1818
|
|
|
1818
1819
|
// src/MatchContext.tsx
|
|
1819
1820
|
var import_react_query3 = require("@tanstack/react-query");
|
|
1820
|
-
var
|
|
1821
|
+
var import_react_intl19 = require("react-intl");
|
|
1821
1822
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
1822
1823
|
var queryClient = new import_react_query3.QueryClient();
|
|
1823
1824
|
var MatchContext = (0, import_react31.createContext)(void 0);
|
|
@@ -2532,54 +2533,19 @@ function useMatchChain() {
|
|
|
2532
2533
|
|
|
2533
2534
|
// src/hooks/useMatchWallet.tsx
|
|
2534
2535
|
var import_react_qrcode = require("react-qrcode");
|
|
2536
|
+
var import_react38 = require("react");
|
|
2537
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
2538
|
+
var import_viem10 = require("viem");
|
|
2539
|
+
var import_react_intl21 = require("react-intl");
|
|
2540
|
+
|
|
2541
|
+
// src/components/ImportToken/index.tsx
|
|
2535
2542
|
var import_react37 = require("react");
|
|
2543
|
+
var import_react_intl20 = require("react-intl");
|
|
2536
2544
|
var import_react_query5 = require("@tanstack/react-query");
|
|
2537
2545
|
var import_viem9 = require("viem");
|
|
2538
|
-
var import_react_intl19 = require("react-intl");
|
|
2539
2546
|
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
2540
|
-
|
|
2541
|
-
const
|
|
2542
|
-
const { address } = useWallet2();
|
|
2543
|
-
const [copied, setCopied] = useCopyClipboard();
|
|
2544
|
-
const toast = useToast();
|
|
2545
|
-
const intl = (0, import_react_intl19.useIntl)();
|
|
2546
|
-
const onCopy = () => {
|
|
2547
|
-
setCopied(address);
|
|
2548
|
-
toast.success(intl.formatMessage({
|
|
2549
|
-
id: "copied"
|
|
2550
|
-
}));
|
|
2551
|
-
};
|
|
2552
|
-
const chainLink = chain.explorerLink("address/" + address);
|
|
2553
|
-
return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-receive-modal`, children: [
|
|
2554
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "matchid-receive-container", children: [
|
|
2555
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: `matchid-receive-text`, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl19.FormattedMessage, { id: "receiveQrcode" }) }),
|
|
2556
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
2557
|
-
import_react_qrcode.QRCode,
|
|
2558
|
-
{
|
|
2559
|
-
margin: "0",
|
|
2560
|
-
className: `matchid-qr-code`,
|
|
2561
|
-
value: address
|
|
2562
|
-
}
|
|
2563
|
-
) }),
|
|
2564
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
2565
|
-
"a",
|
|
2566
|
-
{
|
|
2567
|
-
href: chainLink,
|
|
2568
|
-
target: "_blank",
|
|
2569
|
-
className: `matchid-receive-link`,
|
|
2570
|
-
children: address
|
|
2571
|
-
}
|
|
2572
|
-
)
|
|
2573
|
-
] }),
|
|
2574
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
2575
|
-
import_react_intl19.FormattedMessage,
|
|
2576
|
-
{
|
|
2577
|
-
id: "copyAddress"
|
|
2578
|
-
}
|
|
2579
|
-
) })
|
|
2580
|
-
] });
|
|
2581
|
-
};
|
|
2582
|
-
var ImportTokenModal = ({ close }) => {
|
|
2547
|
+
function ImportToken({ close }) {
|
|
2548
|
+
const [status, setStatus] = (0, import_react37.useState)("");
|
|
2583
2549
|
const { token } = useUserInfo();
|
|
2584
2550
|
const [address, setAddress] = (0, import_react37.useState)("");
|
|
2585
2551
|
const [symbol, setSymbol] = (0, import_react37.useState)("");
|
|
@@ -2588,32 +2554,16 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2588
2554
|
const { publicClient, chainId } = useMatchChain();
|
|
2589
2555
|
const getContractInfo = async () => {
|
|
2590
2556
|
if (!publicClient) return;
|
|
2591
|
-
const erc20Abi3 = [
|
|
2592
|
-
{
|
|
2593
|
-
name: "decimals",
|
|
2594
|
-
type: "function",
|
|
2595
|
-
stateMutability: "view",
|
|
2596
|
-
inputs: [],
|
|
2597
|
-
outputs: [{ name: "decimals", type: "uint8" }]
|
|
2598
|
-
},
|
|
2599
|
-
{
|
|
2600
|
-
name: "symbol",
|
|
2601
|
-
type: "function",
|
|
2602
|
-
stateMutability: "view",
|
|
2603
|
-
inputs: [],
|
|
2604
|
-
outputs: [{ name: "symbol", type: "string" }]
|
|
2605
|
-
}
|
|
2606
|
-
];
|
|
2607
2557
|
const calls = [
|
|
2608
2558
|
{
|
|
2609
2559
|
address,
|
|
2610
|
-
abi:
|
|
2560
|
+
abi: import_viem9.erc20Abi,
|
|
2611
2561
|
functionName: "symbol",
|
|
2612
2562
|
args: []
|
|
2613
2563
|
},
|
|
2614
2564
|
{
|
|
2615
2565
|
address,
|
|
2616
|
-
abi:
|
|
2566
|
+
abi: import_viem9.erc20Abi,
|
|
2617
2567
|
functionName: "decimals",
|
|
2618
2568
|
args: []
|
|
2619
2569
|
}
|
|
@@ -2633,7 +2583,7 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2633
2583
|
});
|
|
2634
2584
|
}
|
|
2635
2585
|
};
|
|
2636
|
-
const intl = (0,
|
|
2586
|
+
const intl = (0, import_react_intl20.useIntl)();
|
|
2637
2587
|
(0, import_react37.useEffect)(() => {
|
|
2638
2588
|
if (address.length === 42) {
|
|
2639
2589
|
const reg = /^0x[0-9a-fA-F]{40}$/;
|
|
@@ -2666,17 +2616,16 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2666
2616
|
decimals
|
|
2667
2617
|
});
|
|
2668
2618
|
if (isSuccess(res)) {
|
|
2669
|
-
|
|
2670
|
-
id: "importSuccess"
|
|
2671
|
-
}));
|
|
2619
|
+
setStatus("success");
|
|
2672
2620
|
queryClient2.invalidateQueries({
|
|
2673
2621
|
queryKey: [USER_IMPORT_TOKEN_LIST_KEY, token, chainId]
|
|
2674
2622
|
});
|
|
2675
|
-
close();
|
|
2676
2623
|
} else {
|
|
2624
|
+
setStatus("fail");
|
|
2677
2625
|
toast.error(res.message);
|
|
2678
2626
|
}
|
|
2679
2627
|
} catch (error2) {
|
|
2628
|
+
setStatus("fail");
|
|
2680
2629
|
toast.error(error2.message);
|
|
2681
2630
|
} finally {
|
|
2682
2631
|
setLoading(false);
|
|
@@ -2698,6 +2647,16 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2698
2647
|
}
|
|
2699
2648
|
return true;
|
|
2700
2649
|
}, [error, address, symbol, decimals]);
|
|
2650
|
+
console.log("status", status);
|
|
2651
|
+
if (status == "success" || status == "fail") {
|
|
2652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-import-token-result matchid-flex`, children: [
|
|
2653
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-import-token-result-box matchid-flex`, children: [
|
|
2654
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("img", { src: status == "success" ? success_default : fail_default, alt: status == "success" ? "success" : "fail", className: `matchid-import-token-result-img` }),
|
|
2655
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: `matchid-import-token-result-text matchid-import-token-result-text-${status}`, children: status == "success" ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "importSuccess" }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "importFail" }) })
|
|
2656
|
+
] }),
|
|
2657
|
+
status == "success" ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Button, { size: "lg", onClick: close, block: true, highlight: true, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "close" }) }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Button, { size: "lg", onClick: () => setStatus(""), block: true, highlight: true, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "back" }) })
|
|
2658
|
+
] });
|
|
2659
|
+
}
|
|
2701
2660
|
return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-import-token`, children: [
|
|
2702
2661
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "matchid-import-token-form", children: [
|
|
2703
2662
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Field, { label: intl.formatMessage({
|
|
@@ -2749,14 +2708,59 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2749
2708
|
loading,
|
|
2750
2709
|
disabled: !canImport,
|
|
2751
2710
|
highlight: true,
|
|
2752
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
2711
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "import" })
|
|
2753
2712
|
}
|
|
2754
2713
|
)
|
|
2755
2714
|
] });
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
// src/hooks/useMatchWallet.tsx
|
|
2718
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
2719
|
+
var ReceiveModal = () => {
|
|
2720
|
+
const chain = useMatchChain();
|
|
2721
|
+
const { address } = useWallet2();
|
|
2722
|
+
const [copied, setCopied] = useCopyClipboard();
|
|
2723
|
+
const toast = useToast();
|
|
2724
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
2725
|
+
const onCopy = () => {
|
|
2726
|
+
setCopied(address);
|
|
2727
|
+
toast.success(intl.formatMessage({
|
|
2728
|
+
id: "copied"
|
|
2729
|
+
}));
|
|
2730
|
+
};
|
|
2731
|
+
const chainLink = chain.explorerLink("address/" + address);
|
|
2732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: `matchid-receive-modal`, children: [
|
|
2733
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "matchid-receive-container", children: [
|
|
2734
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `matchid-receive-text`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react_intl21.FormattedMessage, { id: "receiveQrcode" }) }),
|
|
2735
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
2736
|
+
import_react_qrcode.QRCode,
|
|
2737
|
+
{
|
|
2738
|
+
margin: "0",
|
|
2739
|
+
className: `matchid-qr-code`,
|
|
2740
|
+
value: address
|
|
2741
|
+
}
|
|
2742
|
+
) }),
|
|
2743
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
2744
|
+
"a",
|
|
2745
|
+
{
|
|
2746
|
+
href: chainLink,
|
|
2747
|
+
target: "_blank",
|
|
2748
|
+
className: `matchid-receive-link`,
|
|
2749
|
+
children: address
|
|
2750
|
+
}
|
|
2751
|
+
)
|
|
2752
|
+
] }),
|
|
2753
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
2754
|
+
import_react_intl21.FormattedMessage,
|
|
2755
|
+
{
|
|
2756
|
+
id: "copyAddress"
|
|
2757
|
+
}
|
|
2758
|
+
) })
|
|
2759
|
+
] });
|
|
2756
2760
|
};
|
|
2757
2761
|
function useMatchWallet() {
|
|
2758
2762
|
const modal = useModal();
|
|
2759
|
-
const intl = (0,
|
|
2763
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
2760
2764
|
const showReceiveModal = () => {
|
|
2761
2765
|
modal.open({
|
|
2762
2766
|
title: intl.formatMessage({
|
|
@@ -2768,9 +2772,9 @@ function useMatchWallet() {
|
|
|
2768
2772
|
const showImportTokenModal = () => {
|
|
2769
2773
|
modal.open({
|
|
2770
2774
|
title: intl.formatMessage({
|
|
2771
|
-
id: "
|
|
2775
|
+
id: "customizedToken"
|
|
2772
2776
|
}),
|
|
2773
|
-
content:
|
|
2777
|
+
content: ImportToken
|
|
2774
2778
|
});
|
|
2775
2779
|
};
|
|
2776
2780
|
const showSendListModal = () => {
|
|
@@ -2788,12 +2792,12 @@ function useMatchWallet() {
|
|
|
2788
2792
|
};
|
|
2789
2793
|
}
|
|
2790
2794
|
function useMatchWalletRecords() {
|
|
2791
|
-
const [hasMore, setHasMore] = (0,
|
|
2792
|
-
const [items, setItems] = (0,
|
|
2795
|
+
const [hasMore, setHasMore] = (0, import_react38.useState)(true);
|
|
2796
|
+
const [items, setItems] = (0, import_react38.useState)([]);
|
|
2793
2797
|
const { chainId, publicClient } = useMatchChain();
|
|
2794
2798
|
const { address } = useWallet2();
|
|
2795
|
-
const hasMoreRef = (0,
|
|
2796
|
-
const nextPageParamsRef = (0,
|
|
2799
|
+
const hasMoreRef = (0, import_react38.useRef)(hasMore);
|
|
2800
|
+
const nextPageParamsRef = (0, import_react38.useRef)(void 0);
|
|
2797
2801
|
const { getContract, setContracts } = useContractStore_default();
|
|
2798
2802
|
const fetchMoreData = async () => {
|
|
2799
2803
|
const chainIdStr = chainId ? chainId.toString() : "";
|
|
@@ -2824,13 +2828,13 @@ function useMatchWalletRecords() {
|
|
|
2824
2828
|
for (const contract of contractUnique) {
|
|
2825
2829
|
calls.push({
|
|
2826
2830
|
address: contract,
|
|
2827
|
-
abi:
|
|
2831
|
+
abi: import_viem10.erc20Abi,
|
|
2828
2832
|
functionName: "symbol",
|
|
2829
2833
|
args: []
|
|
2830
2834
|
});
|
|
2831
2835
|
calls.push({
|
|
2832
2836
|
address: contract,
|
|
2833
|
-
abi:
|
|
2837
|
+
abi: import_viem10.erc20Abi,
|
|
2834
2838
|
functionName: "decimals",
|
|
2835
2839
|
args: []
|
|
2836
2840
|
});
|
|
@@ -2869,17 +2873,15 @@ function useMatchWalletRecords() {
|
|
|
2869
2873
|
hasMoreRef.current = true;
|
|
2870
2874
|
fetchMoreData();
|
|
2871
2875
|
};
|
|
2872
|
-
(0,
|
|
2876
|
+
(0, import_react38.useEffect)(() => {
|
|
2873
2877
|
if (chainId && address) {
|
|
2874
2878
|
onInit();
|
|
2875
2879
|
}
|
|
2876
2880
|
}, [chainId, address]);
|
|
2877
2881
|
const { getTransactions, removeTransaction } = useTransactionStore_default();
|
|
2878
|
-
const
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
(0, import_react37.useEffect)(() => {
|
|
2882
|
-
const removeList = localTransaction.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
|
|
2882
|
+
const list = (0, import_react38.useMemo)(() => {
|
|
2883
|
+
const localTransactions = getTransactions(chainId || 0, address) || [];
|
|
2884
|
+
const removeList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
|
|
2883
2885
|
removeList.forEach((item) => {
|
|
2884
2886
|
removeTransaction({
|
|
2885
2887
|
chainId: chainId || 0,
|
|
@@ -2887,16 +2889,18 @@ function useMatchWalletRecords() {
|
|
|
2887
2889
|
address
|
|
2888
2890
|
});
|
|
2889
2891
|
});
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
...getTransactions(chainId || 0, address) || [],
|
|
2892
|
+
const saveList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) < 0);
|
|
2893
|
+
return [
|
|
2894
|
+
...saveList,
|
|
2894
2895
|
...items
|
|
2895
2896
|
].sort((a, b) => {
|
|
2896
2897
|
const btimestamp = typeof b.timestamp === "string" ? parseInt(b.timestamp) : b.timestamp;
|
|
2897
2898
|
const atimestamp = typeof a.timestamp === "string" ? parseInt(a.timestamp) : a.timestamp;
|
|
2898
2899
|
return btimestamp - atimestamp;
|
|
2899
|
-
})
|
|
2900
|
+
});
|
|
2901
|
+
}, [getTransactions, chainId, items, address]);
|
|
2902
|
+
return {
|
|
2903
|
+
items: list,
|
|
2900
2904
|
fetchMoreData,
|
|
2901
2905
|
hasMore
|
|
2902
2906
|
};
|
|
@@ -2914,7 +2918,7 @@ function useMatchWalletAssets({
|
|
|
2914
2918
|
chainId: chainId || 0,
|
|
2915
2919
|
...assetListOptions
|
|
2916
2920
|
});
|
|
2917
|
-
const mergedAssets = (0,
|
|
2921
|
+
const mergedAssets = (0, import_react38.useMemo)(() => {
|
|
2918
2922
|
if (!assetListQuery.data && !importTokenQuery.data) return [];
|
|
2919
2923
|
const assetList = (assetListQuery.data || []).map((asset) => ({
|
|
2920
2924
|
...asset,
|
|
@@ -2982,7 +2986,7 @@ function useMatchWalletAssetList({
|
|
|
2982
2986
|
name: chain?.nativeCurrency.name,
|
|
2983
2987
|
balance: 0
|
|
2984
2988
|
};
|
|
2985
|
-
const nativeBalanceQuery = (0,
|
|
2989
|
+
const nativeBalanceQuery = (0, import_react_query6.useQuery)({
|
|
2986
2990
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
2987
2991
|
queryFn: async () => {
|
|
2988
2992
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -3001,8 +3005,8 @@ function useMatchWalletAssetList({
|
|
|
3001
3005
|
retry: 3
|
|
3002
3006
|
// Retry up to 3 times if failed
|
|
3003
3007
|
});
|
|
3004
|
-
const erc20Tokens = (0,
|
|
3005
|
-
const
|
|
3008
|
+
const erc20Tokens = (0, import_react38.useMemo)(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
3009
|
+
const erc20Abi4 = [
|
|
3006
3010
|
{
|
|
3007
3011
|
"constant": true,
|
|
3008
3012
|
"inputs": [
|
|
@@ -3023,13 +3027,13 @@ function useMatchWalletAssetList({
|
|
|
3023
3027
|
"type": "function"
|
|
3024
3028
|
}
|
|
3025
3029
|
];
|
|
3026
|
-
const erc20BalanceQuery = (0,
|
|
3030
|
+
const erc20BalanceQuery = (0, import_react_query6.useQuery)({
|
|
3027
3031
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
3028
3032
|
queryFn: async () => {
|
|
3029
3033
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
3030
3034
|
const calls = erc20Tokens.map((token) => ({
|
|
3031
3035
|
address: token.address,
|
|
3032
|
-
abi:
|
|
3036
|
+
abi: erc20Abi4,
|
|
3033
3037
|
functionName: "balanceOf",
|
|
3034
3038
|
args: [address]
|
|
3035
3039
|
}));
|
|
@@ -3050,7 +3054,7 @@ function useMatchWalletAssetList({
|
|
|
3050
3054
|
// Refresh every 15 seconds
|
|
3051
3055
|
retry: 3
|
|
3052
3056
|
});
|
|
3053
|
-
const enrichedAssets = (0,
|
|
3057
|
+
const enrichedAssets = (0, import_react38.useMemo)(() => {
|
|
3054
3058
|
if (!list) return [];
|
|
3055
3059
|
const erc20Balances = erc20BalanceQuery.data || [];
|
|
3056
3060
|
return list.map((asset) => {
|
|
@@ -3059,11 +3063,11 @@ function useMatchWalletAssetList({
|
|
|
3059
3063
|
const decimals = typeof asset.decimals === "string" ? parseInt(asset.decimals) : asset.decimals;
|
|
3060
3064
|
if (asset.address === NATIVE_TOKEN_ADDRESS) {
|
|
3061
3065
|
balanceValue = nativeBalanceQuery.data?.toString() || "0";
|
|
3062
|
-
balance = nativeBalanceQuery.data ? Number((0,
|
|
3066
|
+
balance = nativeBalanceQuery.data ? Number((0, import_viem10.formatUnits)(nativeBalanceQuery.data, decimals)) : 0;
|
|
3063
3067
|
} else {
|
|
3064
3068
|
const index = erc20Tokens.findIndex((t) => t.address === asset.address);
|
|
3065
3069
|
if (index !== -1 && erc20Balances[index] && erc20Balances[index].status === "success") {
|
|
3066
|
-
balance = Number((0,
|
|
3070
|
+
balance = Number((0, import_viem10.formatUnits)(erc20Balances[index].result, decimals));
|
|
3067
3071
|
balanceValue = erc20Balances[index].result?.toString() || "0";
|
|
3068
3072
|
}
|
|
3069
3073
|
}
|
|
@@ -3071,7 +3075,7 @@ function useMatchWalletAssetList({
|
|
|
3071
3075
|
return { ...asset, balance, value, balanceValue };
|
|
3072
3076
|
});
|
|
3073
3077
|
}, [list, nativeBalanceQuery.data, erc20BalanceQuery.data]);
|
|
3074
|
-
(0,
|
|
3078
|
+
(0, import_react38.useEffect)(() => {
|
|
3075
3079
|
const list2 = enrichedAssets.sort((a, b) => {
|
|
3076
3080
|
if (a.address === NATIVE_TOKEN_ADDRESS) return -1;
|
|
3077
3081
|
if (b.address === NATIVE_TOKEN_ADDRESS) return 1;
|
|
@@ -3093,14 +3097,14 @@ function useMatchWalletAssetList({
|
|
|
3093
3097
|
}
|
|
3094
3098
|
|
|
3095
3099
|
// src/hooks/useReceipt.tsx
|
|
3096
|
-
var
|
|
3097
|
-
var
|
|
3098
|
-
var
|
|
3100
|
+
var import_react39 = require("react");
|
|
3101
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
3102
|
+
var import_viem11 = require("viem");
|
|
3099
3103
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
3100
3104
|
var MAX_CACHE_SIZE = 500;
|
|
3101
3105
|
var STORAGE_KEY = "match_receipt_logs";
|
|
3102
3106
|
function useReceiptCache() {
|
|
3103
|
-
const [cache, setCache] = (0,
|
|
3107
|
+
const [cache, setCache] = (0, import_react39.useState)(/* @__PURE__ */ new Map());
|
|
3104
3108
|
const isLocalStorageAvailable = (() => {
|
|
3105
3109
|
try {
|
|
3106
3110
|
const testKey = "__test__";
|
|
@@ -3111,7 +3115,7 @@ function useReceiptCache() {
|
|
|
3111
3115
|
return false;
|
|
3112
3116
|
}
|
|
3113
3117
|
})();
|
|
3114
|
-
(0,
|
|
3118
|
+
(0, import_react39.useEffect)(() => {
|
|
3115
3119
|
if (isLocalStorageAvailable) {
|
|
3116
3120
|
try {
|
|
3117
3121
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3130,7 +3134,7 @@ function useReceiptCache() {
|
|
|
3130
3134
|
}
|
|
3131
3135
|
}
|
|
3132
3136
|
}, []);
|
|
3133
|
-
const updateLocalStorage = (0,
|
|
3137
|
+
const updateLocalStorage = (0, import_react39.useCallback)((updatedCache) => {
|
|
3134
3138
|
if (isLocalStorageAvailable) {
|
|
3135
3139
|
try {
|
|
3136
3140
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3147,7 +3151,7 @@ function useReceiptCache() {
|
|
|
3147
3151
|
}
|
|
3148
3152
|
}
|
|
3149
3153
|
}, []);
|
|
3150
|
-
const set = (0,
|
|
3154
|
+
const set = (0, import_react39.useCallback)((key, value) => {
|
|
3151
3155
|
const now = Date.now();
|
|
3152
3156
|
const newCache = new Map(cache);
|
|
3153
3157
|
newCache.forEach((entry, k) => {
|
|
@@ -3165,7 +3169,7 @@ function useReceiptCache() {
|
|
|
3165
3169
|
setCache(newCache);
|
|
3166
3170
|
updateLocalStorage(newCache);
|
|
3167
3171
|
}, [cache, updateLocalStorage]);
|
|
3168
|
-
const get = (0,
|
|
3172
|
+
const get = (0, import_react39.useCallback)((key) => {
|
|
3169
3173
|
const entry = cache.get(key);
|
|
3170
3174
|
if (entry) {
|
|
3171
3175
|
if (Date.now() - entry.timestamp > CACHE_TTL) {
|
|
@@ -3179,7 +3183,7 @@ function useReceiptCache() {
|
|
|
3179
3183
|
}
|
|
3180
3184
|
return void 0;
|
|
3181
3185
|
}, [cache, updateLocalStorage]);
|
|
3182
|
-
const del = (0,
|
|
3186
|
+
const del = (0, import_react39.useCallback)((key) => {
|
|
3183
3187
|
if (cache.has(key)) {
|
|
3184
3188
|
const newCache = new Map(cache);
|
|
3185
3189
|
newCache.delete(key);
|
|
@@ -3187,7 +3191,7 @@ function useReceiptCache() {
|
|
|
3187
3191
|
updateLocalStorage(newCache);
|
|
3188
3192
|
}
|
|
3189
3193
|
}, [cache, updateLocalStorage]);
|
|
3190
|
-
const clear = (0,
|
|
3194
|
+
const clear = (0, import_react39.useCallback)(() => {
|
|
3191
3195
|
setCache(/* @__PURE__ */ new Map());
|
|
3192
3196
|
if (isLocalStorageAvailable) {
|
|
3193
3197
|
localStorage.removeItem(STORAGE_KEY);
|
|
@@ -3202,8 +3206,8 @@ function useReceipt2({
|
|
|
3202
3206
|
const { list } = useMatchChain();
|
|
3203
3207
|
const cache = useReceiptCache();
|
|
3204
3208
|
const chain = list?.find((item) => item.id === chainId);
|
|
3205
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3206
|
-
const query = (0,
|
|
3209
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react39.useState)(true);
|
|
3210
|
+
const query = (0, import_react_query7.useQuery)({
|
|
3207
3211
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
3208
3212
|
queryFn: async () => {
|
|
3209
3213
|
if (!chain || !hash) return false;
|
|
@@ -3212,9 +3216,9 @@ function useReceipt2({
|
|
|
3212
3216
|
return cache.get(cacheKey);
|
|
3213
3217
|
}
|
|
3214
3218
|
try {
|
|
3215
|
-
const publicClient = (0,
|
|
3216
|
-
chain: (0,
|
|
3217
|
-
transport: (0,
|
|
3219
|
+
const publicClient = (0, import_viem11.createPublicClient)({
|
|
3220
|
+
chain: (0, import_viem11.defineChain)(chain),
|
|
3221
|
+
transport: (0, import_viem11.http)()
|
|
3218
3222
|
});
|
|
3219
3223
|
const receipt = await publicClient.getTransactionReceipt({ hash });
|
|
3220
3224
|
if (!receipt) {
|
|
@@ -3228,7 +3232,7 @@ function useReceipt2({
|
|
|
3228
3232
|
},
|
|
3229
3233
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3230
3234
|
});
|
|
3231
|
-
(0,
|
|
3235
|
+
(0, import_react39.useEffect)(() => {
|
|
3232
3236
|
if (query.data) {
|
|
3233
3237
|
setShouldRefetch(false);
|
|
3234
3238
|
}
|
|
@@ -3237,14 +3241,14 @@ function useReceipt2({
|
|
|
3237
3241
|
}
|
|
3238
3242
|
|
|
3239
3243
|
// src/hooks/useTransaction.tsx
|
|
3240
|
-
var
|
|
3241
|
-
var
|
|
3242
|
-
var
|
|
3244
|
+
var import_react40 = require("react");
|
|
3245
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
3246
|
+
var import_viem12 = require("viem");
|
|
3243
3247
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
3244
3248
|
var MAX_CACHE_SIZE2 = 500;
|
|
3245
3249
|
var STORAGE_KEY2 = "match_transaction_logs";
|
|
3246
3250
|
function useTransactionCache() {
|
|
3247
|
-
const [cache, setCache] = (0,
|
|
3251
|
+
const [cache, setCache] = (0, import_react40.useState)(/* @__PURE__ */ new Map());
|
|
3248
3252
|
const isLocalStorageAvailable = (() => {
|
|
3249
3253
|
try {
|
|
3250
3254
|
const testKey = "__test__";
|
|
@@ -3255,7 +3259,7 @@ function useTransactionCache() {
|
|
|
3255
3259
|
return false;
|
|
3256
3260
|
}
|
|
3257
3261
|
})();
|
|
3258
|
-
(0,
|
|
3262
|
+
(0, import_react40.useEffect)(() => {
|
|
3259
3263
|
if (isLocalStorageAvailable) {
|
|
3260
3264
|
try {
|
|
3261
3265
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3274,7 +3278,7 @@ function useTransactionCache() {
|
|
|
3274
3278
|
}
|
|
3275
3279
|
}
|
|
3276
3280
|
}, []);
|
|
3277
|
-
const updateLocalStorage = (0,
|
|
3281
|
+
const updateLocalStorage = (0, import_react40.useCallback)((updatedCache) => {
|
|
3278
3282
|
if (isLocalStorageAvailable) {
|
|
3279
3283
|
try {
|
|
3280
3284
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3291,7 +3295,7 @@ function useTransactionCache() {
|
|
|
3291
3295
|
}
|
|
3292
3296
|
}
|
|
3293
3297
|
}, []);
|
|
3294
|
-
const set = (0,
|
|
3298
|
+
const set = (0, import_react40.useCallback)((key, value) => {
|
|
3295
3299
|
const now = Date.now();
|
|
3296
3300
|
const newCache = new Map(cache);
|
|
3297
3301
|
newCache.forEach((entry, k) => {
|
|
@@ -3309,7 +3313,7 @@ function useTransactionCache() {
|
|
|
3309
3313
|
setCache(newCache);
|
|
3310
3314
|
updateLocalStorage(newCache);
|
|
3311
3315
|
}, [cache, updateLocalStorage]);
|
|
3312
|
-
const get = (0,
|
|
3316
|
+
const get = (0, import_react40.useCallback)((key) => {
|
|
3313
3317
|
const entry = cache.get(key);
|
|
3314
3318
|
if (entry) {
|
|
3315
3319
|
if (Date.now() - entry.timestamp > CACHE_TTL2) {
|
|
@@ -3323,7 +3327,7 @@ function useTransactionCache() {
|
|
|
3323
3327
|
}
|
|
3324
3328
|
return void 0;
|
|
3325
3329
|
}, [cache, updateLocalStorage]);
|
|
3326
|
-
const del = (0,
|
|
3330
|
+
const del = (0, import_react40.useCallback)((key) => {
|
|
3327
3331
|
if (cache.has(key)) {
|
|
3328
3332
|
const newCache = new Map(cache);
|
|
3329
3333
|
newCache.delete(key);
|
|
@@ -3331,7 +3335,7 @@ function useTransactionCache() {
|
|
|
3331
3335
|
updateLocalStorage(newCache);
|
|
3332
3336
|
}
|
|
3333
3337
|
}, [cache, updateLocalStorage]);
|
|
3334
|
-
const clear = (0,
|
|
3338
|
+
const clear = (0, import_react40.useCallback)(() => {
|
|
3335
3339
|
setCache(/* @__PURE__ */ new Map());
|
|
3336
3340
|
if (isLocalStorageAvailable) {
|
|
3337
3341
|
localStorage.removeItem(STORAGE_KEY2);
|
|
@@ -3346,8 +3350,8 @@ function useTransaction({
|
|
|
3346
3350
|
const { list } = useMatchChain();
|
|
3347
3351
|
const cache = useTransactionCache();
|
|
3348
3352
|
const chain = list?.find((item) => item.id === chainId);
|
|
3349
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3350
|
-
const query = (0,
|
|
3353
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react40.useState)(true);
|
|
3354
|
+
const query = (0, import_react_query8.useQuery)({
|
|
3351
3355
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
3352
3356
|
queryFn: async () => {
|
|
3353
3357
|
if (!chain || !hash) return false;
|
|
@@ -3356,9 +3360,9 @@ function useTransaction({
|
|
|
3356
3360
|
return cache.get(cacheKey);
|
|
3357
3361
|
}
|
|
3358
3362
|
try {
|
|
3359
|
-
const publicClient = (0,
|
|
3360
|
-
chain: (0,
|
|
3361
|
-
transport: (0,
|
|
3363
|
+
const publicClient = (0, import_viem12.createPublicClient)({
|
|
3364
|
+
chain: (0, import_viem12.defineChain)(chain),
|
|
3365
|
+
transport: (0, import_viem12.http)()
|
|
3362
3366
|
});
|
|
3363
3367
|
const transaction = await publicClient.getTransaction({ hash });
|
|
3364
3368
|
if (!transaction) {
|
|
@@ -3372,7 +3376,7 @@ function useTransaction({
|
|
|
3372
3376
|
},
|
|
3373
3377
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3374
3378
|
});
|
|
3375
|
-
(0,
|
|
3379
|
+
(0, import_react40.useEffect)(() => {
|
|
3376
3380
|
if (query.data) {
|
|
3377
3381
|
setShouldRefetch(false);
|
|
3378
3382
|
}
|