Skip to content

Commit

Permalink
fix: call internal function and allow manager to grant and revoke per…
Browse files Browse the repository at this point in the history
…missions
  • Loading branch information
blockgroot committed Oct 3, 2024
1 parent 73a1415 commit 0dbfe22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contracts/StaderConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,19 @@ contract StaderConfig is IStaderConfig, AccessControlUpgradeable {
address contractAddress,
string calldata functionSig,
address accountToPermit
) external onlyRole(DEFAULT_ADMIN_ROLE) {
) external onlyRole(MANAGER) {
bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));
grantRole(role, accountToPermit);
_grantRole(role, accountToPermit);
emit PermissionGranted(accountToPermit, contractAddress, functionSig);
}

function revokeCallPermission(
address contractAddress,
string calldata functionSig,
address accountToRevoke
) external onlyRole(DEFAULT_ADMIN_ROLE) {
) external onlyRole(MANAGER) {
bytes32 role = keccak256(abi.encodePacked(contractAddress, functionSig));
revokeRole(role, accountToRevoke);
_revokeRole(role, accountToRevoke);
emit PermissionRevoked(accountToRevoke, contractAddress, functionSig);

Check warning on line 318 in contracts/StaderConfig.sol

View check run for this annotation

Codecov / codecov/patch

contracts/StaderConfig.sol#L316-L318

Added lines #L316 - L318 were not covered by tests
}

Expand Down
6 changes: 6 additions & 0 deletions test/foundry_tests/SDRewardsManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC

contract SDRewardManagerTest is Test {
address staderAdmin;
address staderManager;
address user1;
address user2;
address staderTokenDeployer;
Expand All @@ -35,6 +36,7 @@ contract SDRewardManagerTest is Test {
user2 = vm.addr(102);
staderTokenDeployer = vm.addr(103);
address ethDepositAddr = vm.addr(104);
staderManager = vm.addr(105);

vm.prank(staderTokenDeployer);
staderToken = new StaderTokenMock();
Expand Down Expand Up @@ -70,7 +72,11 @@ contract SDRewardManagerTest is Test {

vm.startPrank(staderAdmin);
staderConfig.updateStaderToken(address(staderToken));
staderConfig.grantRole(staderConfig.MANAGER(), staderManager);
staderConfig.updatePermissionlessSocializingPool(address(permissionlessSP));
vm.stopPrank();

vm.startPrank(staderManager);
staderConfig.giveCallPermission(address(rewardManager), "addRewardEntry(uint256,uint256)", user1);
staderConfig.giveCallPermission(address(rewardManager), "approveEntry(uint256)", user1);
vm.stopPrank();
Expand Down

0 comments on commit 0dbfe22

Please sign in to comment.