From 09d2592c034596cb96846db324160f8dac5597f0 Mon Sep 17 00:00:00 2001 From: 0xLucca <0xlucca.dev@gmail.com> Date: Mon, 11 Mar 2024 19:04:03 +0700 Subject: [PATCH 1/3] Add Hash trait to Selector struct --- crates/metadata/src/specs.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/metadata/src/specs.rs b/crates/metadata/src/specs.rs index 1d9599f668..12ea68aae0 100644 --- a/crates/metadata/src/specs.rs +++ b/crates/metadata/src/specs.rs @@ -52,7 +52,10 @@ use serde::{ Serialize, }; #[cfg(feature = "std")] -use std::collections::BTreeMap; +use std::{ + collections::BTreeMap, + hash::Hash, +}; /// Describes a contract. #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] @@ -1091,7 +1094,7 @@ where } /// The 4 byte selector to identify constructors and messages -#[derive(Debug, Default, PartialEq, Eq, derive_more::From, JsonSchema)] +#[derive(Debug, Default, PartialEq, Eq, derive_more::From, JsonSchema, Hash)] pub struct Selector(#[schemars(with = "String")] [u8; 4]); impl serde::Serialize for Selector { From 0db1fbde763951f943f67a6b4b0e9fce522ac40e Mon Sep 17 00:00:00 2001 From: 0xLucca <0xlucca.dev@gmail.com> Date: Mon, 11 Mar 2024 19:17:12 +0700 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1afe46864b..1c9207a0cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Add Hash trait to Selector struct ## Version 5.0.0-rc.3 From 0ef12f42a11d3e7ebc8b4ba1ff38e7ab7bd16174 Mon Sep 17 00:00:00 2001 From: 0xLucca <0xlucca.dev@gmail.com> Date: Mon, 11 Mar 2024 19:53:10 +0700 Subject: [PATCH 3/3] Make Hash derive conditional --- crates/metadata/src/specs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/metadata/src/specs.rs b/crates/metadata/src/specs.rs index 12ea68aae0..62ff372b7f 100644 --- a/crates/metadata/src/specs.rs +++ b/crates/metadata/src/specs.rs @@ -1094,7 +1094,8 @@ where } /// The 4 byte selector to identify constructors and messages -#[derive(Debug, Default, PartialEq, Eq, derive_more::From, JsonSchema, Hash)] +#[cfg_attr(feature = "std", derive(Hash))] +#[derive(Debug, Default, PartialEq, Eq, derive_more::From, JsonSchema)] pub struct Selector(#[schemars(with = "String")] [u8; 4]); impl serde::Serialize for Selector {