diff --git a/CHANGELOG.md b/CHANGELOG.md index 43f7a742..214b2531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Unreleased +- Add a `Send` bound to the `IntoFuture` implementation of `ContractCall` [#2083](https://github.com/gakonst/ethers-rs/pull/2083) - Bump [`svm-rs`](https://github.com/roynalnaruto/svm-rs) dependency to fix conflicts with Rust Crytpo packages [#2051](https://github.com/gakonst/ethers-rs/pull/2051) - Avoid unnecessary allocations in `utils` [#2046](https://github.com/gakonst/ethers-rs/pull/2046) - Add abigen support for hardhat generated bytecode json format [#2012](https://github.com/gakonst/ethers-rs/pull/2012) diff --git a/ethers-contract/src/call.rs b/ethers-contract/src/call.rs index c9a8ab63..0c5a4985 100644 --- a/ethers-contract/src/call.rs +++ b/ethers-contract/src/call.rs @@ -225,10 +225,10 @@ impl IntoFuture for ContractCall where Self: 'static, M: Middleware, - D: Detokenize, + D: Detokenize + Send + Sync, { type Output = Result>; - type IntoFuture = Pin>>; + type IntoFuture = Pin + Send>>; fn into_future(self) -> Self::IntoFuture { Box::pin(async move { self.call().await }) diff --git a/ethers-contract/tests/it/contract_call.rs b/ethers-contract/tests/it/contract_call.rs new file mode 100644 index 00000000..c1708e04 --- /dev/null +++ b/ethers-contract/tests/it/contract_call.rs @@ -0,0 +1,21 @@ +use ethers_contract_derive::abigen; +use ethers_core::abi::Address; +use ethers_providers::Provider; +use std::{ + future::{Future, IntoFuture}, + sync::Arc, +}; + +#[tokio::test] +async fn contract_call_into_future_is_send() { + abigen!(DsProxyFactory, "ethers-middleware/contracts/DsProxyFactory.json"); + let (provider, _) = Provider::mocked(); + let client = Arc::new(provider); + let contract = DsProxyFactory::new(Address::zero(), client); + + fn is_send(future: T) -> bool { + true + } + + assert!(is_send(contract.cache().into_future())); +} diff --git a/ethers-contract/tests/it/main.rs b/ethers-contract/tests/it/main.rs index 4563e571..63414849 100644 --- a/ethers-contract/tests/it/main.rs +++ b/ethers-contract/tests/it/main.rs @@ -6,5 +6,6 @@ pub(crate) mod common; mod console; #[cfg(feature = "abigen")] mod contract; +mod contract_call; fn main() {}