use crate::Network;
use alloy_consensus::TxType;
use alloy_eips::eip2718::Eip2718Error;
use alloy_rpc_types_eth::{AnyTransactionReceipt, Block, Header, Transaction, TransactionRequest};
use alloy_serde::WithOtherFields;
use core::fmt;
mod builder;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[doc(alias = "AnyTransactionType")]
pub struct AnyTxType(u8);
impl fmt::Display for AnyTxType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AnyTxType({})", self.0)
}
}
impl TryFrom<u8> for AnyTxType {
type Error = Eip2718Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Ok(Self(value))
}
}
impl From<AnyTxType> for u8 {
fn from(value: AnyTxType) -> Self {
value.0
}
}
impl TryFrom<AnyTxType> for TxType {
type Error = Eip2718Error;
fn try_from(value: AnyTxType) -> Result<Self, Self::Error> {
value.0.try_into()
}
}
impl From<TxType> for AnyTxType {
fn from(value: TxType) -> Self {
Self(value as u8)
}
}
#[derive(Clone, Copy, Debug)]
pub struct AnyNetwork {
_private: (),
}
impl Network for AnyNetwork {
type TxType = AnyTxType;
type TxEnvelope = alloy_consensus::TxEnvelope;
type UnsignedTx = alloy_consensus::TypedTransaction;
type ReceiptEnvelope = alloy_consensus::AnyReceiptEnvelope;
type Header = alloy_consensus::Header;
type TransactionRequest = WithOtherFields<TransactionRequest>;
type TransactionResponse = WithOtherFields<Transaction>;
type ReceiptResponse = AnyTransactionReceipt;
type HeaderResponse = Header;
type BlockResponse = WithOtherFields<Block<Self::TransactionResponse, Self::HeaderResponse>>;
}