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