import type { AbiEvent, AbiFunction } from 'abitype' import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js' import type { ErrorType } from '../errors/utils.js' import { type Keccak256ErrorType, keccak256 } from './keccak256.js' import { type ToSignatureErrorType, toSignature } from './toSignature.js' export type ToSignatureHashErrorType = | Keccak256ErrorType | ToBytesErrorType | ToSignatureErrorType | ErrorType /** * Returns the hash (of the function/event signature) for a given event or function definition. */ export function toSignatureHash(fn: string | AbiFunction | AbiEvent) { return keccak256(toBytes(toSignature(fn))) }