Repository: gakonst/ethers-rs
Pull request #1147 (2022-04-15 03:10:17)

chore(deps): bump tracing from 0.1.33 to 0.1.34
Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.33 to 0.1.34.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/tokio-rs/tracing/releases">tracing's releases</a>.</em></p>
<blockquote>
<h2>tracing 0.1.34</h2>
<p>This release includes bug fixes for the &quot;log&quot; support feature and for the use of
both scoped and global default dispatchers in the same program.</p>
<h3>Fixed</h3>
<ul>
<li>Failure to use the global default dispatcher when a thread sets a local
default dispatcher before the global default is set (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2065">#2065</a>)</li>
<li><strong>log</strong>: Compilation errors due to <code>async</code> block/fn futures becoming <code>!Send</code>
when the &quot;log&quot; feature flag is enabled (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2073">#2073</a>)</li>
<li>Broken links in documentation (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2068">#2068</a>)</li>
</ul>
<p>Thanks to <a href="https://github.com/ben0x539"><code>@​ben0x539</code></a> for contributing to this release!</p>
<p><a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2065">#2065</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tracing/pull/2065">tokio-rs/tracing#2065</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2073">#2073</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tracing/pull/2073">tokio-rs/tracing#2073</a>
<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2068">#2068</a>: <a href="https://github-redirect.dependabot.com/tokio-rs/tracing/pull/2068">tokio-rs/tracing#2068</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/tokio-rs/tracing/commit/4f1e46306d4d364fcc69691fdb29a676c7105f72"><code>4f1e463</code></a> tracing: prepare to release v0.1.34 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2076">#2076</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/cb294a99582222a7c515922c22607b1838606ba2"><code>cb294a9</code></a> core: prepare to release v0.1.26</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/96347c7b78d58f3d51b0979cfbe8499dac406583"><code>96347c7</code></a> core: add <code>Value</code> impl for <code>Box\&lt;T&gt; where T: Value</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2071">#2071</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/8c67359846557371bb2fdee2f6534af1ec35c576"><code>8c67359</code></a> tracing: fix the &quot;log&quot; feature making async block futures <code>!Send</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2073">#2073</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/438b013c0174435b5081e69780630b34deaf1cf7"><code>438b013</code></a> docs: use intra-doc links instead of relative file paths (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2068">#2068</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/9d10e2cfe0e9d2d044462ec9e002668a80d45c5d"><code>9d10e2c</code></a> core: prepare to release v0.1.25 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2070">#2070</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/50a726b6470bdd939528a9788434e0eafd0b3348"><code>50a726b</code></a> core: impl <code>Value</code> for <code>dyn Error + Send/Sync</code> (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2066">#2066</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/fc694a5bcc8c97a774f43e8c2c8b6297f5aa2365"><code>fc694a5</code></a> core: fix scoped dispatchers clobbering the global default  (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2065">#2065</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/3c85d9c85c01a881e7d6292d37a3f8ac351beebf"><code>3c85d9c</code></a> subscriber: fix doc link for impl Layer for Vec (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2064">#2064</a>)</li>
<li><a href="https://github.com/tokio-rs/tracing/commit/b9da5441ea0de983e6ad9c2e8c342938779f3e95"><code>b9da544</code></a> subscriber: prepare to release v0.3.11 (<a href="https://github-redirect.dependabot.com/tokio-rs/tracing/issues/2062">#2062</a>)</li>
<li>See full diff in <a href="https://github.com/tokio-rs/tracing/compare/tracing-0.1.33...tracing-0.1.34">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tracing&package-manager=cargo&previous-version=0.1.33&new-version=0.1.34)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index dac6a7a5..af7b567c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3522,9 +3522,9 @@ dependencies = [
 
 [[package]]
 name = "solang-parser"
-version = "0.1.11"
+version = "0.1.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90f49c1bb28a8814fdac132b1ec1f2f65c656186d8dfbc411db8bcaba45cdc06"
+checksum = "e6b2ad9c159bd02219a59368133301e6195fdaa2b5d55c628ccdcd611d49235f"
 dependencies = [
  "lalrpop",
  "lalrpop-util",
@@ -3585,7 +3585,7 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
 [[package]]
 name = "svm-rs"
 version = "0.2.9"
-source = "git+https://github.com/roynalnaruto/svm-rs#9c86111689147842dd76f5fe8db7cf472e729118"
+source = "git+https://github.com/roynalnaruto/svm-rs#1eb7f4e2ccb549096885ded598f6c05b2d96dccf"
 dependencies = [
  "anyhow",
  "cfg-if 1.0.0",
@@ -3614,7 +3614,7 @@ dependencies = [
 [[package]]
 name = "svm-rs-builds"
 version = "0.1.0"
-source = "git+https://github.com/roynalnaruto/svm-rs#9c86111689147842dd76f5fe8db7cf472e729118"
+source = "git+https://github.com/roynalnaruto/svm-rs#1eb7f4e2ccb549096885ded598f6c05b2d96dccf"
 dependencies = [
  "build_const",
  "hex",
@@ -3898,9 +3898,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
 
 [[package]]
 name = "tracing"
-version = "0.1.33"
+version = "0.1.34"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "80b9fa4360528139bc96100c160b7ae879f5567f49f1782b0b02035b0358ebf3"
+checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
 dependencies = [
  "cfg-if 1.0.0",
  "pin-project-lite",
diff --git a/ethers-contract/ethers-contract-derive/src/display.rs b/ethers-contract/ethers-contract-derive/src/display.rs
index 45918207..8fc613f1 100644
--- a/ethers-contract/ethers-contract-derive/src/display.rs
+++ b/ethers-contract/ethers-contract-derive/src/display.rs
@@ -42,7 +42,7 @@ pub(crate) fn derive_eth_display_impl(input: DeriveInput) -> Result<TokenStream,
                 }
                 ParamType::Bytes => {
                     quote! {
-                         write!(f, "0x{}", #hex_encode(self.#ident))?;
+                         write!(f, "0x{}", #hex_encode(&self.#ident))?;
                     }
                 }
                 ParamType::Bool | ParamType::String => {
diff --git a/ethers-contract/ethers-contract-derive/src/utils.rs b/ethers-contract/ethers-contract-derive/src/utils.rs
index 066cbbfa..abef0999 100644
--- a/ethers-contract/ethers-contract-derive/src/utils.rs
+++ b/ethers-contract/ethers-contract-derive/src/utils.rs
@@ -111,10 +111,26 @@ pub fn find_parameter_type(ty: &Type) -> Result<ParamType, Error> {
             Err(Error::new(ty.span(), "Failed to derive proper ABI from array field"))
         }
         Type::Path(ty) => {
-            if let Some(ident) = ty.path.get_ident() {
+            // check for `Vec`
+            if ty.path.segments.len() == 1 && ty.path.segments[0].ident == "Vec" {
+                if let PathArguments::AngleBracketed(ref args) = ty.path.segments[0].arguments {
+                    if args.args.len() == 1 {
+                        if let GenericArgument::Type(ref ty) = args.args.iter().next().unwrap() {
+                            let kind = find_parameter_type(ty)?;
+                            return Ok(ParamType::Array(Box::new(kind)))
+                        }
+                    }
+                }
+            }
+            let mut ident = ty.path.get_ident();
+            if ident.is_none() {
+                ident = ty.path.segments.last().map(|s| &s.ident);
+            }
+            if let Some(ident) = ident {
                 let ident = ident.to_string().to_lowercase();
                 return match ident.as_str() {
                     "address" => Ok(ParamType::Address),
+                    "bytes" => Ok(ParamType::Bytes),
                     "string" => Ok(ParamType::String),
                     "bool" => Ok(ParamType::Bool),
                     "int" | "uint" => Ok(ParamType::Uint(256)),
@@ -126,18 +142,6 @@ pub fn find_parameter_type(ty: &Type) -> Result<ParamType, Error> {
                     }),
                 }
             }
-            // check for `Vec`
-            if ty.path.segments.len() == 1 && ty.path.segments[0].ident == "Vec" {
-                if let PathArguments::AngleBracketed(ref args) = ty.path.segments[0].arguments {
-                    if args.args.len() == 1 {
-                        if let GenericArgument::Type(ref ty) = args.args.iter().next().unwrap() {
-                            let kind = find_parameter_type(ty)?;
-                            return Ok(ParamType::Array(Box::new(kind)))
-                        }
-                    }
-                }
-            }
-
             Err(Error::new(ty.span(), "Failed to derive proper ABI from fields"))
         }
         Type::Tuple(ty) => {
diff --git a/ethers-core/src/types/log.rs b/ethers-core/src/types/log.rs
index 934ef466..dd70fa79 100644
--- a/ethers-core/src/types/log.rs
+++ b/ethers-core/src/types/log.rs
@@ -65,6 +65,15 @@ pub struct Log {
     pub removed: Option<bool>,
 }
 
+impl rlp::Encodable for Log {
+    fn rlp_append(&self, s: &mut rlp::RlpStream) {
+        s.begin_list(3);
+        s.append(&self.address);
+        s.append_list(&self.topics);
+        s.append(&self.data.0);
+    }
+}
+
 #[derive(Copy, Clone, Debug, PartialEq)]
 pub enum FilterBlockOption {
     Range { from_block: Option<BlockNumber>, to_block: Option<BlockNumber> },
diff --git a/ethers-core/src/types/transaction/response.rs b/ethers-core/src/types/transaction/response.rs
index 1c4fc76c..2968dc71 100644
--- a/ethers-core/src/types/transaction/response.rs
+++ b/ethers-core/src/types/transaction/response.rs
@@ -414,6 +414,16 @@ pub struct TransactionReceipt {
     pub effective_gas_price: Option<U256>,
 }
 
+impl rlp::Encodable for TransactionReceipt {
+    fn rlp_append(&self, s: &mut RlpStream) {
+        s.begin_list(4);
+        s.append(&self.status);
+        s.append(&self.cumulative_gas_used);
+        s.append(&self.logs_bloom);
+        s.append_list(&self.logs);
+    }
+}
+
 #[cfg(test)]
 #[cfg(not(feature = "celo"))]
 mod tests {
diff --git a/ethers-middleware/Cargo.toml b/ethers-middleware/Cargo.toml
index afdb013a..6c0b3167 100644
--- a/ethers-middleware/Cargo.toml
+++ b/ethers-middleware/Cargo.toml
@@ -24,7 +24,7 @@ async-trait = { version = "0.1.50", default-features = false }
 serde = { version = "1.0.124", default-features = false, features = ["derive"] }
 thiserror = { version = "1.0.30", default-features = false }
 futures-util = { version = "^0.3" }
-tracing = { version = "0.1.33", default-features = false }
+tracing = { version = "0.1.34", default-features = false }
 tracing-futures = { version = "0.2.5", default-features = false }
 
 # for gas oracles
diff --git a/ethers-providers/Cargo.toml b/ethers-providers/Cargo.toml
index 1a437f83..0e9eb75c 100644
--- a/ethers-providers/Cargo.toml
+++ b/ethers-providers/Cargo.toml
@@ -35,7 +35,7 @@ futures-channel = { version = "0.3.16", default-features = false, optional = tru
 pin-project = { version = "1.0.7", default-features = false }
 
 # tracing
-tracing = { version = "0.1.33", default-features = false }
+tracing = { version = "0.1.34", default-features = false }
 tracing-futures = { version = "0.2.5", default-features = false, features = ["std-future"] }
 
 bytes = { version  = "1.1.0", default-features = false, optional = true }
diff --git a/ethers-signers/Cargo.toml b/ethers-signers/Cargo.toml
index fc4eda84..8714080b 100644
--- a/ethers-signers/Cargo.toml
+++ b/ethers-signers/Cargo.toml
@@ -33,7 +33,7 @@ trezor-client = { version = "0.0.5", optional = true, default-features = false,
 # aws
 rusoto_core = { version = "0.47.0", optional = true }
 rusoto_kms = { version = "0.47.0", optional = true }
-tracing = { version = "0.1.33", optional = true }
+tracing = { version = "0.1.34", optional = true }
 spki = { version = "0.5.4", optional = true }
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
diff --git a/ethers-solc/Cargo.toml b/ethers-solc/Cargo.toml
index e832d5b8..4e8e56f7 100644
--- a/ethers-solc/Cargo.toml
+++ b/ethers-solc/Cargo.toml
@@ -28,14 +28,14 @@ thiserror = "1.0.30"
 hex = "0.4.3"
 colored = "2.0.0"
 glob = "0.3.0"
-tracing = "0.1.33"
+tracing = "0.1.34"
 num_cpus = "1.13.1"
 tiny-keccak = { version = "2.0.2", default-features = false }
 tempfile = { version = "3.3.0", optional = true }
 fs_extra = { version = "1.2.0", optional = true }
 sha2 = { version = "0.9.8", default-features = false, optional = true }
 dunce = "1.0.2"
-solang-parser = { default-features = false, version = "0.1.11" }
+solang-parser = { default-features = false, version = "0.1.12" }
 rayon = "1.5.1"
 rand = { version = "0.8.5", optional = true }
 
diff --git a/ethers-solc/src/config.rs b/ethers-solc/src/config.rs
index d39db454..3b67de83 100644
--- a/ethers-solc/src/config.rs
+++ b/ethers-solc/src/config.rs
@@ -311,7 +311,7 @@ impl ProjectPathsConfig {
         for import in imports.iter() {
             let import_path = self.resolve_import(target_dir, import.data())?;
             let s = self.flatten_node(&import_path, graph, imported, true, true, true)?;
-            let import_content = s.trim().as_bytes();
+            let import_content = s.as_bytes();
             let import_content_len = import_content.len() as isize;
             let (start, end) = import.loc_by_offset(offset);
             content.splice(start..end, import_content.iter().copied());
@@ -321,6 +321,7 @@ impl ProjectPathsConfig {
         let result = String::from_utf8(content).map_err(|err| {
             SolcError::msg(format!("failed to convert extended bytes to string: {}", err))
         })?;
+        let result = utils::RE_THREE_OR_MORE_NEWLINES.replace_all(&result, "\n\n").into_owned();
 
         Ok(result)
     }
diff --git a/ethers-solc/src/utils.rs b/ethers-solc/src/utils.rs
index cbc42d51..bd354228 100644
--- a/ethers-solc/src/utils.rs
+++ b/ethers-solc/src/utils.rs
@@ -32,6 +32,9 @@ pub static RE_SOL_PRAGMA_VERSION: Lazy<Regex> =
 pub static RE_SOL_SDPX_LICENSE_IDENTIFIER: Lazy<Regex> =
     Lazy::new(|| Regex::new(r"///?\s*SPDX-License-Identifier:\s*(?P<license>.+)").unwrap());
 
+/// A regex used to remove extra lines in flatenned files
+pub static RE_THREE_OR_MORE_NEWLINES: Lazy<Regex> = Lazy::new(|| Regex::new("\n{3,}").unwrap());
+
 /// Returns all path parts from any solidity import statement in a string,
 /// `import "./contracts/Contract.sol";` -> `"./contracts/Contract.sol"`.
 ///


Test patch:
diff --git a/ethers-contract/tests/common/derive.rs b/ethers-contract/tests/common/derive.rs
index 65f07ca7..25dd7aaf 100644
--- a/ethers-contract/tests/common/derive.rs
+++ b/ethers-contract/tests/common/derive.rs
@@ -583,3 +583,16 @@ fn can_derive_array_tuples() {
         pub calldata: Bytes,
     }
 }
+
+#[test]
+fn eth_display_works_on_ethers_bytes() {
+    #[derive(Clone, Debug, Default, Eq, PartialEq, EthCall, EthDisplay)]
+    #[ethcall(name = "logBytes", abi = "logBytes(bytes)")]
+    pub struct LogBytesCall {
+        pub p_0: ethers_core::types::Bytes,
+    }
+    let call = LogBytesCall { p_0: hex::decode(b"aaaaaa").unwrap().into() };
+
+    let s = format!("{}", call);
+    assert_eq!(s, "0xaaaaaa");
+}
diff --git a/ethers-solc/tests/project.rs b/ethers-solc/tests/project.rs
index 86939884..2b360c9e 100644
--- a/ethers-solc/tests/project.rs
+++ b/ethers-solc/tests/project.rs
@@ -492,8 +492,11 @@ contract C { }
         result,
         r#"
 pragma solidity ^0.8.10;
+
 contract C { }
+
 contract B { }
+
 contract A { }
 "#
     );
@@ -547,8 +550,11 @@ contract C { }
         r#"
 pragma solidity ^0.8.10;
 pragma experimental ABIEncoderV2;
+
 contract C { }
+
 contract B { }
+
 contract A { }
 "#
     );
@@ -572,6 +578,7 @@ fn can_flatten_file_with_duplicates() {
 pragma solidity >=0.6.0;
 
 contract Bar {}
+
 contract Foo {}
 
 contract FooBar {}
@@ -598,6 +605,7 @@ fn can_flatten_on_solang_failure() {
 pragma solidity ^0.8.10;
 
 library Lib {}
+
 // Intentionally erroneous code
 contract Contract {
     failure();
@@ -650,9 +658,64 @@ contract C { }
     assert_eq!(
         result.trim(),
         r#"pragma solidity ^0.8.10;
+
 contract C { }
+
 error IllegalArgument();
 error IllegalState();
+
+contract A { }"#
+    );
+}
+
+#[test]
+fn can_flatten_remove_extra_spacing() {
+    let project = TempProject::dapptools().unwrap();
+
+    let f = project
+        .add_source(
+            "A",
+            r#"pragma solidity ^0.8.10;
+import "./C.sol";
+import "./B.sol";
+contract A { }
+"#,
+        )
+        .unwrap();
+
+    project
+        .add_source(
+            "B",
+            r#"// This is a B Contract
+pragma solidity ^0.8.10;
+
+import "./C.sol";
+
+contract B { }
+"#,
+        )
+        .unwrap();
+
+    project
+        .add_source(
+            "C",
+            r#"pragma solidity ^0.8.10;
+contract C { }
+"#,
+        )
+        .unwrap();
+
+    let result = project.flatten(&f).unwrap();
+    assert_eq!(
+        result.trim(),
+        r#"pragma solidity ^0.8.10;
+
+contract C { }
+
+// This is a B Contract
+
+contract B { }
+
 contract A { }"#
     );
 }