Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark envOr functions as view #6757

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,15 +1060,14 @@ impl Backend {
env.block.basefee = base;
}

let gas_price =
gas_price.map(|g| g).or(max_fee_per_gas.map(|g| g)).unwrap_or_else(|| self.gas_price());
let gas_price = gas_price.or(max_fee_per_gas).unwrap_or_else(|| self.gas_price());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy was complaining about this

let caller = from.unwrap_or_default();

env.tx = TxEnv {
caller: caller.to_alloy(),
gas_limit: gas_limit.as_u64(),
gas_price,
gas_priority_fee: max_priority_fee_per_gas.map(|f| f),
gas_priority_fee: max_priority_fee_per_gas,
transact_to: match to {
Some(addr) => TransactTo::Call(addr.to_alloy()),
None => TransactTo::Create(CreateScheme::Create),
Expand Down
56 changes: 28 additions & 28 deletions crates/cheatcodes/assets/cheatcodes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,86 +895,86 @@ interface Vm {
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, bool defaultValue) external returns (bool value);
function envOr(string calldata name, bool defaultValue) external view returns (bool value);
/// Gets the environment variable `name` and parses it as `uint256`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value);
function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
/// Gets the environment variable `name` and parses it as `int256`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, int256 defaultValue) external returns (int256 value);
function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
/// Gets the environment variable `name` and parses it as `address`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, address defaultValue) external returns (address value);
function envOr(string calldata name, address defaultValue) external view returns (address value);
/// Gets the environment variable `name` and parses it as `bytes32`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value);
function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
/// Gets the environment variable `name` and parses it as `string`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata defaultValue) external returns (string memory value);
function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
/// Gets the environment variable `name` and parses it as `bytes`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value);
function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);

/// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
external
external view
returns (bool[] memory value);
/// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
external
external view
returns (uint256[] memory value);
/// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
external
external view
returns (int256[] memory value);
/// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
external
external view
returns (address[] memory value);
/// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
external
external view
returns (bytes32[] memory value);
/// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
external
external view
returns (string[] memory value);
/// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
#[cheatcode(group = Environment)]
function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
external
external view
returns (bytes[] memory value);

// ======== Scripts ========
Expand Down
Loading
Loading