From d0c93a797fe850fd81d2c778b0a557fce58f2b3c Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Sat, 7 Sep 2024 00:00:03 +0800 Subject: [PATCH] fix: serde arrays --- era-compiler-common/Cargo.toml | 1 + era-compiler-common/src/hash/mod.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/era-compiler-common/Cargo.toml b/era-compiler-common/Cargo.toml index 2623a97..5d66a19 100644 --- a/era-compiler-common/Cargo.toml +++ b/era-compiler-common/Cargo.toml @@ -14,6 +14,7 @@ anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = [ "arbitrary_precision", "unbounded_depth" ] } serde_stacker = "0.1" +serde_arrays = "0.1" sha3 = "0.10" hex = "0.4" diff --git a/era-compiler-common/src/hash/mod.rs b/era-compiler-common/src/hash/mod.rs index 5911bc8..d7dac42 100644 --- a/era-compiler-common/src/hash/mod.rs +++ b/era-compiler-common/src/hash/mod.rs @@ -11,7 +11,7 @@ use sha3::Digest; /// /// The hash. /// -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub enum Hash { /// The `keccak256` hash. Keccak256 { @@ -23,6 +23,7 @@ pub enum Hash { /// The `ipfs` hash. Ipfs { /// The byte representation. + #[serde(with = "serde_arrays")] bytes: [u8; 2 + crate::BYTE_LENGTH_FIELD], /// The string representation. string: String,