Core
Other
Utils
Equip Render Utils

RMRKEquipRenderUtils

RMRK team

RMRKEquipRenderUtils

Smart contract of the RMRK Equip render utils module.

Extra utility functions for composing RMRK extended assets.

Methods

checkExpectedParent

function checkExpectedParent(address childAddress, uint256 childId, address expectedParent, uint256 expectedParentId) external view

Check if the child is owned by the expected parent.

Reverts if child token is not owned by an NFT.Reverts if child token is not owned by the expected parent.

Parameters

NameTypeDescription
childAddressaddressAddress of the child contract
childIduint256ID of the child token
expectedParentaddressAddress of the expected parent contract
expectedParentIduint256ID of the expected parent token

composeEquippables

function composeEquippables(address target, uint256 tokenId, uint64 assetId) external view returns (string metadataURI, uint64 equippableGroupId, address catalogAddress, struct RMRKEquipRenderUtils.FixedPart[] fixedParts, struct RMRKEquipRenderUtils.EquippedSlotPart[] slotParts)

Used to compose the given equippables.

The full FixedPart struct looks like this: [ partId, z, metadataURI ]The full EquippedSlotPart struct looks like this: [ partId, childAssetId, z, childAddress, childId, childAssetMetadata, partMetadata ]

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token to compose the equipped items in the asset for
assetIduint64ID of the asset being queried for equipped parts

Returns

NameTypeDescription
metadataURIstringMetadata URI of the asset
equippableGroupIduint64Equippable group ID of the asset
catalogAddressaddressAddress of the catalog to which the asset belongs to
fixedPartsRMRKEquipRenderUtils.FixedPart[]An array of fixed parts respresented by the FixedPart structs present on the asset
slotPartsRMRKEquipRenderUtils.EquippedSlotPart[]An array of slot parts represented by the EquippedSlotPart structs present on the asset

directOwnerOfWithParentsPerspective

function directOwnerOfWithParentsPerspective(address collection, uint256 tokenId) external view returns (address directOwner, uint256 ownerId, bool isNFT, bool inParentsActiveChildren, bool inParentsPendingChildren)

Used to retrieve the immediate owner of the given token, and whether it is on the parent's active or pending children list.

If the immediate owner is not an NFT, the function returns false for both inParentsActiveChildren and inParentsPendingChildren.

Parameters

NameTypeDescription
collectionaddressAddress of the token's collection smart contract
tokenIduint256ID of the token

Returns

NameTypeDescription
directOwneraddressAddress of the given token's owner
ownerIduint256The ID of the parent token. Should be 0 if the owner is an externally owned account
isNFTboolThe boolean value signifying whether the owner is an NFT or not
inParentsActiveChildrenboolA boolean value signifying whether the token is in the parent's active children list
inParentsPendingChildrenboolA boolean value signifying whether the token is in the parent's pending children list

equippedChildrenOf

function equippedChildrenOf(address parentAddress, uint256 parentId, uint64 parentAssetId) external view returns (struct IERC6220.Equipment[] equippedChildren)

Used to get information about the current children equipped into a specific parent and asset.

The full IERC6220.Equipment struct looks like this: [ assetId childAssetId childId childEquippableAddress ]

Parameters

NameTypeDescription
parentAddressaddressAddress of the parent token's smart contract
parentIduint256ID of the parent token
parentAssetIduint64ID of the target parent asset to use to equip the child

Returns

NameTypeDescription
equippedChildrenIERC6220.Equipment[]An array of IERC6220.Equipment structs containing the info about the equipped children

getAllEquippableSlotsFromParent

function getAllEquippableSlotsFromParent(address targetChild, uint256 childId, bool onlyEquipped) external view returns (uint256 childIndex, struct RMRKEquipRenderUtils.EquippableData[] equippableData)

Used to get the child's assets and slot parts pairs, identifying parts the said assets can be equipped into, for all of parent's assets.

Reverts if child token is not owned by an NFT.The full EquippableData struct looks like this: [ slotPartId, childAssetId, parentAssetId, priority, parentCatalogAddress, isEquipped, partMetadata ]

Parameters

NameTypeDescription
targetChildaddressAddress of the smart contract of the given token
childIduint256ID of the child token whose assets will be matched against parent's slot parts
onlyEquippedboolBoolean value signifying whether to only return the assets that are currently equipped (true) or to include the non-equipped ones as well (false)

Returns

NameTypeDescription
childIndexuint256Index of the child in the parent's list of active children
equippableDataRMRKEquipRenderUtils.EquippableData[]An array of EquippableData structs containing info about the equippable child assets and their corresponding slot parts

getAssetIdWithTopPriority

function getAssetIdWithTopPriority(address target, uint256 tokenId) external view returns (uint64 maxPriorityAssetId, uint64 maxPriority)

Used to retrieve the ID of the specified token's asset with the highest priority.

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token for which to retrieve the ID of the asset with the highest priority

Returns

NameTypeDescription
maxPriorityAssetIduint64The ID of the asset with the highest priority
maxPriorityuint64The priority value of the asset with the highest priority

getAssetsById

function getAssetsById(address target, uint256 tokenId, uint64[] assetIds) external view returns (string[] assets)

Used to retrieve the metadata URI of specified assets in the specified token.

Requirements: - assetIds must exist.

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token to retrieve the specified assets for
assetIdsuint64[][] An array of asset IDs for which to retrieve the metadata URIs

Returns

NameTypeDescription
assetsstring[]An array of metadata URIs belonging to specified assets

getChildIndex

function getChildIndex(address parentAddress, uint256 parentId, address childAddress, uint256 childId) external view returns (uint256 index)

Used to retrieve the given child's index in its parent's child tokens array.

Parameters

NameTypeDescription
parentAddressaddressAddress of the parent token's collection smart contract
parentIduint256ID of the parent token
childAddressaddressAddress of the child token's colection smart contract
childIduint256ID of the child token

Returns

NameTypeDescription
indexuint256The index of the child token in the parent token's child tokens array

getChildrenWithTopMetadata

function getChildrenWithTopMetadata(address parentAddress, uint256 parentId) external view returns (struct RMRKEquipRenderUtils.ChildWithTopAssetMetadata[] childrenWithMetadata)

The full ChildWithTopAssetMetadata struct looks like this: [ contractAddress, tokenId, metadata ]

Parameters

NameTypeDescription
parentAddressaddressAddress of the collection smart contract of the parent token
parentIduint256ID of the parent token

Returns

NameTypeDescription
childrenWithMetadataRMRKEquipRenderUtils.ChildWithTopAssetMetadata[]An array of ChildWithTopAssetMetadata structs representing the children with their top asset metadata

getEquippableSlotsFromParent

function getEquippableSlotsFromParent(address targetChild, uint256 childId, uint64 parentAssetId) external view returns (uint256 childIndex, struct RMRKEquipRenderUtils.EquippableData[] equippableData)

Used to get the child's assets and slot parts pairs, identifying parts the said assets can be equipped into, for a specific parent asset.

Reverts if child token is not owned by an NFT.The full EquippableData struct looks like this: [ slotPartId, childAssetId, parentAssetId, priority, parentCatalogAddress, isEquipped, partMetadata, childAssetMetadata, parentAssetMetadata ]

Parameters

NameTypeDescription
targetChildaddressAddress of the smart contract of the given token
childIduint256ID of the child token whose assets will be matched against parent's slot parts
parentAssetIduint64ID of the target parent asset to use to equip the child

Returns

NameTypeDescription
childIndexuint256Index of the child in the parent's list of active children
equippableDataRMRKEquipRenderUtils.EquippableData[]An array of EquippableData structs containing info about the equippable child assets and their corresponding slot parts

getEquippableSlotsFromParentForPendingChild

function getEquippableSlotsFromParentForPendingChild(address targetChild, uint256 childId, uint64 parentAssetId) external view returns (uint256 childIndex, struct RMRKEquipRenderUtils.EquippableData[] equippableData)

Used to get the child's assets and slot parts pairs, identifying parts the said assets can be equipped into, for a specific parent asset while the child is in pending array.

Reverts if child token is not owned by an NFT.The full EquippableData struct looks like this: [ slotPartId, childAssetId, parentAssetId, priority, parentCatalogAddress, isEquipped, partMetadata, childAssetMetadata, parentAssetMetadata ]

Parameters

NameTypeDescription
targetChildaddressAddress of the smart contract of the given token
childIduint256ID of the child token whose assets will be matched against parent's slot parts
parentAssetIduint64ID of the target parent asset to use to equip the child

Returns

NameTypeDescription
childIndexuint256Index of the child in the parent's list of pending children
equippableDataRMRKEquipRenderUtils.EquippableData[]An array of EquippableData structs containing info about the equippable child assets and their corresponding slot parts

getEquipped

function getEquipped(address target, uint64 tokenId, uint64 assetId) external view returns (uint64[] slotPartIds, struct IERC6220.Equipment[] childrenEquipped, string[] childrenAssetMetadata)

Used to retrieve the equipped parts of the given token.

NOTE: Some of the equipped children might be empty.The full Equipment struct looks like this: [ assetId, childAssetId, childId, childEquippableAddress ]

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint64ID of the token to retrieve the equipped items in the asset for
assetIduint64ID of the asset being queried for equipped parts

Returns

NameTypeDescription
slotPartIdsuint64[]An array of the IDs of the slot parts present in the given asset
childrenEquippedIERC6220.Equipment[]An array of Equipment structs containing info about the equipped children
childrenAssetMetadatastring[]An array of strings corresponding to asset metadata of the equipped children

getExtendedActiveAssets

function getExtendedActiveAssets(address target, uint256 tokenId) external view returns (struct RMRKMultiAssetRenderUtils.ExtendedActiveAsset[] activeAssets)

Used to get the active assets of the given token.

The full ExtendedActiveAsset looks like this: [ id, priority, metadata ]

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token to retrieve the active assets for

Returns

NameTypeDescription
activeAssetsRMRKMultiAssetRenderUtils.ExtendedActiveAsset[]An array of ActiveAssets present on the given token

getExtendedEquippableActiveAssets

function getExtendedEquippableActiveAssets(address target, uint256 tokenId) external view returns (struct RMRKEquipRenderUtils.ExtendedEquippableActiveAsset[] activeAssets)

Used to get extended active assets of the given token.

The full ExtendedEquippableActiveAsset looks like this: [ ID, equippableGroupId, priority, catalogAddress, metadata, [ fixedPartId0, fixedPartId1, fixedPartId2, slotPartId0, slotPartId1, slotPartId2 ] ]

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token to retrieve the extended active assets for

Returns

NameTypeDescription
activeAssetsRMRKEquipRenderUtils.ExtendedEquippableActiveAsset[]An array of ExtendedEquippableActiveAssets present on the given token

getExtendedNft

function getExtendedNft(uint256 tokenId, address targetCollection) external view returns (struct RMRKRenderUtils.ExtendedNft data)

Used to get extended information about a specified token.

The full ExtendedNft struct looks like this: [ tokenMetadataUri, directOwner, rootOwner, activeAssetCount, pendingAssetCount priorities, maxSupply, totalSupply, issuer, name, symbol, activeChildrenNumber, pendingChildrenNumber, isSoulbound, hasMultiAssetInterface, hasNestingInterface, hasEquippableInterface ]

Parameters

NameTypeDescription
tokenIduint256ID of the token for which to retireve the ExtendedNft struct
targetCollectionaddressAddress of the collection to which the specified token belongs to

Returns

NameTypeDescription
dataRMRKRenderUtils.ExtendedNftThe ExtendedNft struct containing the specified token's data

getExtendedPendingAssets

function getExtendedPendingAssets(address target, uint256 tokenId) external view returns (struct RMRKEquipRenderUtils.ExtendedPendingAsset[] pendingAssets)

Used to get the extended pending assets of the given token.

The full ExtendedPendingAsset looks like this: [ ID, equippableGroupId, acceptRejectIndex, replacesAssetWithId, catalogAddress, metadata, [ fixedPartId0, fixedPartId1, fixedPartId2, slotPartId0, slotPartId1, slotPartId2 ] ]

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token to retrieve the extended pending assets for

Returns

NameTypeDescription
pendingAssetsRMRKEquipRenderUtils.ExtendedPendingAsset[]An array of ExtendedPendingAssets present on the given token

getParent

function getParent(address childAddress, uint256 childId) external view returns (address parentAddress, uint256 parentId)

Used to retrieve the contract address and ID of the parent token of the specified child token.

Reverts if child token is not owned by an NFT.

Parameters

NameTypeDescription
childAddressaddressAddress of the child token's collection smart contract
childIduint256ID of the child token

Returns

NameTypeDescription
parentAddressaddressAddress of the parent token's collection smart contract
parentIduint256ID of the parent token

getPendingAssets

function getPendingAssets(address target, uint256 tokenId) external view returns (struct RMRKMultiAssetRenderUtils.PendingAsset[] pendingAssets)

Used to get the pending assets of the given token.

The full PendingAsset looks like this: [ id, acceptRejectIndex, replacesAssetWithId, metadata ]

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token to retrieve the pending assets for

Returns

NameTypeDescription
pendingAssetsRMRKMultiAssetRenderUtils.PendingAsset[]An array of PendingAssets present on the given token

getPendingChildIndex

function getPendingChildIndex(address parentAddress, uint256 parentId, address childAddress, uint256 childId) external view returns (uint256 index)

Used to retrieve the given child's index in its parent's pending child tokens array.

Parameters

NameTypeDescription
parentAddressaddressAddress of the parent token's collection smart contract
parentIduint256ID of the parent token
childAddressaddressAddress of the child token's colection smart contract
childIduint256ID of the child token

Returns

NameTypeDescription
indexuint256The index of the child token in the parent token's pending child tokens array

getSlotPartsAndCatalog

function getSlotPartsAndCatalog(address tokenAddress, uint256 tokenId, uint64 assetId) external view returns (uint64[] parentSlotPartIds, address catalogAddress)

Used to retrieve the parent address and its slot part IDs for a given target child, and the catalog of the parent asset.

Parameters

NameTypeDescription
tokenAddressaddressAddress of the collection smart contract of parent token
tokenIduint256ID of the parent token
assetIduint64ID of the parent asset from which to get the slot parts

Returns

NameTypeDescription
parentSlotPartIdsuint64[]Array of slot part IDs of the parent token's asset
catalogAddressaddressAddress of the catalog the parent asset belongs to

getTopAsset

function getTopAsset(address target, uint256 tokenId) external view returns (uint64 topAssetId, uint64 topAssetPriority, string topAssetMetadata)

Used to retrieve ID, priority value and metadata URI of the asset with the highest priority that is present on a specified token.

Parameters

NameTypeDescription
targetaddressCollection smart contract of the token for which to retireve the top asset
tokenIduint256ID of the token for which to retrieve the top asset

Returns

NameTypeDescription
topAssetIduint64ID of the asset with the highest priority
topAssetPriorityuint64Priotity value of the asset with the highest priority
topAssetMetadatastringMetadata URI of the asset with the highest priority

getTopAssetAndEquippableDataForToken

function getTopAssetAndEquippableDataForToken(address target, uint256 tokenId) external view returns (struct RMRKEquipRenderUtils.ExtendedEquippableActiveAsset topAsset)

Used to retrieve the equippable data of the specified token's asset with the highest priority.

Parameters

NameTypeDescription
targetaddressAddress of the collection smart contract of the specified token
tokenIduint256ID of the token for which to retrieve the equippable data of the asset with the highest priority

Returns

NameTypeDescription
topAssetRMRKEquipRenderUtils.ExtendedEquippableActiveAssetExtendedEquippableActiveAsset struct with the equippable data containing the asset with the highest priority

getTopAssetMetaForToken

function getTopAssetMetaForToken(address target, uint256 tokenId) external view returns (string metadata)

Used to retrieve the metadata URI of the specified token's asset with the highest priority.

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the given token
tokenIduint256ID of the token for which to retrieve the metadata URI of the asset with the highest priority

Returns

NameTypeDescription
metadatastringThe metadata URI of the asset with the highest priority

getTopAssetMetadataForTokens

function getTopAssetMetadataForTokens(address target, uint256[] tokenIds) external view returns (string[] metadata)

Used to retrieve the metadata URI of the specified token's asset with the highest priority for each of the given tokens.

Parameters

NameTypeDescription
targetaddressAddress of the smart contract of the tokens
tokenIdsuint256[]IDs of the tokens for which to retrieve the metadata URIs

Returns

NameTypeDescription
metadatastring[]An array of strings with the top asset metadata for each of the given tokens, in the same order as the tokens passed in the tokenIds input array

getTotalDescendants

function getTotalDescendants(address collection, uint256 tokenId) external view returns (uint256 totalDescendants, bool hasMoreThanOneLevelOfNesting_)

Used to retrieve the total number of descendants of the given token and whether it has more than one level of nesting.

Parameters

NameTypeDescription
collectionaddressAddress of the token's collection smart contract
tokenIduint256ID of the token

Returns

NameTypeDescription
totalDescendantsuint256The total number of descendants of the given token
hasMoreThanOneLevelOfNesting_boolA boolean value indicating whether the given token has more than one level of nesting

hasMoreThanOneLevelOfNesting

function hasMoreThanOneLevelOfNesting(address collection, uint256 tokenId) external view returns (bool hasMoreThanOneLevelOfNesting_)

Used to retrieve whether a token has more than one level of nesting.

Parameters

NameTypeDescription
collectionaddressAddress of the token's collection smart contract
tokenIduint256ID of the token

Returns

NameTypeDescription
hasMoreThanOneLevelOfNesting_boolA boolean value indicating whether the given token has more than one level of nesting

isAssetEquipped

function isAssetEquipped(address parentAddress, uint256 parentId, address parentAssetCatalog, address childAddress, uint256 childId, uint64 childAssetId, uint64 slotPartId) external view returns (bool isEquipped)

Used to verify whether a given child asset is equipped into a given parent slot.

Parameters

NameTypeDescription
parentAddressaddressAddress of the collection smart contract of the parent token
parentIduint256ID of the parent token
parentAssetCatalogaddressAddress of the catalog the parent asset belongs to
childAddressaddressAddress of the collection smart contract of the child token
childIduint256ID of the child token
childAssetIduint64ID of the child asset
slotPartIduint64ID of the slot part

Returns

NameTypeDescription
isEquippedboolBoolean value signifying whether the child asset is equipped into the parent slot or not

isTokenRejectedOrAbandoned

function isTokenRejectedOrAbandoned(address collection, uint256 tokenId) external view returns (bool isRejectedOrAbandoned)

Used to identify if the given token is rejected or abandoned. That is, it's parent is an NFT but this token is neither on the parent's active nor pending children list.

Returns false if the immediate owner is not an NFT.

Parameters

NameTypeDescription
collectionaddressAddress of the token's collection smart contract
tokenIduint256ID of the token

Returns

NameTypeDescription
isRejectedOrAbandonedboolWhether the token is rejected or abandoned

splitSlotAndFixedParts

function splitSlotAndFixedParts(uint64[] allPartIds, address catalogAddress) external view returns (uint64[] slotPartIds, uint64[] fixedPartIds)

Used to split slot and fixed parts.

Parameters

NameTypeDescription
allPartIdsuint64[][] An array of Part IDs containing both, Slot and Fixed parts
catalogAddressaddressAn address of the catalog to which the given Parts belong to

Returns

NameTypeDescription
slotPartIdsuint64[]An array of IDs of the Slot parts included in the allPartIds
fixedPartIdsuint64[]An array of IDs of the Fixed parts included in the allPartIds

validateChildOf

function validateChildOf(address parentAddress, address childAddress, uint256 parentId, uint256 childId) external view returns (bool validChild)

Used to validate whether the specified child token is owned by a given parent token.

Parameters

NameTypeDescription
parentAddressaddressAddress of the parent token's collection smart contract
childAddressaddressAddress of the child token's collection smart contract
parentIduint256ID of the parent token
childIduint256ID of the child token

Returns

NameTypeDescription
validChildboolA boolean value indicating whether the child token is owned by the parent token or not

validateChildrenOf

function validateChildrenOf(address parentAddress, address[] childAddresses, uint256 parentId, uint256[] childIds) external view returns (bool isValid, bool[] validityOfChildren)

Used to validate whether the specified child token is owned by a given parent token.

Parameters

NameTypeDescription
parentAddressaddressAddress of the parent token's collection smart contract
childAddressesaddress[]An array of the child token's collection smart contract addresses
parentIduint256ID of the parent token
childIdsuint256[]An array of child token IDs to verify

Returns

NameTypeDescription
isValidboolA boolean value indicating whether all of the child tokens are owned by the parent token or not
validityOfChildrenbool[]An array of boolean values indicating whether each of the child tokens are owned by the parent token or not

Errors

RMRKChildNotFoundInParent

error RMRKChildNotFoundInParent()

Attempting to find the index of a child token on a parent which does not own it.

RMRKMismachedArrayLength

error RMRKMismachedArrayLength()

Attempting to pass complementary arrays of different lengths

RMRKNotComposableAsset

error RMRKNotComposableAsset()

Attempting to compose an asset wihtout having an associated Catalog

RMRKParentIsNotNFT

error RMRKParentIsNotNFT()

Attempting an operation requiring the token being nested, while it is not

RMRKTokenHasNoAssets

error RMRKTokenHasNoAssets()

Attempting to determine the asset with the top priority on a token without assets

RMRKUnexpectedParent

error RMRKUnexpectedParent()

Attempting an operation expecting a parent to the token which is not the actual one