Trait SolTypeDecode

Source
pub trait SolTypeDecode: Sized + Sealed {
    type AlloyType: AlloySolType;

    // Required method
    fn detokenize(
        token: <Self::AlloyType as AlloySolType>::Token<'_>,
    ) -> Result<Self, Error>;

    // Provided method
    fn decode(data: &[u8]) -> Result<Self, Error> { ... }
}
Expand description

A Rust/ink! equivalent of a Solidity ABI type that implements logic for Solidity ABI decoding.

§Rust/ink! to Solidity ABI type mapping

Rust/ink! typeSolidity ABI typeNotes
boolbool
iN for N ∈ {8,16,32,64,128}intNe.g i8int8
uN for N ∈ {8,16,32,64,128}uintNe.g u8uint8
U256uint256
Stringstring
Box<str>string
Address / H160addressAddress is a type alias for the H160 type used for addresses in pallet-revive
[T; N] for const N: usizeT[N]e.g. [i8; 64]int8[64]
Vec<T>T[]e.g. Vec<i8>int8[]
Box<[T]>T[]e.g. Box<[i8]>int8[]
SolBytes<u8>bytes1
SolBytes<[u8; N]> for 1 <= N <= 32bytesNe.g. SolBytes<[u8; 32]>bytes32
SolBytes<Vec<u8>>bytes
SolBytes<Box<[u8]>>bytes
(T1, T2, T3, ... T12)(U1, U2, U3, ... U12)where T1U1, … T12U12 e.g. (bool, u8, Address)(bool, uint8, address)

Ref: https://docs.soliditylang.org/en/latest/abi-spec.html#types

§Note

This trait is sealed and cannot be implemented for types outside ink_primitives.

Required Associated Types§

Source

type AlloyType: AlloySolType

Equivalent Solidity ABI type from [alloy_sol_types].

Required Methods§

Source

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Detokenizes this type’s value from the given token.

Provided Methods§

Source

fn decode(data: &[u8]) -> Result<Self, Error>

Solidity ABI decode into this type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SolTypeDecode for bool

Source§

type AlloyType = Bool

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for i8

Source§

type AlloyType = Int<8>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for i16

Source§

type AlloyType = Int<16>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for i32

Source§

type AlloyType = Int<32>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for i64

Source§

type AlloyType = Int<64>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for i128

Source§

type AlloyType = Int<128>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for u8

Source§

type AlloyType = Uint<8>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for u16

Source§

type AlloyType = Uint<16>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for u32

Source§

type AlloyType = Uint<32>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for u64

Source§

type AlloyType = Uint<64>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for u128

Source§

type AlloyType = Uint<128>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for ()

Source§

type AlloyType = ()

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for Box<str>

Source§

type AlloyType = String

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl SolTypeDecode for String

Source§

type AlloyType = String

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<T: SolTypeDecode> SolTypeDecode for Box<[T]>

Source§

type AlloyType = Array<<T as SolTypeDecode>::AlloyType>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<T: SolTypeDecode> SolTypeDecode for Vec<T>

Source§

type AlloyType = Array<<T as SolTypeDecode>::AlloyType>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<T: SolTypeDecode, const N: usize> SolTypeDecode for [T; N]

Source§

type AlloyType = FixedArray<<T as SolTypeDecode>::AlloyType, N>

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode> SolTypeDecode for (TupleElement0,)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType,)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode, TupleElement6: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType, <TupleElement6 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode, TupleElement6: SolTypeDecode, TupleElement7: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType, <TupleElement6 as SolTypeDecode>::AlloyType, <TupleElement7 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode, TupleElement6: SolTypeDecode, TupleElement7: SolTypeDecode, TupleElement8: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType, <TupleElement6 as SolTypeDecode>::AlloyType, <TupleElement7 as SolTypeDecode>::AlloyType, <TupleElement8 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode, TupleElement6: SolTypeDecode, TupleElement7: SolTypeDecode, TupleElement8: SolTypeDecode, TupleElement9: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType, <TupleElement6 as SolTypeDecode>::AlloyType, <TupleElement7 as SolTypeDecode>::AlloyType, <TupleElement8 as SolTypeDecode>::AlloyType, <TupleElement9 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode, TupleElement6: SolTypeDecode, TupleElement7: SolTypeDecode, TupleElement8: SolTypeDecode, TupleElement9: SolTypeDecode, TupleElement10: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType, <TupleElement6 as SolTypeDecode>::AlloyType, <TupleElement7 as SolTypeDecode>::AlloyType, <TupleElement8 as SolTypeDecode>::AlloyType, <TupleElement9 as SolTypeDecode>::AlloyType, <TupleElement10 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Source§

impl<TupleElement0: SolTypeDecode, TupleElement1: SolTypeDecode, TupleElement2: SolTypeDecode, TupleElement3: SolTypeDecode, TupleElement4: SolTypeDecode, TupleElement5: SolTypeDecode, TupleElement6: SolTypeDecode, TupleElement7: SolTypeDecode, TupleElement8: SolTypeDecode, TupleElement9: SolTypeDecode, TupleElement10: SolTypeDecode, TupleElement11: SolTypeDecode> SolTypeDecode for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10, TupleElement11)

Source§

type AlloyType = (<TupleElement0 as SolTypeDecode>::AlloyType, <TupleElement1 as SolTypeDecode>::AlloyType, <TupleElement2 as SolTypeDecode>::AlloyType, <TupleElement3 as SolTypeDecode>::AlloyType, <TupleElement4 as SolTypeDecode>::AlloyType, <TupleElement5 as SolTypeDecode>::AlloyType, <TupleElement6 as SolTypeDecode>::AlloyType, <TupleElement7 as SolTypeDecode>::AlloyType, <TupleElement8 as SolTypeDecode>::AlloyType, <TupleElement9 as SolTypeDecode>::AlloyType, <TupleElement10 as SolTypeDecode>::AlloyType, <TupleElement11 as SolTypeDecode>::AlloyType)

Source§

fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>

Implementors§

Source§

impl SolTypeDecode for U256

Source§

type AlloyType = Uint<256>

Source§

impl SolTypeDecode for Address

Source§

type AlloyType = Address

Source§

impl<T: SolBytesType> SolTypeDecode for SolBytes<T>

Source§

type AlloyType = <T as SolBytesType>::AlloyType