Expand description
Fuel ABI encoding primitives for O2 Exchange.
Implements the exact byte layouts from the O2 integration guide:
- u64 big-endian encoding
- Function selectors (NOT hash-based: u64(len) + utf8(name))
- Identity encoding (discriminant + 32-byte address)
- Option encoding (None = u64(0), Some = u64(1) + data)
- OrderArgs struct encoding (tightly packed enum variants)
- Session signing bytes
- Action signing bytes
Structs§
- CallArg
- A low-level contract call used in action signing.
Enums§
- Order
Type Encoding - Order type variants for encoding.
Constants§
- GAS_MAX
- Gas value: always u64::MAX. The API overrides with its own value.
Functions§
- action_
to_ call - Convert a high-level
Actionto a low-levelCallArgand JSON representation. - build_
actions_ signing_ bytes - Build the signing bytes for session actions (Section 4.7 Step 2).
- build_
session_ signing_ bytes - Build the signing bytes for set_session (Section 4.6 Step 3).
- build_
withdraw_ signing_ bytes - Build the signing bytes for a withdrawal.
- cancel_
order_ to_ call - Convert a CancelOrder action to a low-level CallArg.
- create_
order_ to_ call - Convert a high-level CreateOrder action to a low-level CallArg.
- encode_
identity - Encode a Fuel Identity enum: u64(discriminant) + 32-byte address. discriminant: 0 = Address, 1 = ContractId
- encode_
option_ call_ data - Encode Option for call_data in action signing bytes. None -> u64(0) Some -> u64(1) + u64(len(data)) + data
- encode_
option_ none - Encode Option::None: u64(0).
- encode_
option_ some - Encode Option::Some(data): u64(1) + data.
- encode_
order_ args - Encode OrderArgs struct for CreateOrder call_data. Layout: u64(price) + u64(quantity) + order_type_encoding (tightly packed)
- function_
selector - Encode a Fuel ABI function selector: u64_be(len(name)) + utf8(name). These are NOT hash-based like Solidity selectors.
- register_
referer_ to_ call - Convert a RegisterReferer action to a low-level CallArg.
- settle_
balance_ to_ call - Convert a SettleBalance action to a low-level CallArg.
tois the destination identity (discriminant, address). - u64_be
- Encode a u64 value as 8 bytes big-endian.