implement REWARDS_SUPPLIER_ROLE

This commit is contained in:
Filip Pajic
2025-08-28 13:56:23 +02:00
parent b9381af1b2
commit ab431d05db
2 changed files with 5 additions and 12 deletions

View File

@@ -78,8 +78,10 @@ contract StakeManager is
bool public emergencyModeEnabled;
address public guardian;
/// @notice Operator role keccak256("GUARDIAN_ROLE")
/// @notice Guardian role keccak256("GUARDIAN_ROLE")
bytes32 public constant GUARDIAN_ROLE = 0x55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041;
/// @notice Rewards supplier role keccak256("REWARDS_SUPPLIER_ROLE")
bytes32 public constant REWARDS_SUPPLIER_ROLE = 0x1e153db16d10d4d642e290a54b15e41102f4abaeaa9448b47be3321a9c05a16c;
modifier onlyAdminOrGuardian() {
if (!hasRole(GUARDIAN_ROLE, msg.sender) && !hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
@@ -103,7 +105,7 @@ contract StakeManager is
}
modifier onlyRewardsSupplier() {
if (msg.sender != rewardsSupplier) {
if (!hasRole(REWARDS_SUPPLIER_ROLE, msg.sender)) {
revert StakeManager__Unauthorized();
}
_;
@@ -139,15 +141,6 @@ contract StakeManager is
lastMPUpdatedTime = block.timestamp;
}
/**
* @notice Allows the owner to set the rewards supplier.
* @dev The supplier is going to be the `Karma` token.
* @param _rewardsSupplier The address of the rewards supplier.
*/
function setRewardsSupplier(address _rewardsSupplier) external onlyRole(DEFAULT_ADMIN_ROLE) onlyNotEmergencyMode {
rewardsSupplier = _rewardsSupplier;
}
/**
* @notice Registers a vault with its owner. Called by the vault itself during initialization.
* @dev Only callable by contracts with trusted codehash

View File

@@ -51,7 +51,7 @@ contract StakeManagerTest is StakeMath, Test {
// set up reward distribution
vm.startPrank(admin);
karma.addRewardDistributor(address(streamer));
streamer.setRewardsSupplier(address(karma));
streamer.grantRole(streamer.REWARDS_SUPPLIER_ROLE(), address(karma));
streamer.grantRole(streamer.GUARDIAN_ROLE(), address(guardian));
vm.stopPrank();