Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
chore(clippy): add some deny lints (#1064)
Browse files Browse the repository at this point in the history
* feat: add deny lints

* trim ethers core

* trim ethers eip712

* deny ethers contract derive

* deny ethers contract abigen

* deny ethers contract

* deny ethers providers

* chore: add denies and fix unused deps

* doc: fix links

* fix: wasm build

* doc: fix links

* doc: fix links

* doc: fix inline doc links

* docs: fix intra doc links
  • Loading branch information
mattsse authored Mar 19, 2022
1 parent cde52c7 commit 916e9a7
Show file tree
Hide file tree
Showing 52 changed files with 143 additions and 146 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ethers-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ ethers-solc = { version = "^0.3.0", path = "../ethers-solc", default-features =
tokio = { version = "1.5", default-features = false, features = ["macros"] }

[features]
default = ["rustls"]
eip712 = ["ethers-derive-eip712", "ethers-core/eip712"]
abigen = ["ethers-contract-abigen/reqwest", "ethers-contract-derive"]
abigen-offline = ["ethers-contract-abigen", "ethers-contract-derive"]
Expand Down
1 change: 0 additions & 1 deletion ethers-contract/ethers-contract-abigen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ serde_json = "1.0.61"
serde = { version = "1.0.124", features = ["derive"] }
hex = { version = "0.4.2", default-features = false, features = ["std"] }
reqwest = { version = "0.11.3", default-features = false, features = ["blocking"] , optional = true }
once_cell = "1.8.0"
cfg-if = "1.0.0"
dunce = "1.0.2"
walkdir = "2.3.2"
Expand Down
1 change: 1 addition & 0 deletions ethers-contract/ethers-contract-abigen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(missing_docs, unsafe_code)]
#![deny(rustdoc::broken_intra_doc_links)]

//! Module for generating type-safe bindings to Ethereum smart contracts. This
//! module is intended to be used either indirectly with the `abigen` procedural
Expand Down
3 changes: 2 additions & 1 deletion ethers-contract/ethers-contract-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Implementation of procedural macro for generating type-safe bindings to an
//! ethereum smart contract.
#![deny(missing_docs, unsafe_code)]
#![deny(missing_docs, unsafe_code, unused_crate_dependencies)]
#![deny(rustdoc::broken_intra_doc_links)]

use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/ethers-contract-derive/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn parse_int_param_type(s: &str) -> Option<ParamType> {
// Converts param types for indexed parameters to bytes32 where appropriate
// This applies to strings, arrays, structs and bytes to follow the encoding of
// these indexed param types according to
// https://solidity.readthedocs.io/en/develop/abi-spec.html#encoding-of-indexed-event-parameters
// <https://solidity.readthedocs.io/en/develop/abi-spec.html#encoding-of-indexed-event-parameters>
pub fn topic_param_type_quote(kind: &ParamType) -> proc_macro2::TokenStream {
let core_crate = ethers_core_crate();
match kind {
Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct BaseContract {
/// A mapping from method signature to a name-index pair for accessing
/// functions in the contract ABI. This is used to avoid allocation when
/// searching for matching functions by signature.
// Adapted from: https://github.com/gnosis/ethcontract-rs/blob/master/src/contract.rs
// Adapted from: <https://github.com/gnosis/ethcontract-rs/blob/master/src/contract.rs>
pub methods: HashMap<Selector, (String, usize)>,
}

Expand Down
2 changes: 2 additions & 0 deletions ethers-contract/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![deny(unsafe_code)]

mod contract;
pub use contract::Contract;

Expand Down
2 changes: 1 addition & 1 deletion ethers-contract/src/multicall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub static ADDRESS_BOOK: Lazy<HashMap<U256, Address>> = Lazy::new(|| {
///
/// [`new`]: method@crate::Multicall::new
/// [`block`]: method@crate::Multicall::block
/// [`add_call`]: methond@crate::Multicall::add_call
/// [`add_call`]: method@crate::Multicall::add_call
#[derive(Clone)]
pub struct Multicall<M> {
calls: Vec<Call>,
Expand Down
17 changes: 4 additions & 13 deletions ethers-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ arrayvec = { version = "0.7.2", default-features = false }
rlp-derive = { version = "0.1.0", default-features = false }

# crypto
ecdsa = { version = "0.13.4", default-features = false, features = ["std"] }
elliptic-curve = { version = "0.11.12", default-features = false }
generic-array = { version = "0.14.5", default-features = false }
k256 = { version = "0.10.4", default-features = false, features = ["keccak256", "ecdsa"] }
k256 = { version = "0.10.4", default-features = false, features = ["keccak256", "ecdsa", "std"] }
rand = { version = "0.8.5", default-features = false }
tiny-keccak = { version = "2.0.2", default-features = false }

Expand All @@ -29,36 +28,28 @@ serde_json = { version = "1.0.64", default-features = false }
thiserror = { version = "1.0.30", default-features = false }
bytes = { version = "1.1.0", features = ["serde"] }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
once_cell = "1.10.0"
once_cell = { version = "1.10.0", optional = true }

# macros feature enabled dependencies
cargo_metadata = { version = "0.14.2", optional = true }

# eip712 feature enabled dependencies
convert_case = { version = "0.5.0", optional = true }
syn = { version = "1.0.89", optional = true }
quote = { version = "1.0.16", optional = true }
proc-macro2 = { version = "1.0.36", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# async
tokio = { version = "1.5", default-features = false, optional = true}
futures-util = { version = "^0.3", optional = true }

[dev-dependencies]
serde_json = { version = "1.0.64", default-features = false }
bincode = { version = "1.3.3", default-features = false }
once_cell = { version = "1.10.0" }
hex-literal = "0.3.4"
futures-util = { version = "^0.3" }
rand = "0.8.5"

[features]
celo = ["legacy"] # celo support extends the transaction format with extra fields
setup = ["tokio", "futures-util"] # async support for concurrent setup
legacy = []
eip712 = ["convert_case", "syn", "quote", "proc-macro2"]
macros = ["syn", "cargo_metadata"]
eip712 = ["convert_case", "syn", "proc-macro2"]
macros = ["syn", "cargo_metadata", "once_cell"]

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 0 additions & 2 deletions ethers-core/ethers-derive-eip712/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ quote = "1.0.9"
syn = "1.0.77"
ethers-core = { version = "^0.6.0", path = "../", default-features = false, features = ["eip712", "macros"] }
hex = "0.4.3"
serde = "1.0.130"
serde_json = "1.0.68"
proc-macro2 = "1.0.29"

[dev-dependencies]
ethers-contract = { version = "^0.6.0", path = "../../ethers-contract", features = ["abigen"]}
Expand Down
4 changes: 4 additions & 0 deletions ethers-core/ethers-derive-eip712/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
//!
//! There is an Inner helper attribute `#[eip712]` for fields that will eventually be used to
//! determine if there is a nested eip712 struct. However, this work is not yet complete.
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(unused_crate_dependencies)]

use std::convert::TryFrom;

use ethers_core::{macros::ethers_core_crate, types::transaction::eip712};
Expand Down
4 changes: 2 additions & 2 deletions ethers-core/src/abi/human_readable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,14 @@ impl AbiParser {
/// }
/// ```
///
/// See https://github.com/rust-ethereum/ethabi/issues/254
/// See <https://github.com/rust-ethereum/ethabi/issues/254>
///
/// Therefore, we need to double-check if the `ethabi::Reader` parsed an `uint8`, and ignore the
/// type if `type_str` is not uint8. However can lead to some problems if a function param is
/// array of custom types for example, like `Foo[]`, which the `Reader` would identify as
/// `uint8[]`. Therefor if the `Reader` returns an `uint8` we also check that the input string
/// contains a `uint8`. This however can still lead to false detection of `uint8` and is only
/// solvable with a more sophisticated parser: https://github.com/gakonst/ethers-rs/issues/474
/// solvable with a more sophisticated parser: <https://github.com/gakonst/ethers-rs/issues/474>
fn parse_type(&self, type_str: &str) -> Result<(ParamType, Option<String>)> {
if let Ok(kind) = Reader::read(type_str) {
if is_likely_tuple_not_uint8(&kind, type_str) {
Expand Down
3 changes: 3 additions & 0 deletions ethers-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(unused_crate_dependencies)]

pub mod types;

pub mod abi;
Expand Down
12 changes: 6 additions & 6 deletions ethers-core/src/types/block.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Taken from https://github.com/tomusdrw/rust-web3/blob/master/src/types/block.rs
// Taken from <https://github.com/tomusdrw/rust-web3/blob/master/src/types/block.rs>
use crate::types::{Address, Bloom, Bytes, H256, U256, U64};
#[cfg(not(feature = "celo"))]
use core::cmp::Ordering;
Expand Down Expand Up @@ -91,7 +91,7 @@ pub struct Block<TX> {
pub epoch_snark_data: Option<EpochSnarkData>,
}

// ref https://eips.ethereum.org/EIPS/eip-1559
// ref <https://eips.ethereum.org/EIPS/eip-1559>
#[cfg(not(feature = "celo"))]
pub const ELASTICITY_MULTIPLIER: U256 = U256([2u64, 0, 0, 0]);
// max base fee delta is 12.5%
Expand All @@ -106,7 +106,7 @@ impl<TX> Block<TX> {
}

/// The next block's base fee, it is a function of parent block's base fee and gas usage.
/// Reference: https://eips.ethereum.org/EIPS/eip-1559
/// Reference: <https://eips.ethereum.org/EIPS/eip-1559>
#[cfg(not(feature = "celo"))]
pub fn next_block_base_fee(&self) -> Option<U256> {
let target_usage = self.gas_target();
Expand Down Expand Up @@ -162,7 +162,7 @@ pub struct EpochSnarkData {
/// A Block Hash or Block Number
pub enum BlockId {
// TODO: May want to expand this to include the requireCanonical field
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1898.md
// <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1898.md>
/// A block hash
Hash(H256),
/// A block number
Expand Down Expand Up @@ -291,7 +291,7 @@ mod tests {
}

#[test]
// https://github.com/tomusdrw/rust-web3/commit/3a32ee962c0f2f8d50a5e25be9f2dfec7ae0750d
// <https://github.com/tomusdrw/rust-web3/commit/3a32ee962c0f2f8d50a5e25be9f2dfec7ae0750d>
fn post_london_block() {
let json = serde_json::json!(
{
Expand Down Expand Up @@ -330,7 +330,7 @@ mod tests {

#[test]
fn test_next_block_base_fee() {
// https://etherscan.io/block/14402566
// <https://etherscan.io/block/14402566>
let mut block_14402566 = Block::<TxHash>::default();
block_14402566.number = Some(U64::from(14402566u64));
block_14402566.base_fee_per_gas = Some(U256::from(36_803_013_756u128));
Expand Down
2 changes: 1 addition & 1 deletion ethers-core/src/types/i256.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! This module contains an 256-bit signed integer implementation.
//! This module was derived for ethers-core via https://github.com/gnosis/ethcontract-rs/
//! This module was derived for ethers-core via <https://github.com/gnosis/ethcontract-rs/>
#![allow(clippy::wrong_self_convention)]
use crate::{
abi::{InvalidOutputType, Token, Tokenizable},
Expand Down
2 changes: 1 addition & 1 deletion ethers-core/src/types/trace/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types for the Parity Ad-Hoc Trace API
//!
//! https://openethereum.github.io/wiki/JSONRPC-trace-module
//! <https://openethereum.github.io/wiki/JSONRPC-trace-module>
use crate::types::{Bytes, H160, H256, U256};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
Expand Down
4 changes: 2 additions & 2 deletions ethers-core/src/types/transaction/eip712.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub enum Eip712Error {
/// for `derive_eip712` for more information and example usage.
///
/// For those who wish to manually implement this trait, see:
/// https://eips.ethereum.org/EIPS/eip-712
/// <https://eips.ethereum.org/EIPS/eip-712>
///
/// Any rust struct implementing Eip712 must also have a corresponding
/// struct in the verifying ethereum contract that matches its signature.
Expand Down Expand Up @@ -412,7 +412,7 @@ impl TryFrom<&syn::DeriveInput> for EIP712Domain {
}

/// Parse the eth abi parameter type based on the syntax type;
/// this method is copied from https://github.com/gakonst/ethers-rs/blob/master/ethers-contract/ethers-contract-derive/src/lib.rs#L600
/// this method is copied from <https://github.com/gakonst/ethers-rs/blob/master/ethers-contract/ethers-contract-derive/src/lib.rs#L600>
/// with additional modifications for finding byte arrays
pub fn find_parameter_type(ty: &Type) -> Result<ParamType, TokenStream> {
match ty {
Expand Down
2 changes: 1 addition & 1 deletion ethers-core/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ pub fn secret_key_to_address(secret_key: &SigningKey) -> Address {
}

/// Converts an Ethereum address to the checksum encoding
/// Ref: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
/// Ref: <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md>
pub fn to_checksum(addr: &Address, chain_id: Option<u8>) -> String {
let prefixed_addr = match chain_id {
Some(chain_id) => format!("{}0x{:x}", chain_id, addr),
Expand Down
2 changes: 1 addition & 1 deletion ethers-core/src/utils/moonbeam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::BTreeMap;

use k256::SecretKey;

/// Returns the private developer keys https://docs.moonbeam.network/snippets/code/setting-up-node/dev-accounts/
/// Returns the private developer keys <https://docs.moonbeam.network/snippets/code/setting-up-node/dev-accounts/>
pub fn dev_keys() -> Vec<SecretKey> {
MoonbeamDev::default().into_keys().collect()
}
Expand Down
4 changes: 2 additions & 2 deletions ethers-etherscan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub struct Client {
client: reqwest::Client,
/// Etherscan API key
api_key: String,
/// Etherscan API endpoint like https://api(-chain).etherscan.io/api
/// Etherscan API endpoint like <https://api(-chain).etherscan.io/api>
etherscan_api_url: Url,
/// Etherscan base endpoint like https://etherscan.io
/// Etherscan base endpoint like <https://etherscan.io>
etherscan_url: Url,
}

Expand Down
2 changes: 1 addition & 1 deletion ethers-middleware/src/gas_escalator/geometric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ethers_core::types::U256;
/// Coefficient defaults to 1.125 (12.5%), the minimum increase for Parity to replace a transaction.
/// Coefficient can be adjusted, and there is an optional upper limit.
///
/// https://github.com/makerdao/pymaker/blob/master/pymaker/gas.py#L168
/// <https://github.com/makerdao/pymaker/blob/master/pymaker/gas.py#L168>
#[derive(Clone, Debug)]
pub struct GeometricGasPrice {
every_secs: u64,
Expand Down
2 changes: 1 addition & 1 deletion ethers-middleware/src/gas_escalator/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ethers_core::types::U256;
/// Start with `initial_price`, then increase it by fixed amount `increase_by` every `every_secs`
/// seconds until the transaction gets confirmed. There is an optional upper limit.
///
/// https://github.com/makerdao/pymaker/blob/master/pymaker/gas.py#L129
/// <https://github.com/makerdao/pymaker/blob/master/pymaker/gas.py#L129>
#[derive(Clone, Debug)]
pub struct LinearGasPrice {
every_secs: u64,
Expand Down
7 changes: 5 additions & 2 deletions ethers-middleware/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![doc = include_str!("../README.md")]
#![deny(unsafe_code)]
#![deny(rustdoc::broken_intra_doc_links)]

/// The [Gas Escalator middleware](crate::gas_escalator::GasEscalatorMiddleware)
/// is used to re-broadcast transactions with an increasing gas price to guarantee
Expand All @@ -15,8 +17,9 @@ pub mod gas_oracle;
pub mod nonce_manager;
pub use nonce_manager::NonceManagerMiddleware;

/// The [Transformer](crate::TransformerMiddleware) is used to intercept transactions and transform
/// them to be sent via various supported transformers, e.g., [DSProxy](crate::transformer::DsProxy)
/// The [Transformer](crate::transformer::TransformerMiddleware) is used to intercept transactions
/// and transform them to be sent via various supported transformers, e.g.,
/// [DSProxy](crate::transformer::DsProxy)
pub mod transformer;

/// The [Signer](crate::SignerMiddleware) is used to locally sign transactions and messages
Expand Down
4 changes: 1 addition & 3 deletions ethers-middleware/src/transformer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ pub enum TransformerError {
AbiError(#[from] AbiError),
}

/// `Transformer` is a trait to be implemented by a proxy wallet, eg. [`DSProxy`], that intends to
/// `Transformer` is a trait to be implemented by a proxy wallet, eg. [`DsProxy`], that intends to
/// intercept a transaction request and transform it into one that is instead sent via the proxy
/// contract.
///
/// [`DSProxy`]: struct@crate::ds_proxy::DsProxy
pub trait Transformer: Send + Sync + std::fmt::Debug {
/// Transforms a [`transaction request`] into one that can be broadcasted and execute via the
/// proxy contract.
Expand Down
Loading

0 comments on commit 916e9a7

Please sign in to comment.