Created
September 22, 2021 10:59
-
-
Save dhadrien/a6f041357afcf1c0decd924066009c60 to your computer and use it in GitHub Desktop.
compiling deployer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.8.4; | |
import { ENSRegistry } from "@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol"; | |
import { FIFSRegistrar } from "@ensdomains/ens-contracts/contracts/registry/FIFSRegistrar.sol"; | |
import { ReverseRegistrar, NameResolver } from "@ensdomains/ens-contracts/contracts/registry/ReverseRegistrar.sol"; | |
import { PublicResolver, INameWrapper } from "@ensdomains/ens-contracts/contracts/resolvers/PublicResolver.sol"; | |
// Construct a set of test ENS contracts. | |
contract ENSDeployer { | |
bytes32 constant TLD_LABEL = keccak256("eth"); | |
bytes32 constant RESOLVER_LABEL = keccak256("resolver"); | |
bytes32 constant REVERSE_REGISTRAR_LABEL = keccak256("reverse"); | |
bytes32 constant ADDR_LABEL = keccak256("addr"); | |
ENSRegistry public ens; | |
FIFSRegistrar public fifsRegistrar; | |
ReverseRegistrar public reverseRegistrar; | |
PublicResolver public publicResolver; | |
function namehash(bytes32 node, bytes32 label) public pure returns (bytes32) { | |
return keccak256(abi.encodePacked(node, label)); | |
} | |
constructor() public { | |
ens = new ENSRegistry(); | |
publicResolver = new PublicResolver(ens, INameWrapper(address(0))); | |
// Set up the resolver | |
bytes32 resolverNode = namehash(bytes32(0), RESOLVER_LABEL); | |
ens.setSubnodeOwner(bytes32(0), RESOLVER_LABEL, address(this)); | |
ens.setResolver(resolverNode, address(publicResolver)); | |
publicResolver.setAddr(resolverNode, address(publicResolver)); | |
// Create a FIFS registrar for the TLD | |
fifsRegistrar = new FIFSRegistrar(ens, namehash(bytes32(0), TLD_LABEL)); | |
ens.setSubnodeOwner(bytes32(0), TLD_LABEL, address(fifsRegistrar)); | |
// Construct a new reverse registrar and point it at the public resolver | |
reverseRegistrar = new ReverseRegistrar(ens, NameResolver(address(publicResolver))); | |
// Set up the reverse registrar | |
ens.setSubnodeOwner(bytes32(0), REVERSE_REGISTRAR_LABEL, address(this)); | |
ens.setSubnodeOwner(namehash(bytes32(0), REVERSE_REGISTRAR_LABEL), ADDR_LABEL, address(reverseRegistrar)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment