diff --git a/crates/primitives/src/bits/address.rs b/crates/primitives/src/bits/address.rs index 903dd5dd98..d453e3b65b 100644 --- a/crates/primitives/src/bits/address.rs +++ b/crates/primitives/src/bits/address.rs @@ -450,15 +450,24 @@ impl Address { Self::from_slice(&digest[12..]) } - /// Converts an ECDSA public key to its corresponding Ethereum address. + /// Converts an ECDSA verifying key to its corresponding Ethereum address. #[inline] #[cfg(feature = "k256")] + #[doc(alias = "from_verifying_key")] pub fn from_public_key(pubkey: &k256::ecdsa::VerifyingKey) -> Self { use k256::elliptic_curve::sec1::ToEncodedPoint; let affine: &k256::AffinePoint = pubkey.as_ref(); let encoded = affine.to_encoded_point(false); Self::from_raw_public_key(&encoded.as_bytes()[1..]) } + + /// Converts an ECDSA signing key to its corresponding Ethereum address. + #[inline] + #[cfg(feature = "k256")] + #[doc(alias = "from_signing_key")] + pub fn from_private_key(private_key: &k256::ecdsa::SigningKey) -> Self { + Self::from_public_key(private_key.verifying_key()) + } } /// Stack-allocated buffer for efficiently computing address checksums. diff --git a/crates/primitives/src/bits/fixed.rs b/crates/primitives/src/bits/fixed.rs index ed1026b272..2d97f9a3ea 100644 --- a/crates/primitives/src/bits/fixed.rs +++ b/crates/primitives/src/bits/fixed.rs @@ -67,7 +67,7 @@ impl TryFrom<&[u8]> for FixedBytes { #[inline] fn try_from(slice: &[u8]) -> Result { - <&Self>::try_from(slice).map(|this| *this) + <&Self>::try_from(slice).copied() } } diff --git a/crates/sol-types/tests/ui/keywords.stderr b/crates/sol-types/tests/ui/keywords.stderr index c061e8e9cd..d373164e26 100644 --- a/crates/sol-types/tests/ui/keywords.stderr +++ b/crates/sol-types/tests/ui/keywords.stderr @@ -1793,3 +1793,30 @@ error[E0747]: constant provided when a type was expected | 6 | struct $kw { | ^^^ + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> tests/ui/keywords.rs:5:9 + | +5 | / sol! { +6 | | struct $kw { +7 | | uint $kw; +8 | | } +9 | | +10 | | function $kw(uint $kw); +11 | | } + | | ^ + | | | + | | impl doesn't use only types from inside the current crate + | |_________this is not defined in the current crate because this is a foreign trait + | this is not defined in the current crate because tuples are always foreign +... +42 | / kws! { +43 | | crate +44 | | self +45 | | Self +46 | | super +47 | | } + | |_- in this macro invocation + | + = note: define and implement a trait or new type instead + = note: this error originates in the macro `sol` which comes from the expansion of the macro `kws` (in Nightly builds, run with -Z macro-backtrace for more info)