Skip to main content

foundry_primitives/network/
mod.rs

1use alloy_network::Network;
2
3#[cfg(feature = "optimism")]
4mod optimism;
5mod receipt;
6
7use alloy_provider::fillers::{
8    BlobGasFiller, ChainIdFiller, GasFiller, JoinFill, NonceFiller, RecommendedFillers,
9};
10#[cfg(feature = "optimism")]
11pub use optimism::FoundryTransactionResponse;
12pub use receipt::*;
13
14/// Default JSON-RPC transaction response when the `optimism` feature is disabled.
15#[cfg(not(feature = "optimism"))]
16pub type FoundryTransactionResponse = alloy_rpc_types_eth::Transaction<crate::FoundryTxEnvelope>;
17
18/// Foundry network type.
19///
20/// This network type supports Foundry-specific transaction types, including
21/// op-stack deposit transactions, alongside standard Ethereum transaction types.
22///
23/// Note: This is a basic implementation ("for now") that provides the core Network
24/// trait definitions. Full Foundry-specific RPC types will be implemented in future work.
25/// Currently, this uses Ethereum's Network configuration as a compatibility layer.
26#[derive(Debug, Clone, Copy)]
27pub struct FoundryNetwork {
28    _private: (),
29}
30
31// Use Ethereum's Network trait implementation as the basis.
32// This provides compatibility with the alloy-network ecosystem while we build
33// out Foundry-specific RPC types.
34impl Network for FoundryNetwork {
35    type TxType = crate::FoundryTxType;
36
37    type TxEnvelope = crate::FoundryTxEnvelope;
38
39    type UnsignedTx = crate::FoundryTypedTx;
40
41    type ReceiptEnvelope = crate::FoundryReceiptEnvelope;
42
43    type Header = alloy_consensus::Header;
44
45    type TransactionRequest = crate::FoundryTransactionRequest;
46
47    type TransactionResponse = FoundryTransactionResponse;
48
49    type ReceiptResponse = crate::FoundryTxReceipt;
50
51    type HeaderResponse = alloy_rpc_types_eth::Header;
52
53    type BlockResponse =
54        alloy_rpc_types_eth::Block<Self::TransactionResponse, Self::HeaderResponse>;
55}
56
57impl RecommendedFillers for FoundryNetwork {
58    type RecommendedFillers =
59        JoinFill<GasFiller, JoinFill<BlobGasFiller, JoinFill<NonceFiller, ChainIdFiller>>>;
60
61    fn recommended_fillers() -> Self::RecommendedFillers {
62        Default::default()
63    }
64}