Trait SolTypeEncode

Source
pub trait SolTypeEncode: Sealed {
    type AlloyType: AlloySolType;

    // Required method
    fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>;

    // Provided method
    fn encode(&self) -> Vec<u8>  { ... }
}
Expand description

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

§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)
&str, &mut strstring
&T, &mut T, Box<T>Te.g. &i8 ↔ int8
&[T], &mut [T]T[]e.g. &[i8]int8[]

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 tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Tokenizes the given value into a Self::AlloyType token.

Provided Methods§

Source

fn encode(&self) -> Vec<u8>

Solidity ABI encode the value.

Implementations on Foreign Types§

Source§

impl SolTypeEncode for &str

Source§

type AlloyType = String

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for &mut str

Source§

type AlloyType = String

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for bool
where Self: SolTypeValue<Bool>,

Source§

type AlloyType = Bool

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for i8
where Self: SolTypeValue<Int<8>>,

Source§

type AlloyType = Int<8>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for i16
where Self: SolTypeValue<Int<16>>,

Source§

type AlloyType = Int<16>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for i32
where Self: SolTypeValue<Int<32>>,

Source§

type AlloyType = Int<32>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for i64
where Self: SolTypeValue<Int<64>>,

Source§

type AlloyType = Int<64>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for i128
where Self: SolTypeValue<Int<128>>,

Source§

type AlloyType = Int<128>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for u8
where Self: SolTypeValue<Uint<8>>,

Source§

type AlloyType = Uint<8>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for u16
where Self: SolTypeValue<Uint<16>>,

Source§

type AlloyType = Uint<16>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for u32
where Self: SolTypeValue<Uint<32>>,

Source§

type AlloyType = Uint<32>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for u64
where Self: SolTypeValue<Uint<64>>,

Source§

type AlloyType = Uint<64>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for u128
where Self: SolTypeValue<Uint<128>>,

Source§

type AlloyType = Uint<128>

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for ()

Source§

type AlloyType = ()

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for Box<str>

Source§

type AlloyType = String

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl SolTypeEncode for String
where Self: SolTypeValue<String>,

Source§

type AlloyType = String

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<'a, T: SolTypeEncode> SolTypeEncode for &'a T

Source§

type AlloyType = <T as SolTypeEncode>::AlloyType

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<'a, T: SolTypeEncode> SolTypeEncode for &'a mut T

Source§

type AlloyType = <T as SolTypeEncode>::AlloyType

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<T: SolTypeEncode + Clone> SolTypeEncode for Cow<'_, T>

Source§

type AlloyType = <T as SolTypeEncode>::AlloyType

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<T: SolTypeEncode> SolTypeEncode for &[T]

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<T: SolTypeEncode> SolTypeEncode for &mut [T]

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<T: SolTypeEncode> SolTypeEncode for Box<T>

Source§

type AlloyType = <T as SolTypeEncode>::AlloyType

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

impl<T: SolTypeEncode> SolTypeEncode for Vec<T>

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Source§

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

Source§

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

Source§

fn tokenize(&self) -> <Self::AlloyType as AlloySolType>::Token<'_>

Implementors§

Source§

impl SolTypeEncode for U256

Source§

type AlloyType = Uint<256>

Source§

impl SolTypeEncode for Address

Source§

type AlloyType = Address

Source§

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

Source§

type AlloyType = <T as SolBytesType>::AlloyType