add downcast helpers

add safe transfer for bad tokens

reorder updateData order

refactor tests to be more explicit
This commit is contained in:
Noah Zinsmeister
2019-10-28 16:24:29 -04:00
parent 3f9418e486
commit b6e403ed14
4 changed files with 62 additions and 22 deletions

View File

@ -26,4 +26,14 @@ library SafeMath {
uint256 c = a / b;
return c;
}
function downcastTo64(uint256 a) internal pure returns (uint64) {
require(a <= uint64(-1), "SafeMath: downcast overflow");
return uint64(a);
}
function downcastTo128(uint256 a) internal pure returns (uint128) {
require(a <= uint128(-1), "SafeMath: downcast overflow");
return uint128(a);
}
}