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! type | Solidity ABI type | Notes |
---|---|---|
bool | bool | |
iN for N ∈ {8,16,32,64,128} | intN | e.g i8 ↔ int8 |
uN for N ∈ {8,16,32,64,128} | uintN | e.g u8 ↔ uint8 |
U256 | uint256 | |
String | string | |
Box<str> | string | |
Address / H160 | address | Address is a type alias for the H160 type used for addresses in pallet-revive |
[T; N] for const N: usize | T[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 <= 32 | bytesN | e.g. SolBytes<[u8; 32]> ↔ bytes32 |
SolBytes<Vec<u8>> | bytes | |
SolBytes<Box<[u8]>> | bytes | |
(T1, T2, T3, ... T12) | (U1, U2, U3, ... U12) | where T1 ↔ U1 , … T12 ↔ U12 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§
Required Methods§
Sourcefn detokenize(
token: <Self::AlloyType as AlloySolType>::Token<'_>,
) -> Result<Self, Error>
fn detokenize( token: <Self::AlloyType as AlloySolType>::Token<'_>, ) -> Result<Self, Error>
Detokenizes this type’s value from the given token.
Provided Methods§
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.