At @abcoathup’s request, I’m posting this publicly in case it is helpful to future generations.
I’m working hard on understanding the new upgradable paradigm after getting pretty far with the “regular” stuff.
Confusion has set in about “writing your own” upgradable contract, however.
My stand-alone “regular” version of my contract works really well, with all its extensions and added data, and I’m looking to recreate it as fully-upgradable, custom extended functions and all.
The docs seem to offer conflicting information as to what the import statement should be.
@openzeppelin/contracts-ethereum-package/README.md
:
import '@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol';
import '@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol';
versus https://docs.openzeppelin.com/cli/2.8/dependencies#writing-the-exchange-contract
import '@openzeppelin/upgrades/contracts/Initializable.sol';
import '@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol';
Unfortunately, neither work with the provided example contract code from the README.md
(included at the end of this post):
[02:06:35] [eviljordan@WAT ../xxxContract]$ npx oz deploy
✖ Compiling contracts with solc 0.6.7 (commit.b8d736ae)
Compilation errors:
contracts/xxxContract.sol:6:34: DeclarationError: Identifier not found or not unique.
contract MyNFT is Initializable, ERC721PresetMinterPauserAutoId {
^----------------------------^
contracts/xxxContract.sol:7:32: DeclarationError: Undeclared identifier. Did you mean "initialize"?
function initialize() public initializer {
^---------^
[02:07:01] [eviljordan@WAT ../xxxContract]$ npx oz deploy
✖ Compiling contracts with solc 0.6.7 (commit.b8d736ae)
Compilation errors:
contracts/xxxContract.sol:4:1: DeclarationError: Identifier already declared.
import '@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol';
^-----------------------------------------------------------------------------------------------------^
@openzeppelin/upgrades/contracts/Initializable.sol:16:1: The previous declaration is here:
contract Initializable {
^ (Relevant source part starts here and spans across multiple lines).
This is the solidity code straight from the README.md
documentation:
import '@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol';
import '@openzeppelin/contracts-ethereum-package/contracts/presets/ERC721PresetMinterPauserAutoId.sol';
contract MyNFT is Initializable, ERC721PresetMinterPauserAutoId {
function initialize() public initializer {
ERC721PresetMinterPauserAutoId.initialize("name", "SYM");
}
}