Skip to content

Commit

Permalink
fix: pending RPC transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Aug 16, 2024
1 parent 9703bce commit 4db9378
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions crates/edr_evm/src/block/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ impl RpcTypeFrom<TransactionAndBlock<L1ChainSpec>> for edr_rpc_eth::TransactionW
)
.unzip();

let transaction =
edr_rpc_eth::Transaction::new(&value.transaction, header, transaction_index, hardfork);
let transaction = edr_rpc_eth::Transaction::new(
&value.transaction,
header,
transaction_index,
value.is_pending,
hardfork,
);
let signature = value.transaction.signature();

edr_rpc_eth::TransactionWithSignature::new(
Expand Down
1 change: 1 addition & 0 deletions crates/edr_optimism/src/rpc/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl RpcTypeFrom<TransactionAndBlock<OptimismChainSpec>> for Transaction {
&value.transaction,
header,
transaction_index,
value.is_pending,
hardfork.into(),
);

Expand Down
10 changes: 8 additions & 2 deletions crates/edr_rpc_eth/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl Transaction {
+ IsLegacy),
header: Option<&block::Header>,
transaction_index: Option<u64>,
is_pending: bool,
hardfork: SpecId,
) -> Self {
let base_fee = header.and_then(|header| header.base_fee_per_gas);
Expand Down Expand Up @@ -118,8 +119,13 @@ impl Transaction {
None
};

let (block_hash, block_number) =
header.map(|header| (header.hash(), header.number)).unzip();
let (block_hash, block_number) = if is_pending {
(None, None)
} else {
header.map(|header| (header.hash(), header.number)).unzip()
};

let transaction_index = if is_pending { None } else { transaction_index };

let access_list = if transaction.has_access_list() {
Some(transaction.access_list().to_vec())
Expand Down

0 comments on commit 4db9378

Please sign in to comment.