Skip to content
Merged
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
14 changes: 9 additions & 5 deletions evm/script/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ abstract contract BaseScript is Script, StdCheats {
require(vm.envUint("CHAIN_ID") == block.chainid, "Chain ID mismatch");
// Get the specified sender
address specifiedSender = vm.envOr({ name: "ETH_FROM", defaultValue: address(0) });
bool isMainnetOrOptimism =
block.chainid == getChain("mainnet").chainId || block.chainid == getChain("optimism").chainId;

// We exit early if the chain is mainnet or optimism and no sender is specified
if (isMainnetOrOptimism && specifiedSender == address(0)) {
revert("You must specify a sender for a production deployment");
// Production chains where deriving the broadcaster from a mnemonic is unacceptable: an unset ETH_FROM
// would silently fall back to the public TEST_MNEMONIC key. Each such chain MUST pass an explicit ETH_FROM.
bool isProduction = block.chainid == getChain("mainnet").chainId // ethereum
|| block.chainid == getChain("optimism").chainId // optimism
|| block.chainid == getChain("arbitrum_one").chainId // arbitrum
|| block.chainid == getChain("base").chainId; // base

if (isProduction && specifiedSender == address(0)) {
revert("You must specify a sender (ETH_FROM) for a production deployment");
}

// Select the broadcaster, either the specified sender or the first derived address from the mnemonic
Expand Down
Loading