SetSolo
Inherits: ISet
Minimal standalone implementation of the ISet interface for managing object tokens.
Handles object storage, ownership, versioning, and upgrade logic. Intended to be extended by full set contracts.
State Variables
ID_MAX
uint64 private constant ID_MAX = type(uint64).max - 1;
_objects
mapping(uint64 => ObjectData) internal _objects;
Functions
onlyObjectOwner
Restricts function to the current object owner.
modifier onlyObjectOwner(uint64 id);
create
Create (mint) a new object
function create(address to, uint64 id0, bytes calldata data)
external
virtual
returns (uint64 id, Descriptor memory od);
Parameters
Name | Type | Description |
---|---|---|
to | address | Initial owner of the object |
id0 | uint64 | Requested object ID (0 = auto-assign) |
data | bytes | Encoded creation parameters |
Returns
Name | Type | Description |
---|---|---|
id | uint64 | Final resolved object ID |
od | Descriptor | Descriptor of the newly created object |
update
Update an existing object
function update(uint64 id, bytes calldata data) external virtual returns (Descriptor memory od);
Parameters
Name | Type | Description |
---|---|---|
id | uint64 | Object ID to update |
data | bytes | Encoded update parameters |
Returns
Name | Type | Description |
---|---|---|
od | Descriptor | Descriptor after the update |
upgrade
Upgrade an object to a new kind or set revision
function upgrade(uint64 id, uint32 kindRev0, uint32 setRev0)
external
virtual
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 virtual 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 virtual 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 |
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 |
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
Returns true if this contract implements the interface defined by
interfaceId
. See the corresponding
https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
to learn more about how these ids are created.
This function call must use less than 30 000 gas.
function supportsInterface(bytes4 interfaceId) external pure virtual override returns (bool);
_supportsInterface
function _supportsInterface(bytes4 interfaceId) internal pure virtual returns (bool);
_create
function _create(address to, uint64 id, Descriptor memory od, bytes32[] memory elems)
internal
returns (Descriptor memory);
_create0
function _create0(address to, uint64 id, Descriptor memory od) internal returns (Descriptor memory);
_create1
function _create1(address to, uint64 id, Descriptor memory od, bytes32 elem0) internal returns (Descriptor memory);
_create2
function _create2(address to, uint64 id, Descriptor memory od, bytes32 elem0, bytes32 elem1)
internal
returns (Descriptor memory);
_update
function _update(uint64 id, bytes32[] memory elems) internal returns (Descriptor memory);
_upgrade
function _upgrade(uint64 id, uint32 kindRev0, uint32 setRev0) internal returns (Descriptor memory);
_touch
function _touch(uint64 id) internal returns (Descriptor memory);
_transfer
function _transfer(uint64 id, address to) internal returns (address from);
_owner
function _owner(uint64 id) internal view returns (address);
_decriptor
function _decriptor(uint64 id, uint32 rev0) internal view returns (Descriptor memory);
_snapshot
function _snapshot(uint64 id, uint32 rev0) internal view returns (Descriptor memory od, bytes32[] memory elems);
_postCreate
function _postCreate(address to, uint64 id, Descriptor memory od, bytes32[] memory elems) 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;
_onUpgradeKind
function _onUpgradeKind(uint64 kindId, uint32 kindRev0) internal view virtual returns (uint32);
_onUpgradeSet
function _onUpgradeSet(uint64 setId, uint32 setRev0) internal view virtual returns (uint32);
_objectURI
function _objectURI() internal view virtual returns (string memory);
Errors
CallerNotObjectOwner
error CallerNotObjectOwner();
InvalidObjectId
error InvalidObjectId();
UnknownObjectKind
error UnknownObjectKind();
UnknownObjectSet
error UnknownObjectSet();
InvalidKindRevision
error InvalidKindRevision();
InvalidSetRevision
error InvalidSetRevision();
InvalidUpgradeArguments
error InvalidUpgradeArguments();
ObjectAlreadyExists
error ObjectAlreadyExists();
ObjectNotFound
error ObjectNotFound();
RevisionNotStored
error RevisionNotStored();
RevisionNotFound
error RevisionNotFound();
KindUpgradeRejected
error KindUpgradeRejected();
SetUpgradeRejected
error SetUpgradeRejected();
Unimplemented
error Unimplemented();
Structs
ObjectData
struct ObjectData {
Descriptor desc;
address owner;
bytes32[] elements;
}