From 7603af021be920ca39b610f88c0012328b337cd6 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 21 Aug 2023 13:36:56 +0200 Subject: [PATCH] chore: fix new rustdoc lints (#2563) --- ethers-contract/src/contract.rs | 13 ++++---- ethers-contract/src/event.rs | 11 +++++-- ethers-contract/src/factory.rs | 2 +- ethers-contract/src/multicall/mod.rs | 2 +- ethers-core/src/utils/anvil.rs | 2 +- ethers-core/src/utils/ganache.rs | 2 +- ethers-core/src/utils/geth.rs | 2 +- ethers-middleware/src/builder.rs | 26 ++++++--------- ethers-middleware/src/lib.rs | 33 +++++++++++-------- .../src/transformer/ds_proxy/mod.rs | 2 +- ethers-solc/src/compile/project.rs | 6 ++-- 11 files changed, 54 insertions(+), 47 deletions(-) diff --git a/ethers-contract/src/contract.rs b/ethers-contract/src/contract.rs index cb66b89c6..4977d7311 100644 --- a/ethers-contract/src/contract.rs +++ b/ethers-contract/src/contract.rs @@ -238,9 +238,10 @@ where B: Borrow, M: Middleware, { - /// Returns an [`Event`](crate::builders::Event) builder for the provided event. - /// This function operates in a static context, then it does not require a `self` - /// to reference to instantiate an [`Event`](crate::builders::Event) builder. + /// Returns an [`Event`] builder for the provided event. + /// + /// This function operates in a static context, then it does not require a `self` to reference + /// to instantiate an [`Event`] builder. pub fn event_of_type(client: B) -> Event { Event { provider: client, @@ -299,7 +300,7 @@ where B: Clone + Borrow, M: Middleware, { - /// Returns an [`Event`](crate::builders::Event) builder with the provided filter. + /// Returns an [`Event`] builder with the provided filter. pub fn event_with_filter(&self, filter: Filter) -> Event { Event { provider: self.client.clone(), @@ -309,12 +310,12 @@ where } } - /// Returns an [`Event`](crate::builders::Event) builder for the provided event. + /// Returns an [`Event`] builder for the provided event. pub fn event(&self) -> Event { D::new(Filter::new(), self.client.clone()) } - /// Returns an [`Event`](crate::builders::Event) builder with the provided name. + /// Returns an [`Event`] builder with the provided name. pub fn event_for_name(&self, name: &str) -> Result, Error> { // get the event's full name let event = self.base_contract.abi.event(name)?; diff --git a/ethers-contract/src/event.rs b/ethers-contract/src/event.rs index 7b62340bb..8a1d11f5b 100644 --- a/ethers-contract/src/event.rs +++ b/ethers-contract/src/event.rs @@ -90,15 +90,22 @@ where { /// Turns this event filter into `Stream` that yields decoded events. /// - /// This will first install a new logs filter via [`eth_newFilter`](https://docs.alchemy.com/alchemy/apis/ethereum/eth-newfilter) using the configured `filter` object. See also [`FilterWatcher`](ethers_providers::FilterWatcher). + /// This will first install a new logs filter via [`eth_newFilter`] using the configured + /// `filter` object. See also [`FilterWatcher`]. + /// + /// + /// Once the filter is created, this will periodically call [`eth_getFilterChanges`] to get the + /// newest logs and decode them. /// - /// Once the filter is created, this will periodically call [`eth_getFilterChanges`](https://docs.alchemy.com/alchemy/apis/ethereum/eth-getfilterchanges) to get the newest logs and decode them /// /// **Note:** Compared to [`Self::subscribe`], which is only available on `PubsubClient`s, such /// as Websocket, this is a poll-based subscription, as the node does not notify us when a new /// matching log is available, instead we have to actively ask for new logs using additional RPC /// requests, and this is done on an interval basis. /// + /// [`eth_newFilter`]: https://docs.alchemy.com/alchemy/apis/ethereum/eth-newfilter + /// [`eth_getFilterChanges`]: https://docs.alchemy.com/alchemy/apis/ethereum/eth-getfilterchanges + /// /// # Example // Ignore because `ethers-contract-derive` macros do not work in doctests in `ethers-contract`. /// ```ignore diff --git a/ethers-contract/src/factory.rs b/ethers-contract/src/factory.rs index f93f4fb1b..5ba4cba3c 100644 --- a/ethers-contract/src/factory.rs +++ b/ethers-contract/src/factory.rs @@ -166,7 +166,7 @@ where /// Broadcasts the contract deployment transaction and after waiting for it to /// be sufficiently confirmed (default: 1), it returns a new instance of the contract type at /// the deployed contract's address and the corresponding - /// [`TransactionReceipt`](ethers_core::types::TransactionReceipt). + /// [`TransactionReceipt`]. pub async fn send_with_receipt(self) -> Result<(C, TransactionReceipt), ContractError> { let (contract, receipt) = self.deployer.send_with_receipt().await?; Ok((C::from(contract), receipt)) diff --git a/ethers-contract/src/multicall/mod.rs b/ethers-contract/src/multicall/mod.rs index 2ae6c02ef..821d7b882 100644 --- a/ethers-contract/src/multicall/mod.rs +++ b/ethers-contract/src/multicall/mod.rs @@ -12,7 +12,7 @@ if_providers! { pub mod error; } -/// The version of the [`Multicall`](super::Multicall). +/// The version of the [`Multicall`]. /// Used to determine which methods of the Multicall smart contract to use: /// - [`Multicall`] : `aggregate((address,bytes)[])` /// - [`Multicall2`] : `try_aggregate(bool, (address,bytes)[])` diff --git a/ethers-core/src/utils/anvil.rs b/ethers-core/src/utils/anvil.rs index 2ab189fe9..33d48c497 100644 --- a/ethers-core/src/utils/anvil.rs +++ b/ethers-core/src/utils/anvil.rs @@ -16,7 +16,7 @@ const ANVIL_STARTUP_TIMEOUT_MILLIS: u64 = 10_000; /// An anvil CLI instance. Will close the instance when dropped. /// -/// Construct this using [`Anvil`](crate::utils::Anvil) +/// Construct this using [`Anvil`]. pub struct AnvilInstance { pid: Child, private_keys: Vec, diff --git a/ethers-core/src/utils/ganache.rs b/ethers-core/src/utils/ganache.rs index 5d604fd24..42141225c 100644 --- a/ethers-core/src/utils/ganache.rs +++ b/ethers-core/src/utils/ganache.rs @@ -15,7 +15,7 @@ const GANACHE_STARTUP_TIMEOUT_MILLIS: u64 = 10_000; /// A ganache CLI instance. Will close the instance when dropped. /// -/// Construct this using [`Ganache`](crate::utils::Ganache) +/// Construct this using [`Ganache`]. pub struct GanacheInstance { pid: Child, private_keys: Vec, diff --git a/ethers-core/src/utils/geth.rs b/ethers-core/src/utils/geth.rs index cf24e7b33..6e4742c62 100644 --- a/ethers-core/src/utils/geth.rs +++ b/ethers-core/src/utils/geth.rs @@ -42,7 +42,7 @@ pub enum GethInstanceError { /// A geth instance. Will close the instance when dropped. /// -/// Construct this using [`Geth`](crate::utils::Geth). +/// Construct this using [`Geth`]. #[derive(Debug)] pub struct GethInstance { pid: Child, diff --git a/ethers-middleware/src/builder.rs b/ethers-middleware/src/builder.rs index f824add9d..d35c6560b 100644 --- a/ethers-middleware/src/builder.rs +++ b/ethers-middleware/src/builder.rs @@ -6,10 +6,11 @@ use ethers_core::types::Address; use ethers_providers::Middleware; use ethers_signers::Signer; -/// A builder trait to compose different [`Middleware`](ethers_providers::Middleware) layers -/// and then build a composed [`Provider`](ethers_providers::Provider) architecture. -/// [`Middleware`](ethers_providers::Middleware) composition acts in a wrapping fashion. Adding a -/// new layer results in wrapping its predecessor. +/// A builder trait to compose different [`Middleware`] layers and then build a composed +/// [`Provider`](ethers_providers::Provider) architecture. +/// +/// [`Middleware`] composition acts in a wrapping fashion. Adding a new layer results in wrapping +/// its predecessor. /// /// ```rust /// use ethers_providers::{Middleware, Provider, Http}; @@ -48,10 +49,9 @@ use ethers_signers::Signer; /// } /// ``` pub trait MiddlewareBuilder: Middleware + Sized + 'static { - /// Wraps `self` inside a new [`Middleware`](ethers_providers::Middleware). + /// Wraps `self` inside a new [`Middleware`]. /// - /// `f` Consumes `self`. Must be used to return a new - /// [`Middleware`](ethers_providers::Middleware) wrapping `self`. + /// `f` Consumes `self`. Must be used to return a new [`Middleware`] wrapping `self`. fn wrap_into(self, f: F) -> T where F: FnOnce(Self) -> T, @@ -60,9 +60,7 @@ pub trait MiddlewareBuilder: Middleware + Sized + 'static { f(self) } - /// Wraps `self` inside a [`SignerMiddleware`](crate::SignerMiddleware). - /// - /// [`Signer`](ethers_signers::Signer) + /// Wraps `self` inside a [`SignerMiddleware`]. fn with_signer(self, s: S) -> SignerMiddleware where S: Signer, @@ -70,16 +68,12 @@ pub trait MiddlewareBuilder: Middleware + Sized + 'static { SignerMiddleware::new(self, s) } - /// Wraps `self` inside a [`NonceManagerMiddleware`](crate::NonceManagerMiddleware). - /// - /// [`Address`](ethers_core::types::Address) + /// Wraps `self` inside a [`NonceManagerMiddleware`]. fn nonce_manager(self, address: Address) -> NonceManagerMiddleware { NonceManagerMiddleware::new(self, address) } - /// Wraps `self` inside a [`GasOracleMiddleware`](crate::gas_oracle::GasOracleMiddleware). - /// - /// [`GasOracle`](crate::gas_oracle::GasOracle) + /// Wraps `self` inside a [`GasOracleMiddleware`]. fn gas_oracle(self, gas_oracle: G) -> GasOracleMiddleware where G: GasOracle, diff --git a/ethers-middleware/src/lib.rs b/ethers-middleware/src/lib.rs index 451f1eded..9c7518835 100644 --- a/ethers-middleware/src/lib.rs +++ b/ethers-middleware/src/lib.rs @@ -6,42 +6,47 @@ /// is used to re-broadcast transactions with an increasing gas price to guarantee /// their timely inclusion. pub mod gas_escalator; +pub use gas_escalator::GasEscalatorMiddleware; -/// The gas oracle middleware is used to get the gas price from a list of gas oracles -/// instead of using eth_gasPrice. For usage examples, refer to the -/// [`GasOracle`](crate::gas_oracle::GasOracle) trait. +/// The gas oracle middleware is used to get the gas price from a list of gas oracles instead of +/// using `eth_gasPrice`. For usage examples, refer to the [`GasOracle`] trait. pub mod gas_oracle; +pub use gas_oracle::GasOracle; /// The [Nonce Manager](crate::NonceManagerMiddleware) is used to locally calculate nonces instead /// of using eth_getTransactionCount pub mod nonce_manager; pub use nonce_manager::NonceManagerMiddleware; -/// The [Transformer](crate::transformer::TransformerMiddleware) is used to intercept transactions +/// The [TransformerMiddleware] is used to intercept transactions /// and transform them to be sent via various supported transformers, e.g., -/// [DSProxy](crate::transformer::DsProxy) +/// [DSProxy](crate::transformer::DsProxy). pub mod transformer; +pub use transformer::TransformerMiddleware; -/// The [Signer](crate::SignerMiddleware) is used to locally sign transactions and messages -/// instead of using eth_sendTransaction and eth_sign +/// The [SignerMiddleware] is used to locally sign transactions and messages instead of using +/// `eth_sendTransaction` and `eth_sign`. pub mod signer; pub use signer::SignerMiddleware; -/// The [Policy](crate::PolicyMiddleware) is used to ensure transactions comply with the rules -/// configured in the `PolicyMiddleware` before sending them. +/// The [Policy] is used to ensure transactions comply with the rules configured in the +/// [`PolicyMiddleware`] before sending them. pub mod policy; -pub use policy::PolicyMiddleware; +pub use policy::{ + AllowEverything, Policy, PolicyMiddleware, PolicyMiddlewareError, RejectEverything, +}; -/// The [TimeLag](crate::TimeLag) provides safety against reorgs by querying state N blocks -/// before the chain tip +/// The [TimeLag] middleware provides safety against reorgs by querying state N blocks before the +/// chain tip. pub mod timelag; pub use timelag::TimeLag; -/// The [MiddlewareBuilder](crate::MiddlewareBuilder) provides a way to compose many -/// [`Middleware`](ethers_providers::Middleware) in a concise way +/// [MiddlewareBuilder] provides a way to compose many [`Middleware`]s in a concise way. pub mod builder; pub use builder::MiddlewareBuilder; +pub use ethers_providers::{Middleware, MiddlewareError}; + // For macro expansions only, not public API. // See: [#2235](https://github.com/gakonst/ethers-rs/pull/2235) diff --git a/ethers-middleware/src/transformer/ds_proxy/mod.rs b/ethers-middleware/src/transformer/ds_proxy/mod.rs index 3819d0851..724bbde5f 100644 --- a/ethers-middleware/src/transformer/ds_proxy/mod.rs +++ b/ethers-middleware/src/transformer/ds_proxy/mod.rs @@ -18,7 +18,7 @@ const DS_PROXY_EXECUTE_TARGET: &str = const DS_PROXY_EXECUTE_CODE: &str = "function execute(bytes memory code, bytes memory data) public payable returns (address target, bytes memory response)"; -/// Represents the DsProxy type that implements the [Transformer](super::Transformer) trait. +/// Represents the DsProxy type that implements the [Transformer] trait. /// /// # Example /// diff --git a/ethers-solc/src/compile/project.rs b/ethers-solc/src/compile/project.rs index 423ae39e3..98ef09e7c 100644 --- a/ethers-solc/src/compile/project.rs +++ b/ethers-solc/src/compile/project.rs @@ -77,9 +77,9 @@ //! //! ### Caching and Change detection //! -//! If caching is enabled in the [Project](crate::Project) a cache file will be created upon a -//! successful solc build. The [cache file](crate::cache::SolFilesCache) stores metadata for all the -//! files that were provided to solc. +//! If caching is enabled in the [Project] a cache file will be created upon a successful solc +//! build. The [cache file](crate::cache::SolFilesCache) stores metadata for all the files that were +//! provided to solc. //! For every file the cache file contains a dedicated [cache entry](crate::cache::CacheEntry), //! which represents the state of the file. A solidity file can contain several contracts, for every //! contract a separate [artifact](crate::Artifact) is emitted. Therefor the entry also tracks all