Set Interface
Interface a user-created set must implement.
interface ISet {
// events
event Created(uint64 id, Meta meta, bytes32[] state, address owner);
event Updated(uint64 id, Meta meta, bytes32[] state);
event Upgraded(uint64 id, Meta meta);
event Touched(uint64 id, Meta meta);
event Destroyed(uint64 id, Meta meta);
event Transferred(uint64 id, address from, address to);
// write functions
function update(uint64 id, bytes32[] memory state) external returns (Meta memory);
function upgrade(uint64 id, uint32 kindRev, uint32 setRev) external returns (Meta memory);
function touch(uint64 id) external returns (Meta memory);
function transfer(uint64 id, address to) external;
// view functions
function ownerOf(uint64 id) external view returns (address);
function metaAt(uint64 id, uint32 rev) external view returns (Meta memory);
function stateAt(uint64 id, uint32 rev) external view returns (bytes32[] memory);
function revAt(uint64 id, uint32 rev) external view returns (uint32);
}
Functions
update
Updates the elements of an object.
function update(uint64 id, bytes32[] memory state) external returns (Meta memory);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object to update. |
state | bytes32[] | The new elements of the object. |
Returns
Name | Type | Description |
---|---|---|
<none> | Meta | The updated metadata of the object. |
upgrade
Upgrades the kind and/or set of an object to a newer revision.
function upgrade(uint64 id, uint32 kindRev, uint32 setRev) external returns (Meta memory);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object to upgrade. |
kindRev | uint32 | The new revision of the kind object (0 indicates no upgrade). |
setRev | uint32 | The new revision of the set object (0 indicates no upgrade). |
Returns
Name | Type | Description |
---|---|---|
<none> | Meta | The metadata of the object after the upgrade. |
touch
Touches an object to trigger a revision bump.
function touch(uint64 id) external returns (Meta memory);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object to touch. |
Returns
Name | Type | Description |
---|---|---|
<none> | Meta | The metadata of the object after the touch. |
transfer
Transfers the ownership of an object to a new address.
function transfer(uint64 id, address to) external;
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object to transfer. |
to | address | The address to transfer the ownership to. |
ownerOf
Returns the owner of an object.
function ownerOf(uint64 id) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The address of the object's owner. |
metaAt
Returns the metadata of an object at a particular revision.
function metaAt(uint64 id, uint32 rev) external view returns (Meta memory);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
rev | uint32 | The revision number. A zero value indicates the latest revision. |
Returns
Name | Type | Description |
---|---|---|
<none> | Meta | The metadata of the object. |
stateAt
Returns the elements of an object at a particular revision.
function stateAt(uint64 id, uint32 rev) external view returns (bytes32[] memory);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
rev | uint32 | The revision number. A zero value indicates the latest revision. |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32[] | The elements of the object. |
revAt
Checks if a revision of an object is valid.
function revAt(uint64 id, uint32 rev) external view returns (uint32);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
rev | uint32 | The specific revision. A zero value indicates the latest revision. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint32 | The revision number requested. Zero indicates an invalid revision. |
Events
Created
Emitted when a new object is created within a set.
event Created(uint64 id, Meta meta, bytes32[] state, address owner);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
meta | Meta | The metadata of the object. |
state | bytes32[] | The elements of the object. |
owner | address | The address of the object's owner. |
Updated
Emitted when an object is updated.
event Updated(uint64 id, Meta meta, bytes32[] state);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
meta | Meta | The updated metadata of the object. |
state | bytes32[] | The updated elements of the object. |
Upgraded
Emitted when an object is upgraded.
event Upgraded(uint64 id, Meta meta);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
meta | Meta | The updated metadata of the object after the upgrade. |
Touched
Emitted when an object is touched.
event Touched(uint64 id, Meta meta);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
meta | Meta | The metadata of the object. |
Destroyed
Emitted when an object is destroyed.
event Destroyed(uint64 id, Meta meta);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
meta | Meta | The metadata of the object before destruction. |
Transferred
Emitted when the ownership of an object is transferred.
event Transferred(uint64 id, address from, address to);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | The ID of the object. |
from | address | The address of the current owner. |
to | address | The address of the new owner. |