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: AbiVersionABI 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
impl Contract
Sourcepub fn find_function_by_id(&self, id: u32, input: bool) -> Option<&Function>
pub fn find_function_by_id(&self, id: u32, input: bool) -> Option<&Function>
Finds a method declaration with the specfied id.
Sourcepub fn find_event_by_id(&self, id: u32) -> Option<&Event>
pub fn find_event_by_id(&self, id: u32) -> Option<&Event>
Finds an event with the specified id.
Sourcepub fn update_init_data(
&self,
pubkey: Option<&VerifyingKey>,
tokens: &[NamedAbiValue],
data: &Cell,
) -> Result<Cell>
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.
Sourcepub fn encode_init_data(
&self,
pubkey: &VerifyingKey,
tokens: &[NamedAbiValue],
) -> Result<Cell>
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.
Sourcepub fn decode_init_data(&self, data: &DynCell) -> Result<Vec<NamedAbiValue>>
pub fn decode_init_data(&self, data: &DynCell) -> Result<Vec<NamedAbiValue>>
Tries to parse init data fields of this contract from an account data.
Sourcepub fn encode_fields(&self, tokens: &[NamedAbiValue]) -> Result<CellBuilder>
pub fn encode_fields(&self, tokens: &[NamedAbiValue]) -> Result<CellBuilder>
Encodes an account data with the specified storage fields of this contract.
Sourcepub fn decode_fields(&self, slice: CellSlice<'_>) -> Result<Vec<NamedAbiValue>>
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.
Sourcepub fn decode_fields_ext(
&self,
slice: &mut CellSlice<'_>,
allow_partial: bool,
) -> Result<Vec<NamedAbiValue>>
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.