Skip to content

Commit

Permalink
fix: fix the bool decode and encode for rlp lib
Browse files Browse the repository at this point in the history
  • Loading branch information
yutianwu authored and unclezoro committed Mar 16, 2023
1 parent 5134a57 commit 0b5f963
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion contracts/lib/RLPDecode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ library RLPDecode {
result := byte(0, mload(memPtr))
}

return result == 0 ? false : true;
if (result == 0 || result == STRING_SHORT_START) {
return false;
} else {
return true;
}
}

function toAddress(RLPItem memory item) internal pure returns (address) {
Expand Down
4 changes: 1 addition & 3 deletions contracts/lib/RLPEncode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ library RLPEncode {
*/
function encodeBool(bool self) internal pure returns (bytes memory) {
bytes memory rs = new bytes(1);
if (self) {
rs[0] = bytes1(uint8(1));
}
rs[0] = (self ? bytes1(0x01) : bytes1(0x80));
return rs;
}

Expand Down

0 comments on commit 0b5f963

Please sign in to comment.