c9639c3860
* tests: add solidity test suite * tests: remove require strings * Update tests-solidity/init-test-node.sh * Update tests-solidity/init-test-node.sh Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
24 lines
804 B
Solidity
24 lines
804 B
Solidity
// Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/common/Uint256Helpers.sol
|
|
// Adapted to use pragma ^0.5.8 and satisfy our linter rules
|
|
|
|
pragma solidity ^0.5.8;
|
|
|
|
|
|
library Uint256Helpers {
|
|
uint256 private constant MAX_UINT8 = uint8(-1);
|
|
uint256 private constant MAX_UINT64 = uint64(-1);
|
|
|
|
string private constant ERROR_UINT8_NUMBER_TOO_BIG = "UINT8_NUMBER_TOO_BIG";
|
|
string private constant ERROR_UINT64_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
|
|
|
|
function toUint8(uint256 a) internal pure returns (uint8) {
|
|
require(a <= MAX_UINT8, ERROR_UINT8_NUMBER_TOO_BIG);
|
|
return uint8(a);
|
|
}
|
|
|
|
function toUint64(uint256 a) internal pure returns (uint64) {
|
|
require(a <= MAX_UINT64, ERROR_UINT64_NUMBER_TOO_BIG);
|
|
return uint64(a);
|
|
}
|
|
}
|