hardhat-ignition
hardhat-ignition copied to clipboard
Viem type inference does not work in ignition modules
Version of Hardhat
2.22.4
Docs reference
https://github.com/NomicFoundation/hardhat/blame/dfd91d254362a3f5a0a2c940398e8af7d677f876/docs/src/content/ignition/docs/guides/viem.md#L102
What happened?
Try to setup hardhat project with viem, typescript, ignition. When i compile the smart contract viem helpers work great, type inference for deploy and contract call, but for ignition it does not work. I just can put anything as arguments of deploy, and same with calls. But in document i can see that everything should work
Node: v20.13.1 NPM: v10.5.2
package.json
{
"name": "hardhat-project",
"devDependencies": {
"@nomicfoundation/hardhat-ignition-viem": "^0.15.4",
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
"hardhat": "^2.22.4"
}
}
hardhat.config.ts
import type { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox-viem";
import "@nomicfoundation/hardhat-ignition-viem"
const config: HardhatUserConfig = {
solidity: "0.8.24",
};
export default config;
ignition/module/Lock.ts
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
import { parseEther } from "viem";
const JAN_1ST_2030 = 1893456000;
const ONE_GWEI: bigint = parseEther("0.001");
const LockModule = buildModule("LockModule", (m) => {
const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);
const lock = m.contract("anything", [unlockTime], { // no errors and completion
value: lockedAmount,
});
return { lock };
});
export default LockModule;
Minimal reproduction steps
- Initialize project with
npx hardhat init
- Choose: "Create a TypeScript project (with Viem)"
- After run
npx hardhat compile
- Go to
ignition/modules/Lock.ts
file - No type inference for
m.contract()
- Try to install
@nomicfoundation/hardhat-ignition-viem
- Import
@nomicfoundation/hardhat-ignition-viem
inhardhat.config.ts
- Recomile contracts
- Go to
ignition/modules/Lock.ts
file - No type inference for
m.contract()
Search terms
viem type inference, ignition type inference