Create a new instance from older package version

currently app.sol enable creating a contract instance according to the package name .
this will give always the latest implementation version of the specific package.

what will be the recommended approach to enable creating a contract instance from an older package versions ?

options:

  1. versioning via the package name - each package has its own version- not nice.

  2. bypass app.sol create function. get the package contract to get the specific provider for the require version.

  3. add version field to app.sol create function.

the latest option seems to be cleaner.

1 Like

Hi @oren,

Thanks for asking in the forum. I closed the issue https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1283 as we can discuss here.

I am not sure what would be the best approach.
My initial thought would be option 1, though community members with more experience than me in this area may have a better answer.

Thanks @abcoathup. option 1 seems to override the built in package versioning concept at app.sol.

1 Like

Hi @Oren,

Did you want to discuss this further or do you have the information that you need?

Hey @abcoathup,
I would like to suggest a feature request to add option 3 to openzeppelin app.sol contract.

1 Like

Hi @oren,

I was thinking more on this. Worth looking at how this is done with @openzepplin/contracts-ethereum-package where npm package version is used.

Hi @Oren,

This function might help:

Hey @oren! Agree that option 3 is the cleanest one, but before implementing it, I’d like to better understand your case. Why do you want to create outdated versions of contracts?

For now, option 2 is the best for you, since it does not require any changes in the App contract. In your contract, you’d need to do sth like the following. This could even be packaged into a lib that you import in your contract, with a using Lib for App for convenience.

function create(Application app, string memory packageName, uint64[3] memory version, string memory contractName, address admin, bytes memory data) payable public returns (AdminUpgradeabilityProxy) {
  Package pkg = app.getPackage(packageName);
  ImplementationProvider provider = ImplementationProvider(pkg.getContract(version));
  address impl = provider.getImplementation(contractName);
  AdminUpgradeabilityProxy proxy = (new AdminUpgradeabilityProxy).value(msg.value)(impl, admin, data);
  return proxy;
}
1 Like

Hey @spalladino,
There are few reasons why we would like to enable creation of contracts(in our case daos) from older versions : feature sets which was deprecated on new versions, using old safe audited contracts… and more.
sure, option 2 is doable (and actually we done that already) though why not provide a generic solution at the app.sol level .if it provide create function so lets make it useful.

2 Likes

Makes sense, thanks for the reply! I’ve reopened the issue in github to keep track of the feature request.

Also, is by any chance the repo you are working on this open source? I’d love to take a look at what you are building with the SDK!

1 Like

sure https://github.com/daostack/arc/tree/arc-factory
for now we are just using the @openzeppelin/upgrades contracts package.
not with the SDK.

1 Like