Skip to main content

foundry_primitives/network/
mod.rs

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