Error occurs when migrating
truffle migrate --network development
TypeError: Cannot read property 'layout' of undefined
at unfoldStorageLayout (F:\Project\node_modules\@openzeppelin\upgrades-core\src\validate\query.ts:64:45)
at getStorageLayout (F:\Project\node_modules\@openzeppelin\upgrades-core\src\validate\query.ts:57:10)
at getDeployData (F:\Project\node_modules\@openzeppelin\truffle-upgrades\src\utils\deploy-impl.ts:51:34)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at deployProxyImpl (F:\Project\node_modules\@openzeppelin\truffle-upgrades\src\utils\deploy-impl.ts:60:22)
at deployProxy (F:\Project\node_modules\@openzeppelin\truffle-upgrades\src\deploy-proxy.ts:42:26)
at module.exports (F:\Project\migrations\3_deploy_upgradeable_contracts.js:7:5)
at Migration._deploy (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:72:1)
at Migration._load (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:54:1)
at Migration.run (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:202:1)
at Object.runMigrations (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\migrate\index.js:152:1)
at Object.runFrom (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\migrate\index.js:117:1)
at Object.run (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\migrate\index.js:94:1)
at runMigrations (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate\run.js:78:1)
at Object.module.exports [as run] (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate\run.js:44:1)
at Command.run (C:\Users\ggg\AppData\Roaming\nvm\v14.18.2\node_modules\truffle\build\webpack:\packages\core\lib\command.js:189:1)
Truffle v5.5.0 (core: 5.5.0)
Node v14.18.2
Code to reproduce
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721RoyaltyUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
contract MyToken is
Initializable,
ERC721Upgradeable,
ERC721EnumerableUpgradeable,
ERC721URIStorageUpgradeable,
ERC721RoyaltyUpgradeable,
PausableUpgradeable,
OwnableUpgradeable,
ERC721BurnableUpgradeable
{
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function initialize() public initializer {
__ERC721_init("MyToken", "MTK");
__ERC721Enumerable_init();
__ERC721URIStorage_init();
__ERC721Royalty_init();
__Pausable_init();
__Ownable_init();
__ERC721Burnable_init();
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function safeMint(
address to,
uint256 tokenId,
string memory uri
) public onlyOwner {
_safeMint(to, tokenId);
_setTokenURI(tokenId, uri);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
)
internal
override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
whenNotPaused
{
super._beforeTokenTransfer(from, to, tokenId);
}
// The following functions are overrides required by Solidity.
function _burn(uint256 tokenId)
internal
override(
ERC721Upgradeable,
ERC721URIStorageUpgradeable,
ERC721RoyaltyUpgradeable
)
{
super._burn(tokenId);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(
ERC721Upgradeable,
ERC721EnumerableUpgradeable,
ERC721RoyaltyUpgradeable
)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
Environment
Truffle v5.5.0 (core: 5.5.0)
Ganache v7.0.1
Solidity - 0.8.11 (solc-js)
Node v14.18.2
Web3.js v1.5.3