Is it possible to use App.sol from upgrades in OpenZeppelin 3.0?

Hello, our team relies heavily on creating contracts on the fly from a “registry contract”. We have decided to move from truffle suite to open zeppelin SDK (and CLI), however it seems that the App.sol (solc version 0.5.0) used to create contracts on the fly is not supported in OZ3.0 (using solc version 0.6.0), is it possible to bridge these functionalities or it is not the best practice ? Do OZ 3.0 has new practices for creating contracts on the fly?

:computer: Environment

:memo:Details

:1234: Code to reproduce

For example, the following does not compile, due to upgrades require 0.5.0 but contracts-ethereum-package requires 0.6.0, since we have decided to move to 0.6.0, it is better that we do not fall back to 0.5.0 and an older open zeppelin contracts version

    pragma solidity >=0.4.21 <=0.6.2;
    pragma experimental ABIEncoderV2;

    import "@openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol";
    import "./Token.sol";
    import "@openzeppelin/upgrades/contracts/application/App.sol";
    import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";

    contract TokenFactory is AccessControlUpgradeSafe {
      App private app;
      struct TokenRecord {
        address addr;
        string name;
        string symbol;
        uint8 decimals;
      }

      mapping(string => address) nameMap;
      mapping(string => address) symbolMap;
      bytes32 public constant WHITELIST_ADMIN_ROLE = keccak256("WHITELIST_ADMIN_ROLE");

      TokenRecord[] records;

      event InstanceCreated(address);

      function initialize(App _app) public initializer {
        app = _app;
      }
    ....
2 Likes

Hi @piske-alex,

Welcome to the community :wave:

You would only use App.sol if you were creating Ethereum Packages but the plan is to remove this contract. (See OpenZeppelin/openzeppelin-sdk#1488)

If you are creating upgradeable contracts via Truffle I would recommend looking at OpenZeppelin Truffle Upgrades.

If you are creating upgradeable contracts from a factory in Solidity then you can use ProxyFactory. Though this is Solidity 0.5. There is an initial migration in the solc-0.6 branch. It hasn’t been tested though.

Proxy contracts are in the process of being moved from OpenZeppelin SDK to OpenZeppelin Contracts, though I don’t have a timescale of when this will be completed: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2335

Hi @piske-alex, I would highly encourage taking a look at our Upgrades plugin for Truffle and see if that fits into your current setup. We would love to help you along the way in using it, and hearing your feedback on it.

We’re migrating the proxies over to the OpenZeppelin Contracts project with Solidity 0.6 support (see https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2335), and we plan to put out a release candidate including those contracts next week.

For creating proxies on chain, at the moment we don’t really have a contract we can recommend, because we’ve dropped support for App.sol. It should be relatively simple to build your own proxy factory contract using the proxies we are adding to Contracts. We want to provide a proxy factory out of the box but I don’t know if it will make it into this upcoming release.

1 Like

Hi @piske-alex,

Just checking if you had any further questions?