Struct Contract

Source
pub struct Contract {
    pub abi_version: AbiVersion,
    pub headers: Arc<[AbiHeaderType]>,
    pub functions: HashMap<Arc<str>, Function>,
    pub events: HashMap<Arc<str>, Event>,
    pub init_data: HashMap<Arc<str>, (u64, NamedAbiType)>,
    pub fields: Arc<[NamedAbiType]>,
}
Expand description

Contract ABI definition.

Fields§

§abi_version: AbiVersion

ABI version.

§headers: Arc<[AbiHeaderType]>

List of headers for external messages.

NOTE: header order matters.

§functions: HashMap<Arc<str>, Function>

A mapping with all contract methods by name.

§events: HashMap<Arc<str>, Event>

A mapping with all contract events by name.

§init_data: HashMap<Arc<str>, (u64, NamedAbiType)>

Contract init data.

§fields: Arc<[NamedAbiType]>

Contract storage fields.

Implementations§

Source§

impl Contract

Source

pub fn find_function_by_id(&self, id: u32, input: bool) -> Option<&Function>

Finds a method declaration with the specfied id.

Source

pub fn find_event_by_id(&self, id: u32) -> Option<&Event>

Finds an event with the specified id.

Source

pub fn update_init_data( &self, pubkey: Option<&VerifyingKey>, tokens: &[NamedAbiValue], data: &Cell, ) -> Result<Cell>

Returns a new init data with replaced items.

NOTE: tokens can be a subset of init data fields, all other will not be touched.

Source

pub fn encode_init_data( &self, pubkey: &VerifyingKey, tokens: &[NamedAbiValue], ) -> Result<Cell>

Encodes an account data with the specified initial parameters.

NOTE: tokens can be a subset of init data fields, all other will be set to default.

Source

pub fn decode_init_data(&self, data: &DynCell) -> Result<Vec<NamedAbiValue>>

Tries to parse init data fields of this contract from an account data.

Source

pub fn encode_fields(&self, tokens: &[NamedAbiValue]) -> Result<CellBuilder>

Encodes an account data with the specified storage fields of this contract.

Source

pub fn decode_fields(&self, slice: CellSlice<'_>) -> Result<Vec<NamedAbiValue>>

Tries to parse storage fields of this contract from an account data.

NOTE: The slice is required to contain nothing other than these fields.

Source

pub fn decode_fields_ext( &self, slice: &mut CellSlice<'_>, allow_partial: bool, ) -> Result<Vec<NamedAbiValue>>

Tries to parse storage fields of this contract from an account data.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for Contract

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> EquivalentRepr<T> for T