Skip to content
Lattice

ENSReverseClaimerLib

Git Source

Title: ENSReverseClaimerLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from ENS (https://github.com/ensdomains/ens-contracts)

Library letting a diamond claim and advertise its own primary ENS name via ENS reverse resolution, so resolving the diamond address returns its name (e.g. treasury.myproto.eth).

Three-layer pattern: this library holds all logic and the namespaced storage; the stateless ENSReverseClaimer facet forwards to it. Identity changes are gated on ENS_MANAGER_ROLE. The diamond calls IReverseRegistrar.setName itself, so msg.sender at the registrar is the diamond — exactly what makes the diamond's addr.reverse record resolve to the chosen name.

Functions

ensReverseClaimerStorage

function ensReverseClaimerStorage() internal pure returns (ENSReverseClaimerStorage storage $);

Returns

NameTypeDescription
$ENSReverseClaimerStorage

__ENSReverseClaimer_init

Initializes the ENSReverseClaimer module with the reverse registrar to use.

Must be called inside a pre/postInitializer block. Reverts ENSReverseClaimerZeroRegistrar for a zero registrar. Registers IENSReverseClaimer for ERC-165 discovery.

function __ENSReverseClaimer_init(address _reverseRegistrar) internal;

Parameters

NameTypeDescription
_reverseRegistraraddressThe ENS reverse registrar for this chain.

registerInterface

Registers support for the IENSReverseClaimer interface via ERC-165.

function registerInterface() internal;

setEnsName

Sets the diamond's primary ENS name via the configured reverse registrar.

Gated on ENS_MANAGER_ROLE. The registrar is non-zero by construction (enforced at init and in setReverseRegistrar), so setName always targets a configured registrar. The external setName call uses a void-typed interface so it works against both the L1 ReverseRegistrar (which returns bytes32, ignored) and the L2 L2ReverseRegistrar (which returns nothing). Passing an empty string clears the reverse record (canonical ReverseRegistrar semantics).

function setEnsName(string calldata name) internal;

Parameters

NameTypeDescription
namestringThe ENS name to set as the diamond's primary name.

setReverseRegistrar

Sets or rotates the reverse registrar (per-chain configuration).

Gated on ENS_MANAGER_ROLE. Reverts ENSReverseClaimerZeroRegistrar for a zero address. The registrar is trusted code reached via an external call in setEnsName; only an ENS_MANAGER_ROLE holder can point the diamond at it.

function setReverseRegistrar(address _reverseRegistrar) internal;

Parameters

NameTypeDescription
_reverseRegistraraddressThe reverse registrar to use.

ensName

Returns the diamond's last ENS name set through this facet.

function ensName() internal view returns (string memory);

Returns

NameTypeDescription
<none>string

reverseRegistrar

Returns the currently configured reverse registrar.

function reverseRegistrar() internal view returns (address);

Returns

NameTypeDescription
<none>address