[−][src]Struct ergo_headless_dapp_framework::box_spec::BoxSpec
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]
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]
address: Option<ErgoAddressString>,
value_range: Option<Range<NanoErg>>,
registers: Vec<RegisterSpec>,
tokens: Vec<Option<TokenSpec>>
) -> BoxSpec
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]
address: Option<ErgoAddressString>,
value_range: Option<Range<NanoErg>>,
registers: Vec<RegisterSpec>,
tokens: Vec<Option<TokenSpec>>,
predicate: Option<fn(_: &ErgoBox) -> bool>
) -> BoxSpec
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]
&self,
explorer_response_body: &str
) -> Result<Vec<ErgoBox>>
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]
&self,
predicate: Option<fn(_: &ErgoBox) -> bool>
) -> BoxSpec
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
pub unsafe fn from_abi(js: u32) -> Self[src]
impl IntoWasmAbi for BoxSpec[src]
type Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
pub fn into_abi(self) -> u32[src]
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
pub unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor[src]
impl RefMutFromWasmAbi for BoxSpec[src]
type Abi = u32
Same as RefFromWasmAbi::Abi
type Anchor = RefMut<'static, BoxSpec>
Same as RefFromWasmAbi::Anchor
pub unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor[src]
impl WasmDescribe for BoxSpec[src]
Auto Trait Implementations
impl !RefUnwindSafe for BoxSpec
impl !Send for BoxSpec
impl !Sync for BoxSpec
impl Unpin for BoxSpec
impl !UnwindSafe for BoxSpec
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi, [src]
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
pub fn return_abi(self) -> <T as ReturnWasmAbi>::Abi[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,