proposal-29-update-ipfs/scripts/calculateIPFSContenthashes.ts

25 lines
1.0 KiB
TypeScript
Raw Normal View History

// @ts-ignore
import contentHash from "content-hash";
import fs from "fs";
import path from "path";
import { DeclCalculator } from "./utils";
2023-08-30 22:05:46 +03:00
import { classicUiIpfsCid, novaUiIpfsCid, relayersUiIpfsCid, docsIpfsCid } from "./constants";
const contentHashToBytesMemory = (hash: string) => `hex"${hash}"`;
2023-08-30 22:05:46 +03:00
const classicUiIPFSContenthash = contentHash.fromIpfs(classicUiIpfsCid);
const novaUiIPFSContenthash = contentHash.fromIpfs(novaUiIpfsCid);
const relayersUiIPFSContenthash = contentHash.fromIpfs(relayersUiIpfsCid);
const docsIPFSContenthash = contentHash.fromIpfs(docsIpfsCid);
const solidityDoublePadding = " ".repeat(8);
const { calculateDecl } = new DeclCalculator("bytes memory", solidityDoublePadding, contentHashToBytesMemory);
const solidityCode =
calculateDecl({ classicUiIPFSContenthash }) +
calculateDecl({ novaUiIPFSContenthash }) +
calculateDecl({ relayersUiIPFSContenthash }) +
calculateDecl({ docsIPFSContenthash });
fs.writeFileSync(path.join("data", "ensDomainsIPFSContenthashes.txt"), solidityCode);