-
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
Lazy ownership tree based on pallet-unique's owner #31
Conversation
…r burning an NFT from a non root_owner to trigger expected failure
…orrect bounds to allow for Collection ID & NFT ID to be mapped to Class ID & Instance ID of Uniques pallet
…ns to generate virtual accounts & retrieve collection_id, nft_id. Add CircleDetected error when sending nft to self nft and add test
Updates now allow for creating virtual accounts for NFTs while also decoding the |
pub fn lookup_root_owner(collection_id: CollectionId, nft_id: NftId) -> Result<(T::AccountId, (CollectionId, NftId)), Error<T>> { | ||
let parent = | ||
pallet_uniques::Pallet::<T>::owner(collection_id, nft_id); | ||
// Check if parent returns None which indicates the NFT is not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the cases a NFT can have no parent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought of a couple cases, but the second case would be if we did the "rootless" children and tried to perform a lookup_root_owner
- NFT is already burned (Added a test for this one)
- A case if an ancestor NFT were burned leaving the
…le of collection_id & nft_id as key. Add additional tests to ensure functionality works as expected.
…es and documentation corrections. Remove owner from InstanceInfo as it is no longer needed to be tracked
…dOrCollectionNftTuple
} | ||
Ok(()) | ||
} | ||
|
||
pub fn recursive_burn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The callers must be transactional to avoid stop in the middle problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for recursive_burn
or for is_x_descendent_of_y
?
// Handle Children StorageMap for NFTs | ||
let current_cid_nid = Pallet::<T>::decode_nft_account_id::<T::AccountId>(current_owner.clone()); | ||
if current_cid_nid.is_some() { | ||
// remove child from parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the new owner is not a NFT? Should we still keep tracking the children? It may be on very large for a big player
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we need to change the Children
StorageMap or would this be tracked in NftsByOwner
StorageMap? Right now children are tracked for NFTs that own NFTs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being tracked in Issue #48
Targets
send_nft
to utilize lazy ownership treedo_transfer
Procedure
pallet_unique::Pallet::<T>::mint(origin, owner, col, nft)?;
transfer(origin: OriginFor<T>, col: CollectionId, nft: NftId, dest: AccountIdOrNftTuple)
NFT to another NFTlookup_root_owner(col, nft)
match
dest_account
toAccountId(id)
if Account ownerNFTTuple(c,n)
then calllookup_root_owner(c, n)
& if no circle detection triggered then convert to virtual account withnft_to_account_id(c, n)
origin
does transfer then auto-accept NFT & setpending
=== falsepending
=== trueNFTSent
RMRK Specs