proposal-30-decentralize-so.../test/GoerliENSDomainOwner.sol

51 lines
1.9 KiB
Solidity
Raw Permalink Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { IENSResolver } from "@interfaces/IENSResolver.sol";
import { IENSRegistry } from "@interfaces/IENSRegistry.sol";
import { ENSNamehash } from "./ENSNamehash.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
contract GoerliDomainOwner is Ownable, ERC1155Holder {
address internal ensResolverAddress = 0xd7a4F6473f32aC2Af804B3686AE8F1932bC35750; // goerli ENS resolver
address internal ensRegistryAddress = 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e;
IENSResolver ensResolver = IENSResolver(ensResolverAddress);
IENSRegistry ensRegistry = IENSRegistry(ensRegistryAddress);
function transferDomainOwnership(string memory domain, address to) public onlyOwner {
_transferDomainOwnership(ENSNamehash.namehash(bytes(domain)), to);
}
function _transferDomainOwnership(bytes32 domainNode, address to) private {
require(ensRegistry.owner(domainNode) == address(this), "This test contract must be an owner of domain");
ensRegistry.setOwner(domainNode, to);
}
function calculateSubdomainLabelhash(string memory subdomainLabel) internal pure returns (bytes32) {
return keccak256(bytes(subdomainLabel));
}
function isContract(address _addr) private view returns (bool) {
uint32 size;
assembly {
size := extcodesize(_addr)
}
return (size > 0);
}
function execute(address proposal) public onlyOwner {
require(isContract(proposal), "not a contract");
(bool success, bytes memory data) = proposal.delegatecall(abi.encodeWithSignature("executeProposal()"));
if (!success) {
if (data.length > 0) {
revert(string(data));
} else {
revert("Proposal execution failed");
}
}
}
}