/** Hex helpers. The SDK works in bytes; the chain and the config files speak hex. */ export function hex(bytes: Uint8Array): string { let out = ""; for (const b of bytes) { out += b.toString(16).padStart(2, "0"); } return out; } export function unhex(value: string): Uint8Array { const stripped = value.startsWith("0x") ? value.slice(2) : value; if (stripped.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(stripped)) { throw new RangeError("not an even-length hex string"); } const out = new Uint8Array(stripped.length / 2); for (let i = 0; i < out.length; i++) { out[i] = Number.parseInt(stripped.slice(2 * i, 2 * i + 2), 16); } return out; }