-
Notifications
You must be signed in to change notification settings - Fork 342
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
Add ERC721 hooks #978
Add ERC721 hooks #978
Conversation
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 changes look great, Eric! I left some comments, questions, and suggestions
all of the `owner` assets. | ||
|
||
Requirements: | ||
|
||
- `operator` cannot be the caller. | ||
|
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.
Hm the requirement isn't correct, it should be "operator
cannot be the owner
".
Also, should this be a requirement? I don't see anything against self approvals in the EIP and the current Solidity implementation only has a check that the operator isn't the zero address (here). On top of that, the proposed _approve_with_optional_event
already allows for self approvals (here). Thoughts?
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.
After giving it some time, I think we can remove the requirement.
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.
And we don't need the check for the operator != zero either, since the zero address is always unauthorized in the check_authorized method.
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.
Right, but this would allow is_approved_for_all
to potentially return true when the operator is zero, no?
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.
Yes, but I don't think there's a real issue with that. Even if people approve the zero address, if for some reason the zero address approval causes issues, there must be a big bug somewhere in the process, right?
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.
Even if people approve the zero address, if for some reason the zero address approval causes issues, there must be a big bug somewhere in the process, right?
Totally agree. My uneasiness with removing the check is the fact that it allows the getter to return an incorrect value. To me, that's a bug (a very small one in this context but a bug nonetheless). Do you disagree?
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.
Fair point. I think keeping it as consistent as possible with Solidity is good anyway. Let's keep the operator not zero check.
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
…airo-contracts into feat/add-erc721-hooks-#965
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.
Changes look good! I think we should also add tests for the new internals (_require_owned
, _check_authorized
, _update
). And we should also test the behavior of hooks. Since ERC20 should have hooks tests as well, maybe we can create a separate issue/PR to handle hooks testing (and not further block this PR). WDYT?
I added the tests for the internal methods that were missing, but not sure what's the best approach to test hooks, since the only implementation we provide is empty, and how can we test an empty behavior? If we were to test that functions don't do things that's infinite possibilities right? Any ideas? |
We must test ALL possibilities!!! No, there's no point in testing empty behaviors. What we can test is the side effects of the before and after hook with a mock to confirm they're called in the correct order i.e. Unless you have another idea, I say let's get this merged and regroup on this. WDYT? |
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 left a couple tiny suggestions on the new tests. We just need to conclude on the open discussion and this should be good to go!
…eat/add-erc721-hooks-#965
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.
Last suggestion: let's add the non-zero operator
requirement for _set_approval_for_all
in the API doc and then this should be good to go!
Partially fixes #965
PR Checklist