Add revert string to Counter decrement overflow (#2500)

This commit is contained in:
Hadrien Croubois
2021-02-04 21:28:13 +01:00
committed by GitHub
parent c82895fb65
commit f2112be4d8
2 changed files with 9 additions and 3 deletions

View File

@ -23,10 +23,16 @@ library Counters {
}
function increment(Counter storage counter) internal {
counter._value += 1;
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
counter._value = counter._value - 1;
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
}