import MoralisType from "moralis/types" ; import { useMoralisWeb3Api , useMoralisWeb3ApiCall , UseMoralisWeb3ApiCallOptions , } from "../../core/useMoralisWeb3Api" ; export interface ApiContractParams extends Omit < Parameters < typeof MoralisType . Web3API [ "native" ] [ "runContractFunction" ] > [ 0 ] , "address" | "function_name" | "params" | "abi" > { address ? : string ; functionName : string ; abi : any ; params ? : any ; } export const useApiContract = ( { functionName , address , abi , chain , params } , options = { } ) => { const { native } = useMoralisWeb3Api ( ) ; const payload = { abi , chain , function_name : functionName , address , params , } ; const { fetch : runContractFunction , data , error , isFetching , isLoading , } = useMoralisWeb3ApiCall ( native . runContractFunction , payload , { autoFetch : options . autoFetch ?? false , ... options , } ) ; return { runContractFunction , data , error , isLoading , isFetching } ; } ;