// TODO this is duplicated in tevm/utils import type { Hex } from '@tevm/utils' export type JsonSerializable = | bigint | string | number | boolean | null | JsonSerializableArray | JsonSerializableObject | JsonSerializableSet | (Error & { code: number | string }) export type JsonSerializableArray = ReadonlyArray export type JsonSerializableObject = { [key: string]: JsonSerializable } export type JsonSerializableSet = Set export type BigIntToHex = T extends bigint ? Hex : T export type SetToHex = T extends Set ? Hex : T export type SerializeToJson = T extends Error & { code: infer TCode } ? { code: TCode; message: T['message'] } : T extends JsonSerializableSet ? ReadonlyArray : T extends JsonSerializableObject ? { [P in keyof T]: SerializeToJson } : T extends JsonSerializableArray ? SerializeToJson[] : BigIntToHex>