-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace RLP.sol with RLPReader.sol
- Loading branch information
Showing
11 changed files
with
616 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,49 @@ | ||
pragma solidity 0.5.11; | ||
|
||
import "../../src/utils/RLP.sol"; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "../../src/utils/RLPReader.sol"; | ||
|
||
contract RLPMock { | ||
|
||
using RLP for bytes; | ||
using RLP for RLP.RLPItem; | ||
using RLPReader for bytes; | ||
using RLPReader for RLPReader.RLPItem; | ||
|
||
function decodeBytes32(bytes memory _data) public pure returns (bytes32) { | ||
return _data.toRLPItem().toBytes32(); | ||
return bytes32(_data.toRlpItem().toUint()); | ||
} | ||
|
||
function decodeBytes20(bytes memory _data) public pure returns (bytes20) { | ||
return bytes20(_data.toRlpItem().toAddress()); | ||
} | ||
|
||
function decodeBool(bytes memory _data) public pure returns (bool) { | ||
return _data.toRLPItem().toBool(); | ||
return _data.toRlpItem().toBoolean(); | ||
} | ||
|
||
function decodeInt(bytes memory _data) public pure returns (int) { | ||
return _data.toRLPItem().toInt(); | ||
return int(_data.toRlpItem().toUint()); | ||
} | ||
|
||
function decodeUint(bytes memory _data) public pure returns (uint) { | ||
return _data.toRLPItem().toUint(); | ||
return _data.toRlpItem().toUint(); | ||
} | ||
|
||
function decodeList(bytes memory _data) public pure returns (bytes[] memory) { | ||
RLPReader.RLPItem[] memory items = _data.toRlpItem().toList(); | ||
|
||
bytes[] memory result = new bytes[](items.length); | ||
for (uint i = 0; i < items.length; i++) { | ||
result[i] = items[i].toRlpBytes(); | ||
} | ||
return result; | ||
} | ||
|
||
function decodeString(bytes memory _data) public pure returns (string memory) { | ||
return string(_data.toRlpItem().toBytes()); | ||
} | ||
|
||
function decodeArray(bytes memory _data) public pure returns (uint) { | ||
RLP.RLPItem[] memory items = (_data.toRLPItem().toList()[0]).toList(); | ||
return items.length; | ||
function decodeBytes(bytes memory _data) public pure returns (bytes memory) { | ||
return _data.toRlpItem().toBytes(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.