-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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 ERC20 compatibility to ERC777. #1735
Conversation
Hi, I made a quick review of the contract, see my comments above. What do you think about implementing ERC20 compatibility as a switchable feature ? What if someone does not want ERC20 compatibility ? |
Thank you @frangio and @catageek for the review!
We thought about this and decided it'd be best to have support by default (which has the nice side effect of greatly simplifying the implementation). I'm not sure why someone would not want to have ERC20 support, but we can add a contract that removes it by having all of the ERC20 functions ( @frangio I'm considering getting rid of the The spec says:
WDYT? |
Hm, coverage decreased due to a |
In both of these cases I think for now we should target only the most common use cases. This means ERC20 support built-in, and granularity hardcoded to 1. However, I'd like to understand what a future API would look like if we ever decide to: 1) implement support for opting out of ERC20 compatibility, and 2) opting in to a different granularity. |
I think so, yes. Why not? |
@nventuro and I looked into the potential future API for opting out of ERC20 support and in to granularity. We saw that we can put the ERC777 implementation alone in its own contract and, as long as we provide an internal The same for granularity because it's just adding a couple |
I've commented out the offending |
Just a thought... what do you think about adding a pending test (i.e. empty |
Not sure what you mean, calling a |
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!
Co-Authored-By: nventuro <nicolas.venturo@gmail.com>
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.
* Add ERC20 compatibility. * Reusing ERC20 tests for ERC777. * Improve documentation. * Add changelog entry. * Improved ERC20 behavior tests. * Add revert reasons to ERC777. * ERC20 methods allow sending tokens to contracts with no interface. * Register ERC20 interface. * Add comment about avoidLockingTokens. * Improve revert reason string. * Make ERC777 implement IERC20. * Fix test revert string. * Remove unnecesary require. * Add private _transfer. * Update contracts/drafts/ERC777/ERC777.sol Co-Authored-By: nventuro <nicolas.venturo@gmail.com> * Update private helper names. (cherry picked from commit aa4c9fe)
Fixes #1731.
Our
ERC20
implementation has internal functions for_mint
,_transfer
,_burn
and_approve
, but I did not include any of these here to keep the API small for now. Note that we do have a_mint
function, but it performs ERC777 minting (i.e. it requires a recipient contract to implement the token recipient interface).Should we also add the functions to increase and decrease allowance?