OpenZeppelin / openzeppelin-upgrades

Plugins for Hardhat and Foundry to deploy and manage upgradeable contracts on Ethereum.
MIT License
618 stars 262 forks source link

deployProxy function does not return correct contract type #1082

Open ryanc-bs opened 1 week ago

ryanc-bs commented 1 week ago

I've encountered an issue using the deployProxy method with TypeScript.

When deployed without a proxy using ethers.deployContract, TypeScript is able to infer the correct type for the contract being deployed. For example, if I have a contract named MyContract with method foo then calling ethers.deployContract returns a MyContract instance with the required foo method.

This breaks when using deployProxy - instead of returning the correct contract type according to the factory type, it returns a generic Contract object which needs to be explicitly cast into the correct contract type from typechain-types.

Would it be possible to update deployProxy so that the correct type can be automatically inferred from the factory to avoid this ugly casting?

ericglau commented 1 week ago

Related to https://github.com/OpenZeppelin/openzeppelin-upgrades/pull/535. As that PR hasn't had recent activity, this may be open to contribution if anyone is interested in picking it up.