I've deployed a transparent proxy upgradeable contract ERC721 token that uses AccessControlUpgradeable. In my initializer I use _configRole(MINTER_ROLE, x) to set another contract 2 ("STOREFRONT") as a valid minter. However, when I use STOREFRONT to call the minting function on my token, it reverts:
AccessControl: account 0x2c277145fa6098a9b355bfc610d7833f5453b7d8 is missing role 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6
where 0x2c277145fa6098a9b355bfc610d7833f5453b7d8 is my proxy contract for my token on the rinkeby network and 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6 is my MINTER_ROLE.
I am guessing this has something to do with the upgradeable contract malfunctioning but I don't know how to proceed on this.
here is my deploy main snippet:
const [deployer] = await ethers.getSigners();
const AftersTokenLib = await ethers.getContractFactory("AftersTokenLib");
const aftersTokenLib = await AftersTokenLib.deploy();
await aftersTokenLib.deployed();
const TokenStorage = await ethers.getContractFactory("AftersTokenStorage");
const tokenStorage = await upgrades.deployProxy(TokenStorage, []);
await tokenStorage.deployed();
console.log(`Storage address: ${tokenStorage.address}`);
const Storefront = await ethers.getContractFactory("AftersStorefront");
const storefront = await upgrades.deployProxy(Storefront, [[deployer.address], [1], deployer.address]);
await storefront.deployed();
console.log(`Storefront address: ${storefront.address}`);
const Token = await ethers.getContractFactory("AftersToken");
const token = await upgrades.deployProxy(Token, [tokenStorage.address, storefront.address]);
await token.deployed();
console.log(`Token address: ${token.address}`);
await storefront.setToken(token.address, tokenStorage.address);
And here is my topmost contract for the ERC721 token:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./IAftersTokenStorage.sol";
import "./AftersTokenBase.sol";
import "./AftersStorefront.sol";
contract AftersToken is AftersTokenBase {
/**
Give the minter flexibility to mint into any period even if it's not
a current one.
*/
function safeMint(
uint16 periodId,
uint8 tokenTypeId,
bool isPresale,
address to,
uint16 quantity,
string memory imageCIDOverride
) public onlyRole(MINTER_ROLE) whenNotPaused {
require(quantity > 0, "QUANTITY_ZERO");
require(to != address(0), "NONZERO_TO");
for (uint16 i = 0; i < quantity; i++) {
uint256 lastCount = isPresale
? _storage.incrementPresaleCount(periodId, tokenTypeId)
: _storage.incrementSaleCount(periodId, tokenTypeId);
uint256 tokenId = AftersTokenLib.nextTokenId(
periodId,
tokenTypeId,
isPresale,
lastCount
);
_safeMint(to, tokenId);
if (bytes(imageCIDOverride).length > 0) {
_storage.addTokenCIDOverride(tokenId, imageCIDOverride);
}
}
}
function initialize(IAftersTokenStorage _storage, address storefront)
public
initializer
{
__AftersTokenBase_init(_storage, storefront);
}
}