From 4164b15a2f1c4c9d332d691ae7c581da5de9ddb2 Mon Sep 17 00:00:00 2001 From: snoopy1412 Date: Tue, 19 Nov 2024 19:10:16 +0800 Subject: [PATCH] fix types error --- src/components/collator/collator-tabs.tsx | 4 ++-- src/hooks/useAssetsToVotes.ts | 4 ++-- src/view/stake/_hooks/staked.ts | 15 ++++----------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/collator/collator-tabs.tsx b/src/components/collator/collator-tabs.tsx index f7188ef..91c0b4b 100644 --- a/src/components/collator/collator-tabs.tsx +++ b/src/components/collator/collator-tabs.tsx @@ -119,12 +119,12 @@ const CollatorTabs = ({ onClose, isOpen }: CollatorTabsProps) => { /> )} {selected === 'overview' && ( - + )} {selected === 'manage' && ( diff --git a/src/hooks/useAssetsToVotes.ts b/src/hooks/useAssetsToVotes.ts index f52a15f..c1bc65c 100644 --- a/src/hooks/useAssetsToVotes.ts +++ b/src/hooks/useAssetsToVotes.ts @@ -32,12 +32,12 @@ export async function assetsToVotes( inputAmount: bigint, operation: Operation ): Promise { - return (await readContract(config, { + return await readContract(config, { abi, address, functionName: 'assetsToVotes', args: [commission, calculateAssets(totalAmount, inputAmount, operation)] - })) as unknown as bigint; + }); } function calculateAssets(totalAmount: bigint, inputAmount: bigint, operation: Operation): bigint { diff --git a/src/view/stake/_hooks/staked.ts b/src/view/stake/_hooks/staked.ts index 093c627..b362ea7 100644 --- a/src/view/stake/_hooks/staked.ts +++ b/src/view/stake/_hooks/staked.ts @@ -4,7 +4,6 @@ import useWalletStatus from '@/hooks/useWalletStatus'; import { useCallback, useMemo } from 'react'; import { useReadContract, useReadContracts } from 'wagmi'; import dayjs from 'dayjs'; -import { Abi } from 'viem'; export type StakedDepositsInfo = [account: `0x${string}`, assets: bigint, collator: `0x${string}`]; export type StakedDepositInfo = { @@ -25,7 +24,7 @@ export const useStakedDepositsOf = ({ account, enabled = true }: StakedDepositsO isLoading: isStakedDepositsOfLoading, isRefetching: isStakedDepositsOfRefetching, refetch: refetchStakedDepositsOf - } = useReadContract({ + } = useReadContract({ address, abi: hubAbi, functionName: 'stakedDepositsOf', @@ -44,7 +43,7 @@ export const useStakedDepositsOf = ({ account, enabled = true }: StakedDepositsO refetch: refetchCombinedInfo } = useReadContracts({ contracts: - ((stakedDepositsOf as bigint[])?.flatMap((deposit) => [ + stakedDepositsOf?.flatMap((deposit) => [ { address: address as `0x${string}`, abi: hubAbi, @@ -57,15 +56,9 @@ export const useStakedDepositsOf = ({ account, enabled = true }: StakedDepositsO functionName: 'depositOf', args: [deposit] } - ]) as unknown as readonly { - abi?: Abi | undefined; - functionName?: string | undefined; - args?: readonly unknown[] | undefined; - address?: `0x${string}` | undefined; - chainId?: number | undefined; - }[]) ?? [], + ]) ?? [], query: { - enabled: !!account && !!(stakedDepositsOf as bigint[])?.length, + enabled: !!account && !!stakedDepositsOf?.length, retry: true, retryDelay: 1000, refetchOnWindowFocus: false,