mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 16:18:08 -05:00
feat(rpc): Implement IntoRpcTx with Ethereum RPC transaction response for Extended (#16783)
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
use crate::fees::{CallFees, CallFeesError};
|
||||
use alloy_consensus::{
|
||||
error::ValueError, transaction::Recovered, EthereumTxEnvelope, SignableTransaction, TxEip4844,
|
||||
error::ValueError, transaction::Recovered, EthereumTxEnvelope, Extended, SignableTransaction,
|
||||
Transaction as ConsensusTransaction, TxEip4844,
|
||||
};
|
||||
use alloy_network::Network;
|
||||
use alloy_primitives::{Address, Bytes, Signature, TxKind, U256};
|
||||
@@ -94,6 +95,33 @@ pub trait IntoRpcTx<T> {
|
||||
fn into_rpc_tx(self, signer: Address, tx_info: Self::TxInfo) -> T;
|
||||
}
|
||||
|
||||
impl<BuiltIn, Other> IntoRpcTx<Transaction<Self>> for Extended<BuiltIn, Other>
|
||||
where
|
||||
BuiltIn: ConsensusTransaction,
|
||||
Other: ConsensusTransaction,
|
||||
{
|
||||
type TxInfo = TransactionInfo;
|
||||
|
||||
fn into_rpc_tx(self, signer: Address, tx_info: Self::TxInfo) -> Transaction<Self> {
|
||||
let TransactionInfo {
|
||||
block_hash, block_number, index: transaction_index, base_fee, ..
|
||||
} = tx_info;
|
||||
let effective_gas_price = base_fee
|
||||
.map(|base_fee| {
|
||||
self.effective_tip_per_gas(base_fee).unwrap_or_default() + base_fee as u128
|
||||
})
|
||||
.unwrap_or_else(|| self.max_fee_per_gas());
|
||||
|
||||
Transaction {
|
||||
inner: Recovered::new_unchecked(self, signer),
|
||||
block_hash,
|
||||
block_number,
|
||||
transaction_index,
|
||||
effective_gas_price: Some(effective_gas_price),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts `self` into `T`.
|
||||
///
|
||||
/// Should create a fake transaction for simulation using [`TransactionRequest`].
|
||||
|
||||
Reference in New Issue
Block a user