permissionless
Version:
A utility library for working with ERC-4337
36 lines (31 loc) • 991 B
text/typescript
import { toHex } from "viem"
export const transactionReceiptStatus = {
"0x0": "reverted",
"0x1": "success"
} as const
// 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") {
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))
}
return Object.keys(obj).reduce(
// biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type
(set: any, key: string) => {
set[key] = deepHexlify(obj[key])
return set
},
{}
)
}