-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
A-cheatcodesArea: cheatcodesArea: cheatcodesT-featureType: featureType: featurefirst issueA good way to start contributingA good way to start contributing
Description
Component
Forge
Describe the feature you would like
It would be useful imo to add RLP encoding/decoding related cheats, mirroring the functionality already available in cast
via cast to-rlp
and cast from-rlp
. This would allow contracts to easily manage RLP data in tests without relying on external libraries or tooling.
/// @dev RLP encodes a list of `data` into an rlp payload.
function toRlp(bytes[] calldata data) public pure returns (bytes memory);
/// @dev RLP decodes an `rlp` payload into a list of `data`.
function fromRlp(bytes calldata rlp) public pure returns (bytes[] memory data);
Rather than bytes[] calldata data
it may be cleaner to simply take in bytes calldata abiEncoded
so usage becomes:
bytes memory rlpPayload = vm.toRlp(abi.encode(item0, item1, item2...));
(bytes item0, uint256 item1, address item2, ...) = abi.decode(vm.fromRlp(rlpPayload), (bytes, uint256, address);
Worth noting the abi.encode
pattern might be annoying if you don't want to parse all elements.
Additional context
No response
Metadata
Metadata
Assignees
Labels
A-cheatcodesArea: cheatcodesArea: cheatcodesT-featureType: featureType: featurefirst issueA good way to start contributingA good way to start contributing
Type
Projects
Status
Backlog