Add missing requirements to ERC777 (#2212)

* Restore _approve check for zero sender

* Add non-zero operator check to _send
This commit is contained in:
Nicolás Venturo
2020-04-24 15:33:22 -03:00
committed by GitHub
parent 58a3368215
commit c75b016919
3 changed files with 31 additions and 5 deletions

View File

@ -23,4 +23,8 @@ contract ERC777Mock is Context, ERC777 {
) public {
_mint(operator, to, amount, userData, operatorData);
}
function approveInternal(address holder, address spender, uint256 value) public {
_approve(holder, spender, value);
}
}

View File

@ -352,6 +352,7 @@ contract ERC777 is Context, IERC777, IERC20 {
)
internal
{
require(operator != address(0), "ERC777: operator is the zero address");
require(from != address(0), "ERC777: send from the zero address");
require(to != address(0), "ERC777: send to the zero address");
@ -408,10 +409,13 @@ contract ERC777 is Context, IERC777, IERC20 {
emit Transfer(from, to, amount);
}
/**
* @dev See {ERC20-_approve}.
*
* Note that accounts cannot have allowance issued by their operators.
*/
function _approve(address holder, address spender, uint256 value) internal {
// TODO: restore this require statement if this function becomes internal, or is called at a new callsite. It is
// currently unnecessary.
//require(holder != address(0), "ERC777: approve from the zero address");
require(holder != address(0), "ERC777: approve from the zero address");
require(spender != address(0), "ERC777: approve to the zero address");
_allowances[holder][spender] = value;