Skip to content

Commit 8958021

Browse files
committed
Use the type Address in abi.ts and useFetchContractAbi
1 parent 004065b commit 8958021

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/nextjs/hooks/useFetchContractAbi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from "react";
22
import { useQuery } from "@tanstack/react-query";
3-
import { isAddress } from "viem";
3+
import { Address, isAddress } from "viem";
44
import { UsePublicClientReturnType } from "wagmi";
55
import { fetchContractABIFromEtherscan } from "~~/utils/abi";
66

@@ -19,7 +19,7 @@ const useFetchContractAbi = ({ contractAddress, chainId, disabled = false }: Fet
1919
throw new Error("Invalid contract address");
2020
}
2121

22-
const addressToUse: string = contractAddress;
22+
const addressToUse: Address = contractAddress;
2323
try {
2424
const { abi, implementation } = await fetchContractABIFromEtherscan(addressToUse, chainId);
2525

packages/nextjs/utils/abi.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Address } from "viem";
12
import * as chains from "viem/chains";
23

34
const findChainById = (chainId: number): chains.Chain => {
@@ -32,7 +33,7 @@ const getEtherscanApiKey = (chainId: number): string => {
3233
return apiKey || "";
3334
};
3435

35-
export const fetchContractABIFromEtherscan = async (verifiedContractAddress: string, chainId: number) => {
36+
export const fetchContractABIFromEtherscan = async (verifiedContractAddress: Address, chainId: number) => {
3637
const chain = findChainById(chainId);
3738

3839
if (!chain || !chain.blockExplorers?.default?.apiUrl) {

0 commit comments

Comments
 (0)