chia_sdk_driver

Struct SpendContext

source
pub struct SpendContext {
    pub allocator: Allocator,
    /* private fields */
}
Expand description

A wrapper around Allocator that caches puzzles and keeps track of a list of CoinSpend. It’s used to construct spend bundles in an easy and efficient way.

Fields§

§allocator: Allocator

Implementations§

source§

impl SpendContext

source§

impl SpendContext

source§

impl SpendContext

source

pub fn new() -> Self

source

pub fn iter(&self) -> impl Iterator<Item = &CoinSpend>

source

pub fn take(&mut self) -> Vec<CoinSpend>

Remove all of the CoinSpend that have been collected so far.

source

pub fn insert(&mut self, coin_spend: CoinSpend)

Adds a CoinSpend to the collection.

source

pub fn spend(&mut self, coin: Coin, spend: Spend) -> Result<(), DriverError>

Serializes a Spend and adds it to the list of CoinSpend.

source

pub fn alloc<T>(&mut self, value: &T) -> Result<NodePtr, DriverError>
where T: ToClvm<Allocator>,

Allocate a new node and return its pointer.

source

pub fn extract<T>(&self, ptr: NodePtr) -> Result<T, DriverError>
where T: FromClvm<Allocator>,

Extract a value from a node pointer.

source

pub fn tree_hash(&self, ptr: NodePtr) -> TreeHash

Compute the tree hash of a node pointer.

source

pub fn run( &mut self, puzzle: NodePtr, solution: NodePtr, ) -> Result<NodePtr, DriverError>

Run a puzzle with a solution and return the result.

source

pub fn serialize<T>(&mut self, value: &T) -> Result<Program, DriverError>
where T: ToClvm<Allocator>,

Serialize a value and return a Program.

source

pub fn standard_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the standard puzzle and return its pointer.

source

pub fn cat_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the CAT puzzle and return its pointer.

source

pub fn did_inner_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the DID inner puzzle and return its pointer.

source

pub fn nft_intermediate_launcher(&mut self) -> Result<NodePtr, DriverError>

Allocate the NFT intermediate launcher puzzle and return its pointer.

source

pub fn nft_royalty_transfer(&mut self) -> Result<NodePtr, DriverError>

Allocate the NFT royalty transfer puzzle and return its pointer.

source

pub fn nft_metadata_updater(&mut self) -> Result<NodePtr, DriverError>

Allocate the NFT metadata updater puzzle and return its pointer.

source

pub fn nft_ownership_layer(&mut self) -> Result<NodePtr, DriverError>

Allocate the NFT ownership layer puzzle and return its pointer.

source

pub fn nft_state_layer(&mut self) -> Result<NodePtr, DriverError>

Allocate the NFT state layer puzzle and return its pointer.

source

pub fn singleton_top_layer(&mut self) -> Result<NodePtr, DriverError>

Allocate the singleton top layer puzzle and return its pointer.

source

pub fn singleton_launcher(&mut self) -> Result<NodePtr, DriverError>

Allocate the singleton launcher puzzle and return its pointer.

source

pub fn everything_with_signature_tail_puzzle( &mut self, ) -> Result<NodePtr, DriverError>

Allocate the multi-issuance TAIL puzzle and return its pointer.

source

pub fn genesis_by_coin_id_tail_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the single-issuance TAIL puzzle and return its pointer.

source

pub fn settlement_payments_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the settlement payments puzzle and return its pointer.

source

pub fn p2_delegated_conditions_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the p2 delegated conditions puzzle and return its pointer.

source

pub fn p2_one_of_many_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the p2 one of many puzzle and return its pointer.

source

pub fn p2_singleton_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the p2 singleton puzzle and return its pointer.

source

pub fn p2_delegated_singleton_puzzle(&mut self) -> Result<NodePtr, DriverError>

Allocate the p2 delegated singleton puzzle and return its pointer.

source

pub fn preload(&mut self, puzzle_hash: TreeHash, ptr: NodePtr)

Preload a puzzle into the cache.

source

pub fn get_puzzle(&self, puzzle_hash: &TreeHash) -> Option<NodePtr>

Checks whether a puzzle is in the cache.

source

pub fn puzzle( &mut self, puzzle_hash: TreeHash, puzzle_bytes: &[u8], ) -> Result<NodePtr, DriverError>

Get a puzzle from the cache or allocate a new one.

Trait Implementations§

source§

impl Debug for SpendContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for SpendContext

source§

fn default() -> SpendContext

Returns the “default value” for a type. Read more
source§

impl From<Allocator> for SpendContext

source§

fn from(allocator: Allocator) -> Self

Converts to this type from the input type.
source§

impl IntoIterator for SpendContext

source§

type Item = CoinSpend

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<<SpendContext as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.