2023-07-28 15:11:38 +03:00
|
|
|
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";
|
2023-09-29 15:12:03 +03:00
|
|
|
import { ensDomains } from "./constants";
|
2023-07-28 15:11:38 +03:00
|
|
|
|
|
|
|
const getLabelhashFromDomain = (ensDomain: string) => "0x" + keccak_256(ensDomain.split(".")[0]);
|
|
|
|
|
2023-09-29 15:12:03 +03:00
|
|
|
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"
|
|
|
|
);
|
|
|
|
|
2023-07-28 15:11:38 +03:00
|
|
|
const solidityCode =
|
2023-09-29 15:12:03 +03:00
|
|
|
Object.entries(ensDomains)
|
|
|
|
.map((e) => calculateNodeDecl(e))
|
|
|
|
.join("") +
|
2023-07-28 15:11:38 +03:00
|
|
|
"\n" +
|
2023-09-29 15:12:03 +03:00
|
|
|
Object.entries(ensDomains)
|
|
|
|
.map((e) => calculateLabelDecl(e))
|
|
|
|
.join("");
|
2023-07-28 15:11:38 +03:00
|
|
|
|
|
|
|
fs.writeFileSync(path.join("data", "ensNodesDeclarations.txt"), solidityCode);
|