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

Update contract to use diamond storage #9

Merged
merged 14 commits into from
May 24, 2022

Conversation

Vectorized
Copy link
Collaborator

@Vectorized Vectorized commented May 14, 2022

This is a breaking change.

  • Delete scripts/replace-imports.js.
  • Update scripts/transpile-merge.sh to use @gnus.ai/upgrade-safe-transpiler-diamond.
  • Update package.json to use @gnus.ai/upgrade-safe-transpiler-diamond.
  • Removed OpenZeppelin from package.json.

Due to the high likelihood of namespace collision when someone uses OpenZeppelin Upgradeable repo with this PR, the following re-namings are automatically done:

  • contracts/Initializable.sol -> contracts/ERC721A__Initializable.sol
  • contracts/InitializableStorage.sol -> contracts/ERC721A__InitializableStorage.sol
  • modifer initializer -> modifier initializerERC721A
  • modifer onlyInitializing -> modifier onlyInitializingERC721A

When inheriting from ERC721AUpgradeable and a OpenZeppelin Upgradeable contract, the initializer must have both the initializerERC721A and initializer modifiers.

pragma solidity ^0.8.4;

import 'erc721a-upgradeable/contracts/ERC721AUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

contract Something is ERC721AUpgradeable, OwnableUpgradeable {
  function initialize() initializerERC721A initializer public {
    __ERC721A_init('Something', 'SMTH');
    __Ownable_init();
  }

  function adminMint(uint256 quantity) external payable onlyOwner {
    // _safeMint's second argument now takes in a quantity, not a tokenId.
    _safeMint(msg.sender, quantity);
  }
}

Issue: chiru-labs/ERC721A#267

@cygaar cygaar changed the title Change to diamonds Update contract to use diamond storage May 21, 2022
contracts/ERC721AStorage.sol Show resolved Hide resolved
contracts/ERC721AStorage.sol Outdated Show resolved Hide resolved
contracts/ERC721AStorage.sol Outdated Show resolved Hide resolved
@Vectorized Vectorized merged commit a8369db into chiru-labs:main May 24, 2022
@xpluscal
Copy link

Can you please update the README / docs. Took me some time to find this :) (Current one fails with contract is not initializing

@mataide
Copy link

mataide commented May 30, 2022

Remove the ",":

pragma solidity ^0.8.4;

import 'erc721a-upgradeable/contracts/ERC721AUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';

contract Something is ERC721AUpgradeable, OwnableUpgradeable {
  function initialize() initializerERC721A initializer public {
    __ERC721A_init('Something', 'SMTH');
    __Ownable_init();
  }

  function adminMint(uint256 quantity) external payable onlyOwner {
    // _safeMint's second argument now takes in a quantity, not a tokenId.
    _safeMint(msg.sender, quantity);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants