feat(cast): add --network flag to cast tx for network-specific raw encoding#13745
Conversation
…oding Replace the `FoundryNetwork`-based `transaction_raw` workaround with proper network selection via a new `--network` / `-n` CLI flag. This moves raw tx encoding back into `Cast::transaction` dispatching to the correct provider (Ethereum, Optimism, or Tempo) based on the flag. - Add `NetworkVariant` enum (Ethereum/Optimism/Tempo) in foundry-cli opts - use it w/ `--network` through CastSubcommand::Tx and provider construction - Add test for Tempo raw tx encoding (`tx_raw_tempo`)
zerosnacks
left a comment
There was a problem hiding this comment.
Nice, lgtm - pending @onbjerg's / @0xrusowsky
| /// Network selection, defaulting to Ethereum | ||
| #[derive(Clone, Debug, Default, clap::ValueEnum)] | ||
| pub enum NetworkVariant { | ||
| /// Ethereum (default) | ||
| #[default] | ||
| Ethereum, | ||
| /// Optimism / OP-stack | ||
| Optimism, | ||
| /// Tempo | ||
| Tempo, | ||
| } |
There was a problem hiding this comment.
Makes sense, would like to get @onbjerg's input & OK on this as we had a prior conversation about this when working on tempo-foundry; what is preferable is if we somehow have a central location where this is maintained; I don't have an issue with the current proposal.
Context:
foundry/crates/evm/networks/src/lib.rs
Lines 22 to 37 in ce69566
0xrusowsky
left a comment
There was a problem hiding this comment.
personally i like it.
let's wait for @onbjerg to have a look before merging though
onbjerg
left a comment
There was a problem hiding this comment.
for cast this makes sense, however maybe it's worth thinking about:
- can we autodetect the network in some cases? how would we do this? (e.g. a preliminary call to get chain id with eth transport -> use concrete provider)
- for forge, it would probably make sense to have this in config
wdyt?
Agreed; let's take this into consideration for the next steps @mablr and possibly do this as a follow-up |
Motivation
Replace the
FoundryNetwork-basedtransaction_rawworkaround with proper network selection via a new--network/-nCLI flag. This moves raw tx encoding back intoCast::transactiondispatching to the correct provider (Ethereum, Optimism, or Tempo) based on the flag.Solution
NetworkVariantenum (Ethereum/Optimism/Tempo) in foundry-cli opts--networkthrough CastSubcommand::Tx and provider constructiontx_raw_tempo)PR Checklist