fix(provider): Add Send bound to return type of JsonRpcClient::request (#2072)

This commit is contained in:
wigy 2023-01-27 22:57:08 +01:00 committed by GitHub
parent 83b12a80e3
commit 7da559bbed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 10 deletions

View File

@ -752,6 +752,7 @@ fn can_handle_overloaded_function_with_array() {
} }
#[test] #[test]
#[allow(clippy::disallowed_names)]
fn convert_uses_correct_abi() { fn convert_uses_correct_abi() {
abigen!( abigen!(
Foo, r#"[function foo()]"#; Foo, r#"[function foo()]"#;

View File

@ -76,7 +76,7 @@ pub trait JsonRpcClient: Debug + Send + Sync {
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error> async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
where where
T: Debug + Serialize + Send + Sync, T: Debug + Serialize + Send + Sync,
R: DeserializeOwned; R: DeserializeOwned + Send;
} }
pub trait FromErr<T> { pub trait FromErr<T> {

View File

@ -199,7 +199,7 @@ impl<P: JsonRpcClient> Provider<P> {
pub async fn request<T, R>(&self, method: &str, params: T) -> Result<R, ProviderError> pub async fn request<T, R>(&self, method: &str, params: T) -> Result<R, ProviderError>
where where
T: Debug + Serialize + Send + Sync, T: Debug + Serialize + Send + Sync,
R: Serialize + DeserializeOwned + Debug, R: Serialize + DeserializeOwned + Debug + Send,
{ {
let span = let span =
tracing::trace_span!("rpc", method = method, params = ?serde_json::to_string(&params)?); tracing::trace_span!("rpc", method = method, params = ?serde_json::to_string(&params)?);
@ -215,7 +215,7 @@ impl<P: JsonRpcClient> Provider<P> {
Ok(res) Ok(res)
} }
async fn get_block_gen<Tx: Default + Serialize + DeserializeOwned + Debug>( async fn get_block_gen<Tx: Default + Serialize + DeserializeOwned + Debug + Send>(
&self, &self,
id: BlockId, id: BlockId,
include_txs: bool, include_txs: bool,

View File

@ -238,7 +238,7 @@ where
async fn request<A, R>(&self, method: &str, params: A) -> Result<R, Self::Error> async fn request<A, R>(&self, method: &str, params: A) -> Result<R, Self::Error>
where where
A: Debug + Serialize + Send + Sync, A: Debug + Serialize + Send + Sync,
R: DeserializeOwned, R: DeserializeOwned + Send,
{ {
// Helper type that caches the `params` value across several retries // Helper type that caches the `params` value across several retries
// This is necessary because the wrapper provider is supposed to skip he `params` if it's of // This is necessary because the wrapper provider is supposed to skip he `params` if it's of

View File

@ -105,14 +105,10 @@ where
/// Sends a POST request with the provided method and the params serialized as JSON /// Sends a POST request with the provided method and the params serialized as JSON
/// over HTTP /// over HTTP
async fn request<T: Serialize + Send + Sync, R: DeserializeOwned>( async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
&self,
method: &str,
params: T,
) -> Result<R, Self::Error>
where where
T: std::fmt::Debug + Serialize + Send + Sync, T: std::fmt::Debug + Serialize + Send + Sync,
R: DeserializeOwned, R: DeserializeOwned + Send,
{ {
match method { match method {
"eth_sendTransaction" | "eth_sendRawTransaction" => { "eth_sendTransaction" | "eth_sendRawTransaction" => {