Open humayunj opened 1 year ago
Can I clarify, is it in the module file that you are wanting to pass values into the module definition that have been loaded asynchronously? So:
./ignition/modules/LockModule.js
As opposed to the use of hre.ignition.deploy
in tests or scripts?
Correct, it's the module file ./ignition/modules/LockModule.js
where async value should be passed
We designed buildModule
as synchronous to minimize risks. Our intent is that you should be able to construct the module datastructure in its entirety before execution begins - so we can do static analysis for validation, visualization etc. We don't want users confusing buildModule
time and execution time, and trying to interweave control flow and arbitrary JS code based on futures that will only be executed after module construction has completed.
On reflection this doesn't preclude making buildModule
async, the constraint is just that the module is fully constructed by the end of buildModule
. So this is an option for consideration.
In the meantime, our suggestion would be to leverage buildModule
and hre.ignition.deploy(...)
from a Hardhat script, allowing the retrieval of the latest time asynchronously before running the deploy. Alternatively to pass the latest time as a module parameter, the time can then be passed on the command line, not ideal but possible.
Short version: How can I pass latest block time in constructor args like in hardhat Lock example
Description: I'm not able to find any way to pass async dynamic value to constructor of contract inside
buildModule
. We can either pass params via code or by parameters.json, parameters.json is static while the buildModule doesn't support promises ( it's orchestrated around Futures ). To pass latest block block time I need to wait for the response from RPC liketime.latest()
being used in hardhat lock example