Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: const fns #280

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/providers/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct Stack<Inner, Outer> {

impl<Inner, Outer> Stack<Inner, Outer> {
/// Create a new `Stack`.
pub fn new(inner: Inner, outer: Outer) -> Self {
pub const fn new(inner: Inner, outer: Outer) -> Self {
Stack { inner, outer }
}
}
Expand Down Expand Up @@ -74,7 +74,8 @@ pub struct ProviderBuilder<L, N = ()> {
}

impl<N> ProviderBuilder<Identity, N> {
pub fn new() -> Self {
/// Create a new [`ProviderBuilder`].
pub const fn new() -> Self {
ProviderBuilder { layer: Identity, network: PhantomData }
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/providers/src/heart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct WatchConfig {

impl WatchConfig {
/// Create a new watch for a transaction.
pub fn new(tx_hash: B256) -> Self {
pub const fn new(tx_hash: B256) -> Self {
Self { tx_hash, confirmations: 0, timeout: None }
}

Expand All @@ -40,7 +40,7 @@ impl WatchConfig {
}

/// Set the number of confirmations to wait for.
pub fn with_confirmations(mut self, confirmations: u64) -> Self {
pub const fn with_confirmations(mut self, confirmations: u64) -> Self {
self.confirmations = confirmations;
self
}
Expand All @@ -51,7 +51,7 @@ impl WatchConfig {
}

/// Set the timeout for the transaction.
pub fn with_timeout(mut self, timeout: Duration) -> Self {
pub const fn with_timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
Expand Down Expand Up @@ -129,7 +129,7 @@ impl HeartbeatHandle {

/// Returns a watcher that always sees the latest block.
#[allow(dead_code)]
pub(crate) fn latest(&self) -> &watch::Receiver<Option<Block>> {
pub(crate) const fn latest(&self) -> &watch::Receiver<Option<Block>> {
&self.latest
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// missing_debug_implementations,
// missing_docs,
unreachable_pub,
// clippy::missing_const_for_fn,
clippy::missing_const_for_fn,
rustdoc::all
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
Expand Down
3 changes: 2 additions & 1 deletion crates/providers/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ use std::marker::PhantomData;
/// provider.send_transaction(TransactionRequest::default()).await;
/// # }
/// ```
#[derive(Debug)]
pub struct SignerLayer<S> {
signer: S,
}

impl<S> SignerLayer<S> {
/// Creates a new signing layer with the given signer.
pub fn new(signer: S) -> Self {
pub const fn new(signer: S) -> Self {
Self { signer }
}
}
Expand Down
Loading