How to resolve a contract future in ignition #4777
-
Using hardhat-ignition and viem. We have the following code that is invoked within a build module to create a callData to be invoked from our contract constructor (basic hardhat-deploy 2535 initialization). The args contain a contract future (CONTRACTFUTURE). How do I write this code so that ignition replaces that with the actual address on deploy? const callData = encodeFunctionData({
abi: artifact.abi as any,
functionName: methodName,
args: [CONTRACTFUTURE]
}); Full example here: export default buildModule("xx", (m) => {
const { AccessManager } = m.useModule(AccessManagerModule);
const { DiamondCutFacet,
DiamondLoupeFacet,
OwnershipFacet } = m.useModule(diamondfacets);
const facets =
[ DiamondCutFacet,
DiamondLoupeFacet,
OwnershipFacet,
InitV1Facet,
];
const initFunctions = [
{ contract: InitV1Facet, methodName: 'initV1', args: [AccessManager
] },
]
const mappedFacets= facets.map( a => {
const artifact = hre.artifacts.readArtifactSync(a.contractName);
return getFacetCutsToAddFromAbi(artifact.abi, a);
});
const mappedInitFunctions = initFunctions.map( a => {
const artifact = hre.artifacts.readArtifactSync(a.contract.contractName);
const callData = encodeFunctionData({
abi: artifact.abi as any, // abi of the facet
functionName: a.methodName,
args: a.args
});
return {initContract: a.contract, initData: callData}
});
const Diamond = m.contract("Diamond", [
contractOwner,
mappedFacets as any[],
mappedInitFunctions as any[],
]);
return {
Diamond,
};
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @mwawrusch, Ignition doesn't support executing arbitrary code on futures currently. The value of the future will only be resolved during execution, not when the module is evaluated. I suspect you need a more flexible extension point in Ignition to support diamond deploys - we are trying to build that out using our So you would be able to override how a future is dealt with by providing your own arbitrary code (i.e. the encodeDataFunction above), but crucially you would have access to the complete context of execution at that point, including the addresses of previous deployed futures. |
Beta Was this translation helpful? Give feedback.
Hey @mwawrusch, Ignition doesn't support executing arbitrary code on futures currently. The value of the future will only be resolved during execution, not when the module is evaluated.
I suspect you need a more flexible extension point in Ignition to support diamond deploys - we are trying to build that out using our
create2
strategy as a first example.So you would be able to override how a future is dealt with by providing your own arbitrary code (i.e. the encodeDataFunction above), but crucially you would have access to the complete context of execution at that point, including the addresses of previous deployed futures.