ENSSubdomainRegistrar
Contract · src/framework/utils/ens/ENSSubdomainRegistrar.sol
Explained in: Registries and ENS names
Author: Aragon X - 2022-2023
Inherits: UUPSUpgradeable, DaoAuthorizableUpgradeable, ProtocolVersion
This contract registers ENS subdomains under a parent domain specified in the initialization process and maintains ownership of the subdomain since only the resolver address is set. This contract must either be the domain node owner or an approved operator of the node owner. The default resolver being used is the one specified in the parent domain.
security-contact: sirt@aragon.org
Constructor
constructor
constructor()Dev: Used to disallow initializing the implementation contract by an attacker for extra safety.
oz-upgrades-unsafe-allow: constructor
Functions
dao
function dao() external view returns (IDAO)Selector: 0x4162169f
Returns the DAO contract.
| Returns | Type | Description |
|---|---|---|
[0] | IDAO |
ens
function ens() external view returns (ENS)Selector: 0x3f15457f
The ENS registry contract
initialize
function initialize(IDAO _managingDao, ENS _ens, bytes32 _node) externalSelector: 0x6133f985
Initializes the component by
- checking that the contract is the domain node owner or an approved operator
- initializing the underlying component
- registering the ERC-165 interface ID
- setting the ENS contract, the domain node hash, and resolver.
| Parameter | Type | Description |
|---|---|---|
_managingDao | IDAO | The interface of the DAO managing the components permissions. |
_ens | ENS | The interface of the ENS registry to be used. |
_node | bytes32 | The ENS parent domain node under which the subdomains are to be registered. |
node
function node() external view returns (bytes32)Selector: 0xd70754ec
The namehash of the domain on which subdomains are registered.
protocolVersion
function protocolVersion() external pure returns (uint8[3])Selector: 0x2ae9c600
Returns the semantic Aragon OSx protocol version number that the implementing contract is associated with.
Dev: This version number is not to be confused with the
releaseandbuildnumbers found in theVersion.Tagstruct inside thePluginRepocontract being used to version plugin setup and associated plugin implementation contracts.
| Returns | Type | Description |
|---|---|---|
[0] | uint8[3] | Returns the semantic Aragon OSx protocol version number. |
proxiableUUID
function proxiableUUID() external view returns (bytes32)Selector: 0x52d1902d
Dev: Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the implementation. It is used to validate the implementation's compatibility when performing an upgrade.
IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this function revert if invoked through a proxy. This is guaranteed by the
notDelegatedmodifier.
registerSubnode
function registerSubnode(bytes32 _label, address _targetAddress) externalSelector: 0x89bb4145
Registers a new subdomain with this registrar as the owner and set the target address in the resolver.
Dev: It reverts with no message if this contract isn't the owner nor an approved operator for the given node.
| Parameter | Type | Description |
|---|---|---|
_label | bytes32 | The labelhash of the subdomain name. |
_targetAddress | address | The address to which the subdomain resolves. |
resolver
function resolver() external view returns (address)Selector: 0x04f3bcec
The address of the ENS resolver resolving the names to an address.
setDefaultResolver
function setDefaultResolver(address _resolver) externalSelector: 0xc66485b2
Sets the default resolver contract address that the subdomains being registered will use.
| Parameter | Type | Description |
|---|---|---|
_resolver | address | The resolver contract to be used. |
upgradeTo
function upgradeTo(address newImplementation) externalSelector: 0x3659cfe6
Dev: Upgrade the implementation of the proxy to
newImplementation.Calls {_authorizeUpgrade}.
Emits an {Upgraded} event.
oz-upgrades-unsafe-allow-reachable: delegatecall
upgradeToAndCall
function upgradeToAndCall(address newImplementation, bytes data) external payableSelector: 0x4f1ef286
Dev: Upgrade the implementation of the proxy to
newImplementation, and subsequently execute the function call encoded indata.Calls {_authorizeUpgrade}.
Emits an {Upgraded} event.
oz-upgrades-unsafe-allow-reachable: delegatecall
Events
AdminChanged
event AdminChanged(address previousAdmin, address newAdmin)Dev: Emitted when the admin account has changed.
BeaconUpgraded
event BeaconUpgraded(address indexed beacon)Dev: Emitted when the beacon is changed.
Initialized
event Initialized(uint8 version)Dev: Triggered when the contract has been initialized or reinitialized.
Upgraded
event Upgraded(address indexed implementation)Dev: Emitted when the implementation is upgraded.
Errors
AlreadyRegistered
error AlreadyRegistered(bytes32 subnode, address nodeOwner)Thrown if the subnode is already registered.
| Parameter | Type | Description |
|---|---|---|
subnode | bytes32 | The subnode namehash. |
nodeOwner | address | The node owner address. |
DaoUnauthorized
error DaoUnauthorized(address dao, address where, address who, bytes32 permissionId)Thrown if a call is unauthorized in the associated DAO.
| Parameter | Type | Description |
|---|---|---|
dao | address | The associated DAO. |
where | address | The context in which the authorization reverted. |
who | address | The address (EOA or contract) missing the permission. |
permissionId | bytes32 | The permission identifier. |
InvalidResolver
error InvalidResolver(bytes32 node, address resolver)Thrown if node's resolver is invalid.
| Parameter | Type | Description |
|---|---|---|
node | bytes32 | The node namehash. |
resolver | address | The node resolver address. |
Constants
Public, so each is also readable through a generated getter.
REGISTER_ENS_SUBDOMAIN_PERMISSION_ID
bytes32 public constant REGISTER_ENS_SUBDOMAIN_PERMISSION_ID =
keccak256("REGISTER_ENS_SUBDOMAIN_PERMISSION");Value: 0xbbdfd23f099d7ed9f535e0f97d2123efb1332b16e023b8359b3b879eaecd3c14
The ID of the permission required to call the registerSubnode and setDefaultResolver function.
UPGRADE_REGISTRAR_PERMISSION_ID
bytes32 public constant UPGRADE_REGISTRAR_PERMISSION_ID =
keccak256("UPGRADE_REGISTRAR_PERMISSION");Value: 0xa1fcba4efb1e94b7648f5e0504bfd39734aead5f17965d12705915d771c859ff
The ID of the permission required to call the _authorizeUpgrade function.