NodeRegistryBackfillMigrator

Git Source

One-off migrator that upgrades the NodeRegistry implementation and backfills the canonicalNodes EnumerableSet. It is a copy of GenericEIP1967Migrator with additional functionality.

*This migrator is delegatecalled by the proxy (via the Migratable pattern), so all storage reads and writes operate on the proxy's storage context.

  1. Writes newImpl into the EIP-1967 implementation slot as normally done by a migrator.
  2. Additionally, iterates existing nodes and adds canonical nodes to the canonicalNodes set.*

State Variables

_IMPLEMENTATION_SLOT

bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)

bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

_NODE_INCREMENT

uint32 internal constant _NODE_INCREMENT = 100;

_NODE_REGISTRY_STORAGE_LOCATION

bytes32 internal constant _NODE_REGISTRY_STORAGE_LOCATION =
    0xd48713bc7b5e2644bcb4e26ace7d67dc9027725a9a1ee11596536cc6096a2000;

newImpl

The implementation that the proxy will be upgraded to.

address public immutable newImpl;

Functions

constructor

constructor(address newImpl_);

Parameters

NameTypeDescription
newImpl_addressThe address of the new implementation

fallback

*Runs in the proxy's storage context via delegatecall.

  1. Updates the implementation slot.
  2. Iterates nodes, if canonical and not already in the set, add it.*
fallback() external;

_backfillCanonicalNodes

Reads and writes through the proxy's storage layout via delegatecall. NodeRegistryStorage struct must remain in sync with NodeRegistry.NodeRegistryStorage.

function _backfillCanonicalNodes() internal;

_getNodeRegistryStorage

Returns a storage pointer using the ERC-7201 slot for NodeRegistry. NodeRegistryStorage struct must remain in sync with NodeRegistry.NodeRegistryStorage.

function _getNodeRegistryStorage() internal pure returns (NodeRegistryStorage storage $);

Errors

InvalidImplementation

error InvalidImplementation();

Structs

NodeRegistryStorage

struct NodeRegistryStorage {
    address admin;
    uint8 maxCanonicalNodes;
    uint8 canonicalNodesCount;
    uint32 nodeCount;
    mapping(uint32 tokenId => INodeRegistry.Node node) nodes;
    string baseURI;
    EnumerableSet.UintSet canonicalNodes;
}