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

This commit is contained in:
Hadrien Croubois
2022-02-23 15:28:44 +01:00
committed by GitHub
parent f6b614a7c5
commit 3e74681e77

View File

@ -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);