Read allowance from overridable function in increase/decrease (#3213)

pull/3219/head
Hadrien Croubois 3 years ago committed by GitHub
parent f6b614a7c5
commit 3e74681e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      contracts/token/ERC20/ERC20.sol

@ -180,7 +180,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata {
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, _allowances[owner][spender] + addedValue);
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
@ -200,7 +200,7 @@ contract ERC20 is Context, IERC20, IERC20Metadata {
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = _allowances[owner][spender];
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);

Loading…
Cancel
Save