OpenZeppelin / openzeppelin-sdk

OpenZeppelin SDK repository for CLI and upgrades.js. No longer actively developed.
MIT License
431 stars 200 forks source link

Support changing a proxy to a different contract or package from the CLI #353

Open spalladino opened 6 years ago

spalladino commented 6 years ago

Given a proxy created for a package/contract, such as openzeppelin/ERC20, we should allow the user to upgrade the proxy to a different contract or even a different package. For instance, the user may want to upgrade to openzeppelin/ERC20Pausable to add a new feature to an existing proxy, or to upgrade to openzeppelin-forked/ERC20 in case they want to start following an fork of the package.

We'd need to come up with a new syntax for zos update for this operation. Also, make sure to run storage compatibility checks before performing the upgrade.

nfurfaro commented 5 years ago

@spalladino This would be really cool! Would it be possible to have this same functionality added to the TestHelper? (It's possible that this is already do-able when testing zos deployments/upgrades, so you can ignore this if already implemented.)

Related to:

https://openzeppelin.slack.com/archives/C6DT68JPJ/p1544647937063900

spalladino commented 5 years ago

Would it be possible to have this same functionality added to the TestHelper?

You should be able to call setImplementation in the result of the TestHelper, and change the contract that the name refers to. Something along the lines of the following should do the trick!

const project = await TestHelper(...);
const ContractV2 = Contracts.getFromLocal('ContractV2'); // or artifacts.require('ContractV2') if on truffle
project.setImplementation(ContractV2, 'Contract')
spalladino commented 5 years ago

That said, I understand that the actual use case you have is more related to https://github.com/zeppelinos/zos/issues/86, is that right?

nfurfaro commented 5 years ago

Thanks @spalladino. Yes, my issue is more related to #86, but your example with setimplementation is helpful.