OptionContract

Type Alias OptionContract 

Source
pub type OptionContract = Singleton<OptionInfo>;

Aliased Type§

pub struct OptionContract {
    pub coin: Coin,
    pub proof: Proof,
    pub info: OptionInfo,
}

Fields§

§coin: Coin

The coin that this Singleton represents. Its puzzle hash should match the singleton outer puzzle hash.

§proof: Proof

The proof is needed by the singleton puzzle to prove that this coin is a legitimate singleton. It’s typically obtained by looking up and parsing the parent coin.

Note that while the proof will be a LineageProof for most coins, for the first singleton in the lineage it will be an EveProof instead. However, the eve coin is typically unhinted and spent in the same transaction as it was created, so this is not relevant for database storage or syncing unspent coins.

§info: OptionInfo

The information needed to construct the outer puzzle.

Implementations§

Source§

impl OptionContract

Source

pub fn parse_child( allocator: &mut Allocator, parent_coin: Coin, parent_puzzle: Puzzle, parent_solution: NodePtr, ) -> Result<Option<Self>, DriverError>

Source

pub fn parse( allocator: &Allocator, coin: Coin, puzzle: Puzzle, solution: NodePtr, ) -> Result<Option<(Self, Puzzle, NodePtr)>, DriverError>

Parses an OptionContract and its p2 spend from a coin spend.

If the puzzle is not an option contract, this will return None instead of an error. However, if the puzzle should have been an option contract but had a parsing error, this will return an error.

Source

pub fn parse_metadata( allocator: &mut Allocator, launcher_solution: NodePtr, ) -> Result<OptionMetadata, DriverError>

Source

pub fn spend( &self, ctx: &mut SpendContext, inner_spend: Spend, ) -> Result<Option<Self>, DriverError>

Source

pub fn spend_with<I>( &self, ctx: &mut SpendContext, inner: &I, conditions: Conditions, ) -> Result<Option<Self>, DriverError>

Source

pub fn transfer<I>( self, ctx: &mut SpendContext, inner: &I, p2_puzzle_hash: Bytes32, extra_conditions: Conditions, ) -> Result<Self, DriverError>

Source

pub fn exercise<I>( self, ctx: &mut SpendContext, inner: &I, extra_conditions: Conditions, ) -> Result<(), DriverError>

Source

pub fn child(&self, p2_puzzle_hash: Bytes32, amount: u64) -> Self

Trait Implementations§

Source§

impl AddAsset for OptionContract

Source§

fn add(self, spends: &mut Spends)

Source§

impl Asset for OptionContract

Source§

impl SingletonAsset for OptionContract

Source§

type ChildInfo = ChildOptionInfo

Source§

fn default_child_info(_asset: &Self, spend_kind: &SpendKind) -> Self::ChildInfo

Source§

fn needs_additional_spend(_child_info: &Self::ChildInfo) -> bool

Source§

fn finalize( ctx: &mut SpendContext, singleton: &mut SingletonSpend<Self>, _conditions_puzzle_hash: Bytes32, change_puzzle_hash: Bytes32, ) -> Result<Option<SingletonSpend<Self>>, DriverError>