Skip to content

Commit

Permalink
seals: add serde support
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 15, 2024
1 parent 5ea67fb commit a8b95dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion single_use_seals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ path = "src/lib.rs"

[dependencies]
strict_encoding = { workspace = true, optional = true }
serde = { workspace = true, optional = true }

[features]
default = []
all = ["strict_encoding"]
all = ["strict_encoding", "serde"]

[package.metadata.docs.rs]
features = ["all"]
11 changes: 11 additions & 0 deletions single_use_seals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
#[macro_use]
extern crate strict_encoding;

#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;

use core::borrow::Borrow;
use core::convert::Infallible;
use core::error::Error;
Expand Down Expand Up @@ -202,11 +206,18 @@ pub trait PublishedWitness<Seal: SingleUseSeal> {
derive(StrictType, StrictDumb, StrictEncode, StrictDecode),
strict_type(lib = "SingleUseSeals")
)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
serde(bound = "Seal::PubWitness: serde::Serialize + for<'d> serde::Deserialize<'d>, \
Seal::CliWitness: serde::Serialize + for<'d> serde::Deserialize<'d>")
)]
pub struct SealWitness<Seal>
where Seal: SingleUseSeal
{
pub published: Seal::PubWitness,
pub client: Seal::CliWitness,
#[cfg_attr(feature = "serde", serde(skip))]
#[cfg_attr(feature = "strict_encoding", strict_type(skip))]
_phantom: PhantomData<Seal>,
}
Expand Down

0 comments on commit a8b95dc

Please sign in to comment.