nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gakonst/ethers-rs
Pull request #846 (2022-01-31 07:17:04)

fix(solc): flatten replacement target location
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide: https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and building the
documentation.
-->

## Motivation

<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.
-->

Addresses [foundry #641](https://github.com/gakonst/foundry/issues/641)

## Solution

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->

The end location of the target replacement is adjusted to be exclusive. That's how it was primarily used during flattening.

## PR Checklist

- [x] Added Tests
- [x] Added Documentation
- [x] Updated the changelog



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ed9c6c6..a92aa447 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,8 @@
 
 ### Unreleased
 
+- Fix flatten replacement target location
+  [#846](https://github.com/gakonst/ethers-rs/pull/846)
 - Fix duplicate files during flattening
   [#813](https://github.com/gakonst/ethers-rs/pull/813)
 - Add ability to flatten file imports
diff --git a/ethers-solc/src/resolver.rs b/ethers-solc/src/resolver.rs
index e2c8403d..fce1c88d 100644
--- a/ethers-solc/src/resolver.rs
+++ b/ethers-solc/src/resolver.rs
@@ -485,7 +485,8 @@ impl<T> SolDataUnit<T> {
     pub fn loc_by_offset(&self, offset: isize) -> (usize, usize) {
         (
             offset.saturating_add(self.loc.start as isize) as usize,
-            offset.saturating_add(self.loc.end as isize) as usize,
+            // make the end location exclusive
+            offset.saturating_add(self.loc.end as isize + 1) as usize,
         )
     }
 }


Test patch:
diff --git a/ethers-solc/tests/project.rs b/ethers-solc/tests/project.rs
index c50fd3eb..f7b362d7 100644
--- a/ethers-solc/tests/project.rs
+++ b/ethers-solc/tests/project.rs
@@ -376,4 +376,5 @@ fn can_flatten_file_with_duplicates() {
     assert_eq!(result.matches("contract Foo {").count(), 1);
     assert_eq!(result.matches("contract Bar {").count(), 1);
     assert_eq!(result.matches("contract FooBar {").count(), 1);
+    assert_eq!(result.matches(";").count(), 1);
 }
Repository: gakonst/ethers-rs
Pull request #930 (2022-02-18 17:02:01)

fix(solc): off by one error finding version intersection
<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Contributors guide: https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md

The contributors guide includes instructions for running rustfmt and building the
documentation.
-->

## Motivation
followup https://github.com/gakonst/ethers-rs/pull/882

<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.
-->

## Solution
off by one while determining the intersection of versions
<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->

@lattejed what additional tests do we need?

## PR Checklist

- [ ] Added Tests
- [ ] Added Documentation
- [ ] Updated the changelog



Patch:
diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs
index 11fd3ad0..9841fcc6 100644
--- a/ethers-solc/src/compile/mod.rs
+++ b/ethers-solc/src/compile/mod.rs
@@ -79,7 +79,8 @@ pub static RELEASES: once_cell::sync::Lazy<(svm::Releases, Vec<Version>, bool)>
 
 /// A `Solc` version is either installed (available locally) or can be downloaded, from the remote
 /// endpoint
-#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
+#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
+#[serde(untagged)]
 pub enum SolcVersion {
     Installed(Version),
     Remote(Version),
diff --git a/ethers-solc/src/resolver.rs b/ethers-solc/src/resolver.rs
index 1d9a515a..16bfbc34 100644
--- a/ethers-solc/src/resolver.rs
+++ b/ethers-solc/src/resolver.rs
@@ -476,7 +476,7 @@ impl Graph {
             }
 
             let mut result = sets.pop().cloned().expect("not empty; qed.").clone();
-            if sets.len() > 1 {
+            if !sets.is_empty() {
                 result.retain(|item| sets.iter().all(|set| set.contains(item)));
             }
 


Test patch:
diff --git a/ethers-solc/tests/project.rs b/ethers-solc/tests/project.rs
index ac8c01f7..c1afeb4f 100644
--- a/ethers-solc/tests/project.rs
+++ b/ethers-solc/tests/project.rs
@@ -24,7 +24,6 @@ fn init_tracing() {
 }
 
 #[test]
-#[ignore]
 fn can_get_versioned_linkrefs() {
     let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test-data/test-versioned-linkrefs");
     let paths = ProjectPathsConfig::builder()
@@ -37,8 +36,6 @@ fn can_get_versioned_linkrefs() {
 
     let compiled = project.compile().unwrap();
     assert!(!compiled.has_compiler_errors());
-
-    // TODO:
 }
 
 #[test]
Repository: gakonst/ethers-rs
Pull request #2083 (2023-01-27 19:10:38)

Make ContractCall IntoFuture implement Send
## Motivation

Prior to this PR, it's not possible to move a `ContractCall` using Send via its `IntoFuture` implementation.

This means that, using Tokio, to spawn a non-local task, one must currently use `contract.the_method_to_call().call()`, instead of `contract.the_method_to_call()`. 

## Solution


This PR adds the `Send` bound to the `IntoFuture` implementation of `ContractCall`.


## PR Checklist

-   [x] Added Tests
-   [ ] Added Documentation
-   [x] Updated the changelog
-   [ ] Breaking changes



Patch:
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<M, D> IntoFuture for ContractCall<M, D>
 where
     Self: 'static,
     M: Middleware,
-    D: Detokenize,
+    D: Detokenize + Send + Sync,
 {
     type Output = Result<D, ContractError<M>>;
-    type IntoFuture = Pin<Box<dyn Future<Output = Self::Output>>>;
+    type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
 
     fn into_future(self) -> Self::IntoFuture {
         Box::pin(async move { self.call().await })


Test patch:
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<T: Future + Send + 'static>(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() {}