-
Why not also use the factory for the tests as it gives typed deployment parameter instead of a any[] ?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Because if we do that, we lose compatibility with the Waffle features like snapshots and fixtures (and I think mock contracts too). |
Beta Was this translation helpful? Give feedback.
-
What Paul said is correct, but if you still want to type your deploy args, you can pull them out of the I've made a utility type that makes this more semantically clear and also removes the last import { ContractFactory } from "ethers";
type OmitOverrides<T extends any[]> = Required<T> extends [ ...infer ContractArgs, any ] ? ContractArgs : any[];
export type DeployArgs<T extends ContractFactory> = OmitOverrides<Parameters<T['deploy']>> and you would use it like so: const artifact: Artifact = await artifacts.readArtifact('MyContract');
const deployArgs: DeployArgs<MyContract__factory> = [
'some arg',
'another arg',
]
const myContract = await deployContract(deployer, artifact, deployArgs) as MyContract |
Beta Was this translation helpful? Give feedback.
Because if we do that, we lose compatibility with the Waffle features like snapshots and fixtures (and I think mock contracts too).
https://github.com/paulrberg/solidity-template/blob/caed14d1debac5392ee371d0d74ef8b06868b57e/test/Greeter.ts#L9