Skip to content

Commit

Permalink
Upgrade borsh to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen-stig committed Jun 28, 2024
1 parent e68ae33 commit da215e1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions src/namespaced_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ pub struct NamespacedHash<const NS_ID_SIZE: usize> {

#[cfg(any(test, feature = "borsh"))]
impl<const NS_ID_SIZE: usize> borsh::BorshDeserialize for NamespacedHash<NS_ID_SIZE> {
fn deserialize_reader<R: borsh::maybestd::io::Read>(
fn deserialize_reader<R: std::io::Read>(
reader: &mut R,
) -> borsh::maybestd::io::Result<Self> {
) -> std::io::Result<Self> {
let mut min_ns = NamespaceId([0u8; NS_ID_SIZE]);
reader.read_exact(&mut min_ns.0)?;

Expand Down
16 changes: 15 additions & 1 deletion src/simple_merkle/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit da215e1

Please sign in to comment.