Skip to content

Commit

Permalink
iface: add AllocationWitness type
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 14, 2023
1 parent 5d0dcea commit 0f26324
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions src/interface/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,28 @@ impl From<RevealedAttach> for AttachedState {
}
}

#[derive(Copy, Clone, Eq, PartialEq, Debug, Display)]
pub enum AllocationWitness {
#[display("~")]
Absent,
#[display(inner)]
Present(WitnessId),
}

impl From<Option<WitnessId>> for AllocationWitness {
fn from(value: Option<WitnessId>) -> Self {
match value {
None => AllocationWitness::Absent,
Some(id) => AllocationWitness::Present(id),
}
}
}

// TODO: Consider removing type in favour of `FungibleOutput`
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct FungibleAllocation {
pub owner: Output,
pub witness: Option<WitnessId>,
pub witness: AllocationWitness,
pub value: u64,
}

Expand All @@ -90,7 +107,7 @@ impl From<&FungibleOutput> for FungibleAllocation {
fn from(out: &FungibleOutput) -> Self {
FungibleAllocation {
owner: out.output,
witness: out.witness,
witness: out.witness.into(),
value: out.state.value.as_u64(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ mod suppl;

pub use builder::{BuilderError, ContractBuilder, TransitionBuilder};
pub use contract::{
ContractIface, FilterExclude, FilterIncludeAll, FungibleAllocation, IfaceWrapper,
OutpointFilter, TypedState,
AllocationWitness, ContractIface, FilterExclude, FilterIncludeAll, FungibleAllocation,
IfaceWrapper, OutpointFilter, TypedState,
};
pub use iface::{
ArgMap, ArgSpec, AssignIface, ExtensionIface, GenesisIface, GlobalIface, Iface, IfaceId,
Expand Down

0 comments on commit 0f26324

Please sign in to comment.