import { toHex } from "viem" // biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type export function deepHexlify(obj: any): any { if (typeof obj === "function") { return undefined } if ( obj == null || typeof obj === "string" || typeof obj === "boolean" || typeof obj === "number" // Do not hexlify numbers ) { return obj } if (typeof obj === "bigint") { return toHex(obj) } if (obj._isBigNumber != null || typeof obj !== "object") { return toHex(obj).replace(/^0x0/, "0x") } if (Array.isArray(obj)) { return obj.map((member) => deepHexlify(member)) } // biome-ignore lint/suspicious/noExplicitAny: return Object.keys(obj).reduce((set: any, key: string) => { set[key] = deepHexlify(obj[key]) return set }, {}) }