Skip to content

Commit 86fb382

Browse files
committed
contract: provide custom impl of CommitEncode for operations
1 parent 85a2cd7 commit 86fb382

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/contract/operations.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use std::iter;
2525

2626
use amplify::confinement::{SmallBlob, TinyOrdMap, TinyOrdSet};
2727
use amplify::Wrapper;
28-
use commit_verify::{CommitId, Conceal, MerkleHash, MerkleLeaves, StrictHash};
28+
use commit_verify::{
29+
CommitEncode, CommitEngine, CommitId, Conceal, MerkleHash, MerkleLeaves, StrictHash,
30+
};
2931
use strict_encoding::{StrictDeserialize, StrictEncode, StrictSerialize};
3032

3133
use crate::schema::{self, ExtensionType, OpFullType, OpType, SchemaId, TransitionType};
@@ -194,8 +196,6 @@ pub trait Operation {
194196
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
195197
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
196198
#[strict_type(lib = LIB_NAME_RGB)]
197-
#[derive(CommitEncode)]
198-
#[commit_encode(strategy = conceal, id = OpId)]
199199
#[cfg_attr(
200200
feature = "serde",
201201
derive(Serialize, Deserialize),
@@ -218,8 +218,6 @@ impl StrictDeserialize for Genesis {}
218218
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
219219
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
220220
#[strict_type(lib = LIB_NAME_RGB)]
221-
#[derive(CommitEncode)]
222-
#[commit_encode(strategy = conceal, id = OpId)]
223221
#[cfg_attr(
224222
feature = "serde",
225223
derive(Serialize, Deserialize),
@@ -242,8 +240,6 @@ impl StrictDeserialize for Extension {}
242240
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
243241
#[derive(StrictType, StrictDumb, StrictEncode, StrictDecode)]
244242
#[strict_type(lib = LIB_NAME_RGB)]
245-
#[derive(CommitEncode)]
246-
#[commit_encode(strategy = conceal, id = OpId)]
247243
#[cfg_attr(
248244
feature = "serde",
249245
derive(Serialize, Deserialize),
@@ -299,6 +295,21 @@ impl Conceal for Extension {
299295
}
300296
}
301297

298+
impl CommitEncode for Genesis {
299+
type CommitmentId = OpId;
300+
fn commit_encode(&self, e: &mut CommitEngine) { e.commit_to(&self.commit()) }
301+
}
302+
303+
impl CommitEncode for Transition {
304+
type CommitmentId = OpId;
305+
fn commit_encode(&self, e: &mut CommitEngine) { e.commit_to(&self.commit()) }
306+
}
307+
308+
impl CommitEncode for Extension {
309+
type CommitmentId = OpId;
310+
fn commit_encode(&self, e: &mut CommitEngine) { e.commit_to(&self.commit()) }
311+
}
312+
302313
impl Transition {
303314
/// Returns reference to information about the owned rights in form of
304315
/// [`Inputs`] wrapper structure which this operation updates with

0 commit comments

Comments
 (0)