foundry_cheatcodes::evm

Function read_callers

Source
fn read_callers(state: &Cheatcodes, default_sender: &Address) -> Result
Expand description

Reads the current caller information and returns the current CallerMode, msg.sender and tx.origin.

Depending on the current caller mode, one of the following results will be returned:

  • If there is an active prank:

    • caller_mode will be equal to:
    • msg.sender will be equal to the address set for the prank.
    • tx.origin will be equal to the default sender address unless an alternative one has been set when configuring the prank.
  • If there is an active broadcast:

    • caller_mode will be equal to:
    • msg.sender and tx.origin will be equal to the address provided when setting the broadcast.
  • If no caller modification is active:

    • caller_mode will be equal to CallerMode::None,
    • msg.sender and tx.origin will be equal to the default sender address.