chore: upgrade to latest ethtypes (#137)

* chore: upgrade to latest ethtypes

* chore: fix doctests
This commit is contained in:
Georgios Konstantopoulos 2021-01-10 14:03:37 +02:00 committed by GitHub
parent 25f6bdff22
commit 29a3a16085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 47 deletions

56
Cargo.lock generated
View File

@ -547,36 +547,38 @@ dependencies = [
[[package]] [[package]]
name = "ethabi-next" name = "ethabi-next"
version = "12.0.1" version = "13.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523719389cb738dda51fb8d22c96960e192da6263cdf1e08e7dc8c59de4cb032" checksum = "f4bb43ca3464de349cd4f94bb37113eb4938dfb7df1a28320049bbbe3e9ffc6a"
dependencies = [ dependencies = [
"anyhow",
"ethereum-types", "ethereum-types",
"rustc-hex", "hex",
"serde", "serde",
"serde_json", "serde_json",
"tiny-keccak 1.5.0", "sha3",
"thiserror",
"uint", "uint",
] ]
[[package]] [[package]]
name = "ethbloom" name = "ethbloom"
version = "0.9.2" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" checksum = "22a621dcebea74f2a6f2002d0a885c81ccf6cbdf86760183316a7722b5707ca4"
dependencies = [ dependencies = [
"crunchy", "crunchy",
"fixed-hash", "fixed-hash",
"impl-rlp", "impl-rlp",
"impl-serde", "impl-serde",
"tiny-keccak 2.0.2", "tiny-keccak",
] ]
[[package]] [[package]]
name = "ethereum-types" name = "ethereum-types"
version = "0.9.2" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" checksum = "05dc5f0df4915fa6dff7f975a8366ecfaaa8959c74235469495153e7bb1b280e"
dependencies = [ dependencies = [
"ethbloom", "ethbloom",
"fixed-hash", "fixed-hash",
@ -672,7 +674,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",
"tiny-keccak 2.0.2", "tiny-keccak",
] ]
[[package]] [[package]]
@ -768,12 +770,12 @@ dependencies = [
[[package]] [[package]]
name = "fixed-hash" name = "fixed-hash"
version = "0.6.1" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"rand 0.7.3", "rand 0.8.0",
"rustc-hex", "rustc-hex",
"static_assertions", "static_assertions",
] ]
@ -1134,9 +1136,9 @@ dependencies = [
[[package]] [[package]]
name = "impl-rlp" name = "impl-rlp"
version = "0.2.1" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808"
dependencies = [ dependencies = [
"rlp", "rlp",
] ]
@ -1568,9 +1570,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]] [[package]]
name = "primitive-types" name = "primitive-types"
version = "0.7.3" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" checksum = "b3824ae2c5e27160113b9e029a10ec9e3f0237bad8029f69c7724393c9fdefd8"
dependencies = [ dependencies = [
"fixed-hash", "fixed-hash",
"impl-codec", "impl-codec",
@ -1818,10 +1820,11 @@ checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac"
[[package]] [[package]]
name = "rlp" name = "rlp"
version = "0.4.6" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" checksum = "e54369147e3e7796c9b885c7304db87ca3d09a0a98f72843d532868675bbfba8"
dependencies = [ dependencies = [
"bytes 1.0.0",
"rustc-hex", "rustc-hex",
] ]
@ -2147,15 +2150,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "tiny-keccak"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2"
dependencies = [
"crunchy",
]
[[package]] [[package]]
name = "tiny-keccak" name = "tiny-keccak"
version = "2.0.2" version = "2.0.2"
@ -2339,13 +2333,13 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33"
[[package]] [[package]]
name = "uint" name = "uint"
version = "0.8.5" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" checksum = "e11fe9a9348741cf134085ad57c249508345fe16411b3d7fb4ff2da2f1d6382e"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"crunchy", "crunchy",
"rustc-hex", "hex",
"static_assertions", "static_assertions",
] ]

View File

@ -173,6 +173,7 @@ impl Parse for Method {
}) })
.collect::<ParseResult<Vec<_>>>()?; .collect::<ParseResult<Vec<_>>>()?;
#[allow(deprecated)]
Function { Function {
name, name,
inputs, inputs,
@ -180,7 +181,8 @@ impl Parse for Method {
// NOTE: The output types and const-ness of the function do not // NOTE: The output types and const-ness of the function do not
// affect its signature. // affect its signature.
outputs: vec![], outputs: vec![],
state_mutability: StateMutability::Nonpayable, state_mutability: StateMutability::NonPayable,
constant: false,
} }
}; };
let signature = function.abi_signature(); let signature = function.abi_signature();

View File

@ -129,10 +129,10 @@ use std::{fmt::Debug, marker::PhantomData, sync::Arc};
/// ///
/// impl Detokenize for ValueChanged { /// impl Detokenize for ValueChanged {
/// fn from_tokens(tokens: Vec<Token>) -> Result<ValueChanged, InvalidOutputType> { /// fn from_tokens(tokens: Vec<Token>) -> Result<ValueChanged, InvalidOutputType> {
/// let old_author: Address = tokens[1].clone().to_address().unwrap(); /// let old_author: Address = tokens[1].clone().into_address().unwrap();
/// let new_author: Address = tokens[1].clone().to_address().unwrap(); /// let new_author: Address = tokens[1].clone().into_address().unwrap();
/// let old_value = tokens[2].clone().to_string().unwrap(); /// let old_value = tokens[2].clone().into_string().unwrap();
/// let new_value = tokens[3].clone().to_string().unwrap(); /// let new_value = tokens[3].clone().into_string().unwrap();
/// ///
/// Ok(Self { /// Ok(Self {
/// old_author, /// old_author,

View File

@ -21,10 +21,10 @@ pub struct ValueChanged {
impl Detokenize for ValueChanged { impl Detokenize for ValueChanged {
fn from_tokens(tokens: Vec<Token>) -> Result<ValueChanged, InvalidOutputType> { fn from_tokens(tokens: Vec<Token>) -> Result<ValueChanged, InvalidOutputType> {
let old_author: Address = tokens[1].clone().to_address().unwrap(); let old_author: Address = tokens[1].clone().into_address().unwrap();
let new_author: Address = tokens[1].clone().to_address().unwrap(); let new_author: Address = tokens[1].clone().into_address().unwrap();
let old_value = tokens[2].clone().to_string().unwrap(); let old_value = tokens[2].clone().into_string().unwrap();
let new_value = tokens[3].clone().to_string().unwrap(); let new_value = tokens[3].clone().into_string().unwrap();
Ok(Self { Ok(Self {
old_author, old_author,

View File

@ -11,9 +11,9 @@ keywords = ["ethereum", "web3", "celo", "ethers"]
[dependencies] [dependencies]
# ethereum related # ethereum related
ethereum-types = { version = "0.9.2", default-features = false } ethereum-types = { version = "0.10.0", default-features = false }
rlp = { version = "0.4.6", default-features = false } rlp = { version = "0.5.0", default-features = false }
ethabi = { package = "ethabi-next", version = "12.0.0", default-features = false } ethabi = { package = "ethabi-next", version = "13.0.0", default-features = false }
arrayvec = { version = "0.5.1", default-features = false } arrayvec = { version = "0.5.1", default-features = false }
# crypto # crypto

View File

@ -125,12 +125,14 @@ fn parse_function(fn_string: &str) -> Result<Function, ParseError> {
vec![] vec![]
}; };
#[allow(deprecated)]
Ok(Function { Ok(Function {
name: fn_name.to_owned(), name: fn_name.to_owned(),
inputs, inputs,
outputs, outputs,
// this doesn't really matter // this doesn't really matter
state_mutability: StateMutability::Nonpayable, state_mutability: StateMutability::NonPayable,
constant: false,
}) })
} }

View File

@ -23,6 +23,12 @@ impl AsRef<[u8]> for Bytes {
} }
} }
impl From<bytes::Bytes> for Bytes {
fn from(src: bytes::Bytes) -> Self {
Self(src)
}
}
impl From<Vec<u8>> for Bytes { impl From<Vec<u8>> for Bytes {
fn from(src: Vec<u8>) -> Self { fn from(src: Vec<u8>) -> Self {
Self(src.into()) Self(src.into())

View File

@ -160,7 +160,7 @@ impl TransactionRequest {
rlp.append(&0u8); rlp.append(&0u8);
} }
rlp.out().into() rlp.out().freeze().into()
} }
/// Produces the RLP encoding of the transaction with the provided signature /// Produces the RLP encoding of the transaction with the provided signature
@ -176,7 +176,7 @@ impl TransactionRequest {
rlp.append(&signature.r); rlp.append(&signature.r);
rlp.append(&signature.s); rlp.append(&signature.s);
rlp.out().into() rlp.out().freeze().into()
} }
fn rlp_base(&self, rlp: &mut RlpStream) { fn rlp_base(&self, rlp: &mut RlpStream) {
@ -341,7 +341,7 @@ impl Transaction {
rlp.append(&self.r); rlp.append(&self.r);
rlp.append(&self.s); rlp.append(&self.s);
rlp.out().into() rlp.out().freeze().into()
} }
} }