UNPKG

@ensnode/ensrainbow-sdk

Version:

ENSRainbow SDK for interacting with the ENSRainbow API.

29 lines 823 B
// src/label-utils.ts import { hexToBytes } from "viem"; function labelHashToBytes(labelHash) { try { if (labelHash.length !== 66) { throw new Error(`Invalid labelHash length ${labelHash.length} characters (expected 66)`); } if (labelHash !== labelHash.toLowerCase()) { throw new Error("Labelhash must be in lowercase"); } if (!labelHash.startsWith("0x")) { throw new Error("Labelhash must be 0x-prefixed"); } const bytes = hexToBytes(labelHash); if (bytes.length !== 32) { throw new Error(`Invalid labelHash length ${bytes.length} bytes (expected 32)`); } return bytes; } catch (e) { if (e instanceof Error) { throw e; } throw new Error("Invalid hex format"); } } export { labelHashToBytes }; //# sourceMappingURL=label-utils.js.map