diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 41c4f4b1..76146bc3 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -8,7 +8,7 @@ jobs: strategy: matrix: include: - - rust: 1.52.1 + - rust: 1.56.1 examples: false continue-on-error: false - rust: stable diff --git a/Cargo.toml b/Cargo.toml index 2c35b353..00ad4392 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +edition = "2021" members = [ "ethcontract", "ethcontract-common", diff --git a/README.md b/README.md index a128bb28..9c54296e 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ for interacting with contract functions in a type-safe way. ### Minimum Supported Rust Version -The minimum supported Rust version is 1.52. +The minimum supported Rust version is 1.56.1. ## Generator API diff --git a/ethcontract-common/Cargo.toml b/ethcontract-common/Cargo.toml index 4ea14234..2bb52591 100644 --- a/ethcontract-common/Cargo.toml +++ b/ethcontract-common/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "ethcontract-common" -version = "0.15.4" +version = "0.16.0" authors = ["Gnosis developers "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/gnosis/ethcontract-rs" homepage = "https://github.com/gnosis/ethcontract-rs" @@ -12,11 +12,11 @@ Common types for ethcontract-rs runtime and proc macro. """ [dependencies] -ethabi = "14.1.0" +ethabi = "16.0" hex = "0.4" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" thiserror = "1.0" tiny-keccak = { version = "2.0", features = ["keccak"] } -web3 = { version = "0.17", default-features = false } +web3 = { version = "0.18", default-features = false } diff --git a/ethcontract-common/src/contract.rs b/ethcontract-common/src/contract.rs index 4d05fedc..b24e878f 100644 --- a/ethcontract-common/src/contract.rs +++ b/ethcontract-common/src/contract.rs @@ -35,13 +35,7 @@ impl Contract { pub fn with_name(name: impl Into) -> Self { Contract { name: name.into(), - abi: Abi { - constructor: None, - functions: HashMap::new(), - events: HashMap::new(), - fallback: false, - receive: false, - }, + abi: Default::default(), bytecode: Default::default(), networks: HashMap::new(), devdoc: Default::default(), diff --git a/ethcontract-derive/Cargo.toml b/ethcontract-derive/Cargo.toml index 662c6435..3d3a5650 100644 --- a/ethcontract-derive/Cargo.toml +++ b/ethcontract-derive/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "ethcontract-derive" -version = "0.15.4" +version = "0.16.0" authors = ["Gnosis developers "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/gnosis/ethcontract-rs" homepage = "https://github.com/gnosis/ethcontract-rs" @@ -16,8 +16,8 @@ proc-macro = true [dependencies] anyhow = "1.0" -ethcontract-common = { version = "0.15.4", path = "../ethcontract-common" } -ethcontract-generate = { version = "0.15.4", path = "../ethcontract-generate" } +ethcontract-common = { version = "0.16.0", path = "../ethcontract-common" } +ethcontract-generate = { version = "0.16.0", path = "../ethcontract-generate" } proc-macro2 = "1.0" quote = "1.0" syn = "1.0.12" diff --git a/ethcontract-derive/src/lib.rs b/ethcontract-derive/src/lib.rs index f819b87b..cc295dd1 100644 --- a/ethcontract-derive/src/lib.rs +++ b/ethcontract-derive/src/lib.rs @@ -522,6 +522,7 @@ impl Parse for Method { Ok(Param { name: "".into(), kind, + internal_type: None, }) }) .collect::>>()?; diff --git a/ethcontract-generate/Cargo.toml b/ethcontract-generate/Cargo.toml index 2ffc8e61..fef7776d 100644 --- a/ethcontract-generate/Cargo.toml +++ b/ethcontract-generate/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "ethcontract-generate" -version = "0.15.4" +version = "0.16.0" authors = ["Gnosis developers "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/gnosis/ethcontract-rs" homepage = "https://github.com/gnosis/ethcontract-rs" @@ -14,7 +14,7 @@ Code generation for type-safe bindings to Ethereum smart contracts. [dependencies] anyhow = "1.0" curl = "0.4" -ethcontract-common = { version = "0.15.4", path = "../ethcontract-common" } +ethcontract-common = { version = "0.16.0", path = "../ethcontract-common" } Inflector = "0.11" proc-macro2 = "1.0" quote = "1.0" diff --git a/ethcontract-generate/src/generate/methods.rs b/ethcontract-generate/src/generate/methods.rs index f84a0ae9..6794472f 100644 --- a/ethcontract-generate/src/generate/methods.rs +++ b/ethcontract-generate/src/generate/methods.rs @@ -279,10 +279,12 @@ mod tests { Param { name: "a".to_string(), kind: ParamType::Bool, + internal_type: None, }, Param { name: "b".to_string(), kind: ParamType::Address, + internal_type: None, }, ], ) @@ -302,6 +304,7 @@ mod tests { expand_outputs(&[Param { name: "a".to_string(), kind: ParamType::Bool, + internal_type: None, }]) .unwrap(), { bool }, @@ -315,10 +318,12 @@ mod tests { Param { name: "a".to_string(), kind: ParamType::Bool, + internal_type: None, }, Param { name: "b".to_string(), kind: ParamType::Address, + internal_type: None, }, ],) .unwrap(), diff --git a/ethcontract-mock/Cargo.toml b/ethcontract-mock/Cargo.toml index b71b8832..822643c1 100644 --- a/ethcontract-mock/Cargo.toml +++ b/ethcontract-mock/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "ethcontract-mock" -version = "0.15.4" +version = "0.16.0" authors = ["Gnosis developers "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/gnosis/ethcontract-rs" homepage = "https://github.com/gnosis/ethcontract-rs" @@ -12,7 +12,7 @@ Tools for mocking ethereum contracts. """ [dependencies] -ethcontract = { version = "0.15.4", path = "../ethcontract" } +ethcontract = { version = "0.16.0", path = "../ethcontract" } hex = "0.4" mockall = "0.11" rlp = "0.5" @@ -20,4 +20,4 @@ predicates = "2.0" [dev-dependencies] tokio = { version = "1.6", features = ["macros"] } -ethcontract-derive = { version = "0.15.4", path = "../ethcontract-derive" } +ethcontract-derive = { version = "0.16.0", path = "../ethcontract-derive" } diff --git a/ethcontract-mock/src/details/mod.rs b/ethcontract-mock/src/details/mod.rs index 19338270..fc1fa81d 100644 --- a/ethcontract-mock/src/details/mod.rs +++ b/ethcontract-mock/src/details/mod.rs @@ -643,6 +643,7 @@ impl MockTransport { root: None, logs_bloom: Default::default(), transaction_type: None, + effective_gas_price: Some(U256::from(1)), }; state.receipts.insert(tx.hash, receipt); diff --git a/ethcontract-mock/src/test/eth_estimate_gas.rs b/ethcontract-mock/src/test/eth_estimate_gas.rs index 77b933f6..0de084a1 100644 --- a/ethcontract-mock/src/test/eth_estimate_gas.rs +++ b/ethcontract-mock/src/test/eth_estimate_gas.rs @@ -47,6 +47,8 @@ async fn estimate_gas_is_supported_for_edge_block() -> Result { data: tx.data, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, } }; @@ -93,6 +95,8 @@ async fn estimate_gas_is_not_supported_for_custom_block() { data: tx.data, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, } }; @@ -123,6 +127,8 @@ async fn estimate_gas_is_not_supported_for_earliest_block() { data: tx.data, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, } }; diff --git a/ethcontract/Cargo.toml b/ethcontract/Cargo.toml index 5ae8fa30..97643f84 100644 --- a/ethcontract/Cargo.toml +++ b/ethcontract/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "ethcontract" -version = "0.15.4" +version = "0.16.0" authors = ["Gnosis developers "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/gnosis/ethcontract-rs" homepage = "https://github.com/gnosis/ethcontract-rs" @@ -31,20 +31,20 @@ ipc-tokio = ["web3/ipc-tokio"] [dependencies] arrayvec = "0.7" -ethcontract-common = { version = "0.15.4", path = "../ethcontract-common" } -ethcontract-derive = { version = "0.15.4", path = "../ethcontract-derive", optional = true} +ethcontract-common = { version = "0.16.0", path = "../ethcontract-common" } +ethcontract-derive = { version = "0.16.0", path = "../ethcontract-derive", optional = true} futures = "0.3" futures-timer = "3.0" hex = "0.4" jsonrpc-core = "18.0" lazy_static = "1.4" -primitive-types = { version = "0.9", features = ["fp-conversion"] } +primitive-types = { version = "0.10", features = ["fp-conversion"] } secp256k1 = { version = "0.21", features = ["recovery"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" uint = "0.9" -web3 = { version = "0.17", default-features = false, features = ["signing"] } +web3 = { version = "0.18", default-features = false, features = ["signing"] } zeroize = "1.1" [dev-dependencies] diff --git a/ethcontract/src/batch.rs b/ethcontract/src/batch.rs index 1a589e54..bb4de2e1 100644 --- a/ethcontract/src/batch.rs +++ b/ethcontract/src/batch.rs @@ -3,7 +3,7 @@ use futures::channel::oneshot::{channel, Sender}; use web3::{ - error::Error as Web3Error, + error::{Error as Web3Error, TransportError}, helpers::{self}, types::{BlockId, BlockNumber, Bytes, CallRequest}, BatchTransport as Web3BatchTransport, @@ -42,9 +42,9 @@ impl CallBatch { self.requests.push(((call, block), tx)); async move { rx.await.unwrap_or_else(|_| { - Err(Web3Error::Transport( + Err(Web3Error::Transport(TransportError::Message( "Batch has been dropped without executing".to_owned(), - )) + ))) }) } } @@ -80,9 +80,8 @@ impl CallBatch { .clone() .and_then(helpers::decode), ), - Err(err) => sender.send(Err(Web3Error::Transport(format!( - "Batch failed with: {}", - err + Err(err) => sender.send(Err(Web3Error::Transport(TransportError::Message( + format!("Batch failed with: {}", err), )))), }; } @@ -140,7 +139,9 @@ mod tests { batch.execute_all(usize::MAX).immediate(); match call.immediate().unwrap_err() { - Web3Error::Transport(reason) => assert!(reason.starts_with("Batch failed with:")), + Web3Error::Transport(TransportError::Message(reason)) => { + assert!(reason.starts_with("Batch failed with:")) + } _ => panic!("Wrong Error type"), }; } diff --git a/ethcontract/src/contract.rs b/ethcontract/src/contract.rs index 932fb944..a6a6b310 100644 --- a/ethcontract/src/contract.rs +++ b/ethcontract/src/contract.rs @@ -14,7 +14,7 @@ use ethcontract_common::abi::{Error as AbiError, Result as AbiResult}; use ethcontract_common::abiext::FunctionExt; use ethcontract_common::hash::H32; use ethcontract_common::{Abi, Bytecode, Contract, DeploymentInformation}; -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; use web3::api::Web3; use web3::types::{Address, Bytes, H256}; @@ -365,11 +365,11 @@ impl Deploy for Instance { /// Utility function for creating a mapping between a unique signature and a /// name-index pair for accessing contract ABI items. fn create_mapping( - elements: &HashMap>, + elements: &BTreeMap>, signature: F, ) -> HashMap where - S: Hash + Eq, + S: Hash + Eq + Ord, F: Fn(&T) -> S, { let signature = &signature; diff --git a/ethcontract/src/contract/method.rs b/ethcontract/src/contract/method.rs index ea4787e3..b0eb5ce2 100644 --- a/ethcontract/src/contract/method.rs +++ b/ethcontract/src/contract/method.rs @@ -245,6 +245,8 @@ impl ViewMethodBuilder { data: self.m.tx.data, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, }, self.block, ) @@ -290,6 +292,7 @@ mod tests { outputs: vec![Param { name: "".to_owned(), kind: ParamType::Uint(256), + internal_type: None, }], constant: false, state_mutability: Default::default(), diff --git a/ethcontract/src/errors/revert.rs b/ethcontract/src/errors/revert.rs index 0cb02362..2c905b5c 100644 --- a/ethcontract/src/errors/revert.rs +++ b/ethcontract/src/errors/revert.rs @@ -46,6 +46,7 @@ mod tests { inputs: vec![Param { name: "".into(), kind: ParamType::String, + internal_type: None, }], outputs: Vec::new(), constant: true, diff --git a/ethcontract/src/secret.rs b/ethcontract/src/secret.rs index 40ba0aee..ab7b6fa8 100644 --- a/ethcontract/src/secret.rs +++ b/ethcontract/src/secret.rs @@ -80,6 +80,7 @@ impl Debug for PrivateKey { } } +// Taken from rust-web3's signing.rs. impl Key for &'_ PrivateKey { fn sign(&self, message: &[u8], chain_id: Option) -> Result { let message = Message::from_slice(message).map_err(|_| SigningError::InvalidMessage)?; @@ -99,6 +100,19 @@ impl Key for &'_ PrivateKey { Ok(Signature { v, r, s }) } + fn sign_message(&self, message: &[u8]) -> Result { + let message = Message::from_slice(message).map_err(|_| SigningError::InvalidMessage)?; + let (recovery_id, signature) = Secp256k1::signing_only() + .sign_ecdsa_recoverable(&message, self) + .serialize_compact(); + + let v = recovery_id.to_i32() as u64; + let r = H256::from_slice(&signature[..32]); + let s = H256::from_slice(&signature[32..]); + + Ok(Signature { v, r, s }) + } + fn address(&self) -> Address { self.public_address() } diff --git a/ethcontract/src/transaction.rs b/ethcontract/src/transaction.rs index 248d33ea..ea8c75da 100644 --- a/ethcontract/src/transaction.rs +++ b/ethcontract/src/transaction.rs @@ -197,6 +197,8 @@ impl TransactionBuilder { data: self.data.clone(), transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, }, None, ) diff --git a/ethcontract/src/transaction/build.rs b/ethcontract/src/transaction/build.rs index 6420595d..3bb330eb 100644 --- a/ethcontract/src/transaction/build.rs +++ b/ethcontract/src/transaction/build.rs @@ -156,6 +156,8 @@ impl TransactionRequestOptions { condition: self.1, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, } } } @@ -229,6 +231,8 @@ async fn build_offline_signed_transaction( chain_id, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, }, &key, ) @@ -257,6 +261,8 @@ async fn resolve_gas_limit( data: options.data.clone(), transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, }, None, ) diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 0a7fc9da..3973f3e6 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -2,7 +2,7 @@ name = "examples" version = "0.0.0" publish = false -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" autobins = false diff --git a/examples/documentation/Cargo.toml b/examples/documentation/Cargo.toml index dfe88074..a29238df 100644 --- a/examples/documentation/Cargo.toml +++ b/examples/documentation/Cargo.toml @@ -2,7 +2,7 @@ name = "examples-documentation" version = "0.0.0" publish = false -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" [dependencies] diff --git a/examples/examples/async.rs b/examples/examples/async.rs index ce764e4d..efd22d96 100644 --- a/examples/examples/async.rs +++ b/examples/examples/async.rs @@ -52,6 +52,8 @@ async fn main() { condition: None, transaction_type: None, access_list: None, + max_fee_per_gas: None, + max_priority_fee_per_gas: None, }) .await .expect("send eth failed"); diff --git a/examples/generate/Cargo.toml b/examples/generate/Cargo.toml index 0e23feba..cd957e24 100644 --- a/examples/generate/Cargo.toml +++ b/examples/generate/Cargo.toml @@ -3,7 +3,7 @@ name = "examples-generate" version = "0.0.0" publish = false authors = ["Gnosis developers "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" [dependencies]