Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions ethers-contract/tests/it/abigen.rs
Expand Up @@ -752,6 +752,7 @@ fn can_handle_overloaded_function_with_array() {
}

#[test]
#[allow(clippy::disallowed_names)]
fn convert_uses_correct_abi() {
abigen!(
Foo, r#"[function foo()]"#;
Expand Down
2 changes: 1 addition & 1 deletion ethers-providers/src/lib.rs
Expand Up @@ -76,7 +76,7 @@ pub trait JsonRpcClient: Debug + Send + Sync {
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
where
T: Debug + Serialize + Send + Sync,
R: DeserializeOwned;
R: DeserializeOwned + Send;
}

pub trait FromErr<T> {
Expand Down
4 changes: 2 additions & 2 deletions ethers-providers/src/provider.rs
Expand Up @@ -199,7 +199,7 @@ impl<P: JsonRpcClient> Provider<P> {
pub async fn request<T, R>(&self, method: &str, params: T) -> Result<R, ProviderError>
where
T: Debug + Serialize + Send + Sync,
R: Serialize + DeserializeOwned + Debug,
R: Serialize + DeserializeOwned + Debug + Send,
{
let span =
tracing::trace_span!("rpc", method = method, params = ?serde_json::to_string(&params)?);
Expand All @@ -215,7 +215,7 @@ impl<P: JsonRpcClient> Provider<P> {
Ok(res)
}

async fn get_block_gen<Tx: Default + Serialize + DeserializeOwned + Debug>(
async fn get_block_gen<Tx: Default + Serialize + DeserializeOwned + Debug + Send>(
&self,
id: BlockId,
include_txs: bool,
Expand Down
2 changes: 1 addition & 1 deletion ethers-providers/src/transports/retry.rs
Expand Up @@ -238,7 +238,7 @@ where
async fn request<A, R>(&self, method: &str, params: A) -> Result<R, Self::Error>
where
A: Debug + Serialize + Send + Sync,
R: DeserializeOwned,
R: DeserializeOwned + Send,
{
// 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
Expand Down
8 changes: 2 additions & 6 deletions ethers-providers/src/transports/rw.rs
Expand Up @@ -105,14 +105,10 @@ where

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