ERC20 extension for governance tokens (vote delegation and snapshots) (#2632)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
@ -18,6 +18,21 @@ pragma solidity ^0.8.0;
|
||||
* all math on `uint256` and `int256` and then downcasting.
|
||||
*/
|
||||
library SafeCast {
|
||||
/**
|
||||
* @dev Returns the downcasted uint224 from uint256, reverting on
|
||||
* overflow (when the input is greater than largest uint224).
|
||||
*
|
||||
* Counterpart to Solidity's `uint224` operator.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* - input must fit into 224 bits
|
||||
*/
|
||||
function toUint224(uint256 value) internal pure returns (uint224) {
|
||||
require(value < 2**224, "SafeCast: value doesn\'t fit in 224 bits");
|
||||
return uint224(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Returns the downcasted uint128 from uint256, reverting on
|
||||
* overflow (when the input is greater than largest uint128).
|
||||
|
||||
Reference in New Issue
Block a user