diff --git a/contracts/modules/grouping/GroupingModule.sol b/contracts/modules/grouping/GroupingModule.sol index 275c3113..ce60c559 100644 --- a/contracts/modules/grouping/GroupingModule.sol +++ b/contracts/modules/grouping/GroupingModule.sol @@ -235,7 +235,6 @@ contract GroupingModule is return pool.getAvailableReward(groupId, token, ipIds); } - /// @dev The group members are locked if the group has derivative IPs or license tokens minted. function _checkIfGroupMembersLocked(address groupIpId) internal view { if (LICENSE_REGISTRY.hasDerivativeIps(groupIpId)) { diff --git a/script/foundry/utils/DeployHelper.sol b/script/foundry/utils/DeployHelper.sol index 5a8a6e11..6bfce899 100644 --- a/script/foundry/utils/DeployHelper.sol +++ b/script/foundry/utils/DeployHelper.sol @@ -46,6 +46,7 @@ import { PILicenseTemplate, PILTerms } from "contracts/modules/licensing/PILicen import { LicenseToken } from "contracts/LicenseToken.sol"; import { GroupNFT } from "contracts/GroupNFT.sol"; import { GroupingModule } from "contracts/modules/grouping/GroupingModule.sol"; +import { EvenSplitGroupPool } from "contracts/modules/grouping/EvenSplitGroupPool.sol"; import { PILFlavors } from "contracts/lib/PILFlavors.sol"; import { IPGraphACL } from "contracts/access/IPGraphACL.sol"; @@ -110,6 +111,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag // Grouping GroupNFT internal groupNft; GroupingModule internal groupingModule; + EvenSplitGroupPool internal evenSplitGroupPool; // Token ERC20 private erc20; // keep private to avoid conflict with inheriting contracts @@ -652,6 +654,28 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag console2.log("IPGraphACL already deployed"); } _postdeploy("IPGraphACL", address(ipGraphACL)); + + _predeploy("EvenSplitGroupPool"); + impl = address(new EvenSplitGroupPool( + address(groupingModule), + address(royaltyModule), + address(ipAssetRegistry) + )); + evenSplitGroupPool = EvenSplitGroupPool( + TestProxyHelper.deployUUPSProxy( + create3Deployer, + _getSalt(type(EvenSplitGroupPool).name), + impl, + abi.encodeCall(EvenSplitGroupPool.initialize, address(protocolAccessManager)) + ) + ); + require( + _getDeployedAddress(type(EvenSplitGroupPool).name) == address(evenSplitGroupPool), + "Deploy: EvenSplitGroupPool Address Mismatch" + ); + require(_loadProxyImpl(address(evenSplitGroupPool)) == impl, "EvenSplitGroupPool Proxy Implementation Mismatch"); + impl = address(0); + _postdeploy("EvenSplitGroupPool", address(evenSplitGroupPool)); } function _predeploy(string memory contractKey) private view { @@ -714,6 +738,9 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag // set default license to non-commercial social remixing uint256 licenseId = pilTemplate.registerLicenseTerms(PILFlavors.nonCommercialSocialRemixing()); licenseRegistry.setDefaultLicenseTerms(address(pilTemplate), licenseId); + + // add evenSplitGroupPool to whitelist of group pools + groupingModule.whitelistGroupRewardPool(address(evenSplitGroupPool)); } function _configureRoles() private { diff --git a/test/foundry/integration/flows/grouping/Grouping.t.sol b/test/foundry/integration/flows/grouping/Grouping.t.sol index f02169a4..89c6fcbd 100644 --- a/test/foundry/integration/flows/grouping/Grouping.t.sol +++ b/test/foundry/integration/flows/grouping/Grouping.t.sol @@ -9,7 +9,6 @@ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // contracts // solhint-disable-next-line max-line-length import { PILFlavors } from "../../../../../contracts/lib/PILFlavors.sol"; -import { EvenSplitGroupPool } from "../../../../../contracts/modules/grouping/EvenSplitGroupPool.sol"; import { IGroupingModule } from "../../../../../contracts/interfaces/modules/grouping/IGroupingModule.sol"; import { IIpRoyaltyVault } from "../../../../../contracts/interfaces/modules/royalty/policies/IIpRoyaltyVault.sol"; import { IGroupIPAssetRegistry } from "../../../../../contracts/interfaces/registries/IGroupIPAssetRegistry.sol"; @@ -33,16 +32,12 @@ contract Flows_Integration_Grouping is BaseIntegration { uint32 internal defaultCommRevShare = 10 * 10 ** 6; // 10% uint256 internal commRemixTermsId; - address internal rewardPool; address internal groupOwner; address internal groupId; function setUp() public override { super.setUp(); - rewardPool = address( - new EvenSplitGroupPool(address(groupingModule), address(royaltyModule), address(ipAssetRegistry)) - ); commRemixTermsId = registerSelectedPILicenseTerms( "commercial_remix", PILFlavors.commercialRemix({ @@ -61,12 +56,10 @@ contract Flows_Integration_Grouping is BaseIntegration { } function test_Integration_Grouping() public { - vm.prank(admin); - groupingModule.whitelistGroupRewardPool(rewardPool); // create a group { vm.startPrank(groupOwner); - groupId = groupingModule.registerGroup(rewardPool); + groupId = groupingModule.registerGroup(address(evenSplitGroupPool)); vm.label(groupId, "Group1"); licensingModule.attachLicenseTerms(groupId, address(pilTemplate), commRemixTermsId); vm.stopPrank(); diff --git a/test/foundry/modules/grouping/EvenSplitGroupPool.t.sol b/test/foundry/modules/grouping/EvenSplitGroupPool.t.sol index 564833f5..7d584b5c 100644 --- a/test/foundry/modules/grouping/EvenSplitGroupPool.t.sol +++ b/test/foundry/modules/grouping/EvenSplitGroupPool.t.sol @@ -52,9 +52,7 @@ contract EvenSplitGroupPoolTest is BaseTest { vm.label(ipId3, "IPAccount3"); vm.label(ipId5, "IPAccount5"); - rewardPool = new EvenSplitGroupPool(address(groupingModule), address(royaltyModule), address(ipAssetRegistry)); - vm.prank(admin); - groupingModule.whitelistGroupRewardPool(address(rewardPool)); + rewardPool = evenSplitGroupPool; group1 = groupingModule.registerGroup(address(rewardPool)); group2 = groupingModule.registerGroup(address(rewardPool)); group3 = groupingModule.registerGroup(address(rewardPool)); diff --git a/test/foundry/modules/grouping/GroupingModule.t.sol b/test/foundry/modules/grouping/GroupingModule.t.sol index 4a5440a4..9a9221a7 100644 --- a/test/foundry/modules/grouping/GroupingModule.t.sol +++ b/test/foundry/modules/grouping/GroupingModule.t.sol @@ -64,9 +64,7 @@ contract GroupingModuleTest is BaseTest { vm.label(ipId3, "IPAccount3"); vm.label(ipId5, "IPAccount5"); - rewardPool = new EvenSplitGroupPool(address(groupingModule), address(royaltyModule), address(ipAssetRegistry)); - vm.prank(admin); - groupingModule.whitelistGroupRewardPool(address(rewardPool)); + rewardPool = evenSplitGroupPool; } function test_GroupingModule_registerGroup() public { diff --git a/test/foundry/modules/royalty/RoyaltyModule.t.sol b/test/foundry/modules/royalty/RoyaltyModule.t.sol index bb06c019..05485056 100644 --- a/test/foundry/modules/royalty/RoyaltyModule.t.sol +++ b/test/foundry/modules/royalty/RoyaltyModule.t.sol @@ -16,7 +16,7 @@ import { TestProxyHelper } from "../../utils/TestProxyHelper.sol"; import { MockExternalRoyaltyPolicy1 } from "../../mocks/policy/MockExternalRoyaltyPolicy1.sol"; import { MockExternalRoyaltyPolicy2 } from "../../mocks/policy/MockExternalRoyaltyPolicy2.sol"; import { MockERC721 } from "../../mocks/token/MockERC721.sol"; -import { MockEvenSplitGroupPool } from "../../mocks/grouping/MockEvenSplitGroupPool.sol"; +import { EvenSplitGroupPool } from "../../../../contracts/modules/grouping/EvenSplitGroupPool.sol"; contract TestRoyaltyModule is BaseTest { event RoyaltyPolicyWhitelistUpdated(address royaltyPolicy, bool allowed); @@ -64,7 +64,7 @@ contract TestRoyaltyModule is BaseTest { address public ipId1; address public ipOwner1 = address(0x111); uint256 public tokenId1 = 1; - MockEvenSplitGroupPool public rewardPool; + EvenSplitGroupPool public rewardPool; function setUp() public override { super.setUp(); @@ -118,9 +118,7 @@ contract TestRoyaltyModule is BaseTest { // grouping mockNft.mintId(ipOwner1, tokenId1); ipId1 = ipAssetRegistry.register(block.chainid, address(mockNft), tokenId1); - rewardPool = new MockEvenSplitGroupPool(address(royaltyModule)); - vm.prank(admin); - groupingModule.whitelistGroupRewardPool(address(rewardPool)); + rewardPool = evenSplitGroupPool; } function _setupTree() internal {