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

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use super::base::{decode_function_data, AbiError};
use ethers_core::{
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`.
///
/// Clones `self` internally
#[must_use]
pub fn at<T: Into<Address>>(&self, address: T) -> Self
where
M: Clone,
@ -259,6 +260,7 @@ impl<M: Middleware> Contract<M> {
/// Returns a new contract instance using the provided client
///
/// Clones `self` internally
#[must_use]
pub fn connect(&self, client: Arc<M>) -> Self
where
M: Clone,

View File

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

View File

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

View File

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

View File

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

View File

@ -123,6 +123,7 @@ impl Default for FilterBlockOption {
}
impl FilterBlockOption {
#[must_use]
pub fn set_from_block(&self, block: BlockNumber) -> Self {
let to_block =
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 }
}
#[must_use]
pub fn set_to_block(&self, block: BlockNumber) -> Self {
let from_block =
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) }
}
#[must_use]
pub fn set_hash(&self, hash: H256) -> Self {
FilterBlockOption::AtBlockHash(hash)
}
@ -273,64 +276,75 @@ impl Filter {
/// let filter = Filter::new().select(..1337u64);
/// # }
/// ```
#[must_use]
pub fn select(mut self, filter: impl Into<FilterBlockOption>) -> Self {
self.block_option = filter.into();
self
}
#[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn from_block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.block_option = self.block_option.set_from_block(block.into());
self
}
#[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn to_block<T: Into<BlockNumber>>(mut self, block: T) -> Self {
self.block_option = self.block_option.set_to_block(block.into());
self
}
#[allow(clippy::wrong_self_convention)]
#[must_use]
pub fn at_block_hash<T: Into<H256>>(mut self, hash: T) -> Self {
self.block_option = self.block_option.set_hash(hash.into());
self
}
#[must_use]
pub fn address<T: Into<ValueOrArray<Address>>>(mut self, address: T) -> Self {
self.address = Some(address.into());
self
}
/// 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 {
let hash = H256::from(keccak256(event_name.as_bytes()));
self.topic0(hash)
}
/// Sets topic0 (the event name for non-anonymous events)
#[must_use]
pub fn topic0<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[0] = Some(topic.into());
self
}
/// Sets the 1st indexed topic
#[must_use]
pub fn topic1<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[1] = Some(topic.into());
self
}
/// Sets the 2nd indexed topic
#[must_use]
pub fn topic2<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[2] = Some(topic.into());
self
}
/// Sets the 3rd indexed topic
#[must_use]
pub fn topic3<T: Into<ValueOrArray<H256>>>(mut self, topic: T) -> Self {
self.topics[3] = Some(topic.into());
self
}
#[must_use]
pub fn limit(mut self, limit: usize) -> Self {
self.limit = Some(limit);
self

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -93,18 +93,21 @@ impl Ganache {
}
/// 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 {
self.port = Some(port.into());
self
}
/// 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 {
self.mnemonic = Some(mnemonic.into());
self
}
/// 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 {
self.block_time = Some(block_time.into());
self
@ -114,18 +117,21 @@ impl Ganache {
/// 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
/// using an @ sign: `http://localhost:8545@1599200`
#[must_use]
pub fn fork<T: Into<String>>(mut self, fork: T) -> Self {
self.fork = Some(fork.into());
self
}
/// Adds an argument to pass to the `ganache-cli`.
#[must_use]
pub fn arg<T: Into<String>>(mut self, arg: T) -> Self {
self.args.push(arg.into());
self
}
/// Adds multiple arguments to pass to the `ganache-cli`.
#[must_use]
pub fn args<I, S>(mut self, args: I) -> Self
where
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.
#[must_use]
pub fn port<T: Into<u16>>(mut self, port: T) -> Self {
self.port = Some(port.into());
self
}
/// 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 {
self.block_time = Some(block_time.into());
self
}
/// Manually sets the IPC path for the socket manually.
#[must_use]
pub fn ipc_path<T: Into<PathBuf>>(mut self, path: T) -> Self {
self.ipc_path = Some(path.into());
self

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use ethers_core::types::{Bytes, TransactionReceipt, H256};
use futures_util::{stream::FuturesUnordered, StreamExt};
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
/// to a receipt
#[must_use]
pub fn confirmations(mut self, confs: usize) -> Self {
self.confirmations = confs;
self
}
/// Sets the polling interval
#[must_use]
pub fn interval<T: Into<Duration>>(mut self, duration: T) -> Self {
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 {
self.from = Some(address.into());
self
@ -973,6 +974,7 @@ impl<P: JsonRpcClient> Provider<P> {
}
/// Sets the ENS Address (default: mainnet)
#[must_use]
pub fn ens<T: Into<Address>>(mut self, ens: T) -> Self {
self.ens = Some(ens.into());
self
@ -980,6 +982,7 @@ impl<P: JsonRpcClient> Provider<P> {
/// Sets the default polling interval for event filters and pending transactions
/// (default: 7 seconds)
#[must_use]
pub fn interval<T: Into<Duration>>(mut self, interval: T) -> Self {
self.interval = Some(interval.into());
self

View File

@ -1,3 +1,5 @@
#![allow(clippy::return_self_not_must_use)]
use crate::{JsonRpcClient, Middleware, PinBoxFut, Provider, ProviderError};
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;
/// Sets the signer's chain id
#[must_use]
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();
// 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()
.to("2ed7afa17473e17ac59908f088b4371d28585476".parse::<Address>().unwrap())
.gas(1000000)

View File

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

View File

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

View File

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

View File

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

View File

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