Skip to content

Commit 2757ddd

Browse files
Evalirmds1
andauthored
feat(vm): add rpc and eth_getLogs cheats (#475)
* feat: add rpc and eth_getLogs cheats * chore: fmt * chore: remove shadowed decl * chore: move rpc cheats into new RPC section --------- Co-authored-by: Matt Solomon <[email protected]>
1 parent 37a37ab commit 2757ddd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Vm.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ interface VmSafe {
3333
string url;
3434
}
3535

36+
struct EthGetLogs {
37+
address emitter;
38+
bytes32[] topics;
39+
bytes data;
40+
bytes32 blockHash;
41+
uint64 blockNumber;
42+
bytes32 transactionHash;
43+
uint64 transactionIndex;
44+
uint256 logIndex;
45+
bool removed;
46+
}
47+
3648
struct DirEntry {
3749
string errorMessage;
3850
string path;
@@ -123,6 +135,16 @@ interface VmSafe {
123135
// Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
124136
function resumeGasMetering() external;
125137

138+
// -------- RPC Methods --------
139+
140+
/// Gets all the logs according to specified filter.
141+
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
142+
external
143+
returns (EthGetLogs[] memory logs);
144+
145+
// Performs an Ethereum JSON-RPC request to the current fork URL.
146+
function rpc(string calldata method, string calldata params) external returns (bytes memory data);
147+
126148
// ======== Test Configuration ========
127149

128150
// If the condition is false, discard this run's fuzz inputs and generate new ones.

test/Vm.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ contract VmTest is Test {
99
// inadvertently moved between Vm and VmSafe. This test must be updated each time a function is
1010
// added to or removed from Vm or VmSafe.
1111
function test_interfaceId() public {
12-
assertEq(type(VmSafe).interfaceId, bytes4(0x329f5e71), "VmSafe");
12+
assertEq(type(VmSafe).interfaceId, bytes4(0x1578a242), "VmSafe");
1313
assertEq(type(Vm).interfaceId, bytes4(0x316cedc3), "Vm");
1414
}
1515
}

0 commit comments

Comments
 (0)