INodeRegistry

Git Source

Inherits: IERC721, IERC721Metadata, IERC721Errors, IMigratable, IRegistryParametersErrors

This interface defines the ERC721-based registry for “nodes” in the system. Each node is minted as an NFT with a unique ID (starting at 100 and increasing by 100 with each new node). In addition to the standard ERC721 functionality, the contract supports node-specific features, including node property updates.

Functions

initialize

Initializes the contract.

function initialize() external;

addNode

Adds a new node to the registry and mints its corresponding ERC721 token.

Node IDs start at 100 and increase by 100 for each new node.

function addNode(address owner_, bytes calldata signingPublicKey_, string calldata httpAddress_)
    external
    returns (uint32 nodeId_, address signer_);

Parameters

NameTypeDescription
owner_addressThe address that will own the new node node/NFT.
signingPublicKey_bytesThe public key used for node signing/verification.
httpAddress_stringThe node’s HTTP address.

Returns

NameTypeDescription
nodeId_uint32The unique identifier of the newly added node.
signer_addressThe address derived by the signing public key, for convenience.

addToNetwork

Adds a node to the canonical network.

function addToNetwork(uint32 nodeId_) external;

Parameters

NameTypeDescription
nodeId_uint32The unique identifier of the node.

removeFromNetwork

Removes a node from the canonical network.

function removeFromNetwork(uint32 nodeId_) external;

Parameters

NameTypeDescription
nodeId_uint32The unique identifier of the node.

setBaseURI

Set the base URI for the node NFTs.

function setBaseURI(string calldata baseURI_) external;

Parameters

NameTypeDescription
baseURI_stringThe new base URI. Has to end with a trailing slash.

setHttpAddress

Set the HTTP address of an existing node.

function setHttpAddress(uint32 nodeId_, string calldata httpAddress_) external;

Parameters

NameTypeDescription
nodeId_uint32The unique identifier of the node.
httpAddress_stringThe new HTTP address.

updateAdmin

Updates the admin by referring to the admin parameter from the parameter registry.

function updateAdmin() external;

updateMaxCanonicalNodes

Updates the max canonical nodes by referring to the max canonical nodes parameter from the parameter registry.

function updateMaxCanonicalNodes() external;

NODE_INCREMENT

The increment for node IDs, which allows for 100 shard node IDs per node in the future (modulus 100).

function NODE_INCREMENT() external pure returns (uint32 nodeIncrement_);

admin

The address of the admin.

function admin() external view returns (address admin_);

adminParameterKey

The parameter registry key used to fetch the admin.

function adminParameterKey() external pure returns (string memory key_);

maxCanonicalNodesParameterKey

The parameter registry key used to fetch the max canonical nodes.

function maxCanonicalNodesParameterKey() external pure returns (string memory key_);

migratorParameterKey

The parameter registry key used to fetch the migrator.

function migratorParameterKey() external pure returns (string memory key_);

parameterRegistry

The address of the parameter registry.

function parameterRegistry() external view returns (address parameterRegistry_);

maxCanonicalNodes

The maximum number of nodes that can be part of the canonical network.

function maxCanonicalNodes() external view returns (uint8 maxCanonicalNodes_);

canonicalNodesCount

The number of nodes that are part of the canonical network.

function canonicalNodesCount() external view returns (uint8 canonicalNodesCount_);

getAllNodes

Gets all nodes regardless of their health status.

function getAllNodes() external view returns (NodeWithId[] memory allNodes_);

Returns

NameTypeDescription
allNodes_NodeWithId[]An array of all nodes in the registry.

getAllNodesCount

Gets the total number of nodes in the registry.

function getAllNodesCount() external view returns (uint32 nodeCount_);

Returns

NameTypeDescription
nodeCount_uint32The total number of nodes.

getNode

Retrieves the details of a given node.

function getNode(uint32 nodeId_) external view returns (Node memory node_);

Parameters

NameTypeDescription
nodeId_uint32The unique identifier of the node.

Returns

NameTypeDescription
node_NodeThe Node struct containing the node's details.

getIsCanonicalNode

Retrieves whether a node is part of the canonical network.

function getIsCanonicalNode(uint32 nodeId_) external view returns (bool isCanonicalNode_);

Parameters

NameTypeDescription
nodeId_uint32The unique identifier of the node.

Returns

NameTypeDescription
isCanonicalNode_boolA boolean indicating whether the node is part of the canonical network.

getSigner

Retrieves the signer of a node.

function getSigner(uint32 nodeId_) external view returns (address signer_);

Parameters

NameTypeDescription
nodeId_uint32The unique identifier of the node.

Returns

NameTypeDescription
signer_addressThe address of the signer.

Events

AdminUpdated

Emitted when the admin is updated.

event AdminUpdated(address indexed admin);

Parameters

NameTypeDescription
adminaddressThe new admin.

BaseURIUpdated

Emitted when the base URI is updated.

event BaseURIUpdated(string baseURI);

Parameters

NameTypeDescription
baseURIstringThe new base URI.

HttpAddressUpdated

Emitted when the HTTP address for a node is updated.

event HttpAddressUpdated(uint32 indexed nodeId, string httpAddress);

Parameters

NameTypeDescription
nodeIduint32The identifier of the node.
httpAddressstringThe new HTTP address.

MaxCanonicalNodesUpdated

Emitted when the maximum number of canonical nodes is updated.

event MaxCanonicalNodesUpdated(uint8 maxCanonicalNodes);

Parameters

NameTypeDescription
maxCanonicalNodesuint8The new maximum number of canonical nodes.

NodeAdded

Emitted when a new node is added and its NFT minted.

event NodeAdded(
    uint32 indexed nodeId, address indexed owner, address indexed signer, bytes signingPublicKey, string httpAddress
);

Parameters

NameTypeDescription
nodeIduint32The unique identifier for the node (starts at 100, increments by 100).
owneraddressThe address that receives the new node NFT.
signeraddressThe address derived by the signing public key, for convenience.
signingPublicKeybytesThe public key used for node signing/verification.
httpAddressstringThe node’s HTTP endpoint.

NodeAddedToCanonicalNetwork

Emitted when a node is added to the canonical network.

event NodeAddedToCanonicalNetwork(uint32 indexed nodeId);

Parameters

NameTypeDescription
nodeIduint32The identifier of the node.

NodeRemovedFromCanonicalNetwork

Emitted when a node is removed from the canonical network.

event NodeRemovedFromCanonicalNetwork(uint32 indexed nodeId);

Parameters

NameTypeDescription
nodeIduint32The identifier of the node.

Errors

ZeroParameterRegistry

Thrown when the parameter registry address is being set to zero (i.e. address(0)).

error ZeroParameterRegistry();

FailedToAddNodeToCanonicalNetwork

Thrown when failing to add a node to the canonical network.

error FailedToAddNodeToCanonicalNetwork();

FailedToRemoveNodeFromCanonicalNetwork

Thrown when failing to remove a node from the canonical network.

error FailedToRemoveNodeFromCanonicalNetwork();

InvalidOwner

Thrown when an invalid owner is provided.

error InvalidOwner();

InvalidHttpAddress

Thrown when an invalid HTTP address is provided.

error InvalidHttpAddress();

InvalidSigningPublicKey

Thrown when an invalid signing public key is provided.

error InvalidSigningPublicKey();

InvalidURI

Thrown when an invalid URI is provided.

error InvalidURI();

MaxCanonicalNodesBelowCurrentCount

Thrown when trying to set max canonical nodes below current canonical count.

error MaxCanonicalNodesBelowCurrentCount();

MaxCanonicalNodesReached

Thrown when the maximum number of canonical nodes is reached.

error MaxCanonicalNodesReached();

NoChange

Thrown when there is no change to an updated parameter.

error NoChange();

NotAdmin

Thrown when the caller is not the admin.

error NotAdmin();

MaxNodesReached

Thrown when the maximum number of nodes is reached.

error MaxNodesReached();

NotNodeOwner

Thrown when the caller is not the node owner.

error NotNodeOwner();

Structs

Node

Struct representing a node in the registry.

struct Node {
    address signer;
    bool isCanonical;
    bytes signingPublicKey;
    string httpAddress;
}

Properties

NameTypeDescription
signeraddressThe address derived by the signing public key, for convenience.
isCanonicalboolA flag indicating whether the node is part of the canonical network.
signingPublicKeybytesThe public key used for node signing/verification.
httpAddressstringThe HTTP endpoint address for the node.

NodeWithId

Struct representing a node with its ID.

struct NodeWithId {
    uint32 nodeId;
    Node node;
}

Properties

NameTypeDescription
nodeIduint32The unique identifier for the node.
nodeNodeThe node struct.