Skip to content

Commit

Permalink
doc: more of them for anynetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
prestwich committed Oct 14, 2024
1 parent 6816308 commit 1f31e02
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions crates/network/src/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,28 @@ impl alloy_consensus::Transaction for AnyTypedTransaction {

/// Types for a catch-all network.
///
/// Essentially just returns the regular Ethereum types + a catch all field.
/// This [`Network`] should be used only when the network is not known at
/// compile time.
/// `AnyNetwork`'s associated types allow for many different types of
/// transactions, using catch-all fields. This [`Network`] should be used
/// only when the application needs to support multiple networks via the same
/// codepaths without knowing the networks at compile time.
///
/// ## Rough Edges
///
/// Supporting arbitrary unknown types is hard, and users of this network
/// should be aware of the following:
///
/// - The implementation of [`Decodable2718`] for [`AnyTxEnvelope`] will not work for non-Ethereum
/// transaction types. It will succesfully decode an Ethereum [`TxEnvelope`], but will decode only
/// the type for any unknown transaction type. It will also leave the buffer unconsumed, which
/// will cause further deserialization to produce erroneous results.
/// - The implementation of [`Encodable2718`] for [`AnyTypedTransaction`] will not work for
/// non-Ethereum transaction types. It will encode the type for any unknown transaction type, but
/// will not encode any other fields. This is symmetric with the decoding behavior, but still
/// erroneous.
/// - The [`TransactionRequest`] will build ONLY Ethereum types. It will error when attempting to
/// build any unknown type.
/// - The [`TransactionResponse`] may deserialize unknown metadata fields into the inner
/// [`AnyTxEnvelope`], rather than into the outer [`WithOtherFields`].
#[derive(Clone, Copy, Debug)]
pub struct AnyNetwork {
_private: (),
Expand Down

0 comments on commit 1f31e02

Please sign in to comment.