-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decouple Equip Logic #147
Comments
I'm happy to see your suggestion going in the direction of including the ResourceId in the equip/unequip operations. I agree that equip and unequip should be decoupled. I can work on that. As for the enum rmrk-substrate/traits/src/resource.rs Lines 111 to 128 in 20235f9
rmrk-substrate/traits/src/resource.rs Lines 103 to 109 in 20235f9
I'd recommend we consider if #145 is good to merge (especially with regards to the new commit 20235f9), then just treat this issue as a decoupling of equip/unequip, unless I'm misunderstanding your suggestion. We could also add removing ID from the struct to this issue. |
Yeah, I agree. I'll make some comments on PR if I have anymore, but I think this is a good direction and we can optimize anything else we may run into. |
Currently the Equip Pallet's
equip
function handles the following scenarios:Equippings
storageNfts
fieldequipped
sets tofalse
Equippings
then triggers aSlotUnequipped
root_owner
orequipper_owner
Nfts
fieldequipped
sets tofalse
Equippings
then triggers aSlotUnequipped
BaseId
&SlotId
BaseId
&SlotId
then it will replace the previous Resource.BaseId
&SlotId
then the new Resource is equipped.I recommend creating 2 separate functions:
equip(origin, nft_to_equip: (CollectionId, NftId), parent_nft: (CollectionId, NftId), parent_resource_id: ResourceId, resource_id_to_equip: ResourceId, base: BaseId, slot: SlotId)
BaseId
andSlotId
. Instead of iterating through the Resources of the NFT to be equipped, we can pass in theResourceId
as well since UI can handle finding the rightResourceId
unequip(origin, nft_to_equip: (CollectionId, NftId), parent_nft: (CollectionId, NftId), parent_resource_id: ResourceId, resource_id_to_unequip: ResourceId, base: BaseId, slot: SlotId)
Since all the information will be on the blockchain, we can leave iterating through storage to find the right ResourceId to be equipped to the parent ResourceId w/ a compatible
BaseId
andSlotId
to UI development to query and ensure they have correct info for parameters to be able to equip the NFT.Another suggestion would be restructuring the
ResourceInfo
to have an enumResourceType
to differentiate between the different resources that a resource can be. From my understanding, there can be 3 types: Basic Media, Composable Base & Composable Parts. Separating these types can make the struct forResourceInfo
better to understand & can help with detecting theResourceType
quicker to ensure the equip functions can better handle logic.Any thoughts on this and if there are other optimizations I may be missing?
The text was updated successfully, but these errors were encountered: