@matchain/matchid-sdk-react 0.1.48-alpha.21 → 0.1.48-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icon/index.d.mts +1 -1
- package/dist/assets/icon/index.d.ts +1 -1
- package/dist/{chunk-WXPVHKGJ.mjs → chunk-FB5MHLWX.mjs} +3 -1
- package/dist/{chunk-CHWBALAC.mjs → chunk-FYW4P7HS.mjs} +607 -577
- package/dist/chunk-FYW4P7HS.mjs.map +1 -0
- package/dist/{chunk-IV4F5SHJ.mjs → chunk-SB54XHCJ.mjs} +2 -2
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +450 -461
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -3
- package/dist/hooks/api/index.d.mts +2 -2
- package/dist/hooks/api/index.d.ts +2 -2
- package/dist/hooks/api/index.js +38 -29
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +3 -3
- package/dist/hooks/index.d.mts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +130 -147
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +3 -3
- package/dist/{index-C9qYyRgt.d.mts → index-B4gKj0ro.d.mts} +2 -2
- package/dist/{index-Bpmrd7mh.d.ts → index-BFSCCmlU.d.ts} +1 -1
- package/dist/{index-Cy3K-Yao.d.ts → index-BHXlpUg5.d.ts} +1 -1
- package/dist/{index-Dhtyz0pT.d.mts → index-BObJQar4.d.mts} +2 -1
- package/dist/{index-BcEreCxd.d.ts → index-BOsoQSmx.d.ts} +1 -1
- package/dist/{index-C9F6f2iz.d.mts → index-Bk_dqXKp.d.mts} +2 -2
- package/dist/{index-BMsj8hJv.d.ts → index-CN2jy6bb.d.ts} +2 -2
- package/dist/{index-CFKZWJVt.d.ts → index-CSTyna62.d.ts} +2 -1
- package/dist/{index-BMfaixEx.d.mts → index-Ca30Hgn7.d.mts} +1 -1
- package/dist/{index-Cou96DpL.d.mts → index-CdM22eod.d.mts} +1 -1
- package/dist/{index-D4ju2J_e.d.mts → index-D3GBq1P1.d.mts} +1 -1
- package/dist/{index-Bvc8cjpN.d.ts → index-DTYp8DRd.d.ts} +2 -2
- package/dist/index.css +33 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +261 -233
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/{types-DzVVzMYU.d.mts → types-Dc15ure7.d.mts} +1 -1
- package/dist/{types-DzVVzMYU.d.ts → types-Dc15ure7.d.ts} +1 -1
- package/dist/ui/index.d.mts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-CHWBALAC.mjs.map +0 -1
- /package/dist/{chunk-WXPVHKGJ.mjs.map → chunk-FB5MHLWX.mjs.map} +0 -0
- /package/dist/{chunk-IV4F5SHJ.mjs.map → chunk-SB54XHCJ.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-SB54XHCJ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isSuccess,
|
|
8
8
|
wallet_exports
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-FYW4P7HS.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.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-
|
|
2
|
-
import '../types-
|
|
1
|
+
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-BObJQar4.mjs';
|
|
2
|
+
import '../types-Dc15ure7.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@tanstack/react-query/src/types';
|
|
5
5
|
import 'viem';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-
|
|
2
|
-
import '../types-
|
|
1
|
+
export { c as useCopyClipboard, n as useLayout, f as useMatchChain, a as useMatchEvents, g as useMatchWallet, k as useMatchWalletAssetList, j as useMatchWalletAssets, h as useMatchWalletRecords, d as useModal, l as useReceipt, e as useToast, m as useTransaction, u as useUserInfo, b as useWallet } from '../index-CSTyna62.js';
|
|
2
|
+
import '../types-Dc15ure7.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@tanstack/react-query/src/types';
|
|
5
5
|
import 'viem';
|
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);
|
|
@@ -2114,7 +2115,6 @@ var import_middleware3 = require("zustand/middleware");
|
|
|
2114
2115
|
var persistedState3 = (0, import_middleware3.persist)(
|
|
2115
2116
|
(set, get) => ({
|
|
2116
2117
|
transactions: {},
|
|
2117
|
-
getTransactions: (chainId, address) => get().transactions[`${chainId}-${address}`] || [],
|
|
2118
2118
|
addTransaction: (data) => {
|
|
2119
2119
|
set((state) => {
|
|
2120
2120
|
const updatedTransactions = {
|
|
@@ -2532,54 +2532,19 @@ function useMatchChain() {
|
|
|
2532
2532
|
|
|
2533
2533
|
// src/hooks/useMatchWallet.tsx
|
|
2534
2534
|
var import_react_qrcode = require("react-qrcode");
|
|
2535
|
+
var import_react38 = require("react");
|
|
2536
|
+
var import_react_query6 = require("@tanstack/react-query");
|
|
2537
|
+
var import_viem10 = require("viem");
|
|
2538
|
+
var import_react_intl21 = require("react-intl");
|
|
2539
|
+
|
|
2540
|
+
// src/components/ImportToken/index.tsx
|
|
2535
2541
|
var import_react37 = require("react");
|
|
2542
|
+
var import_react_intl20 = require("react-intl");
|
|
2536
2543
|
var import_react_query5 = require("@tanstack/react-query");
|
|
2537
2544
|
var import_viem9 = require("viem");
|
|
2538
|
-
var import_react_intl19 = require("react-intl");
|
|
2539
2545
|
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 }) => {
|
|
2546
|
+
function ImportToken({ close }) {
|
|
2547
|
+
const [status, setStatus] = (0, import_react37.useState)("");
|
|
2583
2548
|
const { token } = useUserInfo();
|
|
2584
2549
|
const [address, setAddress] = (0, import_react37.useState)("");
|
|
2585
2550
|
const [symbol, setSymbol] = (0, import_react37.useState)("");
|
|
@@ -2588,32 +2553,16 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2588
2553
|
const { publicClient, chainId } = useMatchChain();
|
|
2589
2554
|
const getContractInfo = async () => {
|
|
2590
2555
|
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
2556
|
const calls = [
|
|
2608
2557
|
{
|
|
2609
2558
|
address,
|
|
2610
|
-
abi:
|
|
2559
|
+
abi: import_viem9.erc20Abi,
|
|
2611
2560
|
functionName: "symbol",
|
|
2612
2561
|
args: []
|
|
2613
2562
|
},
|
|
2614
2563
|
{
|
|
2615
2564
|
address,
|
|
2616
|
-
abi:
|
|
2565
|
+
abi: import_viem9.erc20Abi,
|
|
2617
2566
|
functionName: "decimals",
|
|
2618
2567
|
args: []
|
|
2619
2568
|
}
|
|
@@ -2633,7 +2582,7 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2633
2582
|
});
|
|
2634
2583
|
}
|
|
2635
2584
|
};
|
|
2636
|
-
const intl = (0,
|
|
2585
|
+
const intl = (0, import_react_intl20.useIntl)();
|
|
2637
2586
|
(0, import_react37.useEffect)(() => {
|
|
2638
2587
|
if (address.length === 42) {
|
|
2639
2588
|
const reg = /^0x[0-9a-fA-F]{40}$/;
|
|
@@ -2666,17 +2615,16 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2666
2615
|
decimals
|
|
2667
2616
|
});
|
|
2668
2617
|
if (isSuccess(res)) {
|
|
2669
|
-
|
|
2670
|
-
id: "importSuccess"
|
|
2671
|
-
}));
|
|
2618
|
+
setStatus("success");
|
|
2672
2619
|
queryClient2.invalidateQueries({
|
|
2673
2620
|
queryKey: [USER_IMPORT_TOKEN_LIST_KEY, token, chainId]
|
|
2674
2621
|
});
|
|
2675
|
-
close();
|
|
2676
2622
|
} else {
|
|
2623
|
+
setStatus("fail");
|
|
2677
2624
|
toast.error(res.message);
|
|
2678
2625
|
}
|
|
2679
2626
|
} catch (error2) {
|
|
2627
|
+
setStatus("fail");
|
|
2680
2628
|
toast.error(error2.message);
|
|
2681
2629
|
} finally {
|
|
2682
2630
|
setLoading(false);
|
|
@@ -2698,6 +2646,16 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2698
2646
|
}
|
|
2699
2647
|
return true;
|
|
2700
2648
|
}, [error, address, symbol, decimals]);
|
|
2649
|
+
console.log("status", status);
|
|
2650
|
+
if (status == "success" || status == "fail") {
|
|
2651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-import-token-result matchid-flex`, children: [
|
|
2652
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-import-token-result-box matchid-flex`, children: [
|
|
2653
|
+
/* @__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` }),
|
|
2654
|
+
/* @__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" }) })
|
|
2655
|
+
] }),
|
|
2656
|
+
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" }) })
|
|
2657
|
+
] });
|
|
2658
|
+
}
|
|
2701
2659
|
return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-import-token`, children: [
|
|
2702
2660
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "matchid-import-token-form", children: [
|
|
2703
2661
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Field, { label: intl.formatMessage({
|
|
@@ -2749,14 +2707,59 @@ var ImportTokenModal = ({ close }) => {
|
|
|
2749
2707
|
loading,
|
|
2750
2708
|
disabled: !canImport,
|
|
2751
2709
|
highlight: true,
|
|
2752
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
2710
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "import" })
|
|
2753
2711
|
}
|
|
2754
2712
|
)
|
|
2755
2713
|
] });
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
// src/hooks/useMatchWallet.tsx
|
|
2717
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
2718
|
+
var ReceiveModal = () => {
|
|
2719
|
+
const chain = useMatchChain();
|
|
2720
|
+
const { address } = useWallet2();
|
|
2721
|
+
const [copied, setCopied] = useCopyClipboard();
|
|
2722
|
+
const toast = useToast();
|
|
2723
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
2724
|
+
const onCopy = () => {
|
|
2725
|
+
setCopied(address);
|
|
2726
|
+
toast.success(intl.formatMessage({
|
|
2727
|
+
id: "copied"
|
|
2728
|
+
}));
|
|
2729
|
+
};
|
|
2730
|
+
const chainLink = chain.explorerLink("address/" + address);
|
|
2731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: `matchid-receive-modal`, children: [
|
|
2732
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "matchid-receive-container", children: [
|
|
2733
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `matchid-receive-text`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react_intl21.FormattedMessage, { id: "receiveQrcode" }) }),
|
|
2734
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `matchid-qr-container`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
2735
|
+
import_react_qrcode.QRCode,
|
|
2736
|
+
{
|
|
2737
|
+
margin: "0",
|
|
2738
|
+
className: `matchid-qr-code`,
|
|
2739
|
+
value: address
|
|
2740
|
+
}
|
|
2741
|
+
) }),
|
|
2742
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
2743
|
+
"a",
|
|
2744
|
+
{
|
|
2745
|
+
href: chainLink,
|
|
2746
|
+
target: "_blank",
|
|
2747
|
+
className: `matchid-receive-link`,
|
|
2748
|
+
children: address
|
|
2749
|
+
}
|
|
2750
|
+
)
|
|
2751
|
+
] }),
|
|
2752
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Button, { size: "lg", onClick: onCopy, block: true, highlight: true, disabled: copied, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
2753
|
+
import_react_intl21.FormattedMessage,
|
|
2754
|
+
{
|
|
2755
|
+
id: "copyAddress"
|
|
2756
|
+
}
|
|
2757
|
+
) })
|
|
2758
|
+
] });
|
|
2756
2759
|
};
|
|
2757
2760
|
function useMatchWallet() {
|
|
2758
2761
|
const modal = useModal();
|
|
2759
|
-
const intl = (0,
|
|
2762
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
2760
2763
|
const showReceiveModal = () => {
|
|
2761
2764
|
modal.open({
|
|
2762
2765
|
title: intl.formatMessage({
|
|
@@ -2768,9 +2771,9 @@ function useMatchWallet() {
|
|
|
2768
2771
|
const showImportTokenModal = () => {
|
|
2769
2772
|
modal.open({
|
|
2770
2773
|
title: intl.formatMessage({
|
|
2771
|
-
id: "
|
|
2774
|
+
id: "customizedToken"
|
|
2772
2775
|
}),
|
|
2773
|
-
content:
|
|
2776
|
+
content: ImportToken
|
|
2774
2777
|
});
|
|
2775
2778
|
};
|
|
2776
2779
|
const showSendListModal = () => {
|
|
@@ -2788,12 +2791,12 @@ function useMatchWallet() {
|
|
|
2788
2791
|
};
|
|
2789
2792
|
}
|
|
2790
2793
|
function useMatchWalletRecords() {
|
|
2791
|
-
const [hasMore, setHasMore] = (0,
|
|
2792
|
-
const [items, setItems] = (0,
|
|
2794
|
+
const [hasMore, setHasMore] = (0, import_react38.useState)(true);
|
|
2795
|
+
const [items, setItems] = (0, import_react38.useState)([]);
|
|
2793
2796
|
const { chainId, publicClient } = useMatchChain();
|
|
2794
2797
|
const { address } = useWallet2();
|
|
2795
|
-
const hasMoreRef = (0,
|
|
2796
|
-
const nextPageParamsRef = (0,
|
|
2798
|
+
const hasMoreRef = (0, import_react38.useRef)(hasMore);
|
|
2799
|
+
const nextPageParamsRef = (0, import_react38.useRef)(void 0);
|
|
2797
2800
|
const { getContract, setContracts } = useContractStore_default();
|
|
2798
2801
|
const fetchMoreData = async () => {
|
|
2799
2802
|
const chainIdStr = chainId ? chainId.toString() : "";
|
|
@@ -2824,13 +2827,13 @@ function useMatchWalletRecords() {
|
|
|
2824
2827
|
for (const contract of contractUnique) {
|
|
2825
2828
|
calls.push({
|
|
2826
2829
|
address: contract,
|
|
2827
|
-
abi:
|
|
2830
|
+
abi: import_viem10.erc20Abi,
|
|
2828
2831
|
functionName: "symbol",
|
|
2829
2832
|
args: []
|
|
2830
2833
|
});
|
|
2831
2834
|
calls.push({
|
|
2832
2835
|
address: contract,
|
|
2833
|
-
abi:
|
|
2836
|
+
abi: import_viem10.erc20Abi,
|
|
2834
2837
|
functionName: "decimals",
|
|
2835
2838
|
args: []
|
|
2836
2839
|
});
|
|
@@ -2869,14 +2872,14 @@ function useMatchWalletRecords() {
|
|
|
2869
2872
|
hasMoreRef.current = true;
|
|
2870
2873
|
fetchMoreData();
|
|
2871
2874
|
};
|
|
2872
|
-
(0,
|
|
2875
|
+
(0, import_react38.useEffect)(() => {
|
|
2873
2876
|
if (chainId && address) {
|
|
2874
2877
|
onInit();
|
|
2875
2878
|
}
|
|
2876
2879
|
}, [chainId, address]);
|
|
2877
|
-
const {
|
|
2878
|
-
const list = (0,
|
|
2879
|
-
const localTransactions =
|
|
2880
|
+
const { transactions, removeTransaction } = useTransactionStore_default();
|
|
2881
|
+
const list = (0, import_react38.useMemo)(() => {
|
|
2882
|
+
const localTransactions = transactions[`${chainId}-${address}`] || [];
|
|
2880
2883
|
const removeList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
|
|
2881
2884
|
removeList.forEach((item) => {
|
|
2882
2885
|
removeTransaction({
|
|
@@ -2894,7 +2897,7 @@ function useMatchWalletRecords() {
|
|
|
2894
2897
|
const atimestamp = typeof a.timestamp === "string" ? parseInt(a.timestamp) : a.timestamp;
|
|
2895
2898
|
return btimestamp - atimestamp;
|
|
2896
2899
|
});
|
|
2897
|
-
}, [
|
|
2900
|
+
}, [transactions, chainId, items, address]);
|
|
2898
2901
|
return {
|
|
2899
2902
|
items: list,
|
|
2900
2903
|
fetchMoreData,
|
|
@@ -2914,7 +2917,7 @@ function useMatchWalletAssets({
|
|
|
2914
2917
|
chainId: chainId || 0,
|
|
2915
2918
|
...assetListOptions
|
|
2916
2919
|
});
|
|
2917
|
-
const mergedAssets = (0,
|
|
2920
|
+
const mergedAssets = (0, import_react38.useMemo)(() => {
|
|
2918
2921
|
if (!assetListQuery.data && !importTokenQuery.data) return [];
|
|
2919
2922
|
const assetList = (assetListQuery.data || []).map((asset) => ({
|
|
2920
2923
|
...asset,
|
|
@@ -2982,7 +2985,7 @@ function useMatchWalletAssetList({
|
|
|
2982
2985
|
name: chain?.nativeCurrency.name,
|
|
2983
2986
|
balance: 0
|
|
2984
2987
|
};
|
|
2985
|
-
const nativeBalanceQuery = (0,
|
|
2988
|
+
const nativeBalanceQuery = (0, import_react_query6.useQuery)({
|
|
2986
2989
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
2987
2990
|
queryFn: async () => {
|
|
2988
2991
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -3001,35 +3004,14 @@ function useMatchWalletAssetList({
|
|
|
3001
3004
|
retry: 3
|
|
3002
3005
|
// Retry up to 3 times if failed
|
|
3003
3006
|
});
|
|
3004
|
-
const erc20Tokens = (0,
|
|
3005
|
-
const
|
|
3006
|
-
{
|
|
3007
|
-
"constant": true,
|
|
3008
|
-
"inputs": [
|
|
3009
|
-
{
|
|
3010
|
-
"name": "_owner",
|
|
3011
|
-
"type": "address"
|
|
3012
|
-
}
|
|
3013
|
-
],
|
|
3014
|
-
"name": "balanceOf",
|
|
3015
|
-
"outputs": [
|
|
3016
|
-
{
|
|
3017
|
-
"name": "balance",
|
|
3018
|
-
"type": "uint256"
|
|
3019
|
-
}
|
|
3020
|
-
],
|
|
3021
|
-
"payable": false,
|
|
3022
|
-
"stateMutability": "view",
|
|
3023
|
-
"type": "function"
|
|
3024
|
-
}
|
|
3025
|
-
];
|
|
3026
|
-
const erc20BalanceQuery = (0, import_react_query5.useQuery)({
|
|
3007
|
+
const erc20Tokens = (0, import_react38.useMemo)(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
3008
|
+
const erc20BalanceQuery = (0, import_react_query6.useQuery)({
|
|
3027
3009
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
3028
3010
|
queryFn: async () => {
|
|
3029
3011
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
3030
3012
|
const calls = erc20Tokens.map((token) => ({
|
|
3031
3013
|
address: token.address,
|
|
3032
|
-
abi:
|
|
3014
|
+
abi: import_viem10.erc20Abi,
|
|
3033
3015
|
functionName: "balanceOf",
|
|
3034
3016
|
args: [address]
|
|
3035
3017
|
}));
|
|
@@ -3050,7 +3032,7 @@ function useMatchWalletAssetList({
|
|
|
3050
3032
|
// Refresh every 15 seconds
|
|
3051
3033
|
retry: 3
|
|
3052
3034
|
});
|
|
3053
|
-
const enrichedAssets = (0,
|
|
3035
|
+
const enrichedAssets = (0, import_react38.useMemo)(() => {
|
|
3054
3036
|
if (!list) return [];
|
|
3055
3037
|
const erc20Balances = erc20BalanceQuery.data || [];
|
|
3056
3038
|
return list.map((asset) => {
|
|
@@ -3059,11 +3041,11 @@ function useMatchWalletAssetList({
|
|
|
3059
3041
|
const decimals = typeof asset.decimals === "string" ? parseInt(asset.decimals) : asset.decimals;
|
|
3060
3042
|
if (asset.address === NATIVE_TOKEN_ADDRESS) {
|
|
3061
3043
|
balanceValue = nativeBalanceQuery.data?.toString() || "0";
|
|
3062
|
-
balance = nativeBalanceQuery.data ? Number((0,
|
|
3044
|
+
balance = nativeBalanceQuery.data ? Number((0, import_viem10.formatUnits)(nativeBalanceQuery.data, decimals)) : 0;
|
|
3063
3045
|
} else {
|
|
3064
3046
|
const index = erc20Tokens.findIndex((t) => t.address === asset.address);
|
|
3065
3047
|
if (index !== -1 && erc20Balances[index] && erc20Balances[index].status === "success") {
|
|
3066
|
-
balance = Number((0,
|
|
3048
|
+
balance = Number((0, import_viem10.formatUnits)(erc20Balances[index].result, decimals));
|
|
3067
3049
|
balanceValue = erc20Balances[index].result?.toString() || "0";
|
|
3068
3050
|
}
|
|
3069
3051
|
}
|
|
@@ -3071,7 +3053,7 @@ function useMatchWalletAssetList({
|
|
|
3071
3053
|
return { ...asset, balance, value, balanceValue };
|
|
3072
3054
|
});
|
|
3073
3055
|
}, [list, nativeBalanceQuery.data, erc20BalanceQuery.data]);
|
|
3074
|
-
(0,
|
|
3056
|
+
(0, import_react38.useEffect)(() => {
|
|
3075
3057
|
const list2 = enrichedAssets.sort((a, b) => {
|
|
3076
3058
|
if (a.address === NATIVE_TOKEN_ADDRESS) return -1;
|
|
3077
3059
|
if (b.address === NATIVE_TOKEN_ADDRESS) return 1;
|
|
@@ -3087,20 +3069,21 @@ function useMatchWalletAssetList({
|
|
|
3087
3069
|
return {
|
|
3088
3070
|
list: assets,
|
|
3089
3071
|
isLoading: nativeBalanceQuery.isLoading || erc20BalanceQuery.isLoading,
|
|
3072
|
+
isFetched: nativeBalanceQuery.isFetched && erc20BalanceQuery.isFetched,
|
|
3090
3073
|
nativeBalance: nativeBalanceQuery.data,
|
|
3091
3074
|
erc20Balances: erc20BalanceQuery.data
|
|
3092
3075
|
};
|
|
3093
3076
|
}
|
|
3094
3077
|
|
|
3095
3078
|
// src/hooks/useReceipt.tsx
|
|
3096
|
-
var
|
|
3097
|
-
var
|
|
3098
|
-
var
|
|
3079
|
+
var import_react39 = require("react");
|
|
3080
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
3081
|
+
var import_viem11 = require("viem");
|
|
3099
3082
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
3100
3083
|
var MAX_CACHE_SIZE = 500;
|
|
3101
3084
|
var STORAGE_KEY = "match_receipt_logs";
|
|
3102
3085
|
function useReceiptCache() {
|
|
3103
|
-
const [cache, setCache] = (0,
|
|
3086
|
+
const [cache, setCache] = (0, import_react39.useState)(/* @__PURE__ */ new Map());
|
|
3104
3087
|
const isLocalStorageAvailable = (() => {
|
|
3105
3088
|
try {
|
|
3106
3089
|
const testKey = "__test__";
|
|
@@ -3111,7 +3094,7 @@ function useReceiptCache() {
|
|
|
3111
3094
|
return false;
|
|
3112
3095
|
}
|
|
3113
3096
|
})();
|
|
3114
|
-
(0,
|
|
3097
|
+
(0, import_react39.useEffect)(() => {
|
|
3115
3098
|
if (isLocalStorageAvailable) {
|
|
3116
3099
|
try {
|
|
3117
3100
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3130,7 +3113,7 @@ function useReceiptCache() {
|
|
|
3130
3113
|
}
|
|
3131
3114
|
}
|
|
3132
3115
|
}, []);
|
|
3133
|
-
const updateLocalStorage = (0,
|
|
3116
|
+
const updateLocalStorage = (0, import_react39.useCallback)((updatedCache) => {
|
|
3134
3117
|
if (isLocalStorageAvailable) {
|
|
3135
3118
|
try {
|
|
3136
3119
|
const storedData = localStorage.getItem(STORAGE_KEY);
|
|
@@ -3147,7 +3130,7 @@ function useReceiptCache() {
|
|
|
3147
3130
|
}
|
|
3148
3131
|
}
|
|
3149
3132
|
}, []);
|
|
3150
|
-
const set = (0,
|
|
3133
|
+
const set = (0, import_react39.useCallback)((key, value) => {
|
|
3151
3134
|
const now = Date.now();
|
|
3152
3135
|
const newCache = new Map(cache);
|
|
3153
3136
|
newCache.forEach((entry, k) => {
|
|
@@ -3165,7 +3148,7 @@ function useReceiptCache() {
|
|
|
3165
3148
|
setCache(newCache);
|
|
3166
3149
|
updateLocalStorage(newCache);
|
|
3167
3150
|
}, [cache, updateLocalStorage]);
|
|
3168
|
-
const get = (0,
|
|
3151
|
+
const get = (0, import_react39.useCallback)((key) => {
|
|
3169
3152
|
const entry = cache.get(key);
|
|
3170
3153
|
if (entry) {
|
|
3171
3154
|
if (Date.now() - entry.timestamp > CACHE_TTL) {
|
|
@@ -3179,7 +3162,7 @@ function useReceiptCache() {
|
|
|
3179
3162
|
}
|
|
3180
3163
|
return void 0;
|
|
3181
3164
|
}, [cache, updateLocalStorage]);
|
|
3182
|
-
const del = (0,
|
|
3165
|
+
const del = (0, import_react39.useCallback)((key) => {
|
|
3183
3166
|
if (cache.has(key)) {
|
|
3184
3167
|
const newCache = new Map(cache);
|
|
3185
3168
|
newCache.delete(key);
|
|
@@ -3187,7 +3170,7 @@ function useReceiptCache() {
|
|
|
3187
3170
|
updateLocalStorage(newCache);
|
|
3188
3171
|
}
|
|
3189
3172
|
}, [cache, updateLocalStorage]);
|
|
3190
|
-
const clear = (0,
|
|
3173
|
+
const clear = (0, import_react39.useCallback)(() => {
|
|
3191
3174
|
setCache(/* @__PURE__ */ new Map());
|
|
3192
3175
|
if (isLocalStorageAvailable) {
|
|
3193
3176
|
localStorage.removeItem(STORAGE_KEY);
|
|
@@ -3202,8 +3185,8 @@ function useReceipt2({
|
|
|
3202
3185
|
const { list } = useMatchChain();
|
|
3203
3186
|
const cache = useReceiptCache();
|
|
3204
3187
|
const chain = list?.find((item) => item.id === chainId);
|
|
3205
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
3206
|
-
const query = (0,
|
|
3188
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react39.useState)(true);
|
|
3189
|
+
const query = (0, import_react_query7.useQuery)({
|
|
3207
3190
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
3208
3191
|
queryFn: async () => {
|
|
3209
3192
|
if (!chain || !hash) return false;
|
|
@@ -3212,9 +3195,9 @@ function useReceipt2({
|
|
|
3212
3195
|
return cache.get(cacheKey);
|
|
3213
3196
|
}
|
|
3214
3197
|
try {
|
|
3215
|
-
const publicClient = (0,
|
|
3216
|
-
chain: (0,
|
|
3217
|
-
transport: (0,
|
|
3198
|
+
const publicClient = (0, import_viem11.createPublicClient)({
|
|
3199
|
+
chain: (0, import_viem11.defineChain)(chain),
|
|
3200
|
+
transport: (0, import_viem11.http)()
|
|
3218
3201
|
});
|
|
3219
3202
|
const receipt = await publicClient.getTransactionReceipt({ hash });
|
|
3220
3203
|
if (!receipt) {
|
|
@@ -3228,7 +3211,7 @@ function useReceipt2({
|
|
|
3228
3211
|
},
|
|
3229
3212
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3230
3213
|
});
|
|
3231
|
-
(0,
|
|
3214
|
+
(0, import_react39.useEffect)(() => {
|
|
3232
3215
|
if (query.data) {
|
|
3233
3216
|
setShouldRefetch(false);
|
|
3234
3217
|
}
|
|
@@ -3237,14 +3220,14 @@ function useReceipt2({
|
|
|
3237
3220
|
}
|
|
3238
3221
|
|
|
3239
3222
|
// src/hooks/useTransaction.tsx
|
|
3240
|
-
var
|
|
3241
|
-
var
|
|
3242
|
-
var
|
|
3223
|
+
var import_react40 = require("react");
|
|
3224
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
3225
|
+
var import_viem12 = require("viem");
|
|
3243
3226
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
3244
3227
|
var MAX_CACHE_SIZE2 = 500;
|
|
3245
3228
|
var STORAGE_KEY2 = "match_transaction_logs";
|
|
3246
3229
|
function useTransactionCache() {
|
|
3247
|
-
const [cache, setCache] = (0,
|
|
3230
|
+
const [cache, setCache] = (0, import_react40.useState)(/* @__PURE__ */ new Map());
|
|
3248
3231
|
const isLocalStorageAvailable = (() => {
|
|
3249
3232
|
try {
|
|
3250
3233
|
const testKey = "__test__";
|
|
@@ -3255,7 +3238,7 @@ function useTransactionCache() {
|
|
|
3255
3238
|
return false;
|
|
3256
3239
|
}
|
|
3257
3240
|
})();
|
|
3258
|
-
(0,
|
|
3241
|
+
(0, import_react40.useEffect)(() => {
|
|
3259
3242
|
if (isLocalStorageAvailable) {
|
|
3260
3243
|
try {
|
|
3261
3244
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3274,7 +3257,7 @@ function useTransactionCache() {
|
|
|
3274
3257
|
}
|
|
3275
3258
|
}
|
|
3276
3259
|
}, []);
|
|
3277
|
-
const updateLocalStorage = (0,
|
|
3260
|
+
const updateLocalStorage = (0, import_react40.useCallback)((updatedCache) => {
|
|
3278
3261
|
if (isLocalStorageAvailable) {
|
|
3279
3262
|
try {
|
|
3280
3263
|
const storedData = localStorage.getItem(STORAGE_KEY2);
|
|
@@ -3291,7 +3274,7 @@ function useTransactionCache() {
|
|
|
3291
3274
|
}
|
|
3292
3275
|
}
|
|
3293
3276
|
}, []);
|
|
3294
|
-
const set = (0,
|
|
3277
|
+
const set = (0, import_react40.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 useTransactionCache() {
|
|
|
3309
3292
|
setCache(newCache);
|
|
3310
3293
|
updateLocalStorage(newCache);
|
|
3311
3294
|
}, [cache, updateLocalStorage]);
|
|
3312
|
-
const get = (0,
|
|
3295
|
+
const get = (0, import_react40.useCallback)((key) => {
|
|
3313
3296
|
const entry = cache.get(key);
|
|
3314
3297
|
if (entry) {
|
|
3315
3298
|
if (Date.now() - entry.timestamp > CACHE_TTL2) {
|
|
@@ -3323,7 +3306,7 @@ function useTransactionCache() {
|
|
|
3323
3306
|
}
|
|
3324
3307
|
return void 0;
|
|
3325
3308
|
}, [cache, updateLocalStorage]);
|
|
3326
|
-
const del = (0,
|
|
3309
|
+
const del = (0, import_react40.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 useTransactionCache() {
|
|
|
3331
3314
|
updateLocalStorage(newCache);
|
|
3332
3315
|
}
|
|
3333
3316
|
}, [cache, updateLocalStorage]);
|
|
3334
|
-
const clear = (0,
|
|
3317
|
+
const clear = (0, import_react40.useCallback)(() => {
|
|
3335
3318
|
setCache(/* @__PURE__ */ new Map());
|
|
3336
3319
|
if (isLocalStorageAvailable) {
|
|
3337
3320
|
localStorage.removeItem(STORAGE_KEY2);
|
|
@@ -3346,8 +3329,8 @@ function useTransaction({
|
|
|
3346
3329
|
const { list } = useMatchChain();
|
|
3347
3330
|
const cache = useTransactionCache();
|
|
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_react40.useState)(true);
|
|
3333
|
+
const query = (0, import_react_query8.useQuery)({
|
|
3351
3334
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
3352
3335
|
queryFn: async () => {
|
|
3353
3336
|
if (!chain || !hash) return false;
|
|
@@ -3356,9 +3339,9 @@ function useTransaction({
|
|
|
3356
3339
|
return cache.get(cacheKey);
|
|
3357
3340
|
}
|
|
3358
3341
|
try {
|
|
3359
|
-
const publicClient = (0,
|
|
3360
|
-
chain: (0,
|
|
3361
|
-
transport: (0,
|
|
3342
|
+
const publicClient = (0, import_viem12.createPublicClient)({
|
|
3343
|
+
chain: (0, import_viem12.defineChain)(chain),
|
|
3344
|
+
transport: (0, import_viem12.http)()
|
|
3362
3345
|
});
|
|
3363
3346
|
const transaction = await publicClient.getTransaction({ hash });
|
|
3364
3347
|
if (!transaction) {
|
|
@@ -3372,7 +3355,7 @@ function useTransaction({
|
|
|
3372
3355
|
},
|
|
3373
3356
|
refetchInterval: shouldRefetch ? 1e4 : false
|
|
3374
3357
|
});
|
|
3375
|
-
(0,
|
|
3358
|
+
(0, import_react40.useEffect)(() => {
|
|
3376
3359
|
if (query.data) {
|
|
3377
3360
|
setShouldRefetch(false);
|
|
3378
3361
|
}
|