72 lines
2.8 KiB
TypeScript
72 lines
2.8 KiB
TypeScript
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";
|
|
|
|
// Different domain for Goerli testing
|
|
const rootTornadoDomain = "tornadotest.eth";
|
|
const sourcesDomain = "sources." + rootTornadoDomain;
|
|
const minifiedSourcesDomain = "minified." + sourcesDomain;
|
|
const packagesDomain = "packages." + sourcesDomain;
|
|
|
|
export const ensDomains = {
|
|
rootTornadoDomain,
|
|
sourcesDomain,
|
|
minifiedSourcesDomain,
|
|
packagesDomain,
|
|
downloadScriptSourceDomain: "download." + sourcesDomain,
|
|
classicUISourceDomain: "classic-ui." + sourcesDomain,
|
|
novaUISourceDomain: "nova." + sourcesDomain,
|
|
docsSourceDomain: "docs." + sourcesDomain,
|
|
relayersUISourceDomain: "relayers-ui." + sourcesDomain,
|
|
tornTokenSourceDomain: "torn-token." + sourcesDomain,
|
|
classicRelayerSoftwareSourceDomain: "classic-relayer." + sourcesDomain,
|
|
novaRelayerSoftwareSourceDomain: "nova-relayer." + sourcesDomain,
|
|
tornadoCliSourceDomain: "cli." + sourcesDomain,
|
|
infoPageSourceDomain: "info-page." + sourcesDomain,
|
|
classicUIMinifiedDomain: "classic-ui." + minifiedSourcesDomain,
|
|
novaMinifiedDomain: "nova." + minifiedSourcesDomain,
|
|
tornadoCliMinifiedDomain: "cli." + minifiedSourcesDomain,
|
|
websnarkPackageDomain: "websnark." + packagesDomain,
|
|
circomlibPackageDomain: "circomlib." + packagesDomain,
|
|
snarkjsPackageDomain: "snarkjs." + packagesDomain,
|
|
tornadoOraclesPackageDomain: "oracles." + packagesDomain,
|
|
gasPriceOraclePackageDomain: "gas-price-oracle." + packagesDomain,
|
|
tornadoConfigPackageDomain: "config." + packagesDomain,
|
|
anonymityMiningPackageDomain: "anonymity-mining." + packagesDomain,
|
|
tornadoTreesPackageDomain: "trees." + packagesDomain,
|
|
fixedMerkleTreePackageDomain: "fixed-merkle-tree." + packagesDomain,
|
|
txManagerPackageDomain: "tx-manager." + packagesDomain,
|
|
merkleRootUpdaterPackageDomain: "merkle-root-updater." + packagesDomain,
|
|
};
|
|
|
|
const getLabelhashFromDomain = (ensDomain: string) => "0x" + keccak_256(ensDomain.split(".")[0]);
|
|
|
|
const solidityInContractPadding = " ".repeat(4);
|
|
const { calculateDecl: calculateNodeDecl } = new DeclCalculator(
|
|
"bytes32 internal constant",
|
|
solidityInContractPadding,
|
|
hash,
|
|
(name: string) => name + "Node"
|
|
);
|
|
const { calculateDecl: calculateLabelDecl } = new DeclCalculator(
|
|
"bytes32 internal constant",
|
|
solidityInContractPadding,
|
|
getLabelhashFromDomain,
|
|
(name: string) => name + "Labelhash"
|
|
);
|
|
|
|
const solidityCode =
|
|
Object.entries(ensDomains)
|
|
.map((e) => calculateNodeDecl(e))
|
|
.join("") +
|
|
"\n" +
|
|
Object.entries(ensDomains)
|
|
.map((e) => calculateLabelDecl(e))
|
|
.join("");
|
|
|
|
fs.writeFileSync(path.join("data", "test", "ensNodesDeclarations.txt"), solidityCode);
|