SetBase
Inherits: ISet
State Variables
ID_MAX
uint64 private constant ID_MAX = type(uint64).max - 1;
_objects
mapping(uint64 => ObjectData) private _objects;
Functions
onlyObjectOwner
modifier onlyObjectOwner(uint64 id);
upgrade
Upgrade an object to a new kind or set revision
function upgrade(uint64 id, uint32 kindRev0, uint32 setRev0)
external
override
onlyObjectOwner(id)
returns (Descriptor memory desc);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
kindRev0 | uint32 | New kind revision (0 = no change) |
setRev0 | uint32 | New set revision (0 = no change) |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | od Descriptor after upgrade |
touch
Touch an object to increment revision without content change
function touch(uint64 id) external override onlyObjectOwner(id) returns (Descriptor memory od);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
Returns
Name | Type | Description |
---|---|---|
od | Descriptor | Descriptor after touch |
transfer
Transfer ownership of an object
function transfer(uint64 id, address to) external override onlyObjectOwner(id);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
to | address | Address of the new owner |
uri
Get URI template for metadata
Client should replace {id}
and {rev}
placeholders
function uri() external view override returns (string memory uri_);
Returns
Name | Type | Description |
---|---|---|
uri_ | string | URI template string |
owner
Get current owner of an object
function owner(uint64 id) external view override returns (address owner_);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
Returns
Name | Type | Description |
---|---|---|
owner_ | address | Current owner address |
revision
Resolve and validate a revision number
function revision(uint64 id, uint32 rev0) external view override returns (uint32 rev);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
rev0 | uint32 | Revision to check (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
rev | uint32 | Valid revision (0 if invalid) |
descriptor
Get descriptor at a specific revision
function descriptor(uint64 id, uint32 rev0) external view override returns (Descriptor memory od);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
rev0 | uint32 | Revision number (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
od | Descriptor | Descriptor at that revision |
elements
Get elements at a specific revision
function elements(uint64 id, uint32 rev0) external view override returns (bytes32[] memory elems);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
rev0 | uint32 | Revision number (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
elems | bytes32[] | Elements array at that revision |
sota
Get the latest descriptor and current owner
function sota(uint64 id) external view override returns (Descriptor memory desc, address owner_);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
Returns
Name | Type | Description |
---|---|---|
desc | Descriptor | od Descriptor at the specified revision |
owner_ | address | Current owner (not historical) |
snapshot
Get descriptor and elements at a specific revision
function snapshot(uint64 id, uint32 rev0)
external
view
override
returns (Descriptor memory od, bytes32[] memory elems);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID |
rev0 | uint32 | Revision number to query (0 = latest) |
Returns
Name | Type | Description |
---|---|---|
od | Descriptor | Descriptor at the specified revision |
elems | bytes32[] | Elements at the specified revision |
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 interfaceId) external pure virtual override returns (bool);
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
_create
function _create(uint64 id, Descriptor memory od, bytes32[] memory elems, address owner_)
internal
returns (Descriptor memory);
_upgrade
function _upgrade(uint64 id, uint32 kindRev0, uint32 setRev0) internal returns (Descriptor memory);
_update
function _update(uint64 id, bytes32[] memory elems) internal returns (Descriptor memory);
_touch
function _touch(uint64 id) internal returns (Descriptor memory);
_transfer
function _transfer(uint64 id, address to) internal returns (address from);
_ownerOf
function _ownerOf(uint64 id) internal view returns (address);
_decriptor
function _decriptor(uint64 id, uint32 rev0) internal view returns (Descriptor memory);
_revision
function _revision(uint64 id, uint32 rev0) internal view virtual returns (uint32 rev);
_elements
function _elements(uint64 id, uint32 rev0) internal view returns (bytes32[] memory elems);
_sota
function _sota(uint64 id) internal view returns (Descriptor memory od, address owner_);
_snapshot
function _snapshot(uint64 id, uint32 rev0) internal view returns (Descriptor memory od, bytes32[] memory elems);
_postCreate
function _postCreate(uint64 id, Descriptor memory od, bytes32[] memory elems, address owner_) internal virtual;
_postUpgrade
function _postUpgrade(uint64 id, Descriptor memory od, uint32 kindRev0, uint32 setRev0) internal virtual;
_postUpdate
function _postUpdate(uint64 id, Descriptor memory od, bytes32[] memory elems) internal virtual;
_postTouch
function _postTouch(uint64 id, Descriptor memory od) internal virtual;
_postTransfer
function _postTransfer(uint64 id, address from, address to) internal virtual;
_kindRevision
function _kindRevision(uint64 kindId, uint32 kindRev0) internal view virtual returns (uint32);
_setRevision
function _setRevision(uint64 setId, uint32 setRev0) internal view virtual returns (uint32);
_uri
function _uri() internal view virtual returns (string memory);
Errors
CallerNotObjectOwner
error CallerNotObjectOwner();
InvalidObjectId
error InvalidObjectId();
InvalidKindRevision
error InvalidKindRevision();
InvalidSetRevision
error InvalidSetRevision();
InvalidUpgradeRevision
error InvalidUpgradeRevision();
ObjectAlreadyExists
error ObjectAlreadyExists();
ObjectNotFound
error ObjectNotFound();
RevisionNotStored
error RevisionNotStored();
RevisionNotFound
error RevisionNotFound();
KindRevisionNotFound
error KindRevisionNotFound();
SetRevisionNotFound
error SetRevisionNotFound();
Structs
ObjectData
struct ObjectData {
Descriptor desc;
address owner;
bytes32[] elements;
}