Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions client/rpc/src/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use std::{collections::BTreeMap, iter, marker::PhantomData, sync::Arc};

use ethereum::BlockV2 as EthereumBlock;
use ethereum::{BlockV2 as EthereumBlock, TransactionV2 as EthereumTransaction};
use ethereum_types::{H256, U256};
use futures::{FutureExt as _, SinkExt as _, StreamExt as _};
use jsonrpc_core::Result as JsonRpcResult;
Expand Down Expand Up @@ -51,6 +51,8 @@ use fc_rpc_core::{
};
use fp_rpc::EthereumRuntimeRPCApi;

use sp_api::ApiExt;

use crate::{frontier_backend_client, overrides::OverrideHandle};

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
Expand Down Expand Up @@ -335,11 +337,34 @@ where
.filter_map(move |txhash| {
if let Some(xt) = pool.ready_transaction(&txhash) {
let best_block: BlockId<B> = BlockId::Hash(client.info().best_hash);
let res = match client
.runtime_api()
.extrinsic_filter(&best_block, vec![xt.data().clone()])

let api = client.runtime_api();

let api_version = if let Ok(Some(api_version)) =
api.api_version::<dyn EthereumRuntimeRPCApi<B>>(&best_block)
{
Ok(txs) => {
api_version
} else {
return futures::future::ready(None);
};

let xts = vec![xt.data().clone()];

let txs: Option<Vec<EthereumTransaction>> = if api_version > 1 {
api.extrinsic_filter(&best_block, xts).ok()
} else {
#[allow(deprecated)]
if let Ok(legacy) =
api.extrinsic_filter_before_version_2(&best_block, xts)
{
Some(legacy.into_iter().map(|tx| tx.into()).collect())
} else {
None
}
};

let res = match txs {
Some(txs) => {
if txs.len() == 1 {
Some(txs[0].clone())
} else {
Expand Down