|
2 | 2 |
|
3 | 3 | use crate::fees::{CallFees, CallFeesError};
|
4 | 4 | use alloy_consensus::{
|
5 |
| - error::ValueError, transaction::Recovered, EthereumTxEnvelope, SignableTransaction, TxEip4844, |
| 5 | + error::ValueError, transaction::Recovered, EthereumTxEnvelope, Extended, SignableTransaction, |
| 6 | + Transaction as ConsensusTransaction, TxEip4844, |
6 | 7 | };
|
7 | 8 | use alloy_network::Network;
|
8 | 9 | use alloy_primitives::{Address, Bytes, Signature, TxKind, U256};
|
@@ -94,6 +95,33 @@ pub trait IntoRpcTx<T> {
|
94 | 95 | fn into_rpc_tx(self, signer: Address, tx_info: Self::TxInfo) -> T;
|
95 | 96 | }
|
96 | 97 |
|
| 98 | +impl<BuiltIn, Other> IntoRpcTx<Transaction<Self>> for Extended<BuiltIn, Other> |
| 99 | +where |
| 100 | + BuiltIn: ConsensusTransaction, |
| 101 | + Other: ConsensusTransaction, |
| 102 | +{ |
| 103 | + type TxInfo = TransactionInfo; |
| 104 | + |
| 105 | + fn into_rpc_tx(self, signer: Address, tx_info: Self::TxInfo) -> Transaction<Self> { |
| 106 | + let TransactionInfo { |
| 107 | + block_hash, block_number, index: transaction_index, base_fee, .. |
| 108 | + } = tx_info; |
| 109 | + let effective_gas_price = base_fee |
| 110 | + .map(|base_fee| { |
| 111 | + self.effective_tip_per_gas(base_fee).unwrap_or_default() + base_fee as u128 |
| 112 | + }) |
| 113 | + .unwrap_or_else(|| self.max_fee_per_gas()); |
| 114 | + |
| 115 | + Transaction { |
| 116 | + inner: Recovered::new_unchecked(self, signer), |
| 117 | + block_hash, |
| 118 | + block_number, |
| 119 | + transaction_index, |
| 120 | + effective_gas_price: Some(effective_gas_price), |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | + |
97 | 125 | /// Converts `self` into `T`.
|
98 | 126 | ///
|
99 | 127 | /// Should create a fake transaction for simulation using [`TransactionRequest`].
|
|
0 commit comments