-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
ERC777 internal _burn #1908
ERC777 internal _burn #1908
Conversation
Hi all! |
Thanks for contributting @MickdeGraaf! My only concern with this PR is that it allows passing an arbitrary cc @nventuro |
@frangio Being able to set the operator manually allows for much more flexibility when extending this contract. On another note: There are a lot of functions in ERC777 which are private but could be internal or don't have any way to be set from deriving contracts. Setting an operator is now only possible from an external function. In my use case I want to set an operator from a contract deriving from ERC777. In the ERC20 contract things like setting allowances are possible via internal functions. |
We deliberately restricted the internal API and kept many things private or external to give us some time to figure out the implications before committing to opening it up. If we were to design ERC20 today I'm not sure we would allow so many arbitrary things to be done internally. I'm curious to hear about your opinion and experience. In this specific case, what is the functionality that you would like to implement? And is it |
Hi all! |
Hi @MickdeGraaf, I don't want to delay this for much longer but it would be very helpful for us to understand what you were trying to do so that we can design the best solution possible for the use case. Hope you can share a few more details. Thanks! |
IIUC, the fear is that the token itself is acting as an operator, but is not registered as an operator? The canonical example to work with is a wrapper token (e.g., W-ETH) which has a One can certainly imagine a situation where the token contract calls |
Who should be the operator in the events emitted in those cases? |
For deposit/withdraw I think the event should be the same as a user transferring their own assets (which I believe means the operator is set to |
@nventuro and I have been debating this and we have decided to merge this to be consistent with the existence of |
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.
Thanks everyone!
What is the process for getting a new NPM package published to https://www.npmjs.com/package/@openzeppelin/contracts with this change? |
Assuming the release is on some cadence other than "now", can anyone recommend a workaround for authoring a wrapper contract so I can move forward with development while waiting? My thought is to add
|
Hm, I'm actually not sure how you could handle that one. I'd ask on the solidity-dev gitter channel. |
I asked in Solidity Gitter (which I believe is the appropriate room for such questions) but haven't received any advice. Is it possible that the current OZ contracts have a bug in that it is impossible to construct an ERC777 with a default operator? If so I can open a bug, I assumed you all had tested that scenario and I just didn't know what I was doing. :) |
You can pass a default operator, the issue you're having is that you're computing the address if said operator in the constructor itself, and Solidity is not letting you do it due to limitations of the type system. If you knew the address of the operator beforehand, you'd simply pass it as an argument to the constructor. I did some experimenting on Remix and this seems to work: contract ERC777 {
address[] _operators;
constructor(address[] memory operators) public {
_operators = operators;
}
}
contract MyContract is ERC777 {
constructor() ERC777(toArray(address(this))) public {
}
function toArray(address addr) private pure returns (address[] memory) {
address[] memory array = new address[](1);
array[0] = addr;
return array;
}
} |
I'll give that a try once back at a computer, thanks! Though, I think I would have the same problem with a constant address as the error is with passing a dynamic array to the constructor. For example I believe (not at computer to check) that |
Yes, I'd expect the same. I can't think of any solution other than the helper function that I shared above, this probably warrants discussion with the Solidity team. |
Was this intentionally not included in the 2.4.0 release from 5 hours ago or did it somehow get missed? |
The release was announced today but it actually happened a couple days ago. There's several things in Sorry this didn't make it! 2.5 is gonna happen relatively soon anyway. |
That made me notice we forgot to add a changelog entry for this, I addressed that in a20408a |
Fixes #1908
Currently the _burn function is private which makes it hard to build tokens that deflate.
This PR makes the _burn function internal