Skip to content

Allow to deploy proxy contract more than once #38

Open
@pdyraga

Description

@pdyraga

Sometimes I want to deploy a contract behind a proxy in a unit test, outside of deployment scripts. One example of such a contract is L2TBTC. A common parent contract for all L2s and sidechains. Each chain-specific implementation will inherit from that contract and specify the token name and symbol. To not repeat the same tests over and over again, I want to test the parent L2TBTC contract. Since this contract is upgradeable and all L2 tokens are expected to be deployed behind a proxy, I want to test this contract as deployed behind a proxy. At the same time, I do not want to add it to the deployment scripts because it is deployed by a separate project, specific to the given chain.

When I call await helpers.upgrades.deployProxy for the second time (call yarn test twice), the second run fails with * was already deployed error here because the artifact for the contract is stored in deployments/hardhat.

I think this behavior is different from hre.deployments.deploy. From the docs:

This is why the hre.deployments.deploy function will by default only deploy if the contract code has changed, making it easier to write idempotent script.`

If detecting code changes is hard, I would suggest to add a flag allowing to force deployment, even if the contract was already deployed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions