Struct pchain_sdk::ContractCallData
source · [−]pub struct ContractCallData { /* private fields */ }Expand description
wrapper struct got protocol_types::CallData
Implementations
sourceimpl ContractCallData
impl ContractCallData
sourcepub fn get_method_name(&self) -> &str
pub fn get_method_name(&self) -> &str
get method_name as &str from call_data
sourcepub fn get_multiple_arguments(&self) -> Vec<Vec<u8>>
pub fn get_multiple_arguments(&self) -> Vec<Vec<u8>>
The field arguments in CallData defines inputs arguments to the function with name which is defined in the field entrypoint
The function here converts arguments to Vec<Vec
Example
fn method_1(data :i32, name :String) { ...If arguments represents the above function, the output is a vector = {“data”, “name”}
where “data” and “name” are Borsh-Serialized bytes
sourcepub fn parse_multiple_arguments<T: BorshDeserialize>(
args: &Vec<Vec<u8>>,
idx: usize
) -> T
pub fn parse_multiple_arguments<T: BorshDeserialize>(
args: &Vec<Vec<u8>>,
idx: usize
) -> T
Parser function to deserialize indexed argument into defined data type
sourcepub fn from_raw_call_data() -> Option<ContractCallData>
pub fn from_raw_call_data() -> Option<ContractCallData>
Convert the field data in the transaction into CallData.
Valid CallData should follow below requirements
- first 4 bytes are version bytes which matches CALLDATA_VERSION
- if it is less than 4 bytes, it assumes version = 0 and CallData is returned with “empty” data
- return None if version does not match with CALLDATA_VERSION
- the rest of the bytes are borsh-serialized from the structure CallData
Auto Trait Implementations
impl RefUnwindSafe for ContractCallData
impl Send for ContractCallData
impl Sync for ContractCallData
impl Unpin for ContractCallData
impl UnwindSafe for ContractCallData
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more