Skip to content

Commit 7e77c5e

Browse files
committed
extend error information for the seals mismatch
1 parent 4a74f0b commit 7e77c5e

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/verify.rs

+24-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use alloc::vec::Vec;
2828
use amplify::confinement::SmallOrdMap;
2929
use amplify::ByteArray;
3030
use single_use_seals::{PublishedWitness, SealError, SealWitness};
31-
use ultrasonic::{CallError, CellAddr, Codex, ContractId, LibRepo, Memory, Operation, Opid};
31+
use ultrasonic::{AuthToken, CallError, CellAddr, Codex, ContractId, LibRepo, Memory, Operation, Opid};
3232

3333
use crate::{RgbSealDef, RgbSealSrc, LIB_NAME_RGB_CORE};
3434

@@ -110,17 +110,22 @@ pub trait ContractVerify<SealDef: RgbSealDef>: ContractApi<SealDef> {
110110
.operation
111111
.destructible
112112
.iter()
113-
.map(|cell| cell.auth.to_byte_array())
113+
.map(|cell| cell.auth)
114114
.collect::<BTreeSet<_>>();
115-
let sealed = header
115+
let reported = header
116116
.defined_seals
117117
.values()
118-
.map(|seal| seal.auth_token().to_byte_array())
118+
.map(|seal| seal.auth_token())
119119
.collect::<BTreeSet<_>>();
120120
// It is a subset and not equal set since some of the seals might be unknown to us: we know their
121121
// commitment auth token, but do not know definition.
122-
if !sealed.is_subset(&defined) {
123-
return Err(VerificationError::SealsDefinitionMismatch(opid));
122+
if !reported.is_subset(&defined) {
123+
let sources = header
124+
.defined_seals
125+
.iter()
126+
.map(|(pos, seal)| (*pos, seal.to_string()))
127+
.collect();
128+
return Err(VerificationError::SealsDefinitionMismatch { opid, reported, defined, sources });
124129
}
125130

126131
// If the operation was validated before, we need to skip its validation, since its inputs are not a
@@ -217,9 +222,20 @@ pub enum VerificationError<SealSrc: RgbSealSrc> {
217222
/// unknown seal definition for cell address {0}.
218223
SealUnknown(CellAddr),
219224

220-
/// seals, reported to be defined by the operation {0}, do match the assignments in the
225+
/// seals, reported to be defined by the operation {opid}, do match the assignments in the
221226
/// operation.
222-
SealsDefinitionMismatch(Opid),
227+
///
228+
/// Actual operation seals from the assignments: {defined:#?}
229+
///
230+
/// Reported seals: {reported:#?}
231+
///
232+
/// Sources for the reported seals: {sources:#?}
233+
SealsDefinitionMismatch {
234+
opid: Opid,
235+
reported: BTreeSet<AuthToken>,
236+
defined: BTreeSet<AuthToken>,
237+
sources: BTreeMap<u16, String>,
238+
},
223239

224240
#[from]
225241
#[display(inner)]

0 commit comments

Comments
 (0)