Crate example_cheatcode_inspector

Source
Expand description

An example that shows how to implement a Foundry-style Solidity test cheatcode inspector.

The code below mimics relevant parts of the implementation of the transact and rollFork(uint256 forkId, bytes32 transaction) cheatcodes. Both of these cheatcodes initiate transactions from a call step in the cheatcode inspector which is the most advanced cheatcode use-case.

Structsยง

  • Backend ๐Ÿ”’
    Backend for cheatcodes. The problematic cheatcodes are only supported in fork mode, so weโ€™ll omit the non-fork behavior of the Foundry Backend.
  • Cheatcodes ๐Ÿ”’
    An REVM inspector that intercepts calls to the cheatcode address and executes them with the help of the DatabaseExt trait.
  • Env ๐Ÿ”’
    EVM environment

Traitsยง

  • DatabaseExt ๐Ÿ”’
    Used in Foundry to provide extended functionality to cheatcodes. The methods are called from the Cheatcodes inspector.

Functionsยง