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

45 lines
1.9 KiB
TypeScript
Raw Normal View History

import fs from "fs";
import path from "path";
// @ts-ignore
import { hash } from "@ensdomains/eth-ens-namehash";
import { keccak_256 } from "js-sha3";
import { DeclCalculator } from "./utils";
const rootTornadoDomain = "tornadocash.eth";
const stakingDomain = "staking-rewards.contract.tornadocash.eth";
const governanceImplDomain = "governance-impl.contract.tornadocash.eth";
const novaUIDomain = "nova.tornadocash.eth";
const docsDomain = "docs.tornadocash.eth";
const relayersUIDomain = "relayers-network.tornadocash.eth";
const tornadoContractDomain = "contract.tornadocash.eth";
const rootTornadoENSNode = hash(rootTornadoDomain);
const tornadoContractENSNode = hash(tornadoContractDomain);
const stakingRewardsENSNode = hash(stakingDomain);
const governanceImplENSNode = hash(governanceImplDomain);
const novaENSNode = hash(novaUIDomain);
const docsENSNode = hash(docsDomain);
const relayersUIENSNode = hash(relayersUIDomain);
const getLabelhashFromDomain = (ensDomain: string) => "0x" + keccak_256(ensDomain.split(".")[0]);
const tornadoContractENSLabelhash = getLabelhashFromDomain(tornadoContractDomain);
const stakingRewardsENSLabelhash = getLabelhashFromDomain(stakingDomain);
const governanceImplENSLabelhash = getLabelhashFromDomain(governanceImplDomain);
const { calculateDecl } = new DeclCalculator("bytes32");
const solidityCode =
calculateDecl({ rootTornadoENSNode }) +
calculateDecl({ tornadoContractENSNode }) +
calculateDecl({ stakingRewardsENSNode }) +
calculateDecl({ governanceImplENSNode }) +
calculateDecl({ novaENSNode }) +
calculateDecl({ docsENSNode }) +
calculateDecl({ relayersUIENSNode }) +
"\n" +
calculateDecl({ tornadoContractENSLabelhash }) +
calculateDecl({ stakingRewardsENSLabelhash }) +
calculateDecl({ governanceImplENSLabelhash });
fs.writeFileSync(path.join("data", "ensNodesDeclarations.txt"), solidityCode);