Improve clarity of error messages in functions checking token ownership
See original GitHub issueđ§ Motivation Good morning folks. I feel this somewhat walks the line between feature and bug.
While extending some .*transfer()
functionality in the OpenZeppelin contracts (thank you for providing them!) I found some of my tests failing due to an error reading:
ERC721: transfer caller is not owner nor approved
As a newcomer, most of the terminology of ownership in documentation and in the âhigher levelâ contracts refers to the contract owner - with frequently used modifiers like onlyOwner
and the Ownable
contract reinforcing this. I spent quite some verifying that the test was indeed making calls with the ownerâs signature, and that signature matches the .owner()
in the instance of the contract under test.
After delving in a little more I found that the term âownerâ, in this context, refers to the token owner.
(A more dramatic reading of this experience as at the bottom for those interested in such things)
đ Details A small amount of clarification may go a long way to saving others the journey I went on myself, for example extending the error message to
ERC721: transfer caller is not *token* owner nor approved
I have a PR ready with this, and for all similar instances of such messages. Thank you for your consideration.
Dramatic Reading
âBut I am the ownerâ, I whinge at the test suite, exhausted. In red, emblazoned in the flickering terminal: ââERC721: transfer caller is not owner nor approvedââ stands its ground - repeatedly unconvinced of my ownership. I checksum, and I verify. The messages are signed with poise, grace, and cryptographic correctness. The deployer is requesting the transfer. The very deployer that is also the current owner of this fine establishment. So I dig. I fear Iâll dig too greedily and too deep, and awaken something in the darkness. âAh.â I sigh. Owner can mean owner of the contract, but this âownerâ refers to a check of owner of the token. So let this fable guide you all - donât reuse curt terminology for something that is already overloaded. All this could have been avoided with a simple âERC721: transfer caller is not token owner nor approvedâ.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Haha, yes I can send one.
@kanedaaaa I like that! Do you want to submit a PR?