pub trait ABIVariable: Sized {
const BASIC_TYPE: bool;
const STATIC_LENGTH: Option<usize>;
// Required methods
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>;
fn to_abi(&self) -> LinkedBytes;
fn to_packed_abi(&self) -> LinkedBytes;
}Required Associated Constants§
const BASIC_TYPE: bool
const STATIC_LENGTH: Option<usize>
Required Methods§
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
fn to_abi(&self) -> LinkedBytes
fn to_packed_abi(&self) -> LinkedBytes
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 ABIVariable for bool
impl ABIVariable for bool
const BASIC_TYPE: bool = true
const STATIC_LENGTH: Option<usize>
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
fn to_abi(&self) -> LinkedBytes
fn to_packed_abi(&self) -> LinkedBytes
Source§impl ABIVariable for u16
impl ABIVariable for u16
Source§fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
Decode a fixed-size unsigned integer from a 32-byte ABI word.
⚠️ Non-strict decoding (intentional, consensus-critical).
Only validates the 32-byte length and takes the low BITS/8 bytes;
high-order bytes are silently ignored even if non-zero.
This deviates from Solidity/EVM ABI semantics, which require
value < 2^N for uintN (N < 256) and revert otherwise. The same
calldata may therefore be interpreted differently:
- Solidity: reverts on non-zero high bytes.
- Conflux built-in: accepts the call with the truncated low value.
Caller obligations. Built-in functions taking sub-256-bit integers
via this trait MUST perform their own range/overflow checks
(checked_add, U256 widening, explicit bounds, etc.) and MUST NOT
assume the decoder has clamped the value. Treat the ABI-level type as
advisory only.
See tests_basic::test_*_truncates_high_bytes for pinned behavior.
const BASIC_TYPE: bool = true
const STATIC_LENGTH: Option<usize>
fn to_abi(&self) -> LinkedBytes
fn to_packed_abi(&self) -> LinkedBytes
Source§impl ABIVariable for u32
impl ABIVariable for u32
Source§fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
Decode a fixed-size unsigned integer from a 32-byte ABI word.
⚠️ Non-strict decoding (intentional, consensus-critical).
Only validates the 32-byte length and takes the low BITS/8 bytes;
high-order bytes are silently ignored even if non-zero.
This deviates from Solidity/EVM ABI semantics, which require
value < 2^N for uintN (N < 256) and revert otherwise. The same
calldata may therefore be interpreted differently:
- Solidity: reverts on non-zero high bytes.
- Conflux built-in: accepts the call with the truncated low value.
Caller obligations. Built-in functions taking sub-256-bit integers
via this trait MUST perform their own range/overflow checks
(checked_add, U256 widening, explicit bounds, etc.) and MUST NOT
assume the decoder has clamped the value. Treat the ABI-level type as
advisory only.
See tests_basic::test_*_truncates_high_bytes for pinned behavior.
const BASIC_TYPE: bool = true
const STATIC_LENGTH: Option<usize>
fn to_abi(&self) -> LinkedBytes
fn to_packed_abi(&self) -> LinkedBytes
Source§impl ABIVariable for u64
impl ABIVariable for u64
Source§fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
Decode a fixed-size unsigned integer from a 32-byte ABI word.
⚠️ Non-strict decoding (intentional, consensus-critical).
Only validates the 32-byte length and takes the low BITS/8 bytes;
high-order bytes are silently ignored even if non-zero.
This deviates from Solidity/EVM ABI semantics, which require
value < 2^N for uintN (N < 256) and revert otherwise. The same
calldata may therefore be interpreted differently:
- Solidity: reverts on non-zero high bytes.
- Conflux built-in: accepts the call with the truncated low value.
Caller obligations. Built-in functions taking sub-256-bit integers
via this trait MUST perform their own range/overflow checks
(checked_add, U256 widening, explicit bounds, etc.) and MUST NOT
assume the decoder has clamped the value. Treat the ABI-level type as
advisory only.
See tests_basic::test_*_truncates_high_bytes for pinned behavior.
const BASIC_TYPE: bool = true
const STATIC_LENGTH: Option<usize>
fn to_abi(&self) -> LinkedBytes
fn to_packed_abi(&self) -> LinkedBytes
Source§impl ABIVariable for u128
impl ABIVariable for u128
Source§fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>
Decode a fixed-size unsigned integer from a 32-byte ABI word.
⚠️ Non-strict decoding (intentional, consensus-critical).
Only validates the 32-byte length and takes the low BITS/8 bytes;
high-order bytes are silently ignored even if non-zero.
This deviates from Solidity/EVM ABI semantics, which require
value < 2^N for uintN (N < 256) and revert otherwise. The same
calldata may therefore be interpreted differently:
- Solidity: reverts on non-zero high bytes.
- Conflux built-in: accepts the call with the truncated low value.
Caller obligations. Built-in functions taking sub-256-bit integers
via this trait MUST perform their own range/overflow checks
(checked_add, U256 widening, explicit bounds, etc.) and MUST NOT
assume the decoder has clamped the value. Treat the ABI-level type as
advisory only.
See tests_basic::test_*_truncates_high_bytes for pinned behavior.