Commit 644e437c authored by Alina's avatar Alina Committed by GitHub

Simplify Casting (#128)

* abi.decode

* indent fix
parent f53f7653
...@@ -177,6 +177,7 @@ library Lib_BytesUtils { ...@@ -177,6 +177,7 @@ library Lib_BytesUtils {
pure pure
returns (bytes32) returns (bytes32)
{ {
if (_bytes.length < 32) {
bytes32 ret; bytes32 ret;
assembly { assembly {
ret := mload(add(_bytes, 32)) ret := mload(add(_bytes, 32))
...@@ -184,6 +185,9 @@ library Lib_BytesUtils { ...@@ -184,6 +185,9 @@ library Lib_BytesUtils {
return ret; return ret;
} }
return abi.decode(_bytes,(bytes32)); // will truncate if input length > 32 bytes
}
function toUint256( function toUint256(
bytes memory _bytes bytes memory _bytes
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment