Skip to main content

foundry_primitives/network/
mod.rs

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