@matchain/matchid-sdk-react 0.1.48-alpha.32 → 0.1.48-alpha.33

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.
@@ -2713,7 +2713,7 @@ function useMatchWalletRecords() {
2713
2713
  const { address } = useWallet();
2714
2714
  const hasMoreRef = (0, import_react15.useRef)(hasMore);
2715
2715
  const nextPageParamsRef = (0, import_react15.useRef)(void 0);
2716
- const { getContract, setContracts } = useContractStore_default();
2716
+ const { contracts, setContracts } = useContractStore_default();
2717
2717
  const fetchMoreData = async () => {
2718
2718
  const chainIdStr = chainId ? chainId.toString() : "";
2719
2719
  if (!hasMoreRef.current || !chainIdStr) {
@@ -2725,55 +2725,6 @@ function useMatchWalletRecords() {
2725
2725
  });
2726
2726
  if (isSuccess(res)) {
2727
2727
  if (res.data && res.data.transactions && res.data.transactions.length > 0) {
2728
- const contractList = res.data.transactions.filter((item) => item.input.toLowerCase().substring(0, 10) == "0xa9059cbb").map((item) => item.to);
2729
- const contractUnique = Array.from(new Set(contractList)).filter((item) => {
2730
- const contract = getContract(chainId || 0, item);
2731
- if (!contract) {
2732
- return true;
2733
- }
2734
- if (!contract.symbol && !contract.name) {
2735
- return true;
2736
- }
2737
- if (!contract.decimals) {
2738
- return true;
2739
- }
2740
- return false;
2741
- });
2742
- const calls = [];
2743
- for (const contract of contractUnique) {
2744
- calls.push({
2745
- address: contract,
2746
- abi: import_viem8.erc20Abi,
2747
- functionName: "symbol",
2748
- args: []
2749
- });
2750
- calls.push({
2751
- address: contract,
2752
- abi: import_viem8.erc20Abi,
2753
- functionName: "decimals",
2754
- args: []
2755
- });
2756
- }
2757
- const results = await publicClient?.multicall({ contracts: calls });
2758
- if (results) {
2759
- console.log("contract results", calls, results);
2760
- const contractMap = [];
2761
- for (let i = 0; i < contractUnique.length; i++) {
2762
- const info = {};
2763
- if (results[i * 2].status == "success") {
2764
- info.symbol = results[i * 2].result;
2765
- }
2766
- if (results[i * 2 + 1].status == "success") {
2767
- info.decimals = results[i * 2 + 1].result;
2768
- }
2769
- contractMap.push({
2770
- chainId: chainId || 0,
2771
- contractAddress: contractUnique[i],
2772
- info
2773
- });
2774
- }
2775
- setContracts(contractMap);
2776
- }
2777
2728
  setItems(items.concat(res.data.transactions || []));
2778
2729
  }
2779
2730
  hasMoreRef.current = res.data && res.data.transactions && res.data.transactions.length >= 50;
@@ -2794,6 +2745,56 @@ function useMatchWalletRecords() {
2794
2745
  }
2795
2746
  }, [chainId, address]);
2796
2747
  const { transactions, removeTransaction } = useTransactionStore_default();
2748
+ const getContractInfoList = async (contractList) => {
2749
+ const contractUnique = Array.from(new Set(contractList)).filter((item) => {
2750
+ const contract = contracts[`${chainId}-${item.toLowerCase()}`];
2751
+ if (!contract) {
2752
+ return true;
2753
+ }
2754
+ if (!contract.symbol && !contract.name) {
2755
+ return true;
2756
+ }
2757
+ if (!contract.decimals) {
2758
+ return true;
2759
+ }
2760
+ return false;
2761
+ });
2762
+ const calls = [];
2763
+ for (const contract of contractUnique) {
2764
+ calls.push({
2765
+ address: contract,
2766
+ abi: import_viem8.erc20Abi,
2767
+ functionName: "symbol",
2768
+ args: []
2769
+ });
2770
+ calls.push({
2771
+ address: contract,
2772
+ abi: import_viem8.erc20Abi,
2773
+ functionName: "decimals",
2774
+ args: []
2775
+ });
2776
+ }
2777
+ const results = await publicClient?.multicall({ contracts: calls });
2778
+ if (results) {
2779
+ console.log("contract results", calls, results);
2780
+ const contractMap = [];
2781
+ for (let i = 0; i < contractUnique.length; i++) {
2782
+ const info = {};
2783
+ if (results[i * 2].status == "success") {
2784
+ info.symbol = results[i * 2].result;
2785
+ }
2786
+ if (results[i * 2 + 1].status == "success") {
2787
+ info.decimals = results[i * 2 + 1].result;
2788
+ }
2789
+ contractMap.push({
2790
+ chainId: chainId || 0,
2791
+ contractAddress: contractUnique[i],
2792
+ info
2793
+ });
2794
+ }
2795
+ setContracts(contractMap);
2796
+ }
2797
+ };
2797
2798
  const list = (0, import_react15.useMemo)(() => {
2798
2799
  const localTransactions = transactions[`${chainId}-${address}`] || [];
2799
2800
  const removeList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) >= 0);
@@ -2805,7 +2806,7 @@ function useMatchWalletRecords() {
2805
2806
  });
2806
2807
  });
2807
2808
  const saveList = localTransactions.filter((n) => items.findIndex((m) => m.hash == n.hash) < 0);
2808
- return [
2809
+ const list2 = [
2809
2810
  ...saveList,
2810
2811
  ...items
2811
2812
  ].sort((a, b) => {
@@ -2813,6 +2814,9 @@ function useMatchWalletRecords() {
2813
2814
  const atimestamp = typeof a.timestamp === "string" ? parseInt(a.timestamp) : a.timestamp;
2814
2815
  return btimestamp - atimestamp;
2815
2816
  });
2817
+ const contractList = list2.filter((item) => item.input.toLowerCase().substring(0, 10) == "0xa9059cbb").map((item) => item.to);
2818
+ getContractInfoList(contractList);
2819
+ return list2;
2816
2820
  }, [transactions, chainId, items, address]);
2817
2821
  return {
2818
2822
  items: list,