pub trait JsonAbiExt: Sealed {
// Required methods
fn abi_encode_input(&self, values: &[DynSolValue]) -> Result<Vec<u8>>;
fn abi_encode_input_raw(&self, values: &[DynSolValue]) -> Result<Vec<u8>>;
fn abi_decode_input(
&self,
data: &[u8],
validate: bool,
) -> Result<Vec<DynSolValue>>;
}
Expand description
Provides ABI encoding and decoding functionality.
This trait is sealed and cannot be implemented for types outside of this crate. It is implemented only for the following types:
Required Methods§
Sourcefn abi_encode_input(&self, values: &[DynSolValue]) -> Result<Vec<u8>>
fn abi_encode_input(&self, values: &[DynSolValue]) -> Result<Vec<u8>>
ABI-encodes the given values, prefixed by this item’s selector, if any.
The selector is:
None
forConstructor
,Some(self.selector())
forError
andFunction
.
This behaviour is to ensure consistency with ethabi
.
To encode the data without the selector, use
abi_encode_input_raw
.
§Errors
This function will return an error if the given values do not match the expected input types.
Sourcefn abi_encode_input_raw(&self, values: &[DynSolValue]) -> Result<Vec<u8>>
fn abi_encode_input_raw(&self, values: &[DynSolValue]) -> Result<Vec<u8>>
ABI-encodes the given values, without prefixing the data with the item’s selector.
For Constructor
, this is the same as
abi_encode_input
.
§Errors
This function will return an error if the given values do not match the expected input types.
Sourcefn abi_decode_input(
&self,
data: &[u8],
validate: bool,
) -> Result<Vec<DynSolValue>>
fn abi_decode_input( &self, data: &[u8], validate: bool, ) -> Result<Vec<DynSolValue>>
ABI-decodes the given data according to this item’s input types.
§Errors
This function will return an error if the decoded data does not match the expected input types.