From bd5f8608526544488da794ebbd389479d7e1206e Mon Sep 17 00:00:00 2001 From: Matthew Bunday Date: Wed, 14 Feb 2024 08:46:23 -0500 Subject: [PATCH] Fix type errors --- src/hooks/L1/useProveWithdrawalArgs.ts | 2 +- src/hooks/L1/useSimulateProveWithdrawalTransaction.ts | 7 ++++--- src/hooks/L1/useWriteDepositETH.ts | 4 ++-- src/hooks/L1/useWriteFinalizeWithdrawalTransaction.ts | 4 ++-- src/util/getStateTrieProof.ts | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/hooks/L1/useProveWithdrawalArgs.ts b/src/hooks/L1/useProveWithdrawalArgs.ts index 348d1b5..dc3eeed 100644 --- a/src/hooks/L1/useProveWithdrawalArgs.ts +++ b/src/hooks/L1/useProveWithdrawalArgs.ts @@ -27,7 +27,7 @@ export function useProveWithdrawalArgs({ throw new Error('L2 chain not configured') } - const l2PublicClient = usePublicClient({ chainId: l2Chain.chainId }) + const l2PublicClient = usePublicClient({ chainId: l2Chain.chainId })! const { data: blockNumberOfLatestL2OutputProposal } = useBlockNumberOfLatestL2OutputProposal({ config: opConfig, diff --git a/src/hooks/L1/useSimulateProveWithdrawalTransaction.ts b/src/hooks/L1/useSimulateProveWithdrawalTransaction.ts index 7e9cf8f..7af6ace 100644 --- a/src/hooks/L1/useSimulateProveWithdrawalTransaction.ts +++ b/src/hooks/L1/useSimulateProveWithdrawalTransaction.ts @@ -56,8 +56,8 @@ export function useSimulateProveWithdrawalTransaction< } const account = useAccount(rest) - const l1PublicClient = usePublicClient({ chainId: l2Chain.l1ChainId }) - const l2PublicClient = usePublicClient({ chainId: l2ChainId }) + const l1PublicClient = usePublicClient({ chainId: l2Chain.l1ChainId })! + const l2PublicClient = usePublicClient({ chainId: l2ChainId })! const l1Addresses = opConfig.l2chains[l2ChainId].l1Addresses const query = { @@ -103,7 +103,8 @@ export function useSimulateProveWithdrawalTransaction< }), } - const enabled = Boolean(account.address) && (queryOverride?.enabled ?? true) + const enabled = Boolean(account.address) && (queryOverride?.enabled ?? true) && Boolean(l1PublicClient) + && Boolean(l2PublicClient) return { ...useQuery({ ...query, queryKeyHashFn: hashFn, enabled }), queryKey: query.queryKey, diff --git a/src/hooks/L1/useWriteDepositETH.ts b/src/hooks/L1/useWriteDepositETH.ts index bd2ab39..81688e0 100644 --- a/src/hooks/L1/useWriteDepositETH.ts +++ b/src/hooks/L1/useWriteDepositETH.ts @@ -47,8 +47,8 @@ async function writeMutation( { l1ChainId, l2ChainId, args, ...rest }: DepositETHMutationParameters, ) { const walletClient = await getWalletClient(config, { chainId: l1ChainId }) - const l1PublicClient = getPublicClient(config, { chainId: l1ChainId }) - const l2PublicClient = getPublicClient(config, { chainId: l2ChainId }) + const l1PublicClient = await getPublicClient(config, { chainId: l1ChainId })! + const l2PublicClient = await getPublicClient(config, { chainId: l2ChainId })! const l1Addresses = config.l2chains[l2ChainId].l1Addresses const l2GasLimit = args.gasLimit diff --git a/src/hooks/L1/useWriteFinalizeWithdrawalTransaction.ts b/src/hooks/L1/useWriteFinalizeWithdrawalTransaction.ts index c9d4b2f..5048caa 100644 --- a/src/hooks/L1/useWriteFinalizeWithdrawalTransaction.ts +++ b/src/hooks/L1/useWriteFinalizeWithdrawalTransaction.ts @@ -57,8 +57,8 @@ async function writeMutation( { l1ChainId, l2ChainId, args, ...rest }: FinalizeWithdrawalTransactionMutationParameters, ) { const walletClient = await getWalletClient(config, { chainId: l1ChainId }) - const l1PublicClient = getPublicClient(config, { chainId: l1ChainId }) - const l2PublicClient = getPublicClient(config, { chainId: l2ChainId }) + const l1PublicClient = await getPublicClient(config, { chainId: l1ChainId })! + const l2PublicClient = await getPublicClient(config, { chainId: l2ChainId })! const l1Addresses = config.l2chains[l2ChainId].l1Addresses const withdrawalMessages = await getWithdrawalMessages(l2PublicClient, { diff --git a/src/util/getStateTrieProof.ts b/src/util/getStateTrieProof.ts index 7a71154..1e2886b 100644 --- a/src/util/getStateTrieProof.ts +++ b/src/util/getStateTrieProof.ts @@ -25,7 +25,7 @@ export async function makeStateTrieProof( } export function useMakeStateTrieProof( - client: PublicClient, + client: PublicClient | undefined, blockNumber: bigint | undefined, address: `0x${string}`, slot: `0x${string}` | undefined, @@ -33,7 +33,7 @@ export function useMakeStateTrieProof( const [proof, setProof] = useState(undefined) useEffect(() => { - if (!blockNumber || !slot) { + if (!blockNumber || !slot || !client) { return undefined }