pub fn encode_constructor_args<T>(args: T) -> BytesExpand description
ABI-encode constructor arguments.
Pass a tuple of alloy Solidity values matching the constructor parameter
list, e.g. (owner, weth, vault). Single-argument constructors need a
trailing comma so the value is still a tuple: (owner,). An empty tuple
() encodes to empty bytes, which is correct for argument-less
constructors.
The encoding mirrors Solidity constructor parameter encoding
(abi.encode(arg0, arg1, ...)): it uses SolValue::abi_encode_params,
which lays the arguments out as a flat parameter list. This differs from
SolValue::abi_encode, which would wrap a tuple in an extra layer
(matching abi.encode((...))) and produce the wrong bytes for a
constructor.
The trait bounds spell out “any alloy Solidity value tuple”: T: SolValue
means each element implements the alloy Solidity-value trait, and the
TokenSeq bound on T::SolType requires the tuple’s token to be a
sequence so it can be encoded as a parameter list. In practice you do not
construct these bounds yourself — they are satisfied automatically by
tuples of alloy primitives such as Address, U256,
and String.
let args = evm_fork_cache::deploy::encode_constructor_args((owner, weth, vault));