From 29a3a1608524b2c21dd605bae80bd3f25f20486f Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Sun, 10 Jan 2021 14:03:37 +0200 Subject: [PATCH] chore: upgrade to latest ethtypes (#137) * chore: upgrade to latest ethtypes * chore: fix doctests --- Cargo.lock | 56 +++++++++---------- .../ethers-contract-derive/src/abigen.rs | 4 +- ethers-contract/src/contract.rs | 8 +-- ethers-contract/tests/common/mod.rs | 8 +-- ethers-core/Cargo.toml | 6 +- ethers-core/src/abi/human_readable.rs | 4 +- ethers-core/src/types/bytes.rs | 6 ++ ethers-core/src/types/transaction.rs | 6 +- 8 files changed, 51 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58b273c6..64fae011 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -547,36 +547,38 @@ dependencies = [ [[package]] name = "ethabi-next" -version = "12.0.1" +version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523719389cb738dda51fb8d22c96960e192da6263cdf1e08e7dc8c59de4cb032" +checksum = "f4bb43ca3464de349cd4f94bb37113eb4938dfb7df1a28320049bbbe3e9ffc6a" dependencies = [ + "anyhow", "ethereum-types", - "rustc-hex", + "hex", "serde", "serde_json", - "tiny-keccak 1.5.0", + "sha3", + "thiserror", "uint", ] [[package]] name = "ethbloom" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" +checksum = "22a621dcebea74f2a6f2002d0a885c81ccf6cbdf86760183316a7722b5707ca4" dependencies = [ "crunchy", "fixed-hash", "impl-rlp", "impl-serde", - "tiny-keccak 2.0.2", + "tiny-keccak", ] [[package]] name = "ethereum-types" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" +checksum = "05dc5f0df4915fa6dff7f975a8366ecfaaa8959c74235469495153e7bb1b280e" dependencies = [ "ethbloom", "fixed-hash", @@ -672,7 +674,7 @@ dependencies = [ "serde", "serde_json", "thiserror", - "tiny-keccak 2.0.2", + "tiny-keccak", ] [[package]] @@ -768,12 +770,12 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ "byteorder", - "rand 0.7.3", + "rand 0.8.0", "rustc-hex", "static_assertions", ] @@ -1134,9 +1136,9 @@ dependencies = [ [[package]] name = "impl-rlp" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" dependencies = [ "rlp", ] @@ -1568,9 +1570,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "primitive-types" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" +checksum = "b3824ae2c5e27160113b9e029a10ec9e3f0237bad8029f69c7724393c9fdefd8" dependencies = [ "fixed-hash", "impl-codec", @@ -1818,10 +1820,11 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" [[package]] name = "rlp" -version = "0.4.6" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" +checksum = "e54369147e3e7796c9b885c7304db87ca3d09a0a98f72843d532868675bbfba8" dependencies = [ + "bytes 1.0.0", "rustc-hex", ] @@ -2147,15 +2150,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -2339,13 +2333,13 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "uint" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +checksum = "e11fe9a9348741cf134085ad57c249508345fe16411b3d7fb4ff2da2f1d6382e" dependencies = [ "byteorder", "crunchy", - "rustc-hex", + "hex", "static_assertions", ] diff --git a/ethers-contract/ethers-contract-derive/src/abigen.rs b/ethers-contract/ethers-contract-derive/src/abigen.rs index 2d095562..ac718a88 100644 --- a/ethers-contract/ethers-contract-derive/src/abigen.rs +++ b/ethers-contract/ethers-contract-derive/src/abigen.rs @@ -173,6 +173,7 @@ impl Parse for Method { }) .collect::>>()?; + #[allow(deprecated)] Function { name, inputs, @@ -180,7 +181,8 @@ impl Parse for Method { // NOTE: The output types and const-ness of the function do not // affect its signature. outputs: vec![], - state_mutability: StateMutability::Nonpayable, + state_mutability: StateMutability::NonPayable, + constant: false, } }; let signature = function.abi_signature(); diff --git a/ethers-contract/src/contract.rs b/ethers-contract/src/contract.rs index bbadfe57..8d03da1d 100644 --- a/ethers-contract/src/contract.rs +++ b/ethers-contract/src/contract.rs @@ -129,10 +129,10 @@ use std::{fmt::Debug, marker::PhantomData, sync::Arc}; /// /// impl Detokenize for ValueChanged { /// fn from_tokens(tokens: Vec) -> Result { -/// let old_author: Address = tokens[1].clone().to_address().unwrap(); -/// let new_author: Address = tokens[1].clone().to_address().unwrap(); -/// let old_value = tokens[2].clone().to_string().unwrap(); -/// let new_value = tokens[3].clone().to_string().unwrap(); +/// let old_author: Address = tokens[1].clone().into_address().unwrap(); +/// let new_author: Address = tokens[1].clone().into_address().unwrap(); +/// let old_value = tokens[2].clone().into_string().unwrap(); +/// let new_value = tokens[3].clone().into_string().unwrap(); /// /// Ok(Self { /// old_author, diff --git a/ethers-contract/tests/common/mod.rs b/ethers-contract/tests/common/mod.rs index 363cb237..065a2482 100644 --- a/ethers-contract/tests/common/mod.rs +++ b/ethers-contract/tests/common/mod.rs @@ -21,10 +21,10 @@ pub struct ValueChanged { impl Detokenize for ValueChanged { fn from_tokens(tokens: Vec) -> Result { - let old_author: Address = tokens[1].clone().to_address().unwrap(); - let new_author: Address = tokens[1].clone().to_address().unwrap(); - let old_value = tokens[2].clone().to_string().unwrap(); - let new_value = tokens[3].clone().to_string().unwrap(); + let old_author: Address = tokens[1].clone().into_address().unwrap(); + let new_author: Address = tokens[1].clone().into_address().unwrap(); + let old_value = tokens[2].clone().into_string().unwrap(); + let new_value = tokens[3].clone().into_string().unwrap(); Ok(Self { old_author, diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml index 1d81fa9f..707dc1c5 100644 --- a/ethers-core/Cargo.toml +++ b/ethers-core/Cargo.toml @@ -11,9 +11,9 @@ keywords = ["ethereum", "web3", "celo", "ethers"] [dependencies] # ethereum related -ethereum-types = { version = "0.9.2", default-features = false } -rlp = { version = "0.4.6", default-features = false } -ethabi = { package = "ethabi-next", version = "12.0.0", default-features = false } +ethereum-types = { version = "0.10.0", default-features = false } +rlp = { version = "0.5.0", default-features = false } +ethabi = { package = "ethabi-next", version = "13.0.0", default-features = false } arrayvec = { version = "0.5.1", default-features = false } # crypto diff --git a/ethers-core/src/abi/human_readable.rs b/ethers-core/src/abi/human_readable.rs index e06b20af..e4df0881 100644 --- a/ethers-core/src/abi/human_readable.rs +++ b/ethers-core/src/abi/human_readable.rs @@ -125,12 +125,14 @@ fn parse_function(fn_string: &str) -> Result { vec![] }; + #[allow(deprecated)] Ok(Function { name: fn_name.to_owned(), inputs, outputs, // this doesn't really matter - state_mutability: StateMutability::Nonpayable, + state_mutability: StateMutability::NonPayable, + constant: false, }) } diff --git a/ethers-core/src/types/bytes.rs b/ethers-core/src/types/bytes.rs index 479288b9..42b0a059 100644 --- a/ethers-core/src/types/bytes.rs +++ b/ethers-core/src/types/bytes.rs @@ -23,6 +23,12 @@ impl AsRef<[u8]> for Bytes { } } +impl From for Bytes { + fn from(src: bytes::Bytes) -> Self { + Self(src) + } +} + impl From> for Bytes { fn from(src: Vec) -> Self { Self(src.into()) diff --git a/ethers-core/src/types/transaction.rs b/ethers-core/src/types/transaction.rs index 81fc32d7..ae8fe737 100644 --- a/ethers-core/src/types/transaction.rs +++ b/ethers-core/src/types/transaction.rs @@ -160,7 +160,7 @@ impl TransactionRequest { rlp.append(&0u8); } - rlp.out().into() + rlp.out().freeze().into() } /// Produces the RLP encoding of the transaction with the provided signature @@ -176,7 +176,7 @@ impl TransactionRequest { rlp.append(&signature.r); rlp.append(&signature.s); - rlp.out().into() + rlp.out().freeze().into() } fn rlp_base(&self, rlp: &mut RlpStream) { @@ -341,7 +341,7 @@ impl Transaction { rlp.append(&self.r); rlp.append(&self.s); - rlp.out().into() + rlp.out().freeze().into() } }