RMRKCatalogImpl
RMRK team
RMRKCatalogImpl
Implementation of RMRK catalog.
Contract for storing 'catalog' elements of NFTs to be accessed by instances of RMRKAsset implementing contracts. This default implementation includes an OwnableLock dependency, which allows the deployer to freeze the state of the catalog contract.
Methods
addEquippableAddresses
function addEquippableAddresses(uint64 partId, address[] equippableAddresses) external nonpayable
Used to add multiple equippableAddresses
to a single catalog entry.
Can only be called on Part
s of Slot
type.
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | ID of the Part that we are adding the equippable addresses to |
equippableAddresses | address[] | An array of addresses that can be equipped into the Part associated with the partId |
addPart
function addPart(IRMRKCatalog.IntakeStruct intakeStruct) external nonpayable
Parameters
Name | Type | Description |
---|---|---|
intakeStruct | IRMRKCatalog.IntakeStruct | undefined |
addPartList
function addPartList(IRMRKCatalog.IntakeStruct[] intakeStructs) external nonpayable
Parameters
Name | Type | Description |
---|---|---|
intakeStructs | IRMRKCatalog.IntakeStruct[] | undefined |
checkIsEquippable
function checkIsEquippable(uint64 partId, address targetAddress) external view returns (bool isEquippable)
Used to check whether the given address is allowed to equip the desired Part
.
Returns true if a collection may equip asset with partId
.
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | The ID of the part that we are checking |
targetAddress | address | The address that we are checking for whether the part can be equipped into it or not |
Returns
Name | Type | Description |
---|---|---|
isEquippable | bool | The status indicating whether the targetAddress can be equipped into Part with partId or not |
checkIsEquippableToAll
function checkIsEquippableToAll(uint64 partId) external view returns (bool isEquippable)
Used to check if the part is equippable by all addresses.
Returns true if part is equippable to all.
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | ID of the part that we are checking |
Returns
Name | Type | Description |
---|---|---|
isEquippable | bool | The status indicating whether the part with partId can be equipped by any address or not |
getAllPartIds
function getAllPartIds() external view returns (uint64[] partIds)
Used to get all the part IDs in the catalog.
Can get at least 10k parts. Higher limits were not tested.It may fail if there are too many parts, in that case use either getPaginatedPartIds
or getTotalParts
and getPartByIndex
.
Returns
Name | Type | Description |
---|---|---|
partIds | uint64[] | An array of all the part IDs in the catalog |
getLock
function getLock() external view returns (bool isLocked)
Used to retrieve the status of a lockable smart contract.
Returns
Name | Type | Description |
---|---|---|
isLocked | bool | A boolean value signifying whether the smart contract has been locked |
getMetadataURI
function getMetadataURI() external view returns (string)
Used to return the metadata URI of the associated Catalog.
Returns
Name | Type | Description |
---|---|---|
_0 | string | Catalog metadata URI |
getPaginatedPartIds
function getPaginatedPartIds(uint256 offset, uint256 limit) external view returns (uint64[] partIds)
Used to get all the part IDs in the catalog.
Parameters
Name | Type | Description |
---|---|---|
offset | uint256 | The offset to start from |
limit | uint256 | The maximum number of parts to return |
Returns
Name | Type | Description |
---|---|---|
partIds | uint64[] | An array of all the part IDs in the catalog |
getPart
function getPart(uint64 partId) external view returns (struct IRMRKCatalog.Part part)
Used to retrieve a Part
with id partId
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | ID of the part that we are retrieving |
Returns
Name | Type | Description |
---|---|---|
part | IRMRKCatalog.Part | The Part struct associated with given partId |
getPartByIndex
function getPartByIndex(uint256 index) external view returns (struct IRMRKCatalog.Part part)
Used to get a single Part
by the index of its partId
.
Parameters
Name | Type | Description |
---|---|---|
index | uint256 | The index of the partId . |
Returns
Name | Type | Description |
---|---|---|
part | IRMRKCatalog.Part | The Part struct associated with the partId at the given index |
getParts
function getParts(uint64[] partIds) external view returns (struct IRMRKCatalog.Part[] parts)
Used to retrieve multiple parts at the same time.
Parameters
Name | Type | Description |
---|---|---|
partIds | uint64[] | An array of part IDs that we want to retrieve |
Returns
Name | Type | Description |
---|---|---|
parts | IRMRKCatalog.Part[] | An array of Part structs associated with given partIds |
getTotalParts
function getTotalParts() external view returns (uint256 totalParts)
Used to get the total number of parts in the catalog.
Returns
Name | Type | Description |
---|---|---|
totalParts | uint256 | The total number of parts in the catalog |
getType
function getType() external view returns (string)
Used to return the itemType
of the associated Catalog
Returns
Name | Type | Description |
---|---|---|
_0 | string | itemType of the associated Catalog |
isContributor
function isContributor(address contributor) external view returns (bool isContributor_)
Used to check if the address is one of the contributors.
Parameters
Name | Type | Description |
---|---|---|
contributor | address | Address of the contributor whose status we are checking |
Returns
Name | Type | Description |
---|---|---|
isContributor_ | bool | Boolean value indicating whether the address is a contributor or not |
manageContributor
function manageContributor(address contributor, bool grantRole) external nonpayable
Adds or removes a contributor to the smart contract.
Can only be called by the owner.Emits ContributorUpdate event.
Parameters
Name | Type | Description |
---|---|---|
contributor | address | Address of the contributor's account |
grantRole | bool | A boolean value signifying whether the contributor role is being granted (true ) or revoked (false ) |
owner
function owner() external view returns (address owner_)
Returns the address of the current owner.
Returns
Name | Type | Description |
---|---|---|
owner_ | address | Address of the current owner |
renounceOwnership
function renounceOwnership() external nonpayable
Leaves the contract without owner. Functions using the onlyOwner
modifier will be disabled.
Can only be called by the current owner.Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
resetEquippableAddresses
function resetEquippableAddresses(uint64 partId) external nonpayable
Used to remove all of the equippableAddresses
for a Part
associated with the partId
.
Can only be called on Part
s of Slot
type.
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | ID of the part that we are clearing the equippableAddresses from |
setEquippableAddresses
function setEquippableAddresses(uint64 partId, address[] equippableAddresses) external nonpayable
Function used to set the new list of equippableAddresses
.
Overwrites existing equippableAddresses
.Can only be called on Part
s of Slot
type.
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | ID of the Part s that we are overwiting the equippableAddresses for |
equippableAddresses | address[] | A full array of addresses that can be equipped into this Part |
setEquippableToAll
function setEquippableToAll(uint64 partId) external nonpayable
Sets the isEquippableToAll flag to true, meaning that any collection may be equipped into the Part
with this partId
.
Can only be called on Part
s of Slot
type.
Parameters
Name | Type | Description |
---|---|---|
partId | uint64 | ID of the Part that we are setting as equippable by any address |
setLock
function setLock() external nonpayable
Locks the operation.
Once locked, functions using notLocked
modifier cannot be executed.Emits LockSet event.
setMetadataURI
function setMetadataURI(string newContractURI) external nonpayable
Used to set the metadata URI of the catalog.
emits ContractURIUpdated
event
Parameters
Name | Type | Description |
---|---|---|
newContractURI | string | The new metadata URI |
setType
function setType(string newType) external nonpayable
Used to set the type of the catalog.
emits TypeUpdated
event
Parameters
Name | Type | Description |
---|---|---|
newType | string | The new type of the catalog |
supportsInterface
function supportsInterface(bytes4 interfaceId) external view returns (bool)
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[EIP (opens in a new tab) section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | undefined |
Returns
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
transferOwnership
function transferOwnership(address newOwner) external nonpayable
Transfers ownership of the contract to a new owner.
Can only be called by the current owner.
Parameters
Name | Type | Description |
---|---|---|
newOwner | address | Address of the new owner's account |
Events
AddedEquippables
event AddedEquippables(uint64 indexed partId, address[] equippableAddresses)
Event to announce new equippables to the part.
It is emitted when new addresses are marked as equippable for partId
.
Parameters
Name | Type | Description |
---|---|---|
partId indexed | uint64 | ID of the part that had new equippable addresses added |
equippableAddresses | address[] | An array of the new addresses that can equip this part |
AddedPart
event AddedPart(uint64 indexed partId, enum IRMRKCatalog.ItemType indexed itemType, uint8 zIndex, address[] equippableAddresses, string metadataURI)
Event to announce addition of a new part.
It is emitted when a new part is added.
Parameters
Name | Type | Description |
---|---|---|
partId indexed | uint64 | ID of the part that was added |
itemType indexed | enum IRMRKCatalog.ItemType | Enum value specifying whether the part is None , Slot and Fixed |
zIndex | uint8 | An uint specifying the z value of the part. It is used to specify the depth which the part should be rendered at |
equippableAddresses | address[] | An array of addresses that can equip this part |
metadataURI | string | The metadata URI of the part |
ContractURIUpdated
event ContractURIUpdated()
From ERC7572 (Draft) Emitted when the contract-level metadata is updated
ContributorUpdate
event ContributorUpdate(address indexed contributor, bool isContributor)
Event that signifies that an address was granted contributor role or that the permission has been revoked.
This can only be triggered by a current owner, so there is no need to include that information in the event.
Parameters
Name | Type | Description |
---|---|---|
contributor indexed | address | Address of the account that had contributor role status updated |
isContributor | bool | A boolean value signifying whether the role has been granted (true ) or revoked (false ) |
LockSet
event LockSet()
Emitted when the smart contract is locked.
OwnershipTransferred
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
Used to anounce the transfer of ownership.
Parameters
Name | Type | Description |
---|---|---|
previousOwner indexed | address | Address of the account that transferred their ownership role |
newOwner indexed | address | Address of the account receiving the ownership role |
SetEquippableToAll
event SetEquippableToAll(uint64 indexed partId)
Event to announce that a given part can be equipped by any address.
It is emitted when a given part is marked as equippable by any.
Parameters
Name | Type | Description |
---|---|---|
partId indexed | uint64 | ID of the part marked as equippable by any address |
SetEquippables
event SetEquippables(uint64 indexed partId, address[] equippableAddresses)
Event to announce the overriding of equippable addresses of the part.
It is emitted when the existing list of addresses marked as equippable for partId
is overwritten by a new one.
Parameters
Name | Type | Description |
---|---|---|
partId indexed | uint64 | ID of the part whose list of equippable addresses was overwritten |
equippableAddresses | address[] | The new, full, list of addresses that can equip this part |
TypeUpdated
event TypeUpdated(string newType)
Emited when the type of the catalog is updated
Parameters
Name | Type | Description |
---|---|---|
newType | string | The new type of the catalog |
Errors
RMRKBadConfig
error RMRKBadConfig()
Attempting to incorrectly configue a Catalog item
RMRKIdZeroForbidden
error RMRKIdZeroForbidden()
Attempting to use ID 0, which is not supported
The ID 0 in RMRK suite is reserved for empty values. Guarding against its use ensures the expected operation
RMRKLocked
error RMRKLocked()
Attempting to interact with a contract that had its operation locked
RMRKNewContributorIsZeroAddress
error RMRKNewContributorIsZeroAddress()
Attempting to assign a 0x0 address as a contributor
RMRKNewOwnerIsZeroAddress
error RMRKNewOwnerIsZeroAddress()
Attempting to transfer the ownership to the 0x0 address
RMRKNotOwner
error RMRKNotOwner()
Attempting to interact with a management function without being the smart contract's owner
RMRKNotOwnerOrContributor
error RMRKNotOwnerOrContributor()
Attempting to interact with a function without being the owner or contributor of the collection
RMRKPartAlreadyExists
error RMRKPartAlreadyExists()
Attempting to add a Part
with an ID that is already used
RMRKPartDoesNotExist
error RMRKPartDoesNotExist()
Attempting to use a Part
that doesn't exist
RMRKPartIsNotSlot
error RMRKPartIsNotSlot()
Attempting to use a Part
that is Fixed
when Slot
kind of Part
should be used
RMRKZeroLengthIdsPassed
error RMRKZeroLengthIdsPassed()
Attempting not to pass an empty array of equippable addresses when adding or setting the equippable addresses