Upgrade to Rust 2018, update deps.
This commit is contained in:
parent
056738b7ac
commit
744c5bda28
|
@ -5,7 +5,7 @@ dist: trusty
|
|||
language: rust
|
||||
services: docker
|
||||
sudo: required
|
||||
rust: 1.29.0
|
||||
rust: 1.31.0
|
||||
cache: cargo
|
||||
|
||||
env:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
|
@ -3,17 +3,17 @@ name = "poa-ballot-stats"
|
|||
version = "0.4.0"
|
||||
authors = ["Andreas Fackler <AndreasFackler@gmx.de>"]
|
||||
description = "Read POA voting records and rank voters by how many ballots they missed."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
clap = "2.31.2"
|
||||
colored = "1.6.0"
|
||||
error-chain = { version = "0.12", default-features = false }
|
||||
ethabi = "6.0.1"
|
||||
ethabi = "6.1.0"
|
||||
ethabi-contract = "6.0.0"
|
||||
ethabi-derive = "6.0.2"
|
||||
parse_duration = "1.0.1"
|
||||
serde = "1.0.36"
|
||||
serde_derive = "1.0.36"
|
||||
serde_json = "1.0.13"
|
||||
# TODO: Remove ws once https://github.com/tomusdrw/rust-web3/issues/157 is fixed.
|
||||
web3 = { version = "0.4.0", default-features = false, features = ["http", "tls", "ws"] }
|
||||
serde = "1.0.82"
|
||||
serde_derive = "1.0.82"
|
||||
serde_json = "1.0.33"
|
||||
web3 = { version = "0.5.1", default-features = false, features = ["http", "tls"] }
|
||||
|
|
15
src/cli.rs
15
src/cli.rs
|
@ -15,29 +15,34 @@ pub fn get_matches() -> ArgMatches<'static> {
|
|||
.value_name("URL")
|
||||
.help("The JSON-RPC endpoint")
|
||||
.takes_value(true),
|
||||
).arg(
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("verbose")
|
||||
.short("v")
|
||||
.long("verbose")
|
||||
.help("More detailed output")
|
||||
.takes_value(false),
|
||||
).arg(
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("contracts")
|
||||
.short("c")
|
||||
.long("contracts")
|
||||
.help("JSON file with the contract addresses")
|
||||
.takes_value(true),
|
||||
).arg(
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("period")
|
||||
.short("p")
|
||||
.long("period")
|
||||
.help("The period in which votes should be counted, e.g. '5 days', '2 months'.")
|
||||
.takes_value(true),
|
||||
).arg(
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("block")
|
||||
.short("b")
|
||||
.long("block")
|
||||
.help("The earliest block in which votes should be counted.")
|
||||
.takes_value(true),
|
||||
).get_matches()
|
||||
)
|
||||
.get_matches()
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use ethabi::Address;
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
// The `use_contract!` macro triggers several Clippy warnings.
|
||||
#[cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(too_many_arguments, redundant_closure, needless_update)
|
||||
#[allow(
|
||||
clippy::too_many_arguments,
|
||||
clippy::redundant_closure,
|
||||
clippy::needless_update
|
||||
)]
|
||||
pub mod v2 {
|
||||
use_contract!(key_mgr, "abi/v2/KeysManager.abi.json");
|
||||
|
@ -12,10 +14,7 @@ pub mod v2 {
|
|||
}
|
||||
|
||||
// The `use_contract!` macro triggers several Clippy warnings.
|
||||
#[cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(too_many_arguments, redundant_closure, needless_update)
|
||||
)]
|
||||
#[allow(clippy::redundant_closure, clippy::needless_update)]
|
||||
pub mod v1 {
|
||||
use_contract!(voting, "abi/v1/VotingToChangeKeys.abi.json");
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use crate::contracts::v1::voting::events::{ballot_created as ballot_created_v1, vote as vote_v1};
|
||||
use crate::contracts::v2::key_mgr::events::voting_key_changed;
|
||||
use crate::contracts::v2::key_mgr::functions::get_mining_key_by_voting;
|
||||
use crate::contracts::v2::val_meta::functions::validators as validators_fn;
|
||||
use crate::contracts::v2::voting::events::{ballot_created, vote};
|
||||
use crate::contracts::ContractAddresses;
|
||||
use crate::error::{Error, ErrorKind};
|
||||
use crate::stats::Stats;
|
||||
use crate::util::{self, HexList, IntoBallot, TopicFilterExt, Web3LogExt};
|
||||
use colored::{Color, Colorize};
|
||||
use contracts::v1::voting::events::{ballot_created as ballot_created_v1, vote as vote_v1};
|
||||
use contracts::v2::key_mgr::events::voting_key_changed;
|
||||
use contracts::v2::key_mgr::functions::get_mining_key_by_voting;
|
||||
use contracts::v2::val_meta::functions::validators as validators_fn;
|
||||
use contracts::v2::voting::events::{ballot_created, vote};
|
||||
use contracts::ContractAddresses;
|
||||
use error::{Error, ErrorKind};
|
||||
use ethabi::{Address, Bytes, FunctionOutputDecoder, Uint};
|
||||
use stats::Stats;
|
||||
use std::collections::BTreeSet;
|
||||
use std::default::Default;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
use util::{self, HexList, IntoBallot, TopicFilterExt, Web3LogExt};
|
||||
use web3;
|
||||
use web3::futures::Future;
|
||||
|
||||
|
@ -104,7 +104,8 @@ impl Counter {
|
|||
} else if let Ok(ballot) =
|
||||
ballot_created::parse_log(log.clone().into_raw()).or_else(|_| {
|
||||
ballot_created_v1::parse_log(log.clone().into_raw()).map(IntoBallot::into)
|
||||
}) {
|
||||
})
|
||||
{
|
||||
if !self.addrs.is_voting(&log.address) {
|
||||
continue; // Event from another contract instance.
|
||||
}
|
||||
|
@ -207,7 +208,8 @@ impl Counter {
|
|||
.map(|vote| vote.voter)
|
||||
.or_else(|_| vote_v1::parse_log(vote_log.into_raw()).map(|vote| vote.voter))
|
||||
.map_err(Error::from)
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns `true` if the block with the given number is older than `start_time`.
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -1,18 +1,9 @@
|
|||
extern crate clap;
|
||||
extern crate colored;
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate ethabi;
|
||||
#[macro_use(EthabiContract)]
|
||||
extern crate ethabi_derive;
|
||||
#[macro_use(use_contract)]
|
||||
extern crate ethabi_contract;
|
||||
extern crate parse_duration;
|
||||
extern crate serde;
|
||||
#[macro_use(Deserialize)]
|
||||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
extern crate web3;
|
||||
#[macro_use(EthabiContract)]
|
||||
extern crate ethabi_derive;
|
||||
|
||||
mod cli;
|
||||
mod contracts;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::validator::Validator;
|
||||
use colored::{Color, Colorize};
|
||||
use ethabi::Address;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use validator::Validator;
|
||||
|
||||
/// The count of ballots and cast votes, as well as metadata for a particular voter.
|
||||
#[derive(Clone, Default)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::contracts::v1::voting::logs::BallotCreated as BallotCreatedV1;
|
||||
use crate::contracts::v2::voting::logs::BallotCreated;
|
||||
use colored::{Color, Colorize};
|
||||
use contracts::v1::voting::logs::BallotCreated as BallotCreatedV1;
|
||||
use contracts::v2::voting::logs::BallotCreated;
|
||||
use ethabi::{self, Address, Bytes, FunctionOutputDecoder};
|
||||
use std::{fmt, u8};
|
||||
use web3;
|
||||
|
@ -89,7 +89,8 @@ impl TopicFilterExt for ethabi::TopicFilter {
|
|||
self.topic1.to_opt_vec(),
|
||||
self.topic2.to_opt_vec(),
|
||||
self.topic3.to_opt_vec(),
|
||||
).from_block(web3::types::BlockNumber::Earliest)
|
||||
)
|
||||
.from_block(web3::types::BlockNumber::Earliest)
|
||||
.to_block(web3::types::BlockNumber::Latest)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue