Skip to content

Commit

Permalink
Update edition, dependencies, version (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkgnosis authored Feb 17, 2022
1 parent a3a0c5c commit 7f9a757
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
include:
- rust: 1.52.1
- rust: 1.56.1
examples: false
continue-on-error: false
- rust: stable
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
edition = "2021"
members = [
"ethcontract",
"ethcontract-common",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions ethcontract-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "ethcontract-common"
version = "0.15.4"
version = "0.16.0"
authors = ["Gnosis developers <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/gnosis/ethcontract-rs"
homepage = "https://github.com/gnosis/ethcontract-rs"
Expand All @@ -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 }
8 changes: 1 addition & 7 deletions ethcontract-common/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ impl Contract {
pub fn with_name(name: impl Into<String>) -> 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(),
Expand Down
8 changes: 4 additions & 4 deletions ethcontract-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "ethcontract-derive"
version = "0.15.4"
version = "0.16.0"
authors = ["Gnosis developers <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/gnosis/ethcontract-rs"
homepage = "https://github.com/gnosis/ethcontract-rs"
Expand All @@ -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"
1 change: 1 addition & 0 deletions ethcontract-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ impl Parse for Method {
Ok(Param {
name: "".into(),
kind,
internal_type: None,
})
})
.collect::<ParseResult<Vec<_>>>()?;
Expand Down
6 changes: 3 additions & 3 deletions ethcontract-generate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "ethcontract-generate"
version = "0.15.4"
version = "0.16.0"
authors = ["Gnosis developers <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/gnosis/ethcontract-rs"
homepage = "https://github.com/gnosis/ethcontract-rs"
Expand All @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions ethcontract-generate/src/generate/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
)
Expand All @@ -302,6 +304,7 @@ mod tests {
expand_outputs(&[Param {
name: "a".to_string(),
kind: ParamType::Bool,
internal_type: None,
}])
.unwrap(),
{ bool },
Expand All @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions ethcontract-mock/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "ethcontract-mock"
version = "0.15.4"
version = "0.16.0"
authors = ["Gnosis developers <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/gnosis/ethcontract-rs"
homepage = "https://github.com/gnosis/ethcontract-rs"
Expand All @@ -12,12 +12,12 @@ 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"
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" }
1 change: 1 addition & 0 deletions ethcontract-mock/src/details/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions ethcontract-mock/src/test/eth_estimate_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};

Expand Down Expand Up @@ -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,
}
};

Expand Down Expand Up @@ -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,
}
};

Expand Down
12 changes: 6 additions & 6 deletions ethcontract/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "ethcontract"
version = "0.15.4"
version = "0.16.0"
authors = ["Gnosis developers <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/gnosis/ethcontract-rs"
homepage = "https://github.com/gnosis/ethcontract-rs"
Expand Down Expand Up @@ -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]
Expand Down
15 changes: 8 additions & 7 deletions ethcontract/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -42,9 +42,9 @@ impl<T: Web3BatchTransport> CallBatch<T> {
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(),
))
)))
})
}
}
Expand Down Expand Up @@ -80,9 +80,8 @@ impl<T: Web3BatchTransport> CallBatch<T> {
.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),
)))),
};
}
Expand Down Expand Up @@ -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"),
};
}
Expand Down
6 changes: 3 additions & 3 deletions ethcontract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -365,11 +365,11 @@ impl<T: Transport> Deploy<T> for Instance<T> {
/// Utility function for creating a mapping between a unique signature and a
/// name-index pair for accessing contract ABI items.
fn create_mapping<T, S, F>(
elements: &HashMap<String, Vec<T>>,
elements: &BTreeMap<String, Vec<T>>,
signature: F,
) -> HashMap<S, (String, usize)>
where
S: Hash + Eq,
S: Hash + Eq + Ord,
F: Fn(&T) -> S,
{
let signature = &signature;
Expand Down
3 changes: 3 additions & 0 deletions ethcontract/src/contract/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ impl<T: Transport, R: Tokenize> ViewMethodBuilder<T, R> {
data: self.m.tx.data,
transaction_type: None,
access_list: None,
max_fee_per_gas: None,
max_priority_fee_per_gas: None,
},
self.block,
)
Expand Down Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions ethcontract/src/errors/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod tests {
inputs: vec![Param {
name: "".into(),
kind: ParamType::String,
internal_type: None,
}],
outputs: Vec::new(),
constant: true,
Expand Down
14 changes: 14 additions & 0 deletions ethcontract/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>) -> Result<Signature, SigningError> {
let message = Message::from_slice(message).map_err(|_| SigningError::InvalidMessage)?;
Expand All @@ -99,6 +100,19 @@ impl Key for &'_ PrivateKey {
Ok(Signature { v, r, s })
}

fn sign_message(&self, message: &[u8]) -> Result<Signature, SigningError> {
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()
}
Expand Down
2 changes: 2 additions & 0 deletions ethcontract/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ impl<T: Transport> TransactionBuilder<T> {
data: self.data.clone(),
transaction_type: None,
access_list: None,
max_fee_per_gas: None,
max_priority_fee_per_gas: None,
},
None,
)
Expand Down
Loading

0 comments on commit 7f9a757

Please sign in to comment.