mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
EIP4844 variant to TypedTransactionRequest (#5005)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
committed by
GitHub
parent
15fe5edf06
commit
92ceb2fca9
@ -5,10 +5,11 @@
|
||||
|
||||
use alloy_rlp::{BufMut, Decodable, Encodable, Error as RlpError, RlpDecodable, RlpEncodable};
|
||||
use reth_primitives::{
|
||||
AccessList, Address, Bytes, Transaction, TxEip1559, TxEip2930, TxLegacy, U128, U256, U64,
|
||||
kzg::{Blob, Bytes48},
|
||||
AccessList, Address, Bytes, Transaction, TxEip1559, TxEip2930, TxEip4844, TxLegacy, B256, U128,
|
||||
U256, U64,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Container type for various Ethereum transaction requests
|
||||
///
|
||||
/// Its variants correspond to specific allowed transactions:
|
||||
@ -20,6 +21,7 @@ pub enum TypedTransactionRequest {
|
||||
Legacy(LegacyTransactionRequest),
|
||||
EIP2930(EIP2930TransactionRequest),
|
||||
EIP1559(EIP1559TransactionRequest),
|
||||
EIP4844(Eip4844TransactionRequest),
|
||||
}
|
||||
|
||||
impl TypedTransactionRequest {
|
||||
@ -61,6 +63,19 @@ impl TypedTransactionRequest {
|
||||
access_list: tx.access_list,
|
||||
max_priority_fee_per_gas: tx.max_priority_fee_per_gas.to(),
|
||||
}),
|
||||
TypedTransactionRequest::EIP4844(tx) => Transaction::Eip4844(TxEip4844 {
|
||||
chain_id: tx.chain_id,
|
||||
nonce: tx.nonce.to(),
|
||||
gas_limit: tx.gas_limit.to(),
|
||||
max_fee_per_gas: tx.max_fee_per_gas.to(),
|
||||
max_priority_fee_per_gas: tx.max_priority_fee_per_gas.to(),
|
||||
to: tx.kind.into(),
|
||||
value: tx.value.into(),
|
||||
access_list: tx.access_list,
|
||||
blob_versioned_hashes: tx.blob_versioned_hashes,
|
||||
max_fee_per_blob_gas: tx.max_fee_per_blob_gas,
|
||||
input: tx.input,
|
||||
}),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -104,6 +119,24 @@ pub struct EIP1559TransactionRequest {
|
||||
pub access_list: AccessList,
|
||||
}
|
||||
|
||||
/// Represents an EIP-4844 transaction request
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Eip4844TransactionRequest {
|
||||
pub chain_id: u64,
|
||||
pub nonce: U64,
|
||||
pub max_priority_fee_per_gas: U128,
|
||||
pub max_fee_per_gas: U128,
|
||||
pub gas_limit: U256,
|
||||
pub kind: TransactionKind,
|
||||
pub value: U256,
|
||||
pub input: Bytes,
|
||||
pub access_list: AccessList,
|
||||
pub max_fee_per_blob_gas: u128,
|
||||
pub blob_versioned_hashes: Vec<B256>,
|
||||
pub gas_price: U128,
|
||||
pub sidecar: BlobTransactionSidecar,
|
||||
}
|
||||
|
||||
/// Represents the `to` field of a transaction request
|
||||
///
|
||||
/// This determines what kind of transaction this is
|
||||
@ -166,3 +199,14 @@ impl From<TransactionKind> for reth_primitives::TransactionKind {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This represents a set of blobs, and its corresponding commitments and proofs.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
pub struct BlobTransactionSidecar {
|
||||
/// The blob data.
|
||||
pub blobs: Vec<Blob>,
|
||||
/// The blob commitments.
|
||||
pub commitments: Vec<Bytes48>,
|
||||
/// The blob proofs.
|
||||
pub proofs: Vec<Bytes48>,
|
||||
}
|
||||
|
||||
@ -501,6 +501,13 @@ where
|
||||
|
||||
TypedTransactionRequest::EIP1559(m)
|
||||
}
|
||||
Some(TypedTransactionRequest::EIP4844(mut m)) => {
|
||||
m.chain_id = chain_id.to();
|
||||
m.gas_limit = gas_limit;
|
||||
m.gas_price = gas_price;
|
||||
|
||||
TypedTransactionRequest::EIP4844(m)
|
||||
}
|
||||
None => return Err(EthApiError::ConflictingFeeFieldsInRequest),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user