Skip to content

Commit

Permalink
Update dependencies (#934)
Browse files Browse the repository at this point in the history
Went through all outdated dependencies and updated them.
  • Loading branch information
vkgnosis committed Jul 10, 2023
1 parent a28457e commit 6fc046a
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 24 deletions.
4 changes: 2 additions & 2 deletions ethcontract-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Common types for ethcontract-rs runtime and proc macro.
"""

[dependencies]
ethabi = "16.0"
ethabi = "18.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.18", default-features = false }
web3 = { version = "0.19", default-features = false }
2 changes: 1 addition & 1 deletion ethcontract-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ ethcontract-common = { version = "0.24.0", path = "../ethcontract-common" }
ethcontract-generate = { version = "0.24.0", path = "../ethcontract-generate", default-features = false }
proc-macro2 = "1.0"
quote = "1.0"
syn = "1.0.12"
syn = "2.0"
15 changes: 7 additions & 8 deletions ethcontract-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl ParseInner for ContractArgs {
input.parse::<Token![,]>()?;
}
let parameters = input
.parse_terminated::<_, Token![,]>(Parameter::parse)?
.parse_terminated(Parameter::parse, Token![,])?
.into_iter()
.collect();

Expand Down Expand Up @@ -404,7 +404,7 @@ impl Parse for Parameter {
braced!(content in input);
let deployments = {
let parsed =
content.parse_terminated::<_, Token![,]>(Spanned::<Deployment>::parse)?;
content.parse_terminated(Spanned::<Deployment>::parse, Token![,])?;

let mut deployments = Vec::with_capacity(parsed.len());
let mut networks = HashSet::new();
Expand All @@ -427,8 +427,7 @@ impl Parse for Parameter {
let content;
braced!(content in input);
let methods = {
let parsed =
content.parse_terminated::<_, Token![;]>(Spanned::<Method>::parse)?;
let parsed = content.parse_terminated(Spanned::<Method>::parse, Token![;])?;

let mut methods = Vec::with_capacity(parsed.len());
let mut signatures = HashSet::new();
Expand Down Expand Up @@ -458,7 +457,7 @@ impl Parse for Parameter {
let content;
parenthesized!(content in input);
let derives = content
.parse_terminated::<_, Token![,]>(Path::parse)?
.parse_terminated(Path::parse, Token![,])?
.into_iter()
.map(|path| path.to_token_stream().to_string())
.collect();
Expand Down Expand Up @@ -514,7 +513,7 @@ impl Parse for Method {
let content;
parenthesized!(content in input);
let inputs = content
.parse_terminated::<_, Token![,]>(Ident::parse)?
.parse_terminated(Ident::parse, Token![,])?
.iter()
.map(|ident| {
let kind = ParamType::from_str(&ident.to_string())
Expand All @@ -535,7 +534,7 @@ impl Parse for Method {
// NOTE: The output types and const-ness of the function do not
// affect its signature.
outputs: vec![],
constant: false,
constant: None,
state_mutability: Default::default(),
}
};
Expand Down Expand Up @@ -728,7 +727,7 @@ mod tests {
contract_args_err!(
"artifact.json",
methods {
myMethod(invalid) as my_method;
myMethod(invalid invalid) as my_method;
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion ethcontract-generate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ ethcontract-common = { version = "0.24.0", path = "../ethcontract-common" }
Inflector = "0.11"
proc-macro2 = "1.0"
quote = "1.0"
syn = "1.0.12"
syn = "2.0"
url = "2.1"
2 changes: 1 addition & 1 deletion ethcontract-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ethcontract = { version = "0.24.0", path = "../ethcontract", default-features =
hex = "0.4"
mockall = "0.11"
rlp = "0.5"
predicates = "2.0"
predicates = "3.0"

[dev-dependencies]
tokio = { version = "1.6", features = ["macros", "rt"] }
Expand Down
8 changes: 4 additions & 4 deletions ethcontract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ futures-timer = "3.0"
hex = "0.4"
jsonrpc-core = "18.0"
lazy_static = "1.4"
primitive-types = { version = "0.10", features = ["fp-conversion"] }
primitive-types = { version = "0.12", features = ["fp-conversion"] }
rlp = { version = "0.5", default-features = false, optional = true }
secp256k1 = { version = "0.21", features = ["recovery"] }
secp256k1 = { version = "0.27", features = ["recovery"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
uint = "0.9"
web3 = { version = "0.18", default-features = false, features = ["signing"] }
web3 = { version = "0.19", default-features = false, features = ["signing"] }
zeroize = "1.1"

[dev-dependencies]
hex-literal = "0.3"
hex-literal = "0.4"
tokio = { version = "1.6", features = ["macros"] }
4 changes: 2 additions & 2 deletions ethcontract/src/contract/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<T: Transport> MethodBuilder<T, ()> {
name: "fallback".into(),
inputs: vec![],
outputs: vec![],
constant: false,
constant: None,
state_mutability: Default::default(),
};
MethodBuilder::new(web3, function, address, data)
Expand Down Expand Up @@ -313,7 +313,7 @@ mod tests {
kind: ParamType::Uint(256),
internal_type: None,
}],
constant: false,
constant: None,
state_mutability: Default::default(),
};
let data = function
Expand Down
2 changes: 1 addition & 1 deletion ethcontract/src/errors/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod tests {
internal_type: None,
}],
outputs: Vec::new(),
constant: true,
constant: None,
state_mutability: Default::default(),
};
revert
Expand Down
19 changes: 18 additions & 1 deletion ethcontract/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use futures::stream::{self, Stream, TryStreamExt};
use std::num::NonZeroU64;
use std::time::Duration;
use web3::api::Web3;
use web3::types::{Address, BlockNumber, Filter, FilterBuilder, Log, H256};
use web3::error::Error as Web3Error;
use web3::types::{Address, BlockId, BlockNumber, Filter, FilterBuilder, Log, H256};
use web3::Transport;

/// The default poll interval to use for polling logs from the block chain.
Expand Down Expand Up @@ -246,6 +247,20 @@ enum PastLogsStream<T: Transport> {
Querying(Web3<T>, Filter),
}

async fn block_number(
web3: &Web3<impl Transport>,
block: BlockNumber,
) -> Result<Option<u64>, Web3Error> {
if let BlockNumber::Number(number) = block {
return Ok(Some(number.as_u64()));
}
let block_ = web3.eth().block(BlockId::Number(block)).await?;
let Some(block_) = block_ else {
return Err(Web3Error::InvalidResponse(format!("block {block:?} does not exist")));
};
Ok(block_.number.map(|n| n.as_u64()))
}

impl<T: Transport> PastLogsStream<T> {
async fn next(mut self) -> Result<Option<(Vec<Log>, Self)>, ExecutionError> {
loop {
Expand Down Expand Up @@ -286,6 +301,7 @@ impl<T: Transport> PastLogsStream<T> {
BlockNumber::Earliest => Some(0),
BlockNumber::Number(value) => Some(value.as_u64()),
BlockNumber::Latest | BlockNumber::Pending => None,
BlockNumber::Safe | BlockNumber::Finalized => block_number(&web3, from_block).await?,
};
let end_block = match to_block {
BlockNumber::Earliest => None,
Expand All @@ -294,6 +310,7 @@ impl<T: Transport> PastLogsStream<T> {
let latest_block = web3.eth().block_number().await?;
Some(latest_block.as_u64())
}
BlockNumber::Safe | BlockNumber::Finalized => block_number(&web3, to_block).await?,
};

let next = match (start_block, end_block) {
Expand Down
11 changes: 8 additions & 3 deletions ethcontract/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::errors::InvalidPrivateKey;
use ethcontract_common::hash;
use secp256k1::{Message, PublicKey, Secp256k1, SecretKey, ONE_KEY};
use secp256k1::{Message, PublicKey, Secp256k1, SecretKey};
use std::fmt::{self, Debug, Formatter};
use std::ops::Deref;
use std::str::FromStr;
Expand Down Expand Up @@ -131,7 +131,9 @@ impl From<SecretKey> for ZeroizeableSecretKey {

impl Default for ZeroizeableSecretKey {
fn default() -> Self {
ONE_KEY.into()
SecretKey::from_str("0000000000000000000000000000000000000000000000000000000000000001")
.unwrap()
.into()
}
}

Expand Down Expand Up @@ -199,7 +201,10 @@ mod tests {
fn drop_private_key() {
let mut key = key!("0x0102030405060708091011121314151617181920212223242526272829303132");
key.0.zeroize();
assert_eq!(*key, ONE_KEY);
let one_key =
SecretKey::from_str("0000000000000000000000000000000000000000000000000000000000000001")
.unwrap();
assert_eq!(*key, one_key);
}

#[test]
Expand Down

0 comments on commit 6fc046a

Please sign in to comment.