Skip to content

Commit

Permalink
Update Deployment Script to Deploy Native EvenSplitGroupPool (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster-will authored Oct 11, 2024
1 parent 37d1162 commit 52e9f84
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
1 change: 0 additions & 1 deletion contracts/modules/grouping/GroupingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
27 changes: 27 additions & 0 deletions script/foundry/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 1 addition & 8 deletions test/foundry/integration/flows/grouping/Grouping.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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({
Expand All @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions test/foundry/modules/grouping/EvenSplitGroupPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions test/foundry/modules/grouping/GroupingModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions test/foundry/modules/royalty/RoyaltyModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 52e9f84

Please sign in to comment.