chore(clippy): make clippy happy (#705)

This commit is contained in:
Matthias Seitz 2021-12-19 05:28:38 +01:00 committed by GitHub
parent f7fea53d62
commit e24117a1e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 136 additions and 3 deletions

View File

@ -81,6 +81,7 @@ impl Abigen {
/// Manually adds a solidity event alias to specify what the event struct /// Manually adds a solidity event alias to specify what the event struct
/// and function name will be in Rust. /// and function name will be in Rust.
#[must_use]
pub fn add_event_alias<S1, S2>(mut self, signature: S1, alias: S2) -> Self pub fn add_event_alias<S1, S2>(mut self, signature: S1, alias: S2) -> Self
where where
S1: Into<String>, S1: Into<String>,
@ -93,6 +94,7 @@ impl Abigen {
/// Manually adds a solidity method alias to specify what the method name /// Manually adds a solidity method alias to specify what the method name
/// will be in Rust. For solidity methods without an alias, the snake cased /// will be in Rust. For solidity methods without an alias, the snake cased
/// method name will be used. /// method name will be used.
#[must_use]
pub fn add_method_alias<S1, S2>(mut self, signature: S1, alias: S2) -> Self pub fn add_method_alias<S1, S2>(mut self, signature: S1, alias: S2) -> Self
where where
S1: Into<String>, S1: Into<String>,
@ -107,6 +109,7 @@ impl Abigen {
/// ///
/// Note that in case `rustfmt` does not exist or produces an error, the /// Note that in case `rustfmt` does not exist or produces an error, the
/// unformatted code will be used. /// unformatted code will be used.
#[must_use]
pub fn rustfmt(mut self, rustfmt: bool) -> Self { pub fn rustfmt(mut self, rustfmt: bool) -> Self {
self.rustfmt = rustfmt; self.rustfmt = rustfmt;
self self
@ -116,6 +119,7 @@ impl Abigen {
/// ///
/// This makes it possible to for example derive serde::Serialize and /// This makes it possible to for example derive serde::Serialize and
/// serde::Deserialize for events. /// serde::Deserialize for events.
#[must_use]
pub fn add_event_derive<S>(mut self, derive: S) -> Self pub fn add_event_derive<S>(mut self, derive: S) -> Self
where where
S: Into<String>, S: Into<String>,

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use super::base::{decode_function_data, AbiError}; use super::base::{decode_function_data, AbiError};
use ethers_core::{ use ethers_core::{
abi::{AbiDecode, AbiEncode, Detokenize, Function, InvalidOutputType, Tokenizable}, abi::{AbiDecode, AbiEncode, Detokenize, Function, InvalidOutputType, Tokenizable},

View File

@ -247,6 +247,7 @@ impl<M: Middleware> Contract<M> {
/// Returns a new contract instance at `address`. /// Returns a new contract instance at `address`.
/// ///
/// Clones `self` internally /// Clones `self` internally
#[must_use]
pub fn at<T: Into<Address>>(&self, address: T) -> Self pub fn at<T: Into<Address>>(&self, address: T) -> Self
where where
M: Clone, M: Clone,
@ -259,6 +260,7 @@ impl<M: Middleware> Contract<M> {
/// Returns a new contract instance using the provided client /// Returns a new contract instance using the provided client
/// ///
/// Clones `self` internally /// Clones `self` internally
#[must_use]
pub fn connect(&self, client: Arc<M>) -> Self pub fn connect(&self, client: Arc<M>) -> Self
where where
M: Clone, M: Clone,

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use crate::{log::LogMeta, stream::EventStream, ContractError, EthLogDecode}; use crate::{log::LogMeta, stream::EventStream, ContractError, EthLogDecode};
use ethers_core::{ use ethers_core::{

View File

@ -24,17 +24,20 @@ pub struct Deployer<M> {
impl<M: Middleware> Deployer<M> { impl<M: Middleware> Deployer<M> {
/// Sets the number of confirmations to wait for the contract deployment transaction /// Sets the number of confirmations to wait for the contract deployment transaction
#[must_use]
pub fn confirmations<T: Into<usize>>(mut self, confirmations: T) -> Self { pub fn confirmations<T: Into<usize>>(mut self, confirmations: T) -> Self {
self.confs = confirmations.into(); self.confs = confirmations.into();
self self
} }
#[must_use]
pub fn block<T: Into<BlockNumber>>(mut self, block: T) -> Self { pub fn block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.block = block.into(); self.block = block.into();
self self
} }
/// Uses a Legacy transaction instead of an EIP-1559 one to do the deployment /// Uses a Legacy transaction instead of an EIP-1559 one to do the deployment
#[must_use]
pub fn legacy(mut self) -> Self { pub fn legacy(mut self) -> Self {
self.tx = match self.tx { self.tx = match self.tx {
TypedTransaction::Eip1559(inner) => { TypedTransaction::Eip1559(inner) => {

View File

@ -173,12 +173,14 @@ impl<M: Middleware> Multicall<M> {
} }
/// Makes a legacy transaction instead of an EIP-1559 one /// Makes a legacy transaction instead of an EIP-1559 one
#[must_use]
pub fn legacy(mut self) -> Self { pub fn legacy(mut self) -> Self {
self.legacy = true; self.legacy = true;
self self
} }
/// Sets the `block` field for the multicall aggregate call /// Sets the `block` field for the multicall aggregate call
#[must_use]
pub fn block<T: Into<BlockNumber>>(mut self, block: T) -> Self { pub fn block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.block = Some(block.into()); self.block = Some(block.into());
self self

View File

@ -329,6 +329,7 @@ impl I256 {
} }
/// Returns the sign of the number. /// Returns the sign of the number.
#[must_use]
pub fn signum(self) -> Self { pub fn signum(self) -> Self {
self.signum64().into() self.signum64().into()
} }
@ -370,6 +371,7 @@ impl I256 {
/// # Panics /// # Panics
/// ///
/// In debug mode, will panic if it overflows. /// In debug mode, will panic if it overflows.
#[must_use]
pub fn abs(self) -> Self { pub fn abs(self) -> Self {
handle_overflow(self.overflowing_abs()) handle_overflow(self.overflowing_abs())
} }
@ -402,12 +404,14 @@ impl I256 {
/// Saturating absolute value. Computes `self.abs()`, returning `MAX` if /// Saturating absolute value. Computes `self.abs()`, returning `MAX` if
/// `self == MIN` instead of overflowing. /// `self == MIN` instead of overflowing.
#[must_use]
pub fn saturating_abs(self) -> Self { pub fn saturating_abs(self) -> Self {
self.checked_abs().unwrap_or(I256::MAX) self.checked_abs().unwrap_or(I256::MAX)
} }
/// Wrapping absolute value. Computes `self.abs()`, wrapping around at the /// Wrapping absolute value. Computes `self.abs()`, wrapping around at the
/// boundary of the type. /// boundary of the type.
#[must_use]
pub fn wrapping_abs(self) -> Self { pub fn wrapping_abs(self) -> Self {
let (result, _) = self.overflowing_abs(); let (result, _) = self.overflowing_abs();
result result
@ -446,12 +450,14 @@ impl I256 {
/// Saturating negation. Computes `self.neg()`, returning `MAX` if /// Saturating negation. Computes `self.neg()`, returning `MAX` if
/// `self == MIN` instead of overflowing. /// `self == MIN` instead of overflowing.
#[must_use]
pub fn saturating_neg(self) -> Self { pub fn saturating_neg(self) -> Self {
self.checked_neg().unwrap_or(I256::MAX) self.checked_neg().unwrap_or(I256::MAX)
} }
/// Wrapping negation. Computes `self.neg()`, returning `MIN` if /// Wrapping negation. Computes `self.neg()`, returning `MIN` if
/// `self == MIN` instead of overflowing. /// `self == MIN` instead of overflowing.
#[must_use]
pub fn wrapping_neg(self) -> Self { pub fn wrapping_neg(self) -> Self {
let (result, _) = self.overflowing_neg(); let (result, _) = self.overflowing_neg();
result result
@ -567,6 +573,7 @@ impl I256 {
} }
/// Addition which saturates at the maximum value (Self::max_value()). /// Addition which saturates at the maximum value (Self::max_value()).
#[must_use]
pub fn saturating_add(self, other: Self) -> Self { pub fn saturating_add(self, other: Self) -> Self {
let (result, overflow) = self.overflowing_add(other); let (result, overflow) = self.overflowing_add(other);
if overflow { if overflow {
@ -580,6 +587,7 @@ impl I256 {
} }
/// Wrapping addition. /// Wrapping addition.
#[must_use]
pub fn wrapping_add(self, other: Self) -> Self { pub fn wrapping_add(self, other: Self) -> Self {
let (result, _) = self.overflowing_add(other); let (result, _) = self.overflowing_add(other);
result result
@ -620,6 +628,7 @@ impl I256 {
} }
/// Subtraction which saturates at zero. /// Subtraction which saturates at zero.
#[must_use]
pub fn saturating_sub(self, other: Self) -> Self { pub fn saturating_sub(self, other: Self) -> Self {
let (result, overflow) = self.overflowing_sub(other); let (result, overflow) = self.overflowing_sub(other);
if overflow { if overflow {
@ -633,6 +642,7 @@ impl I256 {
} }
/// Wrapping subtraction. /// Wrapping subtraction.
#[must_use]
pub fn wrapping_sub(self, other: Self) -> Self { pub fn wrapping_sub(self, other: Self) -> Self {
let (result, _) = self.overflowing_sub(other); let (result, _) = self.overflowing_sub(other);
result result
@ -662,6 +672,7 @@ impl I256 {
} }
/// Multiplication which saturates at the maximum value.. /// Multiplication which saturates at the maximum value..
#[must_use]
pub fn saturating_mul(self, rhs: Self) -> Self { pub fn saturating_mul(self, rhs: Self) -> Self {
self.checked_mul(rhs).unwrap_or_else(|| { self.checked_mul(rhs).unwrap_or_else(|| {
match Sign::from_signum64(self.signum64() * rhs.signum64()) { match Sign::from_signum64(self.signum64() * rhs.signum64()) {
@ -672,6 +683,7 @@ impl I256 {
} }
/// Wrapping multiplication. /// Wrapping multiplication.
#[must_use]
pub fn wrapping_mul(self, rhs: Self) -> Self { pub fn wrapping_mul(self, rhs: Self) -> Self {
let (result, _) = self.overflowing_mul(rhs); let (result, _) = self.overflowing_mul(rhs);
result result
@ -702,12 +714,14 @@ impl I256 {
} }
/// Division which saturates at the maximum value. /// Division which saturates at the maximum value.
#[must_use]
pub fn saturating_div(self, rhs: Self) -> Self { pub fn saturating_div(self, rhs: Self) -> Self {
// There is only one overflow (I256::MIN / -1 = I256::MAX) // There is only one overflow (I256::MIN / -1 = I256::MAX)
self.checked_div(rhs).unwrap_or(I256::MAX) self.checked_div(rhs).unwrap_or(I256::MAX)
} }
/// Wrapping division. /// Wrapping division.
#[must_use]
pub fn wrapping_div(self, rhs: Self) -> Self { pub fn wrapping_div(self, rhs: Self) -> Self {
self.overflowing_div(rhs).0 self.overflowing_div(rhs).0
} }
@ -737,6 +751,7 @@ impl I256 {
/// Wrapping remainder. Returns the result of the operation % /// Wrapping remainder. Returns the result of the operation %
/// regardless of whether or not the division overflowed. /// regardless of whether or not the division overflowed.
#[must_use]
pub fn wrapping_rem(self, rhs: Self) -> Self { pub fn wrapping_rem(self, rhs: Self) -> Self {
self.overflowing_rem(rhs).0 self.overflowing_rem(rhs).0
} }
@ -749,6 +764,7 @@ impl I256 {
/// rhs`: /// rhs`:
/// * If `self > 0`, this is equal to round towards zero (the default in Rust); /// * If `self > 0`, this is equal to round towards zero (the default in Rust);
/// * If `self < 0`, this is equal to round towards +/- infinity. /// * If `self < 0`, this is equal to round towards +/- infinity.
#[must_use]
pub fn div_euclid(self, rhs: Self) -> Self { pub fn div_euclid(self, rhs: Self) -> Self {
let q = self / rhs; let q = self / rhs;
if (self % rhs).is_negative() { if (self % rhs).is_negative() {
@ -761,6 +777,7 @@ impl I256 {
/// This is done as if by the _Euclidean division algorithm_ /// This is done as if by the _Euclidean division algorithm_
/// given `r = self.rem_euclid(rhs)`, `self = rhs * self.div_euclid(rhs) + r, and 0 <= r < /// given `r = self.rem_euclid(rhs)`, `self = rhs * self.div_euclid(rhs) + r, and 0 <= r <
/// abs(rhs)`. /// abs(rhs)`.
#[must_use]
pub fn rem_euclid(self, rhs: Self) -> Self { pub fn rem_euclid(self, rhs: Self) -> Self {
let r = self % rhs; let r = self % rhs;
if r < Self::zero() { if r < Self::zero() {
@ -801,6 +818,7 @@ impl I256 {
/// (where `MIN` is the negative minimal value for the type). /// (where `MIN` is the negative minimal value for the type).
/// This is equivalent to `-MIN`, a positive value that is too large to represent in the type. /// This is equivalent to `-MIN`, a positive value that is too large to represent in the type.
/// In this case, this method returns `MIN` itself. /// In this case, this method returns `MIN` itself.
#[must_use]
pub fn wrapping_div_euclid(self, rhs: Self) -> Self { pub fn wrapping_div_euclid(self, rhs: Self) -> Self {
self.overflowing_div_euclid(rhs).0 self.overflowing_div_euclid(rhs).0
} }
@ -823,6 +841,7 @@ impl I256 {
/// (where `MIN` is the negative minimal value for the type). /// (where `MIN` is the negative minimal value for the type).
/// In this case, this method returns `0`. /// In this case, this method returns `0`.
/// Panics when `rhs == 0` /// Panics when `rhs == 0`
#[must_use]
pub fn wrapping_rem_euclid(self, rhs: Self) -> Self { pub fn wrapping_rem_euclid(self, rhs: Self) -> Self {
self.overflowing_rem_euclid(rhs).0 self.overflowing_rem_euclid(rhs).0
} }
@ -867,6 +886,7 @@ impl I256 {
/// # Panics /// # Panics
/// ///
/// Panics if the result overflows the type in debug mode. /// Panics if the result overflows the type in debug mode.
#[must_use]
pub fn pow(self, exp: u32) -> Self { pub fn pow(self, exp: u32) -> Self {
handle_overflow(self.overflowing_pow(exp)) handle_overflow(self.overflowing_pow(exp))
} }
@ -895,6 +915,7 @@ impl I256 {
/// Raises self to the power of `exp`, saturating at the numeric bounds /// Raises self to the power of `exp`, saturating at the numeric bounds
/// instead of overflowing. /// instead of overflowing.
#[must_use]
pub fn saturating_pow(self, exp: u32) -> Self { pub fn saturating_pow(self, exp: u32) -> Self {
let (result, overflow) = self.overflowing_pow(exp); let (result, overflow) = self.overflowing_pow(exp);
if overflow { if overflow {
@ -909,6 +930,7 @@ impl I256 {
/// Wrapping powolute value. Computes `self.pow()`, wrapping around at the /// Wrapping powolute value. Computes `self.pow()`, wrapping around at the
/// boundary of the type. /// boundary of the type.
#[must_use]
pub fn wrapping_pow(self, exp: u32) -> Self { pub fn wrapping_pow(self, exp: u32) -> Self {
let (result, _) = self.overflowing_pow(exp); let (result, _) = self.overflowing_pow(exp);
result result
@ -1635,7 +1657,7 @@ mod tests {
#[test] #[test]
#[cfg_attr(debug_assertions, should_panic)] #[cfg_attr(debug_assertions, should_panic)]
fn div_euclid_overflow() { fn div_euclid_overflow() {
I256::MIN.div_euclid(-I256::one()); let _ = I256::MIN.div_euclid(-I256::one());
} }
#[test] #[test]

View File

@ -123,6 +123,7 @@ impl Default for FilterBlockOption {
} }
impl FilterBlockOption { impl FilterBlockOption {
#[must_use]
pub fn set_from_block(&self, block: BlockNumber) -> Self { pub fn set_from_block(&self, block: BlockNumber) -> Self {
let to_block = let to_block =
if let FilterBlockOption::Range { to_block, .. } = self { *to_block } else { None }; if let FilterBlockOption::Range { to_block, .. } = self { *to_block } else { None };
@ -130,6 +131,7 @@ impl FilterBlockOption {
FilterBlockOption::Range { from_block: Some(block), to_block } FilterBlockOption::Range { from_block: Some(block), to_block }
} }
#[must_use]
pub fn set_to_block(&self, block: BlockNumber) -> Self { pub fn set_to_block(&self, block: BlockNumber) -> Self {
let from_block = let from_block =
if let FilterBlockOption::Range { from_block, .. } = self { *from_block } else { None }; if let FilterBlockOption::Range { from_block, .. } = self { *from_block } else { None };
@ -137,6 +139,7 @@ impl FilterBlockOption {
FilterBlockOption::Range { from_block, to_block: Some(block) } FilterBlockOption::Range { from_block, to_block: Some(block) }
} }
#[must_use]
pub fn set_hash(&self, hash: H256) -> Self { pub fn set_hash(&self, hash: H256) -> Self {
FilterBlockOption::AtBlockHash(hash) FilterBlockOption::AtBlockHash(hash)
} }
@ -273,64 +276,75 @@ impl Filter {
/// let filter = Filter::new().select(..1337u64); /// let filter = Filter::new().select(..1337u64);
/// # } /// # }
/// ``` /// ```
#[must_use]
pub fn select(mut self, filter: impl Into<FilterBlockOption>) -> Self { pub fn select(mut self, filter: impl Into<FilterBlockOption>) -> Self {
self.block_option = filter.into(); self.block_option = filter.into();
self self
} }
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn from_block<T: Into<BlockNumber>>(mut self, block: T) -> Self { pub fn from_block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.block_option = self.block_option.set_from_block(block.into()); self.block_option = self.block_option.set_from_block(block.into());
self self
} }
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn to_block<T: Into<BlockNumber>>(mut self, block: T) -> Self { pub fn to_block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.block_option = self.block_option.set_to_block(block.into()); self.block_option = self.block_option.set_to_block(block.into());
self self
} }
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn at_block_hash<T: Into<H256>>(mut self, hash: T) -> Self { pub fn at_block_hash<T: Into<H256>>(mut self, hash: T) -> Self {
self.block_option = self.block_option.set_hash(hash.into()); self.block_option = self.block_option.set_hash(hash.into());
self self
} }
#[must_use]
pub fn address<T: Into<ValueOrArray<Address>>>(mut self, address: T) -> Self { pub fn address<T: Into<ValueOrArray<Address>>>(mut self, address: T) -> Self {
self.address = Some(address.into()); self.address = Some(address.into());
self self
} }
/// given the event in string form, it hashes it and adds it to the topics to monitor /// given the event in string form, it hashes it and adds it to the topics to monitor
#[must_use]
pub fn event(self, event_name: &str) -> Self { pub fn event(self, event_name: &str) -> Self {
let hash = H256::from(keccak256(event_name.as_bytes())); let hash = H256::from(keccak256(event_name.as_bytes()));
self.topic0(hash) self.topic0(hash)
} }
/// Sets topic0 (the event name for non-anonymous events) /// Sets topic0 (the event name for non-anonymous events)
#[must_use]
pub fn topic0<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self { pub fn topic0<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[0] = Some(topic.into()); self.topics[0] = Some(topic.into());
self self
} }
/// Sets the 1st indexed topic /// Sets the 1st indexed topic
#[must_use]
pub fn topic1<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self { pub fn topic1<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[1] = Some(topic.into()); self.topics[1] = Some(topic.into());
self self
} }
/// Sets the 2nd indexed topic /// Sets the 2nd indexed topic
#[must_use]
pub fn topic2<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self { pub fn topic2<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[2] = Some(topic.into()); self.topics[2] = Some(topic.into());
self self
} }
/// Sets the 3rd indexed topic /// Sets the 3rd indexed topic
#[must_use]
pub fn topic3<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self { pub fn topic3<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[3] = Some(topic.into()); self.topics[3] = Some(topic.into());
self self
} }
#[must_use]
pub fn limit(mut self, limit: usize) -> Self { pub fn limit(mut self, limit: usize) -> Self {
self.limit = Some(limit); self.limit = Some(limit);
self self

View File

@ -29,6 +29,7 @@ pub struct TraceFilter {
impl TraceFilter { impl TraceFilter {
/// Sets From block /// Sets From block
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn from_block<T: Into<BlockNumber>>(mut self, block: T) -> Self { pub fn from_block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.from_block = Some(block.into()); self.from_block = Some(block.into());
self self
@ -36,6 +37,7 @@ impl TraceFilter {
/// Sets to block /// Sets to block
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn to_block<T: Into<BlockNumber>>(mut self, block: T) -> Self { pub fn to_block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.to_block = Some(block.into()); self.to_block = Some(block.into());
self self
@ -43,6 +45,7 @@ impl TraceFilter {
/// Sets to address /// Sets to address
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn to_address(mut self, address: Vec<H160>) -> Self { pub fn to_address(mut self, address: Vec<H160>) -> Self {
self.to_address = Some(address); self.to_address = Some(address);
self self
@ -50,18 +53,21 @@ impl TraceFilter {
/// Sets from address /// Sets from address
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn from_address(mut self, address: Vec<H160>) -> Self { pub fn from_address(mut self, address: Vec<H160>) -> Self {
self.from_address = Some(address); self.from_address = Some(address);
self self
} }
/// Sets after offset /// Sets after offset
#[must_use]
pub fn after(mut self, after: usize) -> Self { pub fn after(mut self, after: usize) -> Self {
self.after = Some(after); self.after = Some(after);
self self
} }
/// Sets amount of traces to display /// Sets amount of traces to display
#[must_use]
pub fn count(mut self, count: usize) -> Self { pub fn count(mut self, count: usize) -> Self {
self.count = Some(count); self.count = Some(count);
self self

View File

@ -68,54 +68,63 @@ impl Eip1559TransactionRequest {
// Builder pattern helpers // Builder pattern helpers
/// Sets the `from` field in the transaction to the provided value /// Sets the `from` field in the transaction to the provided value
#[must_use]
pub fn from<T: Into<Address>>(mut self, from: T) -> Self { pub fn from<T: Into<Address>>(mut self, from: T) -> Self {
self.from = Some(from.into()); self.from = Some(from.into());
self self
} }
/// Sets the `to` field in the transaction to the provided value /// Sets the `to` field in the transaction to the provided value
#[must_use]
pub fn to<T: Into<NameOrAddress>>(mut self, to: T) -> Self { pub fn to<T: Into<NameOrAddress>>(mut self, to: T) -> Self {
self.to = Some(to.into()); self.to = Some(to.into());
self self
} }
/// Sets the `gas` field in the transaction to the provided value /// Sets the `gas` field in the transaction to the provided value
#[must_use]
pub fn gas<T: Into<U256>>(mut self, gas: T) -> Self { pub fn gas<T: Into<U256>>(mut self, gas: T) -> Self {
self.gas = Some(gas.into()); self.gas = Some(gas.into());
self self
} }
/// Sets the `max_priority_fee_per_gas` field in the transaction to the provided value /// Sets the `max_priority_fee_per_gas` field in the transaction to the provided value
#[must_use]
pub fn max_priority_fee_per_gas<T: Into<U256>>(mut self, max_priority_fee_per_gas: T) -> Self { pub fn max_priority_fee_per_gas<T: Into<U256>>(mut self, max_priority_fee_per_gas: T) -> Self {
self.max_priority_fee_per_gas = Some(max_priority_fee_per_gas.into()); self.max_priority_fee_per_gas = Some(max_priority_fee_per_gas.into());
self self
} }
/// Sets the `max_fee_per_gas` field in the transaction to the provided value /// Sets the `max_fee_per_gas` field in the transaction to the provided value
#[must_use]
pub fn max_fee_per_gas<T: Into<U256>>(mut self, max_fee_per_gas: T) -> Self { pub fn max_fee_per_gas<T: Into<U256>>(mut self, max_fee_per_gas: T) -> Self {
self.max_fee_per_gas = Some(max_fee_per_gas.into()); self.max_fee_per_gas = Some(max_fee_per_gas.into());
self self
} }
/// Sets the `value` field in the transaction to the provided value /// Sets the `value` field in the transaction to the provided value
#[must_use]
pub fn value<T: Into<U256>>(mut self, value: T) -> Self { pub fn value<T: Into<U256>>(mut self, value: T) -> Self {
self.value = Some(value.into()); self.value = Some(value.into());
self self
} }
/// Sets the `data` field in the transaction to the provided value /// Sets the `data` field in the transaction to the provided value
#[must_use]
pub fn data<T: Into<Bytes>>(mut self, data: T) -> Self { pub fn data<T: Into<Bytes>>(mut self, data: T) -> Self {
self.data = Some(data.into()); self.data = Some(data.into());
self self
} }
/// Sets the `access_list` field in the transaction to the provided value /// Sets the `access_list` field in the transaction to the provided value
#[must_use]
pub fn access_list<T: Into<AccessList>>(mut self, access_list: T) -> Self { pub fn access_list<T: Into<AccessList>>(mut self, access_list: T) -> Self {
self.access_list = access_list.into(); self.access_list = access_list.into();
self self
} }
/// Sets the `nonce` field in the transaction to the provided value /// Sets the `nonce` field in the transaction to the provided value
#[must_use]
pub fn nonce<T: Into<U256>>(mut self, nonce: T) -> Self { pub fn nonce<T: Into<U256>>(mut self, nonce: T) -> Self {
self.nonce = Some(nonce.into()); self.nonce = Some(nonce.into());
self self

View File

@ -119,7 +119,7 @@ mod tests {
let enc = rlp::encode(&tx.rlp_signed(1, &sig).as_ref()); let enc = rlp::encode(&tx.rlp_signed(1, &sig).as_ref());
let expected = "b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b2660a032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d37521"; let expected = "b86601f8630103018261a894b94f5374fce5edbc8e2a8697c15331677e6ebf0b0a825544c001a0c9519f4f2b30335884581971573fadf60c6204f59a911df35ee8a540456b2660a032f1e8e2c5dd761f9e4f88f41c8310aeaba26a8bfcdacfedfa12ec3862d37521";
assert_eq!(hex::encode(enc.to_vec()), expected); assert_eq!(hex::encode(&enc), expected);
} }
#[test] #[test]

View File

@ -166,6 +166,7 @@ impl<T: Eip712 + Clone> EIP712WithDomain<T> {
Ok(Self { domain, inner }) Ok(Self { domain, inner })
} }
#[must_use]
pub fn set_domain(self, domain: EIP712Domain) -> Self { pub fn set_domain(self, domain: EIP712Domain) -> Self {
Self { domain, inner: self.inner } Self { domain, inner: self.inner }
} }

View File

@ -75,42 +75,49 @@ impl TransactionRequest {
// Builder pattern helpers // Builder pattern helpers
/// Sets the `from` field in the transaction to the provided value /// Sets the `from` field in the transaction to the provided value
#[must_use]
pub fn from<T: Into<Address>>(mut self, from: T) -> Self { pub fn from<T: Into<Address>>(mut self, from: T) -> Self {
self.from = Some(from.into()); self.from = Some(from.into());
self self
} }
/// Sets the `to` field in the transaction to the provided value /// Sets the `to` field in the transaction to the provided value
#[must_use]
pub fn to<T: Into<NameOrAddress>>(mut self, to: T) -> Self { pub fn to<T: Into<NameOrAddress>>(mut self, to: T) -> Self {
self.to = Some(to.into()); self.to = Some(to.into());
self self
} }
/// Sets the `gas` field in the transaction to the provided value /// Sets the `gas` field in the transaction to the provided value
#[must_use]
pub fn gas<T: Into<U256>>(mut self, gas: T) -> Self { pub fn gas<T: Into<U256>>(mut self, gas: T) -> Self {
self.gas = Some(gas.into()); self.gas = Some(gas.into());
self self
} }
/// Sets the `gas_price` field in the transaction to the provided value /// Sets the `gas_price` field in the transaction to the provided value
#[must_use]
pub fn gas_price<T: Into<U256>>(mut self, gas_price: T) -> Self { pub fn gas_price<T: Into<U256>>(mut self, gas_price: T) -> Self {
self.gas_price = Some(gas_price.into()); self.gas_price = Some(gas_price.into());
self self
} }
/// Sets the `value` field in the transaction to the provided value /// Sets the `value` field in the transaction to the provided value
#[must_use]
pub fn value<T: Into<U256>>(mut self, value: T) -> Self { pub fn value<T: Into<U256>>(mut self, value: T) -> Self {
self.value = Some(value.into()); self.value = Some(value.into());
self self
} }
/// Sets the `data` field in the transaction to the provided value /// Sets the `data` field in the transaction to the provided value
#[must_use]
pub fn data<T: Into<Bytes>>(mut self, data: T) -> Self { pub fn data<T: Into<Bytes>>(mut self, data: T) -> Self {
self.data = Some(data.into()); self.data = Some(data.into());
self self
} }
/// Sets the `nonce` field in the transaction to the provided value /// Sets the `nonce` field in the transaction to the provided value
#[must_use]
pub fn nonce<T: Into<U256>>(mut self, nonce: T) -> Self { pub fn nonce<T: Into<U256>>(mut self, nonce: T) -> Self {
self.nonce = Some(nonce.into()); self.nonce = Some(nonce.into());
self self
@ -174,6 +181,7 @@ impl TransactionRequest {
/// Sets the `fee_currency` field in the transaction to the provided value /// Sets the `fee_currency` field in the transaction to the provided value
#[cfg_attr(docsrs, doc(cfg(feature = "celo")))] #[cfg_attr(docsrs, doc(cfg(feature = "celo")))]
#[must_use]
pub fn fee_currency<T: Into<Address>>(mut self, fee_currency: T) -> Self { pub fn fee_currency<T: Into<Address>>(mut self, fee_currency: T) -> Self {
self.fee_currency = Some(fee_currency.into()); self.fee_currency = Some(fee_currency.into());
self self
@ -181,6 +189,7 @@ impl TransactionRequest {
/// Sets the `gateway_fee` field in the transaction to the provided value /// Sets the `gateway_fee` field in the transaction to the provided value
#[cfg_attr(docsrs, doc(cfg(feature = "celo")))] #[cfg_attr(docsrs, doc(cfg(feature = "celo")))]
#[must_use]
pub fn gateway_fee<T: Into<U256>>(mut self, gateway_fee: T) -> Self { pub fn gateway_fee<T: Into<U256>>(mut self, gateway_fee: T) -> Self {
self.gateway_fee = Some(gateway_fee.into()); self.gateway_fee = Some(gateway_fee.into());
self self
@ -188,6 +197,7 @@ impl TransactionRequest {
/// Sets the `gateway_fee_recipient` field in the transaction to the provided value /// Sets the `gateway_fee_recipient` field in the transaction to the provided value
#[cfg_attr(docsrs, doc(cfg(feature = "celo")))] #[cfg_attr(docsrs, doc(cfg(feature = "celo")))]
#[must_use]
pub fn gateway_fee_recipient<T: Into<Address>>(mut self, gateway_fee_recipient: T) -> Self { pub fn gateway_fee_recipient<T: Into<Address>>(mut self, gateway_fee_recipient: T) -> Self {
self.gateway_fee_recipient = Some(gateway_fee_recipient.into()); self.gateway_fee_recipient = Some(gateway_fee_recipient.into());
self self

View File

@ -93,18 +93,21 @@ impl Ganache {
} }
/// Sets the port which will be used when the `ganache-cli` instance is launched. /// Sets the port which will be used when the `ganache-cli` instance is launched.
#[must_use]
pub fn port<T: Into<u16>>(mut self, port: T) -> Self { pub fn port<T: Into<u16>>(mut self, port: T) -> Self {
self.port = Some(port.into()); self.port = Some(port.into());
self self
} }
/// Sets the mnemonic which will be used when the `ganache-cli` instance is launched. /// Sets the mnemonic which will be used when the `ganache-cli` instance is launched.
#[must_use]
pub fn mnemonic<T: Into<String>>(mut self, mnemonic: T) -> Self { pub fn mnemonic<T: Into<String>>(mut self, mnemonic: T) -> Self {
self.mnemonic = Some(mnemonic.into()); self.mnemonic = Some(mnemonic.into());
self self
} }
/// Sets the block-time which will be used when the `ganache-cli` instance is launched. /// Sets the block-time which will be used when the `ganache-cli` instance is launched.
#[must_use]
pub fn block_time<T: Into<u64>>(mut self, block_time: T) -> Self { pub fn block_time<T: Into<u64>>(mut self, block_time: T) -> Self {
self.block_time = Some(block_time.into()); self.block_time = Some(block_time.into());
self self
@ -114,18 +117,21 @@ impl Ganache {
/// at a given block. Input should be the HTTP location and port of the other client, /// at a given block. Input should be the HTTP location and port of the other client,
/// e.g. `http://localhost:8545`. You can optionally specify the block to fork from /// e.g. `http://localhost:8545`. You can optionally specify the block to fork from
/// using an @ sign: `http://localhost:8545@1599200` /// using an @ sign: `http://localhost:8545@1599200`
#[must_use]
pub fn fork<T: Into<String>>(mut self, fork: T) -> Self { pub fn fork<T: Into<String>>(mut self, fork: T) -> Self {
self.fork = Some(fork.into()); self.fork = Some(fork.into());
self self
} }
/// Adds an argument to pass to the `ganache-cli`. /// Adds an argument to pass to the `ganache-cli`.
#[must_use]
pub fn arg<T: Into<String>>(mut self, arg: T) -> Self { pub fn arg<T: Into<String>>(mut self, arg: T) -> Self {
self.args.push(arg.into()); self.args.push(arg.into());
self self
} }
/// Adds multiple arguments to pass to the `ganache-cli`. /// Adds multiple arguments to pass to the `ganache-cli`.
#[must_use]
pub fn args<I, S>(mut self, args: I) -> Self pub fn args<I, S>(mut self, args: I) -> Self
where where
I: IntoIterator<Item = S>, I: IntoIterator<Item = S>,

View File

@ -87,18 +87,21 @@ impl Geth {
} }
/// Sets the port which will be used when the `geth-cli` instance is launched. /// Sets the port which will be used when the `geth-cli` instance is launched.
#[must_use]
pub fn port<T: Into<u16>>(mut self, port: T) -> Self { pub fn port<T: Into<u16>>(mut self, port: T) -> Self {
self.port = Some(port.into()); self.port = Some(port.into());
self self
} }
/// Sets the block-time which will be used when the `geth-cli` instance is launched. /// Sets the block-time which will be used when the `geth-cli` instance is launched.
#[must_use]
pub fn block_time<T: Into<u64>>(mut self, block_time: T) -> Self { pub fn block_time<T: Into<u64>>(mut self, block_time: T) -> Self {
self.block_time = Some(block_time.into()); self.block_time = Some(block_time.into());
self self
} }
/// Manually sets the IPC path for the socket manually. /// Manually sets the IPC path for the socket manually.
#[must_use]
pub fn ipc_path<T: Into<PathBuf>>(mut self, path: T) -> Self { pub fn ipc_path<T: Into<PathBuf>>(mut self, path: T) -> Self {
self.ipc_path = Some(path.into()); self.ipc_path = Some(path.into());
self self

View File

@ -49,16 +49,19 @@ impl VerifyContract {
} }
} }
#[must_use]
pub fn contract_name(mut self, name: impl Into<String>) -> Self { pub fn contract_name(mut self, name: impl Into<String>) -> Self {
self.contract_name = Some(name.into()); self.contract_name = Some(name.into());
self self
} }
#[must_use]
pub fn runs(mut self, runs: u32) -> Self { pub fn runs(mut self, runs: u32) -> Self {
self.runs = Some(format!("{}", runs)); self.runs = Some(format!("{}", runs));
self self
} }
#[must_use]
pub fn optimization(self, optimization: bool) -> Self { pub fn optimization(self, optimization: bool) -> Self {
if optimization { if optimization {
self.optimized() self.optimized()
@ -67,26 +70,31 @@ impl VerifyContract {
} }
} }
#[must_use]
pub fn optimized(mut self) -> Self { pub fn optimized(mut self) -> Self {
self.optimization_used = Some("1".to_string()); self.optimization_used = Some("1".to_string());
self self
} }
#[must_use]
pub fn not_optimized(mut self) -> Self { pub fn not_optimized(mut self) -> Self {
self.optimization_used = Some("0".to_string()); self.optimization_used = Some("0".to_string());
self self
} }
#[must_use]
pub fn code_format(mut self, code_format: CodeFormat) -> Self { pub fn code_format(mut self, code_format: CodeFormat) -> Self {
self.code_format = code_format; self.code_format = code_format;
self self
} }
#[must_use]
pub fn evm_version(mut self, evm_version: impl Into<String>) -> Self { pub fn evm_version(mut self, evm_version: impl Into<String>) -> Self {
self.evm_version = Some(evm_version.into()); self.evm_version = Some(evm_version.into());
self self
} }
#[must_use]
pub fn constructor_arguments( pub fn constructor_arguments(
mut self, mut self,
constructor_arguments: Option<impl Into<String>>, constructor_arguments: Option<impl Into<String>>,

View File

@ -73,6 +73,7 @@ impl EthGasStation {
} }
/// Sets the gas price category to be used when fetching the gas price. /// Sets the gas price category to be used when fetching the gas price.
#[must_use]
pub fn category(mut self, gas_category: GasCategory) -> Self { pub fn category(mut self, gas_category: GasCategory) -> Self {
self.gas_category = gas_category; self.gas_category = gas_category;
self self

View File

@ -44,6 +44,7 @@ impl Etherchain {
} }
/// Sets the gas price category to be used when fetching the gas price. /// Sets the gas price category to be used when fetching the gas price.
#[must_use]
pub fn category(mut self, gas_category: GasCategory) -> Self { pub fn category(mut self, gas_category: GasCategory) -> Self {
self.gas_category = gas_category; self.gas_category = gas_category;
self self

View File

@ -20,6 +20,7 @@ impl Etherscan {
} }
/// Sets the gas price category to be used when fetching the gas price. /// Sets the gas price category to be used when fetching the gas price.
#[must_use]
pub fn category(mut self, gas_category: GasCategory) -> Self { pub fn category(mut self, gas_category: GasCategory) -> Self {
self.gas_category = gas_category; self.gas_category = gas_category;
self self

View File

@ -130,6 +130,7 @@ where
&self.signer &self.signer
} }
#[must_use]
pub fn with_signer(&self, signer: S) -> Self pub fn with_signer(&self, signer: S) -> Self
where where
S: Clone, S: Clone,

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use ethers_core::types::{Bytes, TransactionReceipt, H256}; use ethers_core::types::{Bytes, TransactionReceipt, H256};
use futures_util::{stream::FuturesUnordered, StreamExt}; use futures_util::{stream::FuturesUnordered, StreamExt};
use pin_project::pin_project; use pin_project::pin_project;

View File

@ -57,12 +57,14 @@ impl<'a, P: JsonRpcClient> PendingTransaction<'a, P> {
/// Sets the number of confirmations for the pending transaction to resolve /// Sets the number of confirmations for the pending transaction to resolve
/// to a receipt /// to a receipt
#[must_use]
pub fn confirmations(mut self, confs: usize) -> Self { pub fn confirmations(mut self, confs: usize) -> Self {
self.confirmations = confs; self.confirmations = confs;
self self
} }
/// Sets the polling interval /// Sets the polling interval
#[must_use]
pub fn interval<T: Into<Duration>>(mut self, duration: T) -> Self { pub fn interval<T: Into<Duration>>(mut self, duration: T) -> Self {
let duration = duration.into(); let duration = duration.into();

View File

@ -175,6 +175,7 @@ impl<P: JsonRpcClient> Provider<P> {
} }
} }
#[must_use]
pub fn with_sender(mut self, address: impl Into<Address>) -> Self { pub fn with_sender(mut self, address: impl Into<Address>) -> Self {
self.from = Some(address.into()); self.from = Some(address.into());
self self
@ -973,6 +974,7 @@ impl<P: JsonRpcClient> Provider<P> {
} }
/// Sets the ENS Address (default: mainnet) /// Sets the ENS Address (default: mainnet)
#[must_use]
pub fn ens<T: Into<Address>>(mut self, ens: T) -> Self { pub fn ens<T: Into<Address>>(mut self, ens: T) -> Self {
self.ens = Some(ens.into()); self.ens = Some(ens.into());
self self
@ -980,6 +982,7 @@ impl<P: JsonRpcClient> Provider<P> {
/// Sets the default polling interval for event filters and pending transactions /// Sets the default polling interval for event filters and pending transactions
/// (default: 7 seconds) /// (default: 7 seconds)
#[must_use]
pub fn interval<T: Into<Duration>>(mut self, interval: T) -> Self { pub fn interval<T: Into<Duration>>(mut self, interval: T) -> Self {
self.interval = Some(interval.into()); self.interval = Some(interval.into());
self self

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use crate::{JsonRpcClient, Middleware, PinBoxFut, Provider, ProviderError}; use crate::{JsonRpcClient, Middleware, PinBoxFut, Provider, ProviderError};
use ethers_core::types::{Transaction, TxHash, U256}; use ethers_core::types::{Transaction, TxHash, U256};

View File

@ -79,5 +79,6 @@ pub trait Signer: std::fmt::Debug + Send + Sync {
fn chain_id(&self) -> u64; fn chain_id(&self) -> u64;
/// Sets the signer's chain id /// Sets the signer's chain id
#[must_use]
fn with_chain_id<T: Into<u64>>(self, chain_id: T) -> Self; fn with_chain_id<T: Into<u64>>(self, chain_id: T) -> Self;
} }

View File

@ -249,7 +249,7 @@ mod tests {
let trezor = TrezorEthereum::new(DerivationType::TrezorLive(0), 1).await.unwrap(); let trezor = TrezorEthereum::new(DerivationType::TrezorLive(0), 1).await.unwrap();
// invalid data // invalid data
let big_data = hex::decode("095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff".to_string()+ &"ff".repeat(1032*2) + &"aa".to_string()).unwrap(); let big_data = hex::decode("095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff".to_string()+ &"ff".repeat(1032*2) + "aa").unwrap();
let tx_req = TransactionRequest::new() let tx_req = TransactionRequest::new()
.to("2ed7afa17473e17ac59908f088b4371d28585476".parse::<Address>().unwrap()) .to("2ed7afa17473e17ac59908f088b4371d28585476".parse::<Address>().unwrap())
.gas(1000000) .gas(1000000)

View File

@ -82,6 +82,7 @@ impl<W: Wordlist> MnemonicBuilder<W> {
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
#[must_use]
pub fn phrase<P: Into<PathOrString>>(mut self, phrase: P) -> Self { pub fn phrase<P: Into<PathOrString>>(mut self, phrase: P) -> Self {
self.phrase = Some(phrase.into()); self.phrase = Some(phrase.into());
self self
@ -104,6 +105,7 @@ impl<W: Wordlist> MnemonicBuilder<W> {
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
#[must_use]
pub fn word_count(mut self, count: usize) -> Self { pub fn word_count(mut self, count: usize) -> Self {
self.word_count = count; self.word_count = count;
self self
@ -127,6 +129,7 @@ impl<W: Wordlist> MnemonicBuilder<W> {
} }
/// Sets the password used to construct the seed from the mnemonic phrase. /// Sets the password used to construct the seed from the mnemonic phrase.
#[must_use]
pub fn password(mut self, password: &str) -> Self { pub fn password(mut self, password: &str) -> Self {
self.password = Some(password.to_string()); self.password = Some(password.to_string());
self self
@ -134,6 +137,7 @@ impl<W: Wordlist> MnemonicBuilder<W> {
/// Sets the path to which the randomly generated phrase will be written to. This field is /// Sets the path to which the randomly generated phrase will be written to. This field is
/// ignored when building a wallet from the provided mnemonic phrase. /// ignored when building a wallet from the provided mnemonic phrase.
#[must_use]
pub fn write_to<P: Into<PathBuf>>(mut self, path: P) -> Self { pub fn write_to<P: Into<PathBuf>>(mut self, path: P) -> Self {
self.write_to = Some(path.into()); self.write_to = Some(path.into());
self self

View File

@ -40,12 +40,14 @@ impl CompilerInput {
} }
/// Sets the EVM version for compilation /// Sets the EVM version for compilation
#[must_use]
pub fn evm_version(mut self, version: EvmVersion) -> Self { pub fn evm_version(mut self, version: EvmVersion) -> Self {
self.settings.evm_version = Some(version); self.settings.evm_version = Some(version);
self self
} }
/// Sets the optimizer runs (default = 200) /// Sets the optimizer runs (default = 200)
#[must_use]
pub fn optimizer(mut self, runs: usize) -> Self { pub fn optimizer(mut self, runs: usize) -> Self {
self.settings.optimizer.runs(runs); self.settings.optimizer.runs(runs);
self self
@ -53,6 +55,7 @@ impl CompilerInput {
/// Normalizes the EVM version used in the settings to be up to the latest one /// Normalizes the EVM version used in the settings to be up to the latest one
/// supported by the provided compiler version. /// supported by the provided compiler version.
#[must_use]
pub fn normalize_evm_version(mut self, version: &Version) -> Self { pub fn normalize_evm_version(mut self, version: &Version) -> Self {
if let Some(ref mut evm_version) = self.settings.evm_version { if let Some(ref mut evm_version) = self.settings.evm_version {
self.settings.evm_version = evm_version.normalize_version(version); self.settings.evm_version = evm_version.normalize_version(version);
@ -60,6 +63,7 @@ impl CompilerInput {
self self
} }
#[must_use]
pub fn with_remappings(mut self, remappings: Vec<Remapping>) -> Self { pub fn with_remappings(mut self, remappings: Vec<Remapping>) -> Self {
self.settings.remappings = remappings; self.settings.remappings = remappings;
self self
@ -172,6 +176,7 @@ impl Settings {
} }
/// Adds `ast` to output /// Adds `ast` to output
#[must_use]
pub fn with_ast(mut self) -> Self { pub fn with_ast(mut self) -> Self {
let output = self.output_selection.entry("*".to_string()).or_insert_with(BTreeMap::default); let output = self.output_selection.entry("*".to_string()).or_insert_with(BTreeMap::default);
output.insert("".to_string(), vec!["ast".to_string()]); output.insert("".to_string(), vec!["ast".to_string()]);

View File

@ -219,16 +219,19 @@ pub struct SolFilesCacheBuilder {
} }
impl SolFilesCacheBuilder { impl SolFilesCacheBuilder {
#[must_use]
pub fn format(mut self, format: impl Into<String>) -> Self { pub fn format(mut self, format: impl Into<String>) -> Self {
self.format = Some(format.into()); self.format = Some(format.into());
self self
} }
#[must_use]
pub fn solc_config(mut self, solc_config: SolcConfig) -> Self { pub fn solc_config(mut self, solc_config: SolcConfig) -> Self {
self.solc_config = Some(solc_config); self.solc_config = Some(solc_config);
self self
} }
#[must_use]
pub fn root(mut self, root: impl Into<PathBuf>) -> Self { pub fn root(mut self, root: impl Into<PathBuf>) -> Self {
self.root = Some(root.into()); self.root = Some(root.into());
self self

View File

@ -88,12 +88,14 @@ impl Solc {
} }
/// Adds an argument to pass to the `solc` command. /// Adds an argument to pass to the `solc` command.
#[must_use]
pub fn arg<T: Into<String>>(mut self, arg: T) -> Self { pub fn arg<T: Into<String>>(mut self, arg: T) -> Self {
self.args.push(arg.into()); self.args.push(arg.into());
self self
} }
/// Adds multiple arguments to pass to the `solc`. /// Adds multiple arguments to pass to the `solc`.
#[must_use]
pub fn args<I, S>(mut self, args: I) -> Self pub fn args<I, S>(mut self, args: I) -> Self
where where
I: IntoIterator<Item = S>, I: IntoIterator<Item = S>,

View File

@ -529,39 +529,46 @@ pub struct ProjectBuilder<Artifacts: ArtifactOutput = MinimalCombinedArtifacts>
} }
impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> { impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> {
#[must_use]
pub fn paths(mut self, paths: ProjectPathsConfig) -> Self { pub fn paths(mut self, paths: ProjectPathsConfig) -> Self {
self.paths = Some(paths); self.paths = Some(paths);
self self
} }
#[must_use]
pub fn solc(mut self, solc: impl Into<Solc>) -> Self { pub fn solc(mut self, solc: impl Into<Solc>) -> Self {
self.solc = Some(solc.into()); self.solc = Some(solc.into());
self self
} }
#[must_use]
pub fn solc_config(mut self, solc_config: SolcConfig) -> Self { pub fn solc_config(mut self, solc_config: SolcConfig) -> Self {
self.solc_config = Some(solc_config); self.solc_config = Some(solc_config);
self self
} }
#[must_use]
pub fn ignore_error_code(mut self, code: u64) -> Self { pub fn ignore_error_code(mut self, code: u64) -> Self {
self.ignored_error_codes.push(code); self.ignored_error_codes.push(code);
self self
} }
/// Disables cached builds /// Disables cached builds
#[must_use]
pub fn ephemeral(mut self) -> Self { pub fn ephemeral(mut self) -> Self {
self.cached = false; self.cached = false;
self self
} }
/// Disables writing artifacts to disk /// Disables writing artifacts to disk
#[must_use]
pub fn no_artifacts(mut self) -> Self { pub fn no_artifacts(mut self) -> Self {
self.no_artifacts = true; self.no_artifacts = true;
self self
} }
/// Disables automatic solc version detection /// Disables automatic solc version detection
#[must_use]
pub fn no_auto_detect(mut self) -> Self { pub fn no_auto_detect(mut self) -> Self {
self.auto_detect = false; self.auto_detect = false;
self self
@ -572,6 +579,7 @@ impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> {
/// # Panics /// # Panics
/// ///
/// `jobs` must be at least 1 /// `jobs` must be at least 1
#[must_use]
pub fn solc_jobs(mut self, jobs: usize) -> Self { pub fn solc_jobs(mut self, jobs: usize) -> Self {
assert!(jobs > 0); assert!(jobs > 0);
self.solc_jobs = Some(jobs); self.solc_jobs = Some(jobs);
@ -579,6 +587,7 @@ impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> {
} }
/// Sets the number of parallel `solc` processes to `1`, no parallelization /// Sets the number of parallel `solc` processes to `1`, no parallelization
#[must_use]
pub fn single_solc_jobs(self) -> Self { pub fn single_solc_jobs(self) -> Self {
self.solc_jobs(1) self.solc_jobs(1)
} }
@ -612,12 +621,14 @@ impl<Artifacts: ArtifactOutput> ProjectBuilder<Artifacts> {
} }
/// Adds an allowed-path to the solc executable /// Adds an allowed-path to the solc executable
#[must_use]
pub fn allowed_path<T: Into<PathBuf>>(mut self, path: T) -> Self { pub fn allowed_path<T: Into<PathBuf>>(mut self, path: T) -> Self {
self.allowed_paths.push(path.into()); self.allowed_paths.push(path.into());
self self
} }
/// Adds multiple allowed-path to the solc executable /// Adds multiple allowed-path to the solc executable
#[must_use]
pub fn allowed_paths<I, S>(mut self, args: I) -> Self pub fn allowed_paths<I, S>(mut self, args: I) -> Self
where where
I: IntoIterator<Item = S>, I: IntoIterator<Item = S>,