[][src]Struct ergo_headless_dapp_framework::box_spec::BoxSpec

pub struct BoxSpec { /* fields omitted */ }

A specification which specifies parameters of an ErgoBox. This spec is used as a "source of truth" to both verify and find ErgoBoxes which match the spec. This is often used for defining Stages in multi-stage smart contract protocols, but can also be used to define input boxes for Actions. All fields are wrapped in Options to allow ignoring specifying the field.

Implementations

impl BoxSpec[src]

Method definitions for BoxSpec that are WASM-compatible by default and/or are wrapper functions for Rust methods so that they are made WASM-compatible.

pub fn utxo_scan_json(&self) -> String[src]

pub fn modified_address(&self, address: Option<ErgoAddressString>) -> BoxSpec[src]

Returns a new BoxSpec with all fields exactly the same except the address is set to the String provided as input. This method is generally used to hone down a more generic BoxSpec definition into a more specific one for your given use case. Ie. Add a user's P2PK address to find boxes matching the BoxSpec in their wallet.

pub fn w_verify_box(&self, wrapped_ergo_box: WErgoBox) -> bool[src]

pub fn w_explorer_endpoint(
    &self,
    explorer_api_url: &str
) -> Result<String, JsValue>
[src]

pub fn w_process_explorer_response(
    &self,
    explorer_response_body: &str
) -> Result<ErgoBoxes, JsValue>
[src]

impl BoxSpec[src]

Method definitions for BoxSpec that are intended to be used in Rust.

pub fn new(
    address: Option<ErgoAddressString>,
    value_range: Option<Range<NanoErg>>,
    registers: Vec<RegisterSpec>,
    tokens: Vec<Option<TokenSpec>>
) -> BoxSpec
[src]

Create a new basic BoxSpec with no predicate.

pub fn new_predicated(
    address: Option<ErgoAddressString>,
    value_range: Option<Range<NanoErg>>,
    registers: Vec<RegisterSpec>,
    tokens: Vec<Option<TokenSpec>>,
    predicate: Option<fn(_: &ErgoBox) -> bool>
) -> BoxSpec
[src]

Create a new BoxSpec with a custom predicate defined.

pub fn ergo_tree(&self) -> Result<ErgoTree>[src]

Acquire the ErgoTree of the address in the BoxSpec

pub fn verify_box(&self, ergo_box: &ErgoBox) -> Result<()>[src]

Verify that a provided ErgoBox matches the spec

pub fn explorer_endpoint(&self, explorer_api_url: &str) -> Result<String>[src]

Generates a URL for the Ergo Explorer Backend API to find boxes which may match your BoxSpec. This method uses the explorer_api_url you provide as input which must be formatted as such: https://api.ergoplatform.com/api This method is intended to be used in tandem with process_explorer_response()

pub fn process_explorer_response(
    &self,
    explorer_response_body: &str
) -> Result<Vec<ErgoBox>>
[src]

Using the response JSON (as a String) from the Ergo Explorer API endpoint generated by the explorer_endpoint() method, filter all returned ErgoBoxes against the BoxSpec using the verify_box() method.

impl BoxSpec[src]

Methods related to modifying fields (which aren't WASM-compatible)

pub fn modified_value_range(&self, value_range: Option<Range<u64>>) -> BoxSpec[src]

Returns a new BoxSpec with all fields exactly the same except the value_range is set to the range provided as input.

pub fn modified_registers(&self, registers: Vec<RegisterSpec>) -> BoxSpec[src]

Returns a new BoxSpec with all fields exactly the same except the registers are set to the registers provided as input.

pub fn modified_tokens(&self, tokens: Vec<Option<TokenSpec>>) -> BoxSpec[src]

Returns a new BoxSpec with all fields exactly the same except the tokens are set to the TokenSpecs provided as input.

pub fn modified_predicate(
    &self,
    predicate: Option<fn(_: &ErgoBox) -> bool>
) -> BoxSpec
[src]

Returns a new BoxSpec with all fields exactly the same except the predicate is set to the one provided as input.

Trait Implementations

impl Clone for BoxSpec[src]

impl From<BoxSpec> for JsValue[src]

impl FromWasmAbi for BoxSpec[src]

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

impl IntoWasmAbi for BoxSpec[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

impl OptionFromWasmAbi for BoxSpec[src]

impl OptionIntoWasmAbi for BoxSpec[src]

impl RefFromWasmAbi for BoxSpec[src]

type Abi = u32

The wasm ABI type references to Self are recovered from.

type Anchor = Ref<'static, BoxSpec>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more

impl RefMutFromWasmAbi for BoxSpec[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

type Anchor = RefMut<'static, BoxSpec>

Same as RefFromWasmAbi::Anchor

impl WasmDescribe for BoxSpec[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ReturnWasmAbi for T where
    T: IntoWasmAbi
[src]

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<F> TryExtractInto<F> for F[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,