ABIVariable

Trait ABIVariable 

Source
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§

Required 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.

Implementations on Foreign Types§

Source§

impl ABIVariable for bool

Source§

impl ABIVariable for u16

Source§

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.

Source§

const BASIC_TYPE: bool = true

Source§

const STATIC_LENGTH: Option<usize>

Source§

fn to_abi(&self) -> LinkedBytes

Source§

fn to_packed_abi(&self) -> LinkedBytes

Source§

impl ABIVariable for u32

Source§

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.

Source§

const BASIC_TYPE: bool = true

Source§

const STATIC_LENGTH: Option<usize>

Source§

fn to_abi(&self) -> LinkedBytes

Source§

fn to_packed_abi(&self) -> LinkedBytes

Source§

impl ABIVariable for u64

Source§

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.

Source§

const BASIC_TYPE: bool = true

Source§

const STATIC_LENGTH: Option<usize>

Source§

fn to_abi(&self) -> LinkedBytes

Source§

fn to_packed_abi(&self) -> LinkedBytes

Source§

impl ABIVariable for u128

Source§

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.

Source§

const BASIC_TYPE: bool = true

Source§

const STATIC_LENGTH: Option<usize>

Source§

fn to_abi(&self) -> LinkedBytes

Source§

fn to_packed_abi(&self) -> LinkedBytes

Source§

impl ABIVariable for String

Source§

impl ABIVariable for Vec<u8>

Source§

impl ABIVariable for Address

Source§

impl ABIVariable for H256

Source§

const BASIC_TYPE: bool = true

Source§

const STATIC_LENGTH: Option<usize> = <[u8; 32]>::STATIC_LENGTH

Source§

fn from_abi(data: &[u8]) -> Result<Self, ABIDecodeError>

Source§

fn to_abi(&self) -> LinkedBytes

Source§

fn to_packed_abi(&self) -> LinkedBytes

Source§

impl ABIVariable for U256

Source§

impl<T: ABIVariable + Debug, const N: usize> ABIVariable for [T; N]

Source§

impl<T: ABIVariable> ABIVariable for Vec<T>

Source§

impl<const N: usize> ABIVariable for [u8; N]
where [u8; N]: SolidityBytes,

Implementors§