Skip to main content

encode_params

Function encode_params 

Source
pub fn encode_params(params: &ConditionalOrderParams) -> String
Expand description

ABI-encode ConditionalOrderParams into a 0x-prefixed hex string.

Encodes (address handler, bytes32 salt, bytes staticInput) using the standard ABI tuple encoding used by ComposableCow watchtowers. The staticInput field is encoded as dynamic bytes with a 32-byte length prefix, zero-padded to a 32-byte boundary.

Decode with decode_params. Mirrors encodeParams from the TypeScript SDK’s composable utils.

§Example

use alloy_primitives::Address;
use cow_composable::{ConditionalOrderParams, encode_params};

let params = ConditionalOrderParams {
    handler: Address::ZERO,
    salt: alloy_primitives::B256::ZERO,
    static_input: vec![0xab, 0xcd],
};
let hex = encode_params(&params);
assert!(hex.starts_with("0x"));
assert_eq!(hex.len(), 2 + 2 * (5 * 32)); // head (3 × 32) + len (32) + padded data (32)