import type { Hex } from 'viem' type JsonSerializable = | bigint | string | number | boolean | null | JsonSerializableArray | JsonSerializableObject | JsonSerializableSet type JsonSerializableArray = ReadonlyArray type JsonSerializableObject = { [key: string]: JsonSerializable } type JsonSerializableSet< T extends bigint | string | number | boolean = | bigint | string | number | boolean, > = Set type BigIntToHex = T extends bigint ? Hex : T type SetToHex = T extends Set ? Hex : T export type SerializeToJson = T extends JsonSerializableSet ? ReadonlyArray : T extends JsonSerializableObject ? { [P in keyof T]: SerializeToJson } : T extends JsonSerializableArray ? SerializeToJson[] : BigIntToHex>