diff --git a/.changelog/unreleased/improvements/1011-status-verify-active.md b/.changelog/unreleased/improvements/1011-status-verify-active.md new file mode 100644 index 000000000..65b3e911a --- /dev/null +++ b/.changelog/unreleased/improvements/1011-status-verify-active.md @@ -0,0 +1,2 @@ +- `[ibc-primitives]` Derive `Hash` on `Timestamp` instead of explicit + implementation ([#1011](https://github.com/cosmos/ibc-rs/pull/1005)) diff --git a/ibc-primitives/src/types/timestamp.rs b/ibc-primitives/src/types/timestamp.rs index ef54a4630..c7d8e5aae 100644 --- a/ibc-primitives/src/types/timestamp.rs +++ b/ibc-primitives/src/types/timestamp.rs @@ -1,7 +1,7 @@ //! Defines the representation of timestamps used in IBC. use core::fmt::{Display, Error as FmtError, Formatter}; -use core::hash::{Hash, Hasher}; +use core::hash::Hash; use core::num::ParseIntError; use core::ops::{Add, Sub}; use core::str::FromStr; @@ -24,7 +24,7 @@ pub const ZERO_DURATION: Duration = Duration::from_secs(0); /// of timestamp. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -#[derive(PartialEq, Eq, Copy, Clone, Debug, Default, PartialOrd, Ord)] +#[derive(PartialEq, Eq, Copy, Clone, Debug, Default, PartialOrd, Ord, Hash)] pub struct Timestamp { // Note: The schema representation is the timestamp in nanoseconds (as we do with borsh). #[cfg_attr(feature = "schema", schemars(with = "u64"))] @@ -85,16 +85,6 @@ impl scale_info::TypeInfo for Timestamp { } } -// TODO: derive when tendermint::Time supports it: -// https://github.com/informalsystems/tendermint-rs/pull/1054 -#[allow(clippy::derived_hash_with_manual_eq)] -impl Hash for Timestamp { - fn hash(&self, state: &mut H) { - let odt: Option = self.time.map(Into::into); - odt.hash(state); - } -} - /// The expiry result when comparing two timestamps. /// - If either timestamp is invalid (0), the result is `InvalidTimestamp`. /// - If the left timestamp is strictly after the right timestamp, the result is `Expired`.