Skip to content

Commit

Permalink
iface: filter contract state basing on the witness mining status
Browse files Browse the repository at this point in the history
Closes #287
  • Loading branch information
dr-orlovsky committed Jan 7, 2025
1 parent c00aa3b commit aaeeade
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/interface/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::borrow::Borrow;
use std::collections::{BTreeSet, HashMap, HashSet};

use invoice::{Allocation, Amount};
use rgb::vm::WitnessOrd;
use rgb::{
AssignmentType, AttachState, ContractId, DataState, OpId, RevealedAttach, RevealedData,
RevealedValue, Schema, VoidState, XOutpoint, XOutputSeal, XWitnessId,
Expand Down Expand Up @@ -303,7 +304,15 @@ impl<S: ContractStateRead> ContractIface<S> {
.ok_or(ContractError::FieldNameUnknown(name))?;
Ok(state
.into_iter()
.filter(move |outp| outp.opout.ty == type_id)
.filter(move |outp| {
outp.opout.ty == type_id
&& outp
.witness
.and_then(|id| self.witness_info(id))
// TODO: Check the mining depth
.map(|w| matches!(w.ord, WitnessOrd::Mined(_)))
.unwrap_or(true)
})

Check warning on line 315 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L307-L315

Added lines #L307 - L315 were not covered by tests
.cloned()
.map(OutputAssignment::<A>::transmute))
}
Expand Down

0 comments on commit aaeeade

Please sign in to comment.