Skip to content

Commit

Permalink
broader strict encoding support
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 15, 2024
1 parent a8b95dc commit da58016
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions single_use_seals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};
use core::marker::PhantomData;

#[cfg(feature = "strict_encoding")]
use strict_encoding::{StrictDecode, StrictDumb, StrictEncode};

#[cfg(not(feature = "strict_encoding"))]
trait StrictDumb {}
#[cfg(not(feature = "strict_encoding"))]
impl<T> StrictDumb for T {}

#[cfg(not(feature = "strict_encoding"))]
trait StrictEncode {}
#[cfg(not(feature = "strict_encoding"))]
impl<T> StrictEncode for T {}

#[cfg(not(feature = "strict_encoding"))]
trait StrictDecode {}
#[cfg(not(feature = "strict_encoding"))]
impl<T> StrictDecode for T {}

/// Trait for proof-of-publication medium on which the seals are defined,
/// closed, verified and which can be used for convenience operations related to
/// seals:
Expand All @@ -139,21 +157,9 @@ pub trait SingleUseSeal: Clone + Debug + Display {
/// Message type that is supported by the current single-use-seal.
type Message: Copy + Eq;

#[cfg(not(feature = "strict_encoding"))]
type PubWitness: PublishedWitness<Self>;
#[cfg(feature = "strict_encoding")]
type PubWitness: PublishedWitness<Self>
+ strict_encoding::StrictDumb
+ strict_encoding::StrictEncode
+ strict_encoding::StrictDecode;
type PubWitness: PublishedWitness<Self> + StrictDumb + StrictEncode + StrictDecode;

#[cfg(not(feature = "strict_encoding"))]
type CliWitness: ClientSideWitness<Seal = Self>;
#[cfg(feature = "strict_encoding")]
type CliWitness: ClientSideWitness<Seal = Self>
+ strict_encoding::StrictDumb
+ strict_encoding::StrictEncode
+ strict_encoding::StrictDecode;
type CliWitness: ClientSideWitness<Seal = Self> + StrictDumb + StrictEncode + StrictDecode;

fn is_included(&self, message: Self::Message, witness: &SealWitness<Self>) -> bool;
}
Expand Down

0 comments on commit da58016

Please sign in to comment.