-
Notifications
You must be signed in to change notification settings - Fork 13
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
Getting the parent of a child #52
Conversation
@bobo-k2 can you please take a look and comment |
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.
We discussed previously that it is hard to track parent NFT, but in case of nesting, the parent-NFT-address is the owner of the child NFT.
And childNFT can have only one parent
I like the idea, because this is the feature I am missing from current implementation. I agree with @Maar-io. Calling |
@Maar-io @bobo-k2 It seems like calling any query from the
Should I test the new query with an integration test, seems like we are not testing any other queries. |
Do you have an example of a query being called? |
@boyswan You mean do I have an example of the get parent query being called, or? For me calling any query in the integration test results in the above-mentioned error. I am not sure if others are facing the same problem. This is the way I make the query: // code inside the nesting integration test.
// -- snip --
const _ = await child.query.getParentOfChild([child.address, { u64: 1}]);
// ^^^^ Making this call results in an error.
// -- snip -- |
@Szegoo Mario and I debugged similar issue last week. Maybe I can help to find root cause of the problem |
I did some digging and it seems like the issue lies with how the query functions call their storage (was using It looks like this behaviour has broken since ink 4.0, which will require some changes to how the Query trait works. We can make a separate issue/PR for this, as it's out of the scope of this feature! |
I've created a separate issue for this: #64 |
you get OUTPUT_IS_NULL when your contract crashes. The way to see what was the error code is to make breakpoint on the line you posted and check something like |
After running in debug mode and some logging I got the following error message:
https://github.com/paritytech/substrate/blob/3f8dc9ed594fdba455d0bf6780768e7176188514/frame/contracts/src/lib.rs#L829-L832 |
Ahh of course - makes total sense now! So all we need to do is allow reentrancy for these calls. For example: let parent_collection = PSP34Ref::owner_of_builder(&child_collection, child_id)
.call_flags(ink::env::CallFlags::default().set_allow_reentry(true))
.try_invoke(); |
Oh, I got a bit confused, but I understand now :) |
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.
With clone fix, LGTM
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.
LGTM
Introduces a new storage structure that keeps track of the parent of a child.
This is required for the new query for getting the parent of a child.
Closes: #12