From d53454a5c6c440b163b7eb399aa276049dc6a08a Mon Sep 17 00:00:00 2001 From: Armando Dutra Date: Tue, 26 Dec 2023 15:47:43 -0300 Subject: [PATCH] fix: bundle merge reveal check --- src/accessors/bundle.rs | 2 +- src/accessors/merge_reveal.rs | 16 +++++++++------- src/persistence/hoard.rs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/accessors/bundle.rs b/src/accessors/bundle.rs index aba5d9d1..3318598f 100644 --- a/src/accessors/bundle.rs +++ b/src/accessors/bundle.rs @@ -62,7 +62,7 @@ impl BundleExt for TransitionBundle { return Ok(false); } self.known_transitions - .insert(opid, transition.clone()) + .insert(opid, transition) .expect("same size as input map"); Ok(true) } diff --git a/src/accessors/merge_reveal.rs b/src/accessors/merge_reveal.rs index 7a951df3..6fd33536 100644 --- a/src/accessors/merge_reveal.rs +++ b/src/accessors/merge_reveal.rs @@ -42,8 +42,8 @@ pub enum MergeRevealError { #[display(inner)] AnchorMismatch(MergeError), - /// the merged bundles contain excessive transactions. - ExcessiveTransactions, + /// the merged bundles contain excessive transitions. + ExcessiveTransitions, /// contract id provided for the merge-reveal operation doesn't matches /// multi-protocol commitment. @@ -187,12 +187,14 @@ impl MergeReveal for Assignments { impl MergeReveal for TransitionBundle { fn merge_reveal(mut self, other: Self) -> Result { debug_assert_eq!(self.commitment_id(), other.commitment_id()); - if self.known_transitions.len() + other.known_transitions.len() > self.input_map.len() || - self.known_transitions - .extend(other.known_transitions) - .is_err() + + if self + .known_transitions + .extend(other.known_transitions) + .is_err() || + self.input_map.len() < self.known_transitions.len() { - return Err(MergeRevealError::ExcessiveTransactions); + return Err(MergeRevealError::ExcessiveTransitions); } Ok(self) } diff --git a/src/persistence/hoard.rs b/src/persistence/hoard.rs index 827012d0..db7bc9e2 100644 --- a/src/persistence/hoard.rs +++ b/src/persistence/hoard.rs @@ -190,7 +190,7 @@ impl Hoard { // Update asset tags self.asset_tags - .insert(contract_id, consignment.asset_tags.clone())?; + .insert(contract_id, consignment.asset_tags)?; Ok(()) }