KindRegistry
Inherits: IKindRegistry, KindRegistryErrors, OwnableUpgradeable, UUPSUpgradeable, Soke
Kind registration and management
State Variables
KINDREGISTRY_STORAGE_LOCATION
Deterministic storage slot per ERC-7201
keccak256(abi.encode(uint256(keccak256("every.storage.KindRegistry")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant KINDREGISTRY_STORAGE_LOCATION =
0xb8c55f98767a73472af02b22c010d8184657966d48d072fe22562cfc13903400;
Functions
_getKindRegistryStorage
function _getKindRegistryStorage() private pure returns (KindRegistryStorage storage $);
_authorizeUpgrade
function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner;
semver
function semver() external pure returns (uint32 version);
initialize
function initialize(address owner, address setr, address omnir, address elemr) public initializer;
kindRegister
Registers a new kind
function kindRegister(bytes32 code, bytes32 data, ElementType[] memory elemSpec, uint64[] memory rels)
external
override
returns (uint64 id, Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
code | bytes32 | Code hash of the kind |
data | bytes32 | Data hash of the kind |
elemSpec | ElementType[] | Element type layout for objects of this kind |
rels | uint64[] | Supported relation IDs |
Returns
Name | Type | Description |
---|---|---|
id | uint64 | New kind ID |
desc | Descriptor | Descriptor after registration |
kindUpdate
Updates code and/or data of an existing kind
function kindUpdate(uint64 id, bytes32 code, bytes32 data) external override returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
code | bytes32 | New code hash (0 = skip) |
data | bytes32 | New data hash (0 = skip) |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Updated descriptor |
kindUpdate
Updates code and/or data of an existing kind
function kindUpdate(uint64 id, uint64[] memory rels) external override returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
rels | uint64[] |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Updated descriptor |
kindUpdate
Updates code and/or data of an existing kind
function kindUpdate(uint64 id, bytes32 code, bytes32 data, uint64[] memory rels)
external
override
returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
code | bytes32 | New code hash (0 = skip) |
data | bytes32 | New data hash (0 = skip) |
rels | uint64[] |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Updated descriptor |
kindUpgrade
Upgrades kind/set revision of an existing kind
function kindUpgrade(uint64 id, uint32 kindRev, uint32 setRev) external override returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
kindRev | uint32 | New kind revision (0 = skip) |
setRev | uint32 | New set revision (0 = skip) |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Descriptor after upgrade |
kindTouch
Touches a kind (bumps revision with no content changes)
function kindTouch(uint64 id) external override returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Descriptor after touch |
kindTransfer
Transfers ownership of a kind
function kindTransfer(uint64 id, address to) external override returns (address from);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
to | address | New owner address |
Returns
Name | Type | Description |
---|---|---|
from | address | Previous owner address |
kindRevision
Resolves and validates a specific revision
function kindRevision(uint64 id, uint32 rev0) external view override returns (uint32 rev);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
rev0 | uint32 | Revision to check (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
rev | uint32 | Valid revision number (0 if not found) |
kindDescriptor
Returns the descriptor at a given revision
function kindDescriptor(uint64 id, uint32 rev0) external view override returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
rev0 | uint32 | Revision to query (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Descriptor at that revision |
kindSnapshot
Returns descriptor and elements at a specific revision
function kindSnapshot(uint64 id, uint32 rev0)
external
view
override
returns (Descriptor memory desc, bytes32[] memory elems);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
rev0 | uint32 | Revision to query (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Descriptor at the revision |
elems | bytes32[] | Element hashes of the kind at the revision |
kindOwner
Returns the current owner of a kind
function kindOwner(uint64 id) external view override returns (address owner);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
Returns
Name | Type | Description |
---|---|---|
owner | address | Owner address |
kindSota
Returns the latest descriptor and current owner of a kind
function kindSota(uint64 id) external view override returns (Descriptor memory desc, address owner);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Kind ID |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | Latest descriptor |
owner | address | Current owner address |
kindStatus
Checks whether all specified kinds are active (rev > 0)
function kindStatus(uint64[] memory ids) external view override returns (bool active);
Parameters
Name | Type | Description |
---|---|---|
ids | uint64[] | List of kind IDs |
Returns
Name | Type | Description |
---|---|---|
active | bool | True if all specified kinds exist and are active |
kindAdmit
Checks whether a kind at a given revision admits a specific relation
function kindAdmit(uint64 id, uint32 rev, uint64 rel) public view override returns (bool admit, uint32 relRev);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | |
rev | uint32 | Kind revision (0 = latest) |
rel | uint64 | Relation ID to check |
Returns
Name | Type | Description |
---|---|---|
admit | bool | Whether the relation is admitted |
relRev | uint32 | Specific relation revision admitted (0 = latest) |
_validateHolder
Reverts if msg.sender is not the current owner of the given kind
function _validateHolder(uint64 id) private view;
_validateRelations
Validates the given relations are active
function _validateRelations(uint64[] memory rels) private view;
_validateElementTypes
function _validateElementTypes(ElementType[] memory elemSpec) private pure;
_kindOfKindRevision
Returns the latest revision of the Kind-of-Kind object
function _kindOfKindRevision() private view returns (uint32);
_setOfKindRevision
Returns the latest revision of the Set-of-Kind object
function _setOfKindRevision() private view returns (uint32);
_registerKind
function _registerKind(
uint64 id,
uint32 kindRev,
uint32 setRev,
bytes32 code,
bytes32 data,
ElementType[] memory elemSpec,
uint64[] memory rels,
address owner
) private returns (Descriptor memory desc);
_unpack
function _unpack(uint64 revid) private pure returns (uint16 rev, uint48 id);
Structs
KindRegistryStorage
Note: storage-location: erc7201:every.storage.KindRegistry
struct KindRegistryStorage {
Counter48.Counter counter;
Snapshots.Storage kinds;
}