Skip to content

Commit ecbe5de

Browse files
committed
iface: filter contract state basing on the witness mining status
Closes #287
1 parent b374468 commit ecbe5de

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/interface/contract.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::borrow::Borrow;
2323
use std::collections::{BTreeSet, HashMap, HashSet};
2424

2525
use invoice::{Allocation, Amount};
26+
use rgb::vm::WitnessOrd;
2627
use rgb::{
2728
AssignmentType, AttachState, ContractId, DataState, OpId, RevealedAttach, RevealedData,
2829
RevealedValue, Schema, VoidState, XOutpoint, XOutputSeal, XWitnessId,
@@ -303,7 +304,15 @@ impl<S: ContractStateRead> ContractIface<S> {
303304
.ok_or(ContractError::FieldNameUnknown(name))?;
304305
Ok(state
305306
.into_iter()
306-
.filter(move |outp| outp.opout.ty == type_id)
307+
.filter(move |outp| {
308+
outp.opout.ty == type_id
309+
&& outp
310+
.witness
311+
.and_then(|id| self.witness_info(id))
312+
// TODO: Check the mining depth
313+
.map(|w| matches!(w.ord, WitnessOrd::Mined(_)))
314+
.unwrap_or(true)
315+
})
307316
.cloned()
308317
.map(OutputAssignment::<A>::transmute))
309318
}

0 commit comments

Comments
 (0)