Skip to content

Commit

Permalink
feat: add ignition-ethers to the mocha/ethers template
Browse files Browse the repository at this point in the history
To support imports at `@ignored/hardhat-vnext-ignition`, ignition was
add to the dev dependencies as well.
  • Loading branch information
kanej committed Feb 14, 2025
1 parent 6707756 commit f562052
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const name = await apollo.read.name();
const status = await apollo.read.status();

console.log(
`Deployed rocket with Ignition from a Hardhat Script 🚀
`Deployed rocket with Ignition and Viem from a Hardhat Script 🚀
address: ${address}
name: ${name}
Expand Down
16 changes: 16 additions & 0 deletions v-next/hardhat/templates/02-mocha-ethers/contracts/Rocket.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

contract Rocket {
string public name;
string public status;

constructor(string memory _name) {
name = _name;
status = "ignition";
}

function launch() public {
status = "lift-off";
}
}
2 changes: 2 additions & 0 deletions v-next/hardhat/templates/02-mocha-ethers/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import HardhatNetworkHelpers from "@ignored/hardhat-vnext-network-helpers";
import HardhatKeystore from "@ignored/hardhat-vnext-keystore";
import HardhatChaiMatchers from "@ignored/hardhat-vnext-ethers-chai-matchers";
import HardhatTypechain from "@ignored/hardhat-vnext-typechain";
import HardhatIgnitionEthers from "@ignored/hardhat-vnext-ignition-ethers";

const config: HardhatUserConfig = {
/*
Expand All @@ -25,6 +26,7 @@ const config: HardhatUserConfig = {
HardhatKeystore,
HardhatChaiMatchers,
HardhatTypechain,
HardhatIgnitionEthers,
],
solidity: {
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { buildModule } from "@ignored/hardhat-vnext-ignition/modules";

export default buildModule("Apollo", (m) => {
const apollo = m.contract("Rocket", ["Saturn V"]);

m.call(apollo, "launch", []);

return { apollo };
});
2 changes: 2 additions & 0 deletions v-next/hardhat/templates/02-mocha-ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"@ignored/hardhat-vnext": "workspace:^3.0.0-next.18",
"@ignored/hardhat-vnext-ethers-chai-matchers": "workspace:^3.0.0-next.14",
"@ignored/hardhat-vnext-ethers": "workspace:^3.0.0-next.14",
"@ignored/hardhat-vnext-ignition": "workspace:^2.0.0",
"@ignored/hardhat-vnext-ignition-ethers": "workspace:^2.0.0",
"@ignored/hardhat-vnext-keystore": "workspace:^3.0.0-next.14",
"@ignored/hardhat-vnext-mocha-test-runner": "workspace:^3.0.0-next.14",
"@ignored/hardhat-vnext-network-helpers": "workspace:^3.0.0-next.14",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import apolloModule from "../../../../example-project/ignition/modules/Apollo.js";
import { createHardhatRuntimeEnvironment } from "@ignored/hardhat-vnext/hre";
import hardhatIgnitionEthersPlugin from "@ignored/hardhat-vnext-ignition-ethers";

const hre = await createHardhatRuntimeEnvironment({
plugins: [hardhatIgnitionEthersPlugin],
});

const { ignition } = await hre.network.connect();

const { apollo } = await ignition.deploy(apolloModule);

const address = await apollo.getAddress();
const name = await apollo.name();
const status = await apollo.status();

console.log(
`Deployed rocket with Ignition and Ethers from a Hardhat Script 🚀
address: ${address}
name: ${name}
status: ${status}`,
);

0 comments on commit f562052

Please sign in to comment.