alloy_network_primitives/
tx_builders.rsuse core::ops::{Deref, DerefMut};
use alloc::vec::Vec;
use alloy_consensus::BlobTransactionSidecar;
use alloy_eips::eip7702::SignedAuthorization;
use alloy_serde::WithOtherFields;
pub trait TransactionBuilder4844: Default + Sized + Send + Sync + 'static {
fn max_fee_per_blob_gas(&self) -> Option<u128>;
fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128);
fn with_max_fee_per_blob_gas(mut self, max_fee_per_blob_gas: u128) -> Self {
self.set_max_fee_per_blob_gas(max_fee_per_blob_gas);
self
}
fn blob_sidecar(&self) -> Option<&BlobTransactionSidecar>;
fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecar);
fn with_blob_sidecar(mut self, sidecar: BlobTransactionSidecar) -> Self {
self.set_blob_sidecar(sidecar);
self
}
}
pub trait TransactionBuilder7702: Default + Sized + Send + Sync + 'static {
fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>>;
fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>);
fn with_authorization_list(mut self, authorization_list: Vec<SignedAuthorization>) -> Self {
self.set_authorization_list(authorization_list);
self
}
}
impl<T> TransactionBuilder4844 for WithOtherFields<T>
where
T: TransactionBuilder4844,
{
fn max_fee_per_blob_gas(&self) -> Option<u128> {
self.deref().max_fee_per_blob_gas()
}
fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128) {
self.deref_mut().set_max_fee_per_blob_gas(max_fee_per_blob_gas)
}
fn blob_sidecar(&self) -> Option<&BlobTransactionSidecar> {
self.deref().blob_sidecar()
}
fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecar) {
self.deref_mut().set_blob_sidecar(sidecar)
}
}
impl<T> TransactionBuilder7702 for WithOtherFields<T>
where
T: TransactionBuilder7702,
{
fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>> {
self.deref().authorization_list()
}
fn set_authorization_list(&mut self, authorization_list: Vec<SignedAuthorization>) {
self.deref_mut().set_authorization_list(authorization_list)
}
}