UNPKG

@lifi/compose-spec

Version:

Public wire-format types and schemas for Compose flows

17 lines (15 loc) 1.12 kB
// Shared hex-string patterns for the compose wire format. Zero-dependency leaf // so both the Effect-schema side (`descriptor.ts`) and the standalone Zod // mirror (`zodSchemas.ts`) consume one source of truth without importing across // layers. compose-spec is the wire-format leaf and may not import `@lifi/utils` // (enforced by `scripts/check-compose-boundaries.mjs`), so the equivalent of // `makeHexStringRegex(32, { lowercase: true })` is inlined here. // A `0x`-prefixed, exactly-32-byte, STRICTLY lowercase hex string. Validated // strictly — deliberately overriding compose-spec's lenient `0x`-prefix-only // convention for address fields. These hashes (`validationProgramHash`, // `paramsHash`) are machine-generated (ethers `keccak256` emits lowercase) and // never hand-typed, so strictness costs nothing; leniency would admit two // serializations of one hash (mixed case) and truncated values, both of which // poison determinism and the byte-identity fixture discipline. A zero hash // `0x00…00` (64 zeros) remains valid under the strict rule. export const BYTES32_LOWER_HEX = /^0x[0-9a-f]{64}$/;