export LookupContractReturnTypeForContractName
I am trying to create a helper to simplify our tests. To that extent I would like to reexport deployment results, like so:
import hre from "hardhat";
import v1 from '../ignition/modules/migrations/m001';
import { LookupContractReturnTypeForContractName } from '????';
export interface DeployTestInfrastructureResult {
ROJIERC721Diamond: LookupContractReturnTypeForContractName<"ROJIERC721Diamond">;
}
export const deployTestInfrastructure = async (): Promise<DeployTestInfrastructureResult> => {
const { ROJIERC721Diamond } = await hre.ignition.deploy(v1,
{
parameters: {
rojiVerseAccessManager: {
"primaryOwnerAddress": "XXXXXX"
},
},
});
return {
ROJIERC721Diamond,
}
}
Unfortunately LookupContractReturnTypeForContractName and possibly other types are not exported which makes this a less than ideal experience.
I suspect we should export a new type that can be used in this situation, so you would set the return of the helper function to something like: ViemIgnitionResultFor<typeof v1> rather than having to deal with ugly intermediary types of our viem conversion.
In the meantime @mwawrusch, you might be able to get away with leveragin hardhat-viem types that are exported, so something like:
import hre from "hardhat";
import v1 from '../ignition/modules/migrations/m001';
import { ArtifactsMap } from "hardhat/types";
import { GetContractReturnType } from "@nomicfoundation/hardhat-viem/types";
export interface DeployTestInfrastructureResult {
ROJIERC721Diamond: GetContractReturnType<ArtifactsMap["ROJIERC721Diamond"]["abi"]>;
}
export const deployTestInfrastructure = async (): Promise<DeployTestInfrastructureResult> => {
const { ROJIERC721Diamond } = await hre.ignition.deploy(v1,
{
parameters: {
rojiVerseAccessManager: {
"primaryOwnerAddress": "XXXXXX"
},
},
});
return {
ROJIERC721Diamond,
}
}
The artifacts map is a type generated on Hardhat compile that includes the abi types of each compile contract, which can then be passed to Viems type to generate the contract instance types. That type to type conversion process is wrapped up in the GetContractReturnType from hardhat-viem.
Thx