Skip to content

Commit

Permalink
contract: provide custom impl of CommitEncode for operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Feb 15, 2024
1 parent 6165362 commit 03b5ee6
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/contract/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ use std::iter;

use amplify::confinement::{SmallBlob, TinyOrdMap, TinyOrdSet};
use amplify::Wrapper;
use commit_verify::{CommitId, Conceal, MerkleHash, MerkleLeaves, StrictHash};
use commit_verify::{
CommitEncode, CommitEngine, CommitId, Conceal, MerkleHash, MerkleLeaves, StrictHash,
};
use strict_encoding::{StrictDeserialize, StrictEncode, StrictSerialize};

use crate::schema::{self, ExtensionType, OpFullType, OpType, SchemaId, TransitionType};
Expand Down Expand Up @@ -194,8 +196,6 @@ pub trait Operation {
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_RGB)]
#[derive(CommitEncode)]
#[commit_encode(strategy = conceal, id = OpId)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
Expand All @@ -218,8 +218,6 @@ impl StrictDeserialize for Genesis {}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_RGB)]
#[derive(CommitEncode)]
#[commit_encode(strategy = conceal, id = OpId)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
Expand All @@ -242,8 +240,6 @@ impl StrictDeserialize for Extension {}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
#[strict_type(lib = LIB_NAME_RGB)]
#[derive(CommitEncode)]
#[commit_encode(strategy = conceal, id = OpId)]
#[cfg_attr(
feature = "serde",
derive(Serialize, Deserialize),
Expand Down Expand Up @@ -299,6 +295,21 @@ impl Conceal for Extension {
}
}

impl CommitEncode for Genesis {
type CommitmentId = OpId;
fn commit_encode(&self, e: &mut CommitEngine) { e.commit_to(&self.commit()) }
}

impl CommitEncode for Transition {
type CommitmentId = OpId;
fn commit_encode(&self, e: &mut CommitEngine) { e.commit_to(&self.commit()) }
}

impl CommitEncode for Extension {
type CommitmentId = OpId;
fn commit_encode(&self, e: &mut CommitEngine) { e.commit_to(&self.commit()) }
}

impl Transition {
/// Returns reference to information about the owned rights in form of
/// [`Inputs`] wrapper structure which this operation updates with
Expand Down

0 comments on commit 03b5ee6

Please sign in to comment.