Skip to content

Commit

Permalink
Support unwhitelisting a group reward pool (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will authored Oct 17, 2024
1 parent a50c930 commit 1efaf9e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion contracts/interfaces/modules/grouping/IGroupingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ interface IGroupingModule is IModule {

/// @notice Whitelists a group reward pool.
/// @param rewardPool The address of the group reward pool.
function whitelistGroupRewardPool(address rewardPool) external;
/// @param allowed Whether the group reward pool is whitelisted.
function whitelistGroupRewardPool(address rewardPool, bool allowed) external;

/// @notice Adds IP to group.
/// the function must be called by the Group IP owner or an authorized operator.
Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/registries/IGroupIPAssetRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ interface IGroupIPAssetRegistry {

/// @notice Whitelists a group reward pool
/// @param rewardPool The address of the group reward pool
function whitelistGroupRewardPool(address rewardPool) external;
/// @param allowed Whether the group reward pool is whitelisted
function whitelistGroupRewardPool(address rewardPool, bool allowed) external;

/// @notice Adds a member to a Group IPA
/// @param groupId The address of the Group IPA.
Expand Down
5 changes: 3 additions & 2 deletions contracts/modules/grouping/GroupingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ contract GroupingModule is

/// @notice Whitelists a group reward pool.
/// @param rewardPool The address of the group reward pool.
function whitelistGroupRewardPool(address rewardPool) external restricted {
/// @param allowed Whether the group reward pool is whitelisted.
function whitelistGroupRewardPool(address rewardPool, bool allowed) external restricted {
if (rewardPool == address(0)) {
revert Errors.GroupingModule__ZeroGroupRewardPool();
}

GROUP_IP_ASSET_REGISTRY.whitelistGroupRewardPool(rewardPool);
GROUP_IP_ASSET_REGISTRY.whitelistGroupRewardPool(rewardPool, allowed);
}

/// @notice Adds IP to group.
Expand Down
5 changes: 3 additions & 2 deletions contracts/registries/GroupIPAssetRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ abstract contract GroupIPAssetRegistry is IGroupIPAssetRegistry, ProtocolPausabl

/// @notice Whitelists a group reward pool
/// @param rewardPool The address of the group reward pool
function whitelistGroupRewardPool(address rewardPool) external onlyGroupingModule whenNotPaused {
/// @param allowed Whether the group reward pool is whitelisted
function whitelistGroupRewardPool(address rewardPool, bool allowed) external onlyGroupingModule whenNotPaused {
if (rewardPool == address(0)) {
revert Errors.GroupIPAssetRegistry__InvalidGroupRewardPool(rewardPool);
}
_getGroupIPAssetRegistryStorage().whitelistedGroupRewardPools[rewardPool] = true;
_getGroupIPAssetRegistryStorage().whitelistedGroupRewardPools[rewardPool] = allowed;
}

/// @notice Adds a member to a Group IPA
Expand Down
2 changes: 1 addition & 1 deletion script/foundry/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
licenseRegistry.setDefaultLicenseTerms(address(pilTemplate), licenseId);

// add evenSplitGroupPool to whitelist of group pools
groupingModule.whitelistGroupRewardPool(address(evenSplitGroupPool));
groupingModule.whitelistGroupRewardPool(address(evenSplitGroupPool), true);
}

function _configureRoles() private {
Expand Down
6 changes: 5 additions & 1 deletion test/foundry/modules/grouping/GroupingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ contract GroupingModuleTest is BaseTest {

function test_GroupingModule_whitelistRewardPool() public {
vm.prank(admin);
groupingModule.whitelistGroupRewardPool(address(rewardPool));
groupingModule.whitelistGroupRewardPool(address(rewardPool), true);
assertEq(ipAssetRegistry.isWhitelistedGroupRewardPool(address(rewardPool)), true);

assertEq(ipAssetRegistry.isWhitelistedGroupRewardPool(address(0x123)), false);

vm.prank(admin);
groupingModule.whitelistGroupRewardPool(address(rewardPool), false);
assertEq(ipAssetRegistry.isWhitelistedGroupRewardPool(address(rewardPool)), false);
}

function test_GroupingModule_addIp() public {
Expand Down

0 comments on commit 1efaf9e

Please sign in to comment.