Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oz proxy backwards compatible #4143

Merged
merged 32 commits into from
Oct 19, 2023
Merged

Oz proxy backwards compatible #4143

merged 32 commits into from
Oct 19, 2023

Conversation

bunsenstraat
Copy link
Collaborator

@bunsenstraat bunsenstraat commented Oct 16, 2023

  • allows deploying and upgrading on v4 and v5 of the erc1967 proxy
  • add tests for both versions plus tests for the debugger

how to test:

  • add a token, v5 will require version > 8.20:
  • v5 can be added using remix templates
  • v4 example:
      // SPDX-License-Identifier: MIT
      pragma solidity ^0.8.4;
      
      import "@openzeppelin/contracts-upgradeable@4.8.3/token/ERC721/ERC721Upgradeable.sol";
      import "@openzeppelin/contracts-upgradeable@4.8.3/access/OwnableUpgradeable.sol";
      import "@openzeppelin/contracts-upgradeable@4.8.3/proxy/utils/Initializable.sol";
      import "@openzeppelin/contracts-upgradeable@4.8.3/proxy/utils/UUPSUpgradeable.sol";
      
      contract MyToken is Initializable, ERC721Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
          /// @custom:oz-upgrades-unsafe-allow constructor
          constructor() {
              _disableInitializers();
          }
      
          function initialize() initializer public {
              __ERC721_init("MyToken", "MTK");
              __Ownable_init();
              __UUPSUpgradeable_init();
          }
      
          function _authorizeUpgrade(address newImplementation)
              internal
              onlyOwner
              override
          {}
      }
  • deploy this with proxy, for v5 add an address at parameter
  • upgrade this contract with:
      import "./myTokenV1.sol";

      contract MyTokenV2 is MyToken {
        function version () public view returns (string memory) {
            return "MyTokenV2!";
        }
    }
  • run a call ie 'version' on the second deployed proxy
  • it should return MyTokenV2!
  • run the debugger on this call

@bunsenstraat bunsenstraat self-assigned this Oct 16, 2023
@netlify
Copy link

netlify bot commented Oct 16, 2023

Deploy Preview for remixproject ready!

Name Link
🔨 Latest commit 91d8bab
🔍 Latest deploy log https://app.netlify.com/sites/remixproject/deploys/653120237abbad00089e40a9
😎 Deploy Preview https://deploy-preview-4143--remixproject.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bunsenstraat bunsenstraat added the bug Something isn't working label Oct 16, 2023
@bunsenstraat bunsenstraat added this to In progress in 0.37.0 - Feature Freeze 31/10 - Release 07/11 via automation Oct 18, 2023
@bunsenstraat bunsenstraat changed the title Ozbackwards Oz proxy backwards compatible Oct 18, 2023
() => {},
() => {},
() => {},
async (error, txResult, _address, returnValue) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part didn't change too right? except of the new logs in the terminal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it's wrapped in a callback from the tx that gets the version of the erc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it makes two calls depending on the version

0.37.0 - Feature Freeze 31/10 - Release 07/11 automation moved this from In progress to Reviewer approved Oct 19, 2023
@Aniket-Engg Aniket-Engg merged commit 3ee974d into master Oct 19, 2023
32 checks passed
0.37.0 - Feature Freeze 31/10 - Release 07/11 automation moved this from Reviewer approved to Done Oct 19, 2023
@Aniket-Engg Aniket-Engg deleted the ozbackwards branch October 19, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants