diff --git a/Cargo.lock b/Cargo.lock index 0b00692fe6..9d2ed23434 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1853,6 +1853,7 @@ dependencies = [ "async-trait", "cfg-if", "kona-common", + "serde", "tempfile", "tokio", "tracing", diff --git a/crates/preimage/Cargo.toml b/crates/preimage/Cargo.toml index 51eb95a4af..69c817004d 100644 --- a/crates/preimage/Cargo.toml +++ b/crates/preimage/Cargo.toml @@ -19,6 +19,12 @@ async-trait.workspace = true # local kona-common = { path = "../common", version = "0.0.1" } +serde = { version = "1.0.203", features = ["derive"], optional = true } + [dev-dependencies] tokio = { version = "1.38.0", features = ["full"] } tempfile = "3.10.1" + +[features] +default = [] +serde = ["dep:serde"] diff --git a/crates/preimage/src/key.rs b/crates/preimage/src/key.rs index 1ba26b15c4..99784bb2bf 100644 --- a/crates/preimage/src/key.rs +++ b/crates/preimage/src/key.rs @@ -2,8 +2,11 @@ //! the preimage oracle. use alloy_primitives::{B256, U256}; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; /// +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)] #[repr(u8)] pub enum PreimageKeyType { @@ -53,6 +56,7 @@ impl TryFrom for PreimageKeyType { /// |---------|-------------| /// | [0, 1) | Type byte | /// | [1, 32) | Data | +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)] pub struct PreimageKey { data: [u8; 31],