Skip to content
This repository was archived by the owner on Dec 9, 2023. It is now read-only.

Commit ae4da21

Browse files
authored
Merge pull request #212 from zoedberg/process_attachment_assignments
2 parents ff08b30 + fe2ccd9 commit ae4da21

File tree

1 file changed

+55
-26
lines changed

1 file changed

+55
-26
lines changed

src/bucketd/processor.rs

+55-26
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ use rgb::psbt::RgbExt;
1919
use rgb::schema::{OwnedRightType, TransitionType};
2020
use rgb::seal::Revealed;
2121
use rgb::{
22-
bundle, validation, Anchor, Assignment, BundleId, Consignment, ConsignmentType, ContractId,
23-
ContractState, ContractStateMap, Disclosure, Genesis, InmemConsignment, Node, NodeId,
24-
OwnedRights, PedersenStrategy, Schema, SchemaId, SealEndpoint, StateTransfer, Transition,
25-
TransitionBundle, TypedAssignments, Validator, Validity,
22+
bundle, validation, Anchor, Assignment, AttachmentStrategy, BundleId, Consignment,
23+
ConsignmentType, ContractId, ContractState, ContractStateMap, Disclosure, Genesis,
24+
InmemConsignment, Node, NodeId, OwnedRights, PedersenStrategy, Schema, SchemaId, SealEndpoint,
25+
StateTransfer, Transition, TransitionBundle, TypedAssignments, Validator, Validity,
2626
};
2727
use rgb_rpc::{FinalizeTransfersRes, OutpointFilter, Reveal, TransferFinalize};
2828
use storm::chunk::ChunkIdExt;
@@ -282,30 +282,59 @@ impl Runtime {
282282

283283
let mut owned_rights: BTreeMap<OwnedRightType, TypedAssignments> = bmap! {};
284284
for (owned_type, assignments) in transition.owned_rights().iter() {
285-
let outpoints = assignments.to_value_assignments();
286-
287-
let mut revealed_assignment: Vec<Assignment<PedersenStrategy>> =
288-
empty!();
289-
290-
for out in outpoints {
291-
if out.commit_conceal().to_confidential_seal()
292-
!= reveal_outpoint.to_concealed_seal()
293-
{
294-
revealed_assignment.push(out);
295-
} else {
296-
let accept = match out.as_revealed_state() {
297-
Some(seal) => Assignment::Revealed {
298-
seal: reveal_outpoint,
299-
state: *seal,
300-
},
301-
_ => out,
302-
};
303-
revealed_assignment.push(accept);
285+
match assignments {
286+
TypedAssignments::Value(outpoints) => {
287+
let mut assignment: Vec<Assignment<PedersenStrategy>> =
288+
empty!();
289+
290+
for out in outpoints.clone() {
291+
if out.commit_conceal().to_confidential_seal()
292+
!= reveal_outpoint.to_concealed_seal()
293+
{
294+
assignment.push(out);
295+
} else {
296+
let accept = match out.as_revealed_state() {
297+
Some(seal) => Assignment::Revealed {
298+
seal: reveal_outpoint,
299+
state: *seal,
300+
},
301+
_ => out,
302+
};
303+
assignment.push(accept);
304+
}
305+
}
306+
307+
owned_rights
308+
.insert(*owned_type, TypedAssignments::Value(assignment));
304309
}
310+
TypedAssignments::Attachment(outpoints) => {
311+
let mut assignment: Vec<Assignment<AttachmentStrategy>> =
312+
empty!();
313+
314+
for out in outpoints.clone() {
315+
if out.commit_conceal().to_confidential_seal()
316+
!= reveal_outpoint.to_concealed_seal()
317+
{
318+
assignment.push(out);
319+
} else {
320+
let accept = match out.as_revealed_state() {
321+
Some(seal) => Assignment::Revealed {
322+
seal: reveal_outpoint,
323+
state: seal.clone(),
324+
},
325+
_ => out,
326+
};
327+
assignment.push(accept);
328+
}
329+
}
330+
331+
owned_rights.insert(
332+
*owned_type,
333+
TypedAssignments::Attachment(assignment),
334+
);
335+
}
336+
_ => {}
305337
}
306-
307-
owned_rights
308-
.insert(*owned_type, TypedAssignments::Value(revealed_assignment));
309338
}
310339

311340
let tmp: Transition = Transition::with(

0 commit comments

Comments
 (0)