Repository navigation
|
Why not also use the factory for the tests as it gives typed deployment parameter instead of a any[] ? |
Answered by
PaulRBerg
Jul 1, 2021
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). |
0 replies
Answer selected by
PaulRBerg
|
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 |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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