diff --git a/ethers-contract/ethers-contract-abigen/src/contract/common.rs b/ethers-contract/ethers-contract-abigen/src/contract/common.rs index 2235fe8d..41b7b668 100644 --- a/ethers-contract/ethers-contract-abigen/src/contract/common.rs +++ b/ethers-contract/ethers-contract-abigen/src/contract/common.rs @@ -95,7 +95,6 @@ pub(crate) fn struct_declaration(cx: &Context) -> TokenStream { let abi_name = cx.inline_abi_ident(); let ethers_core = ethers_core_crate(); - let ethers_providers = ethers_providers_crate(); let ethers_contract = ethers_contract_crate(); let abi_parse = if !cx.human_readable { @@ -144,7 +143,7 @@ pub(crate) fn struct_declaration(cx: &Context) -> TokenStream { fn deref(&self) -> &Self::Target { &self.0 } } - impl std::fmt::Debug for #name { + impl std::fmt::Debug for #name { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_tuple(stringify!(#name)) .field(&self.address()) diff --git a/ethers-contract/src/contract.rs b/ethers-contract/src/contract.rs index 0508debf..17443e5a 100644 --- a/ethers-contract/src/contract.rs +++ b/ethers-contract/src/contract.rs @@ -152,9 +152,16 @@ use std::{fmt::Debug, marker::PhantomData, sync::Arc}; /// [`method`]: method@crate::Contract::method #[derive(Debug)] pub struct Contract { + address: Address, base_contract: BaseContract, client: Arc, - address: Address, +} + +impl std::ops::Deref for Contract { + type Target = BaseContract; + fn deref(&self) -> &Self::Target { + &self.base_contract + } } impl Clone for Contract { @@ -167,10 +174,31 @@ impl Clone for Contract { } } +impl Contract { + /// Returns the contract's address + pub fn address(&self) -> Address { + self.address + } + + /// Returns a reference to the contract's ABI + pub fn abi(&self) -> &Abi { + &self.base_contract.abi + } + + /// Returns a reference to the contract's client + pub fn client(&self) -> &M { + &self.client + } +} + impl Contract { /// Creates a new contract from the provided client, abi and address - pub fn new(address: Address, abi: impl Into, client: impl Into>) -> Self { - Self { base_contract: abi.into(), client: client.into(), address } + pub fn new( + address: impl Into
, + abi: impl Into, + client: impl Into>, + ) -> Self { + Self { base_contract: abi.into(), client: client.into(), address: address.into() } } /// Returns an [`Event`](crate::builders::Event) builder for the provided event. @@ -277,26 +305,4 @@ impl Contract { { Contract { base_contract: self.base_contract.clone(), client, address: self.address } } - - /// Returns the contract's address - pub fn address(&self) -> Address { - self.address - } - - /// Returns a reference to the contract's ABI - pub fn abi(&self) -> &Abi { - &self.base_contract.abi - } - - /// Returns a reference to the contract's client - pub fn client(&self) -> &M { - &self.client - } -} - -impl std::ops::Deref for Contract { - type Target = BaseContract; - fn deref(&self) -> &Self::Target { - &self.base_contract - } } diff --git a/ethers-contract/src/multicall/multicall_contract.rs b/ethers-contract/src/multicall/multicall_contract.rs index 0b0c7c2a..7154f287 100644 --- a/ethers-contract/src/multicall/multicall_contract.rs +++ b/ethers-contract/src/multicall/multicall_contract.rs @@ -26,7 +26,7 @@ pub mod multicall_3 { &self.0 } } - impl std::fmt::Debug for Multicall3 { + impl std::fmt::Debug for Multicall3 { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_tuple(stringify!(Multicall3)).field(&self.address()).finish() } diff --git a/ethers-core/src/types/i256.rs b/ethers-core/src/types/i256.rs index 6b00105b..a8a94e87 100644 --- a/ethers-core/src/types/i256.rs +++ b/ethers-core/src/types/i256.rs @@ -339,13 +339,7 @@ impl I256 { /// Returns an `i64` representing the sign of the number. fn signum64(self) -> i64 { match self.sign() { - Sign::Positive => { - if self.is_zero() { - 0 - } else { - 1 - } - } + Sign::Positive => (!self.is_zero()) as i64, Sign::Negative => -1, } } diff --git a/ethers-signers/src/ledger/app.rs b/ethers-signers/src/ledger/app.rs index 3db050f3..fc9e4fe2 100644 --- a/ethers-signers/src/ledger/app.rs +++ b/ethers-signers/src/ledger/app.rs @@ -141,11 +141,7 @@ impl LedgerEthereum { signature.v = match tx { TypedTransaction::Eip2930(_) | TypedTransaction::Eip1559(_) => { - if ecc_parity % 2 == 1 { - 0 - } else { - 1 - } + (ecc_parity % 2 != 1) as u64 } TypedTransaction::Legacy(_) => eip155_chain_id + ecc_parity, };