This commit is contained in:
Georgios Konstantopoulos 2020-05-26 13:37:17 +03:00
parent 2bec170968
commit 6a73bab70d
No known key found for this signature in database
GPG Key ID: FA607837CD26EDBC
5 changed files with 52 additions and 7 deletions

35
Cargo.lock generated
View File

@ -127,6 +127,19 @@ dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "ethabi"
version = "12.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ethereum-types 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.110 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uint 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "ethbloom" name = "ethbloom"
version = "0.9.2" version = "0.9.2"
@ -152,6 +165,18 @@ dependencies = [
"uint 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "ethers-abi"
version = "0.1.0"
dependencies = [
"arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethers-types 0.1.0",
"ethers-utils 0.1.0",
"serde_json 1.0.53 (registry+https://github.com/rust-lang/crates.io-index)",
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "ethers-providers" name = "ethers-providers"
version = "0.1.0" version = "0.1.0"
@ -1009,6 +1034,14 @@ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "tiny-keccak"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "tiny-keccak" name = "tiny-keccak"
version = "2.0.2" version = "2.0.2"
@ -1302,6 +1335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" "checksum dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3"
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
"checksum encoding_rs 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" "checksum encoding_rs 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171"
"checksum ethabi 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "052a565e3de82944527d6d10a465697e6bb92476b772ca7141080c901f6a63c6"
"checksum ethbloom 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" "checksum ethbloom 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df"
"checksum ethereum-types 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" "checksum ethereum-types 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0"
"checksum fixed-hash 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" "checksum fixed-hash 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c"
@ -1395,6 +1429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344" "checksum thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344"
"checksum thiserror-impl 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479" "checksum thiserror-impl 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479"
"checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" "checksum time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
"checksum tiny-keccak 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2"
"checksum tiny-keccak 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" "checksum tiny-keccak 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
"checksum tokio 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" "checksum tokio 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58"
"checksum tokio-rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" "checksum tokio-rustls 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4"

View File

@ -2,7 +2,7 @@
members = [ members = [
# "./crates/ethers", # "./crates/ethers",
# "./crates/ethers-abi", "./crates/ethers-abi",
# "./crates/ethers-contract", # "./crates/ethers-contract",
# "./crates/ethers-derive", # "./crates/ethers-derive",
"./crates/ethers-providers", "./crates/ethers-providers",

View File

@ -7,3 +7,12 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
ethers-types = { path = "../ethers-types" }
ethers-utils = { path = "../ethers-utils" }
ethabi = "12.0.0"
arrayvec = "0.5.1"
thiserror = { version = "1.0.19", default-features = false }
[dev-dependencies]
serde_json = { version = "1.0.53", default-features = false }

View File

@ -1,10 +1,13 @@
//! This module implements extensions to the `ethabi` API. //! This module implements extensions to the `ethabi` API.
//! Taken from: https://github.com/gnosis/ethcontract-rs/blob/master/common/src/abiext.rs //! Taken from: https://github.com/gnosis/ethcontract-rs/blob/master/common/src/abiext.rs
use ethers_types::Selector;
use ethers_utils::id;
pub use ethabi::Contract as Abi; pub use ethabi::Contract as Abi;
pub use ethabi::*; pub use ethabi::*;
use crate::{types::Selector, utils::id}; mod tokens;
pub use tokens::{Detokenize, Tokenizable, TokenizableItem, Tokenize};
/// Extension trait for `ethabi::Function`. /// Extension trait for `ethabi::Function`.
pub trait FunctionExt { pub trait FunctionExt {
@ -54,8 +57,6 @@ impl EventExt for Event {
} }
} }
// Tokenization macros: Given ABI -> codegen: copy Gnosis' thing
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View File

@ -1,9 +1,9 @@
//! Contract Functions Output types. //! Contract Functions Output types.
//! Adapted from: https://github.com/tomusdrw/rust-web3/blob/master/src/contract/tokens.rs //! Adapted from: https://github.com/tomusdrw/rust-web3/blob/master/src/contract/tokens.rs
use crate::Token;
use crate::types::{Address, Bytes, H256, U128, U256};
use arrayvec::ArrayVec; use arrayvec::ArrayVec;
use ethabi::Token; use ethers_types::{Address, Bytes, H256, U128, U256};
use thiserror::Error; use thiserror::Error;
#[derive(Clone, Debug, Error)] #[derive(Clone, Debug, Error)]
@ -469,8 +469,8 @@ impl_fixed_types!(1024);
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{Detokenize, Tokenizable}; use super::{Detokenize, Tokenizable};
use crate::types::{Address, U256};
use ethabi::Token; use ethabi::Token;
use ethers_types::{Address, U256};
fn output<R: Detokenize>() -> R { fn output<R: Detokenize>() -> R {
unimplemented!() unimplemented!()