Skip to content

Commit c8fbaa3

Browse files
committed
feat(10027-cheatcode-mutability-tags): make eth_getLogs getMappingLength getMappingSlotAt view
1 parent 98ae17c commit c8fbaa3

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

crates/cheatcodes/assets/cheatcodes.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cheatcodes/spec/src/vm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,17 +441,18 @@ interface Vm {
441441

442442
/// Gets the number of elements in the mapping at the given slot, for a given address.
443443
#[cheatcode(group = Evm, safety = Safe)]
444-
function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
444+
function getMappingLength(address target, bytes32 mappingSlot) external view returns (uint256 length);
445445

446446
/// Gets the elements at index idx of the mapping at the given slot, for a given address. The
447447
/// index must be less than the length of the mapping (i.e. the number of keys in the mapping).
448448
#[cheatcode(group = Evm, safety = Safe)]
449-
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
449+
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external view returns (bytes32 value);
450450

451451
/// Gets the map key and parent of a mapping at a given slot, for a given address.
452452
#[cheatcode(group = Evm, safety = Safe)]
453453
function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
454454
external
455+
view
455456
returns (bool found, bytes32 key, bytes32 parent);
456457

457458
// -------- Block and Transaction Properties --------
@@ -871,6 +872,7 @@ interface Vm {
871872
#[cheatcode(group = Evm, safety = Safe)]
872873
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
873874
external
875+
view
874876
returns (EthGetLogs[] memory logs);
875877

876878
// --- Behavior ---

docs/dev/cheatcode-mutability-review.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ Mark `view`:
4242

4343
- [x] `accessList`: `accessList(address,bytes32[])` _resolved: not view, keep as is due to test coverage indicating stateful behavior_
4444
- [x] `accesses`: `accesses(address)` _suggested: `view`_
45-
- [ ] `eth_getLogs`: `eth_getLogs(uint256,uint256,address,bytes32[])`
45+
- [x] `eth_getLogs`: `eth_getLogs(uint256,uint256,address,bytes32[])` _suggested: `view`_
4646
- [ ] `getMappingKeyAndParentOf`: `getMappingKeyAndParentOf(address,bytes32)`
47-
- [ ] `getMappingLength`: `getMappingLength(address,bytes32)`
48-
- [ ] `getMappingSlotAt`: `getMappingSlotAt(address,bytes32,uint256)`
47+
- [x] `getMappingLength`: `getMappingLength(address,bytes32)` _suggested: `view`_
48+
- [x] `getMappingSlotAt`: `getMappingSlotAt(address,bytes32,uint256)` _suggested: `view`_
4949
- [ ] `getNonce_1`: `getNonce(address,uint256,uint256,uint256)`
5050
- [ ] `getRecordedLogs`: `getRecordedLogs()`
5151
- [ ] `getWallets`: `getWallets()`

0 commit comments

Comments
 (0)