// @ts-ignore import contentHash from "content-hash"; import fs from "fs"; import path from "path"; import { DeclCalculator } from "./utils"; import { ipfsCids } from "./constants"; const contentHashToBytesMemory = (hash: string) => `hex"${hash}"`; const ipfsCidToBytesMemory = (cid: string) => contentHashToBytesMemory(contentHash.fromIpfs(cid)); const solidityDoublePadding = " ".repeat(8); const { calculateDecl: calculateContenthashDecl } = new DeclCalculator( "bytes memory", solidityDoublePadding, ipfsCidToBytesMemory, (name: string) => name + "Contenthash" ); const solidityCode = Object.entries(ipfsCids) .map((e) => calculateContenthashDecl(e)) .join(""); fs.writeFileSync(path.join("data", "ensDomainsIPFSContenthashes.txt"), solidityCode);