diff --git a/client/rpc/src/eth_pubsub.rs b/client/rpc/src/eth_pubsub.rs index a54f10c167..fa676a0062 100644 --- a/client/rpc/src/eth_pubsub.rs +++ b/client/rpc/src/eth_pubsub.rs @@ -29,7 +29,7 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_runtime::traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto}; 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 fc_rpc_core::{ types::{ @@ -53,6 +53,8 @@ use jsonrpc_core::Result as JsonRpcResult; use sc_network::{ExHashT, NetworkService}; +use sp_api::ApiExt; + use crate::{frontier_backend_client, overrides::OverrideHandle}; #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] @@ -348,11 +350,32 @@ where .filter_map(move |txhash| { if let Some(xt) = pool.ready_transaction(&txhash) { let best_block: BlockId = BlockId::Hash(client.info().best_hash); - let res = match client - .runtime_api() - .extrinsic_filter(&best_block, vec![xt.data().clone()]) - { - Ok(txs) => { + + let api = client.runtime_api(); + + let api_version = + if let Ok(Some(api_version)) = api.api_version::>(&best_block) { + api_version + } else { + return futures::future::ready(None); + }; + + let xts = vec![xt.data().clone()]; + + let txs: Option> = 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 {