hardhat-ignition
hardhat-ignition copied to clipboard
Add function to encode function call args
m.encodeFunctionCall<
ContractNameT extends string,
FunctionNameT extends string
>(
contract: CallableContractFuture<ContractNameT>,
functionName: FunctionNameT,
args: ArgumentType[]
): EncodeFunctionCallFuture
interface EncodeFunctionCallFuture<
ContractNameT extends string,
FunctionNameT extends string
> {
type: FutureType.ENCODE_FUNCTION_CALL;
id: string;
module: IgnitionModule;
dependencies: Set<Future>;
contract: ContractFuture<ContractNameT>;
functionName: FunctionNameT;
args: ArgumentType[];
}
args
should accept the same types as m.call
EncodeFunctionCallFuture
should be able to be passed as an arg to:
-
contract constructors
-
m.call
args -
m.staticCall
args -
m.send
data
Validations and reconciliations should be same as for m.call
, minus things they don’t have in common like value
and from
Usage:
example using proxy initialization function
const proxyAdminOwner = m.getAccount(0);
const contract = m.contract("Contract");
const data = m.encodeFunctionCall(contract, "initialize", [proxyAdminOwner])
const proxy = m.contract("TransparentUpgradeableProxy", [..., data]);
// etc.