-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default deployment #791
Comments
I like the idea of starting a local Hardhat node already setup with an Ignition module. |
As a temporary workaround, you can do something like this: const { subtask } = require("hardhat/config")
const { TASK_NODE_SERVER_READY } = require("hardhat/builtin-tasks/task-names");
const path = require("path")
subtask(TASK_NODE_SERVER_READY, async (_, hre, runSuper) => {
const result = await runSuper();
await hre.run({
scope: "ignition",
task: "deploy"
}, {
modulePath: path.resolve(__dirname, "ignition", "modules", "Foo.js")
})
return result;
}); This will only work for the |
I tried the workaround suggested, and the issues I have is that calling this task directly does not generate a This happens because This isn't good for my use-case because I need to get the addresses of the deployed contracts, but |
Ah, interesting! @kanej is there an option to "force" ignition to write deployments to disk, even if the chain is the in-process network? |
We don't have a way of forcing Ignition to ignore that it is running against the Hardhat node. Adding an override is an option, but I suspect that @SebastienGllmt is more interested in getting the list of contracts + deployed addresses even when running against an in-memory node. Currently the task invocation doesn't return any response, that could be changed to be something more useful like the deployed addresses. The viem/ethers packages enhance the hre with an subtask(TASK_NODE_SERVER_READY, async (_: any, hre: any, runSuper: any) => {
const result = await runSuper();
const { default: myModule } = require(path.resolve(
__dirname,
"ignition",
"modules",
"Lock.ts"
));
const deployResult = await hre.ignition.deploy(myModule, {});
for (const futureId of Object.keys(deployResult)) {
console.log(futureId, await deployResult[futureId].getAddress());
}
return result;
}); Now the underlying deployed addresses information is available, we just choose to narrow the returned information to contract instances returned from the module. Some options here would be:
|
Trying to leverage the result of deploy sounds a but tricky because I care about all contracts deployed historically (not just any new contracts deployed). In another project I also had a case where I had to add some externally deployed stuff to the deployed address list as well, so I feel just reading the file feels like the most foolproof way I can easily get the file content through the deployments list task you folks added for me previously (thanks!), so some option to firce-write to disk sounds fine to me. Although I'm not at my computer to double-check, my understanding is that Hardhat itself also still writes compiler outputs to disk even if running in in-memory mode If you don't want this (maybe some other plugins keep everything in memory for hardhat network and you don't want to deviate), a task to get all the deployed addresses for a specific deployment ID also sounds reasonable |
To me the idea that an explicit deployment id overrides the logic of "is this the in-process network? then don't write to disk" makes a lot of sense. This, combined with what @SebastienGllmt mentioned:
seems like an interesting solution that doesn't affect at all simpler use cases. |
After thinking about this more, maybe this is a bit tricky for the in-memory case because
On a related note, I don't think there is a good event like |
Describe the feature
Right now, when testing locally, I always have to do
it's annoying to have to open two terminals and do an extra command just for this, and it's easy to accidentally forget to run the deploy script (esp. for new contributors to our project trying to setup their env for the first time)
Ideally, there would be a way in my hardhat config to specify a default hardhat ignition deployment (or maybe multiple deployments if there is a base deployment + mock data) to run when using the localhost network so that people don't have to type this manually
This is somewhat philosophically similar to #752
Search terms
deploy, node, default
The text was updated successfully, but these errors were encountered: