Hello,
I am trying to write something like a whitelisting function with grantRole()
to a user and then allowing that user to call a function.
function whitelistManager(address manager)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
require(!isManager[manager], "msg.sender is already a manager");
grantRole(PENDING_MANAGER, manager);
}
function acceptNomination() external onlyRole(PENDING_MANAGER) {
address potentialManager = msg.sender;
require(
!isManager[potentialManager],
"potentialManager is already a manager"
);
isManager[potentialManager] = true;
revokeRole(PENDING_MANAGER, potentialManager);
grantRole(MANAGER, potentialManager);
}
But after calling acceptNomination()
, I run into
Traces:
[101699] ContractTest::testWhitelist()
├─ [0] VM::prank(admin: [0x9af2e2b7e57c1cd7c68c5c3796d8ea67e0018db7])
│ └─ ← ()
├─ [34221] myContract::whitelist(manager: [0x2f66c75a001ba71ccb135934f48d844b46454543])
│ ├─ emit RoleGranted(role: 0x5d4e9d4ddf29d33dcb4adf498c491f88fe3b910c18190899deacfebbdf5e6f80, account: manager: [0x2f66c75a001ba71ccb135934f48d844b46454543], sender: admin: [0x9af2e2b7e57c1cd7c68c5c3796d8ea67e0018db7])
│ └─ ← ()
├─ [652] myContract::isManager(manager: [0x2f66c75a001ba71ccb135934f48d844b46454543]) [staticcall]
│ └─ ← false
├─ [0] VM::prank(manager: [0x2f66c75a001ba71ccb135934f48d844b46454543])
│ └─ ← ()
├─ [52848] myContract::acceptNomination()
│ └─ ← "AccessControl: account 0x2f66c75a001ba71ccb135934f48d844b46454543 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"
└─ ← "AccessControl: account 0x2f66c75a001ba71ccb135934f48d844b46454543 is missing role 0x0000000000000000000000000000000000000000000000000000000000000000"
After removing onlyRole(PENDING_MANAGER)
, I still run into the same error. Can someone please help me out? Thank you.