diff --git a/Cargo.toml b/Cargo.toml index 7787c6f..033a3cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,15 +14,16 @@ repository = "https://github.com/sovereign-labs/nmt-rs" sha2 = { version = "0.10.6", default-features = false } bytes = { version = "1", default-features = false } serde = { version = "1", optional = true, features = ["derive"] } -borsh = { version = "0.10.0", optional = true } +borsh = { version = "1", features = ["derive"], optional = true } [dev-dependencies] -borsh = { version = "0.10.0" } +borsh = { version = "1" } serde_json = "1.0.96" postcard = { version = "1.0.4" } -tendermint = {version = "0.35.0"} +tendermint = { version = "0.35.0" } [features] default = ["std"] -serde = ["dep:serde", "postcard/use-std"] std = [] +serde = ["dep:serde", "postcard/use-std"] +borsh = ["dep:borsh", "std"] diff --git a/src/namespaced_hash.rs b/src/namespaced_hash.rs index 78b0ef2..d1832d5 100644 --- a/src/namespaced_hash.rs +++ b/src/namespaced_hash.rs @@ -197,9 +197,9 @@ pub struct NamespacedHash { #[cfg(any(test, feature = "borsh"))] impl borsh::BorshDeserialize for NamespacedHash { - fn deserialize_reader( + fn deserialize_reader( reader: &mut R, - ) -> borsh::maybestd::io::Result { + ) -> std::io::Result { let mut min_ns = NamespaceId([0u8; NS_ID_SIZE]); reader.read_exact(&mut min_ns.0)?; diff --git a/src/simple_merkle/tree.rs b/src/simple_merkle/tree.rs index 6240fcb..24b6e32 100644 --- a/src/simple_merkle/tree.rs +++ b/src/simple_merkle/tree.rs @@ -68,7 +68,7 @@ pub trait MerkleHash { + serde::de::DeserializeOwned; /// The output of this hasher - #[cfg(all(feature = "serde", feature = "std"))] + #[cfg(all(feature = "serde", not(feature = "borsh"), feature = "std"))] type Output: Debug + PartialEq + Eq @@ -79,6 +79,20 @@ pub trait MerkleHash { + serde::Serialize + serde::de::DeserializeOwned; + /// The output of this hasher + #[cfg(all(feature = "serde", feature = "borsh", feature = "std"))] + type Output: Debug + + PartialEq + + Eq + + Clone + + Default + + Hash + + Ord + + serde::Serialize + + serde::de::DeserializeOwned + + borsh::BorshSerialize + + borsh::BorshDeserialize; + /// The hash of the empty tree. This is often defined as the hash of the empty string const EMPTY_ROOT: Self::Output;