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

29 lines
1.2 KiB
TypeScript

// @ts-ignore
import contentHash from "content-hash";
import fs from "fs";
import path from "path";
import { DeclCalculator } from "./utils";
const classicUiIPFSCid = "QmX2mqjsZYaZGoLHCBFX9QpV38jFtU5eNDUR3M7a7fzRY9";
const novaUiIPFSCid = "QmVS4SPsH44oJPCffUZZUGTXqCpSx3eK8UJ8YmZsSDygop";
const relayersUiIPFSCid = "QmSUG2SNSPc6UUc6tgTZJWQKExhUGqjxHQPcJNZuU5FcxW";
const docsIPFSCid = "QmNvimy7WNYG3H8cYmANLZjfvKeDFLUHDVvLMLiKj5AWsC";
const contentHashToBytesMemory = (hash: string) => `hex"${hash}"`;
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);