Skip to content

Commit

Permalink
Merge pull request RGB-WG#219 from cymqqqq/more-operations
Browse files Browse the repository at this point in the history
add rights, attachment operations
  • Loading branch information
dr-orlovsky authored Jun 18, 2024
2 parents 41c881c + e27ece8 commit d2f99cf
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/interface/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,38 @@ impl ContractIface {
witness_filter,
))
}

pub fn rights_ops<C: StateChange<State = VoidState>>(
&self,
name: impl Into<FieldName>,
witness_filter: impl WitnessFilter + Copy,
outpoint_filter: impl OutpointFilter + Copy,
) -> Result<HashMap<XWitnessId, IfaceOp<C>>, ContractError> {
Ok(self.operations(
self.state
.rights()
.iter()
.cloned()
.map(OutputAssignment::transmute),
self.rights(name, outpoint_filter)?,
witness_filter,
))
}

pub fn attachment_ops<C: StateChange<State = AttachedState>>(
&self,
name: impl Into<FieldName>,
witness_filter: impl WitnessFilter + Copy,
outpoint_filter: impl OutpointFilter + Copy,
) -> Result<HashMap<XWitnessId, IfaceOp<C>>, ContractError> {
Ok(self.operations(
self.state
.attach()
.iter()
.cloned()
.map(OutputAssignment::transmute),
self.attachments(name, outpoint_filter)?,
witness_filter,
))
}
}

0 comments on commit d2f99cf

Please sign in to comment.