pub fn encode_gat_struct(d: &GatData) -> Vec<u8> ⓘExpand description
ABI-encode a GatData struct into the staticInput bytes expected by
the on-chain GoodAfterTime handler.
Encoding layout (each word is 32 bytes, big-endian):
- Words 0-11:
GpV2OrderStructfields (sell_token,buy_token,receiver,sell_amount,buy_amount,valid_to,app_data,fee_amount,kind,partially_fillable,sell_token_balance,buy_token_balance) - Word 12:
start_time(uint32) - Word 13:
tx_deadline(uint32)
Total: 14 × 32 = 448 bytes.
use alloy_primitives::{Address, B256, U256};
use cow_composable::{GatData, GpV2OrderStruct, encode_gat_struct};
let order = GpV2OrderStruct {
sell_token: Address::ZERO,
buy_token: Address::ZERO,
receiver: Address::ZERO,
sell_amount: U256::from(1_000u64),
buy_amount: U256::from(900u64),
valid_to: 9_999_999,
app_data: B256::ZERO,
fee_amount: U256::ZERO,
kind: B256::ZERO,
partially_fillable: false,
sell_token_balance: B256::ZERO,
buy_token_balance: B256::ZERO,
};
let data = GatData { order, start_time: 1_000_000, tx_deadline: 2_000_000 };
let encoded = encode_gat_struct(&data);
assert_eq!(encoded.len(), 448);