Skip to content
Verified contractExactMIT

HexMirrorRegistrar

Address0x81374cd4e6e7da5c88a8054ca0fa580518949332
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.25

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.25+commit.b61c2a91
Language
solidity
Optimization
Yes, 1,000 runs
EVM version
shanghai
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,425,321
Creation transaction
0x227427ff4c…287c9567a9

src/ethereum/HexMirrorRegistrar.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {IPermissionedRegistry} from "@ensv2/registry/interfaces/IPermissionedRegistry.sol";
import {IRegistry} from "@ensv2/registry/interfaces/IRegistry.sol";
import {RegistryRolesLib} from "@ensv2/registry/libraries/RegistryRolesLib.sol";
import {LibLabel} from "@ensv2/utils/LibLabel.sol";

import {BridgeLink} from "../common/BridgeLink.sol";
import {ZeroAddress} from "../common/Errors.sol";
import {IAMB} from "../interfaces/IAMB.sol";
import {IHexMirrorReceiver} from "../interfaces/IHexBridge.sol";

/// @title HexMirrorRegistrar
/// @notice Keeps the Ethereum copy of .hex in step with PulseChain, where names live.
/// @dev The only writer of the Ethereum .hex registry. It holds that registry's register,
///      unregister and renew roles, and acts only on messages from the linked `HexMirrorSync` on
///      PulseChain, delivered by the official bridge. For each message it makes the Ethereum entry
///      match what PulseChain reported:
///        - same owner, later expiry: the expiry is extended;
///        - new owner: the old entry is removed and a fresh one is made for the new owner, so
///          nothing set by the previous owner on Ethereum carries over;
///        - not registered or expired on PulseChain: the entry is removed.
///      Names on Ethereum cannot be transferred, since ownership follows PulseChain. Their owner can
///      still set a resolver and a subregistry on Ethereum.
///
///      Messages may arrive out of order, so each carries a nonce and older ones are ignored. A
///      message never reverts once it is authenticated, so the bridge never marks one as failed.
contract HexMirrorRegistrar is BridgeLink, IHexMirrorReceiver {
    /// @notice Roles an owner gets on an Ethereum entry: set its resolver and subregistry (and let
    ///         others do so). No transfer role.
    uint256 public constant OWNER_ROLES = RegistryRolesLib.ROLE_SET_SUBREGISTRY
        | RegistryRolesLib.ROLE_SET_SUBREGISTRY_ADMIN | RegistryRolesLib.ROLE_SET_RESOLVER
        | RegistryRolesLib.ROLE_SET_RESOLVER_ADMIN;

    /// @notice The Ethereum .hex registry this contract writes.
    IPermissionedRegistry public immutable REGISTRY;

    /// @notice The nonce of the last message applied for each name, by label id.
    mapping(uint256 labelId => uint64 nonce) public lastNonce;

    /// @notice The Ethereum entry for `label` now matches PulseChain.
    event Mirrored(string label, address indexed owner, uint64 expiry, uint64 indexed nonce);
    /// @notice A message older than the last one applied for `label` was ignored.
    event MirrorStale(string label, uint64 indexed nonce, uint64 lastNonce);
    /// @notice The registry refused the new entry (for example, the owner address cannot hold the
    ///         token on Ethereum), so `label` has no Ethereum entry for now.
    event MirrorFailed(string label, address indexed owner, uint64 indexed nonce, bytes reason);

    /// @param amb The bridge's message contract on Ethereum.
    /// @param pulseChainId The chain id of PulseChain (369).
    /// @param linker Who may set the PulseChain `HexMirrorSync`, once.
    /// @param registry The Ethereum .hex registry.
    constructor(IAMB amb, uint256 pulseChainId, address linker, IPermissionedRegistry registry)
        BridgeLink(amb, pulseChainId, linker)
    {
        if (address(registry) == address(0)) revert ZeroAddress();
        REGISTRY = registry;
    }

    /// @inheritdoc IHexMirrorReceiver
    function mirror(string calldata label, address owner, uint64 expiry, uint64 nonce) external onlyPeerMessage {
        uint256 labelId = LibLabel.id(label);
        uint64 last = lastNonce[labelId];
        if (nonce <= last) {
            emit MirrorStale(label, nonce, last);
            return;
        }
        lastNonce[labelId] = nonce;

        bool live = owner != address(0) && expiry > block.timestamp;
        IPermissionedRegistry.State memory state = REGISTRY.getState(labelId);
        // The same owner, no earlier expiry: extend the copy, keeping any settings its owner made on
        // Ethereum. That includes a copy that has lapsed here, as when its owner renews during the
        // grace period (this contract's root ROLE_RENEW lets it revive the entry).
        if (live && state.latestOwner == owner && expiry >= state.expiry) {
            if (expiry > state.expiry) REGISTRY.renew(labelId, expiry);
            emit Mirrored(label, owner, expiry, nonce);
            return;
        }
        if (state.status != IPermissionedRegistry.Status.AVAILABLE) REGISTRY.unregister(labelId);
        if (!live) {
            emit Mirrored(label, address(0), expiry, nonce);
            return;
        }
        try REGISTRY.register(label, owner, IRegistry(address(0)), address(0), OWNER_ROLES, expiry) {
            emit Mirrored(label, owner, expiry, nonce);
        } catch (bytes memory reason) {
            emit MirrorFailed(label, owner, nonce, reason);
        }
    }
}

lib/contracts-v2/contracts/lib/openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[ERC].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the value of tokens of token type `id` owned by `account`.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the zero address.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}

lib/contracts-v2/contracts/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

lib/contracts-v2/contracts/src/access-control/interfaces/IEnhancedAccessControl.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/// @notice Interface for Enhanced Access Control system that allows for:
/// * Resource-based roles
/// * Obtaining assignee count for each role in each resource
/// * Root resource override
/// * Up to 32 roles and 32 corresponding admin roles
/// * Up to 15 assignees per role
///
/// @dev Interface selector: `0x8f452d62`
interface IEnhancedAccessControl {
    ////////////////////////////////////////////////////////////////////////
    // Events
    ////////////////////////////////////////////////////////////////////////

    /// @notice Emitted when roles are changed.
    /// @param resource The resource that the roles were changed within.
    /// @param account The account that the roles were changed for.
    /// @param oldRoleBitmap The old roles for the account.
    /// @param newRoleBitmap The new roles for the account.
    event EACRolesChanged(
        uint256 indexed resource,
        address indexed account,
        uint256 oldRoleBitmap,
        uint256 newRoleBitmap
    );

    ////////////////////////////////////////////////////////////////////////
    // Errors
    ////////////////////////////////////////////////////////////////////////

    /// @dev Error selector: `0x4b27a133`
    error EACUnauthorizedAccountRoles(uint256 resource, uint256 roleBitmap, address account);

    /// @dev Error selector: `0xd1a3b355`
    error EACCannotGrantRoles(uint256 resource, uint256 roleBitmap, address account);

    /// @dev Error selector: `0xa604e318`
    error EACCannotRevokeRoles(uint256 resource, uint256 roleBitmap, address account);

    /// @dev Error selector: `0xc2842458`
    error EACRootResourceNotAllowed();

    /// @dev Error selector: `0xf9165348`
    error EACMaxAssignees(uint256 resource, uint256 role);

    /// @dev Error selector: `0x1f80c19b`
    error EACMinAssignees(uint256 resource, uint256 role);

    /// @dev Error selector: `0x2a7b2d20`
    error EACInvalidRoleBitmap(uint256 roleBitmap);

    /// @dev Error selector: `0xec3fc592`
    error EACInvalidAccount();

    ////////////////////////////////////////////////////////////////////////
    // Functions
    ////////////////////////////////////////////////////////////////////////

    /// @notice Grants all roles in the given role bitmap to `account`.
    /// @param resource The resource to grant roles within.
    /// @param roleBitmap The roles bitmap to grant.
    /// @param account The account to grant roles to.
    /// @return `true` if the roles were granted, `false` otherwise.
    function grantRoles(uint256 resource, uint256 roleBitmap, address account)
        external
        returns (bool);

    /// @notice Grants all roles in the given role bitmap to `account` in the ROOT_RESOURCE.
    /// @param roleBitmap The roles bitmap to grant.
    /// @param account The account to grant roles to.
    /// @return `true` if the roles were granted, `false` otherwise.
    function grantRootRoles(uint256 roleBitmap, address account) external returns (bool);

    /// @notice Revokes all roles in the given role bitmap from `account`.
    /// @param resource The resource to revoke roles within.
    /// @param roleBitmap The roles bitmap to revoke.
    /// @param account The account to revoke roles from.
    /// @return `true` if the roles were revoked, `false` otherwise.
    function revokeRoles(uint256 resource, uint256 roleBitmap, address account)
        external
        returns (bool);

    /// @notice Revokes all roles in the given role bitmap from `account` in the ROOT_RESOURCE.
    /// @param roleBitmap The roles bitmap to revoke.
    /// @param account The account to revoke roles from.
    /// @return `true` if the roles were revoked, `false` otherwise.
    function revokeRootRoles(uint256 roleBitmap, address account) external returns (bool);

    /// @notice Returns the `ROOT_RESOURCE` constant.
    function ROOT_RESOURCE() external view returns (uint256);

    /// @notice Returns the roles bitmap for an account in a resource.
    /// @param resource The resource to get the roles for.
    /// @param account The account to get the roles for.
    /// @return The roles bitmap for the account in the resource.
    function roles(uint256 resource, address account) external view returns (uint256);

    /// @notice Returns the role count bitmap for a resource.
    /// @param resource The resource to get the role count for.
    /// @return count The role count bitmap for the resource.
    function roleCount(uint256 resource) external view returns (uint256);

    /// @notice Checks if the given account has been granted all the given roles in the `ROOT_RESOURCE`.
    /// @param roleBitmap The roles bitmap to check.
    /// @param account The account to check.
    /// @return `true` if `account` has been granted all the given roles in the `ROOT_RESOURCE`, `false` otherwise.
    function hasRootRoles(uint256 roleBitmap, address account) external view returns (bool);

    /// @notice Checks if the given account has been granted all the given roles in the given resource or the `ROOT_RESOURCE`.
    /// @param resource The resource to check.
    /// @param roleBitmap The roles bitmap to check.
    /// @param account The account to check.
    /// @return `true` if `account` has been granted all the given roles in the given resource or the `ROOT_RESOURCE`, `false` otherwise.
    function hasRoles(uint256 resource, uint256 roleBitmap, address account)
        external
        view
        returns (bool);

    /// @notice Checks if any of the roles in the given role bitmap has assignees.
    /// @param resource The resource to check.
    /// @param roleBitmap The roles bitmap to check.
    /// @return `true` if any of the roles in the given role bitmap has assignees, `false` otherwise.
    function hasAssignees(uint256 resource, uint256 roleBitmap) external view returns (bool);

    /// @notice Returns the number of assignees for the roles in the given role bitmap.
    /// @param resource The resource to check.
    /// @param roleBitmap The roles bitmap to check.
    /// @return counts The number of assignees for each of the roles in the given role bitmap, expressed as a packed array of 4-bit ints.
    /// @return mask The mask for the given role bitmap.
    function getAssigneeCount(uint256 resource, uint256 roleBitmap)
        external
        view
        returns (uint256 counts, uint256 mask);
}

lib/contracts-v2/contracts/src/erc1155/interfaces/IERC1155Singleton.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

/// @notice Extends IERC1155 with an `ownerOf` function that returns the single owner of a token ID
///         (analogous to ERC721's `ownerOf`).
/// @dev Interface selector: `0x6352211e`
interface IERC1155Singleton is IERC1155 {
    /// @notice Returns the owner of a token.
    /// @param id The token ID.
    /// @return owner The owner of the token.
    function ownerOf(uint256 id) external view returns (address owner);
}

lib/contracts-v2/contracts/src/registry/interfaces/IOwnedRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IRegistry} from "./IRegistry.sol";

/// @notice A registry with owners.
/// @dev Interface selector: `0x63560a8e`
interface IOwnedRegistry is IRegistry {
    /// @notice Fetches the label owner.
    /// @param label The label to query.
    /// @return The owner of the label.
    function findOwner(string calldata label) external view returns (address);
}

lib/contracts-v2/contracts/src/registry/interfaces/IPermissionedRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IEnhancedAccessControl} from "../../access-control/interfaces/IEnhancedAccessControl.sol";
import {IContractNamer} from "../../reverse-registrar/interfaces/IContractNamer.sol";

import {IStandardRegistry} from "./IStandardRegistry.sol";

/// @dev Interface selector: `0x6be50c69`
interface IPermissionedRegistry is IStandardRegistry, IEnhancedAccessControl, IContractNamer {
    ////////////////////////////////////////////////////////////////////////
    // Types
    ////////////////////////////////////////////////////////////////////////

    /// @notice The registration status of a label.
    enum Status {
        AVAILABLE,
        RESERVED,
        REGISTERED
    }

    /// @notice The registration state of a label.
    struct State {
        Status status; // getStatus()
        uint64 expiry; // getExpiry()
        address latestOwner; // latestOwnerOf()
        uint256 tokenId; // getTokenId()
        uint256 resource; // getResource()
    }

    ////////////////////////////////////////////////////////////////////////
    // Events
    ////////////////////////////////////////////////////////////////////////

    /// @notice Associate a token with an EAC resource.
    /// @param tokenId The token ID.
    /// @param resource The EAC resource.
    event TokenResource(uint256 indexed tokenId, uint256 indexed resource);

    ////////////////////////////////////////////////////////////////////////
    // Errors
    ////////////////////////////////////////////////////////////////////////

    /// @notice Label cannot be reserved again.
    /// @dev Error selector: `0xf60759e0`
    error LabelAlreadyReserved(string label);

    ////////////////////////////////////////////////////////////////////////
    // Functions
    ////////////////////////////////////////////////////////////////////////

    /// @notice Get the latest owner of a token.
    ///         If the token was burned, returns null.
    /// @param tokenId The token ID to query.
    /// @return owner The latest owner address.
    function latestOwnerOf(uint256 tokenId) external view returns (address owner);

    /// @notice Get the state of a label.
    /// @param anyId The labelhash, token ID, or resource.
    /// @return state The state of the label.
    function getState(uint256 anyId) external view returns (State memory state);

    /// @notice Get `Status` from `anyId`.
    /// @param anyId The labelhash, token ID, or resource.
    /// @return status The status of the label.
    function getStatus(uint256 anyId) external view returns (Status status);

    /// @notice Get `resource` from `anyId`.
    /// @param anyId The labelhash, token ID, or resource.
    /// @return resource The resource.
    function getResource(uint256 anyId) external view returns (uint256 resource);

    /// @notice Get `tokenId` from `anyId`.
    /// @param anyId The labelhash, token ID, or resource.
    /// @return tokenId The token ID.
    function getTokenId(uint256 anyId) external view returns (uint256 tokenId);

    /// @notice Get token owner from `anyId`.
    /// @param anyId The labelhash, token ID, or resource.
    /// @return owner The token owner.
    function getOwner(uint256 anyId) external view returns (address owner);
}

lib/contracts-v2/contracts/src/registry/interfaces/IRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IRegistryEvents} from "./IRegistryEvents.sol";

/// @dev Interface selector: `0x51f67f40`
interface IRegistry is IRegistryEvents {
    /// @notice Fetches the registry for a label.
    /// @param label The label to resolve.
    /// @return The address of the registry for this label, or `address(0)` if none exists.
    function getSubregistry(string calldata label) external view returns (IRegistry);

    /// @notice Fetches the resolver responsible for the specified label.
    /// @param label The label to fetch a resolver for.
    /// @return resolver The address of a resolver responsible for this label, or `address(0)` if none exists.
    function getResolver(string calldata label) external view returns (address);

    /// @notice Get canonical "location" of this registry.
    /// @return parent The canonical parent of this registry.
    /// @return label The canonical subdomain of this registry.
    function getParent() external view returns (IRegistry parent, string memory label);
}

lib/contracts-v2/contracts/src/registry/interfaces/IRegistryEvents.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IRegistry} from "./IRegistry.sol";

/// @notice Events interface for the registry, following ENSIP16.
interface IRegistryEvents {
    /// @notice A registry was created/initialized.
    event RegistryCreated();

    /// @notice A label was registered.
    /// @param tokenId The token ID registered.
    /// @param labelHash The label hash registered.
    /// @param label The label registered.
    /// @param owner The owner of the label.
    /// @param expiry The expiry of the label.
    /// @param sender The sender of the call to register.
    event LabelRegistered(
        uint256 indexed tokenId,
        bytes32 indexed labelHash,
        string label,
        address owner,
        uint64 expiry,
        address indexed sender
    );

    /// @notice A label was reserved.
    /// @param tokenId The token ID reserved.
    /// @param labelHash The label hash reserved.
    /// @param label The label reserved.
    /// @param expiry The expiry of the label.
    /// @param sender The sender of the call to reserve.
    event LabelReserved(
        uint256 indexed tokenId,
        bytes32 indexed labelHash,
        string label,
        uint64 expiry,
        address indexed sender
    );

    /// @notice A label was unregistered.
    /// @param tokenId The token ID unregistered.
    /// @param sender The sender of the call to unregister.
    event LabelUnregistered(uint256 indexed tokenId, address indexed sender);

    /// @notice Expiry of label was changed.
    /// @param tokenId The token ID of the label.
    /// @param newExpiry The new expiry of the label.
    /// @param sender The sender of the call to update the expiry.
    event ExpiryUpdated(uint256 indexed tokenId, uint64 indexed newExpiry, address indexed sender);

    /// @notice Subregistry of label was changed.
    /// @param tokenId The token ID of the label.
    /// @param subregistry The new subregistry.
    /// @param sender The sender of the call to update the subregistry.
    event SubregistryUpdated(
        uint256 indexed tokenId,
        IRegistry indexed subregistry,
        address indexed sender
    );

    /// @notice Resolver of label was changed.
    /// @param tokenId The token ID of the label.
    /// @param resolver The new resolver.
    /// @param sender The sender of the call to update the resolver.
    event ResolverUpdated(
        uint256 indexed tokenId,
        address indexed resolver,
        address indexed sender
    );

    /// @notice URI was changed.
    /// @param uri The new URI.
    /// @param renderer The new render address.
    /// @param sender The sender of the call to update the URI.
    event URIUpdated(string uri, address renderer, address indexed sender);

    /// @notice Token was regenerated with a new token ID.
    ///         This occurs when roles are granted or revoked to maintain ERC1155 compliance.
    /// @param oldTokenId The old token ID.
    /// @param newTokenId The new token ID.
    event TokenRegenerated(uint256 indexed oldTokenId, uint256 indexed newTokenId);

    /// @notice Parent was changed.
    /// @param parent The new parent.
    /// @param label The new label.
    /// @param sender The sender of the call to update the parent.
    event ParentUpdated(IRegistry indexed parent, string label, address indexed sender);
}

lib/contracts-v2/contracts/src/registry/interfaces/IStandardRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IRegistry} from "./IRegistry.sol";
import {ITemporalRegistry} from "./ITemporalRegistry.sol";
import {ITokenizedRegistry} from "./ITokenizedRegistry.sol";

/// @title IStandardRegistry
/// @notice A tokenized registry with registrations that expire.
/// @dev Interface selector: `0xb844ab6c`
interface IStandardRegistry is ITemporalRegistry, ITokenizedRegistry {
    ////////////////////////////////////////////////////////////////////////
    // Errors
    ////////////////////////////////////////////////////////////////////////

    /// @notice Label is already registered.
    /// @dev Error selector: `0xdef545a4`
    error LabelAlreadyRegistered(string label);

    /// @notice Label is expired/unregistered.
    /// @dev Error selector: `0xc44e2374`
    error LabelExpired(uint256 tokenId);

    /// @notice Label expiry cannot be reduced.
    /// @dev Error selector: `0x68c1425a`
    error CannotReduceExpiry(uint64 oldExpiry, uint64 newExpiry);

    /// @notice Label expiry cannot be before now.
    /// @dev Error selector: `0xf1d446c3`
    error CannotSetPastExpiry(uint64 expiry);

    /// @notice Transfer is not allowed due to missing transfer admin role.
    /// @dev Error selector: `0xe58f6d5a`
    error TransferDisallowed(uint256 tokenId, address from);

    ////////////////////////////////////////////////////////////////////////
    // Functions
    ////////////////////////////////////////////////////////////////////////

    /// @notice Registers a new label.
    /// @param label The label to register.
    /// @param owner The address of the owner of the label.
    /// @param registry The registry to set as the label.
    /// @param resolver The resolver to set for the label.
    /// @param roleBitmap The role bitmap to set for the label.
    /// @param expiry The expiry of the label, in seconds.
    /// @return tokenId The token ID.
    function register(
        string calldata label,
        address owner,
        IRegistry registry,
        address resolver,
        uint256 roleBitmap,
        uint64 expiry
    )
        external
        returns (uint256 tokenId);

    /// @notice Renew a label.
    /// @param anyId The labelhash, token ID, or resource.
    /// @param newExpiry The new expiry, in seconds.
    function renew(uint256 anyId, uint64 newExpiry) external;

    /// @notice Delete a label.
    /// @param anyId The labelhash, token ID, or resource.
    function unregister(uint256 anyId) external;

    /// @notice Change registry of label.
    /// @param anyId The labelhash, token ID, or resource.
    /// @param registry The new registry.
    function setSubregistry(uint256 anyId, IRegistry registry) external;

    /// @notice Change resolver of label.
    /// @param anyId The labelhash, token ID, or resource.
    /// @param resolver The new resolver.
    function setResolver(uint256 anyId, address resolver) external;

    /// @notice Change canonical "location".
    /// @dev Should emit `ParentUpdated`.
    /// @param parent The canonical parent of this registry.
    /// @param label The canonical subdomain of this registry.
    function setParent(IRegistry parent, string calldata label) external;

    /// @notice Get expiry of label.
    /// @param anyId The labelhash, token ID, or resource.
    /// @return expiry The expiry of the label, in seconds.
    function getExpiry(uint256 anyId) external view returns (uint64 expiry);
}

lib/contracts-v2/contracts/src/registry/interfaces/ITemporalRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IRegistry} from "./IRegistry.sol";

/// @notice A registry with expirations.
/// @dev Interface selector: `0x6f537c72`
interface ITemporalRegistry is IRegistry {
    /// @notice Fetches the label expiry.
    /// @param label The label to query.
    /// @return The expiry of the label.
    function findExpiry(string calldata label) external view returns (uint64);
}

lib/contracts-v2/contracts/src/registry/interfaces/ITokenizedRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

import {IERC1155Singleton} from "../../erc1155/interfaces/IERC1155Singleton.sol";

import {IOwnedRegistry} from "./IOwnedRegistry.sol";

/// @notice A tokenized registry.
/// @dev Interface selector: `0x91b3c037`
interface ITokenizedRegistry is IOwnedRegistry, IERC1155Singleton {
    /// @notice Fetches the token ID for a label.
    /// @param label The label to query.
    /// @return The token ID of the label.
    function findTokenId(string calldata label) external view returns (uint256);
}

lib/contracts-v2/contracts/src/registry/libraries/RegistryRolesLib.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

/// @dev Defines the registry-specific roles used by `PermissionedRegistry` within the
///      `EnhancedAccessControl` nybble-packed bitmap system. Each role occupies one nybble (4 bits)
///      at a specific index, with its admin counterpart shifted 128 bits higher.
library RegistryRolesLib {
    /// @dev Nybble 0: authorizes registering and reserving new names. Root only.
    uint256 internal constant ROLE_REGISTRAR = 1 << 0;
    /// @dev Nybble 32: authorizes setting `ROLE_REGISTRAR`.
    uint256 internal constant ROLE_REGISTRAR_ADMIN = ROLE_REGISTRAR << 128;

    /// @dev Nybble 1: authorizes registering a reserved name (promoting it from RESERVED to REGISTERED). Root-only.
    uint256 internal constant ROLE_REGISTER_RESERVED = 1 << 4;
    /// @dev Nybble 33: authorizes setting `ROLE_REGISTER_RESERVED`.
    uint256 internal constant ROLE_REGISTER_RESERVED_ADMIN = ROLE_REGISTER_RESERVED << 128;

    /// @dev Nybble 2: authorizes setting the parent registry. Root-only.
    uint256 internal constant ROLE_SET_PARENT = 1 << 8;
    /// @dev Nybble 34: authorizes setting `ROLE_SET_PARENT`.
    uint256 internal constant ROLE_SET_PARENT_ADMIN = ROLE_SET_PARENT << 128;

    /// @dev Nybble 3: authorizes unregistering names. Root or token.
    uint256 internal constant ROLE_UNREGISTER = 1 << 12;
    /// @dev Nybble 35: authorizes setting `ROLE_UNREGISTER`.
    uint256 internal constant ROLE_UNREGISTER_ADMIN = ROLE_UNREGISTER << 128;

    /// @dev Nybble 4: authorizes extending name expiry. Root or token.
    uint256 internal constant ROLE_RENEW = 1 << 16;
    /// @dev Nybble 36: authorizes setting `ROLE_RENEW`.
    uint256 internal constant ROLE_RENEW_ADMIN = ROLE_RENEW << 128;

    /// @dev Nybble 5: authorizes changing a name's child registry. Root or token.
    uint256 internal constant ROLE_SET_SUBREGISTRY = 1 << 20;
    /// @dev Nybble 37: authorizes setting `ROLE_SET_SUBREGISTRY`.
    uint256 internal constant ROLE_SET_SUBREGISTRY_ADMIN = ROLE_SET_SUBREGISTRY << 128;

    /// @dev Nybble 6: authorizes changing a name's resolver. Root or token.
    uint256 internal constant ROLE_SET_RESOLVER = 1 << 24;
    /// @dev Nybble 38: authorizes setting `ROLE_SET_RESOLVER`.
    uint256 internal constant ROLE_SET_RESOLVER_ADMIN = ROLE_SET_RESOLVER << 128;

    /// @dev Nybble 39: authorizes ERC1155 token transfers. Root or token.
    ///      This role is only checked on the token owner, not the operator.
    uint256 internal constant ROLE_CAN_TRANSFER_ADMIN = (1 << 28) << 128;

    /// @dev Nybble 8: tags a name that was registered via `ROLE_REGISTER_RESERVED`. Token only. Not revokable.
    uint256 internal constant ROLE_WAS_RESERVED = (1 << 32);

    /// @dev Nybble 9: authorizes setting the URI. Root-only.
    uint256 internal constant ROLE_SET_URI = 1 << 36;
    /// @dev Nybble 41: authorizes setting `ROLE_SET_URI`.
    uint256 internal constant ROLE_SET_URI_ADMIN = ROLE_SET_URI << 128;

    /// @dev Nybble 30: authorizes contract naming. Root-only.
    uint256 internal constant ROLE_CAN_NAME = 1 << 120;
    /// @dev Nybble 62: authorizes setting ROLE_CAN_NAME.
    uint256 internal constant ROLE_CAN_NAME_ADMIN = ROLE_CAN_NAME << 128;

    /// @dev Nybble 31: authorizes UUPS proxy upgrades. Root-only.
    uint256 internal constant ROLE_UPGRADE = 1 << 124;
    /// @dev Nybble 63: authorizes setting `ROLE_UPGRADE`.
    uint256 internal constant ROLE_UPGRADE_ADMIN = ROLE_UPGRADE << 128;
}

lib/contracts-v2/contracts/src/reverse-registrar/interfaces/IContractNamer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

/// @dev Interface selector: `0x6f3ff726`
interface IContractNamer {
    /// @notice Determine if an account is authorized to name this contract.
    ///         Called by reverse registrars.
    /// @param namer The address to check.
    /// @return `true` if authorized.
    function isContractNamer(address namer) external view returns (bool);
}

lib/contracts-v2/contracts/src/utils/LibLabel.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.13;

/// @dev Utilities for computing labelhash-based token IDs and applying version suffixes.
library LibLabel {
    /// @dev Compute `labelhash(label)`.
    function id(string memory label) internal pure returns (uint256) {
        return uint256(keccak256(bytes(label)));
    }

    /// @dev Replace the lower 32-bits of `anyId` with `versionId`.
    /// @param anyId The labelhash, token ID, or resource.
    /// @param versionId The version ID.
    /// @return The versioned ID.
    function withVersion(uint256 anyId, uint32 versionId) internal pure returns (uint256) {
        return anyId ^ uint32(anyId) ^ versionId;
    }
}

src/common/BridgeLink.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {IAMB} from "../interfaces/IAMB.sol";
import {ZeroAddress} from "./Errors.sol";

/// @title BridgeLink
/// @notice Pairs a contract with one contract on the other chain, over the official PulseChain bridge.
/// @dev Each side needs the other's address, so neither can take it as a constructor argument.
///      `LINKER` sets it once with `link`, and after that nothing can change it.
abstract contract BridgeLink {
    /// @notice The bridge's message contract on this chain.
    IAMB public immutable AMB;

    /// @notice The chain the paired contract is on.
    uint256 public immutable PEER_CHAIN_ID;

    /// @notice The only account that may call `link`, once.
    address public immutable LINKER;

    /// @notice The paired contract on the other chain, or zero until linked.
    address public peer;

    /// @notice The paired contract was set.
    event Linked(address indexed peer);

    /// @notice `link` was called by someone other than `LINKER`.
    error NotLinker();
    /// @notice `link` was already called.
    error AlreadyLinked();
    /// @notice A message needed the paired contract before it was set.
    error NotLinked();
    /// @notice The call did not come from the paired contract through the bridge.
    error NotFromPeer();

    constructor(IAMB amb, uint256 peerChainId, address linker) {
        if (address(amb) == address(0) || linker == address(0)) revert ZeroAddress();
        AMB = amb;
        PEER_CHAIN_ID = peerChainId;
        LINKER = linker;
    }

    /// @notice Sets the paired contract on the other chain. Can only be done once, by `LINKER`.
    function link(address peer_) external {
        if (msg.sender != LINKER) revert NotLinker();
        if (peer != address(0)) revert AlreadyLinked();
        if (peer_ == address(0)) revert ZeroAddress();
        peer = peer_;
        emit Linked(peer_);
    }

    /// @dev Lets a call through only if the bridge is delivering a message the paired contract
    ///      sent from the paired chain.
    modifier onlyPeerMessage() {
        address p = peer;
        if (
            msg.sender != address(AMB) || p == address(0) || AMB.messageSender() != p
                || AMB.messageSourceChainId() != PEER_CHAIN_ID
        ) {
            revert NotFromPeer();
        }
        _;
    }

    /// @dev Sends `data` to the paired contract, to be run with `gas` gas.
    function _sendToPeer(bytes memory data, uint256 gas) internal returns (bytes32 messageId) {
        address p = peer;
        if (p == address(0)) revert NotLinked();
        return AMB.requireToPassMessage(p, data, gas);
    }
}

src/common/Errors.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

/// @notice An address argument was zero.
error ZeroAddress();

src/interfaces/IAMB.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

/// @notice The parts of the official PulseChain bridge's Arbitrary Message Bridge (AMB) used here.
/// @dev TokenBridge AMB, interfaces version 6.2.0, the same contract family as Gnosis Chain's bridge.
///      Home side on PulseChain: 0x6ef79FD6f9f840264332884240539Ed7A2dA8b2b.
///      Foreign side on Ethereum: 0xd0764FAe29E0a6a96fF685f71CfC685456D5636c.
///      Both are signed for by the same 8 validators, 5 of whom must sign each message
///      (checked on-chain on 2026-11-05). Any contract may send a message.
interface IAMB {
    /// @notice Queues a call to `target` on the other chain, run with `gas` gas once validators sign.
    /// @return messageId The bridge's id for the message.
    function requireToPassMessage(address target, bytes calldata data, uint256 gas) external returns (bytes32 messageId);

    /// @notice While a message from the other chain is running: the contract that sent it.
    function messageSender() external view returns (address);

    /// @notice While a message from the other chain is running: the chain it was sent from.
    function messageSourceChainId() external view returns (uint256);

    /// @notice The most gas a message may ask for.
    function maxGasPerTx() external view returns (uint256);
}

src/interfaces/IHexBridge.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

/// @notice The two messages PulseChain sends to Ethereum over the bridge.

/// @notice Received by `HexOrderBook` on Ethereum, sent by `HexOrderFiller` on PulseChain.
interface IHexOrderSettlement {
    /// @notice Closes an Ethereum order. `filled` true pays `payee`, false refunds the buyer.
    /// @param orderId The order's id in `HexOrderBook`.
    /// @param commitment The registrar commitment the order was placed with.
    /// @param deadline The order's fill deadline.
    function settle(uint256 orderId, bytes32 commitment, uint64 deadline, address payee, bool filled) external;
}

/// @notice Received by `HexMirrorRegistrar` on Ethereum, sent by `HexMirrorSync` on PulseChain.
interface IHexMirrorReceiver {
    /// @notice Copies the PulseChain state of `label`.hex: its owner (zero if not registered) and
    ///         expiry. `nonce` increases with every message, so stale ones can be ignored.
    function mirror(string calldata label, address owner, uint64 expiry, uint64 nonce) external;
}

/// @notice `HexMirrorSync` on PulseChain.
interface IHexMirrorSync {
    /// @notice Sends the current PulseChain state of `label`.hex to Ethereum.
    function sync(string calldata label) external returns (bytes32 messageId);
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 1000,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": [
    "@ens/contracts/=lib/contracts-v2/contracts/lib/ens-contracts/contracts/",
    "@ensdomains/buffer/=lib/contracts-v2/contracts/lib/buffer/",
    "@ensdomains/verifiable-factory/=lib/contracts-v2/contracts/lib/verifiable-factory/src/",
    "@ensv2/=lib/contracts-v2/contracts/src/",
    "@openzeppelin/contracts-upgradeable/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts-v5/=lib/contracts-v2/contracts/lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts/=lib/contracts-v2/contracts/lib/openzeppelin-contracts/contracts/",
    "@unruggable/gateways/=lib/contracts-v2/contracts/lib/unruggable-gateways/",
    "buffer/=lib/contracts-v2/contracts/lib/buffer/contracts/",
    "contracts-v2/=lib/contracts-v2/",
    "ens-contracts/=lib/contracts-v2/contracts/lib/ens-contracts/contracts/",
    "forge-std/=lib/contracts-v2/contracts/lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts-v4/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-v4/",
    "openzeppelin-contracts/=lib/contracts-v2/contracts/lib/openzeppelin-contracts/",
    "optimism/=lib/contracts-v2/contracts/lib/unruggable-gateways/lib/optimism/packages/contracts-bedrock/src/",
    "solady/=lib/contracts-v2/contracts/lib/solady/src/",
    "solsha1/=lib/contracts-v2/contracts/lib/solsha1/contracts/",
    "unruggable-gateways/=lib/contracts-v2/contracts/lib/unruggable-gateways/contracts/",
    "verifiable-factory/=lib/contracts-v2/contracts/lib/verifiable-factory/src/",
    "lib/contracts-v2/contracts/lib/ens-contracts/:@ensdomains/solsha1/contracts/=lib/contracts-v2/contracts/lib/solsha1/contracts/",
    "lib/contracts-v2/contracts/lib/ens-contracts/:@openzeppelin/contracts-v5/=lib/contracts-v2/contracts/lib/openzeppelin-contracts/contracts/",
    "lib/contracts-v2/contracts/lib/ens-contracts/:@openzeppelin/contracts/=lib/contracts-v2/contracts/lib/openzeppelin-contracts-v4/contracts/",
    "lib/contracts-v2/contracts/lib/ens-contracts/:@unruggable/gateways/=lib/contracts-v2/contracts/lib/unruggable-gateways/contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.