diff --git a/contracts/interfaces/workflows/IDerivativeWorkflows.sol b/contracts/interfaces/workflows/IDerivativeWorkflows.sol index a5b076a..56bf492 100644 --- a/contracts/interfaces/workflows/IDerivativeWorkflows.sol +++ b/contracts/interfaces/workflows/IDerivativeWorkflows.sol @@ -28,16 +28,15 @@ interface IDerivativeWorkflows { /// @param tokenId The ID of the NFT. /// @param derivData The derivative data to be used for registerDerivative. /// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP. - /// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module. - /// @param sigRegister Signature data for registerDerivative for the IP via the Licensing Module. + /// @param sigMetadataAndRegister OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module + /// and registerDerivative for the IP via the Licensing Module. /// @return ipId The ID of the newly registered IP. function registerIpAndMakeDerivative( address nftContract, uint256 tokenId, WorkflowStructs.MakeDerivative calldata derivData, WorkflowStructs.IPMetadata calldata ipMetadata, - WorkflowStructs.SignatureData calldata sigMetadata, - WorkflowStructs.SignatureData calldata sigRegister + WorkflowStructs.SignatureData calldata sigMetadataAndRegister ) external returns (address ipId); /// @notice Mint an NFT from a SPGNFT collection and register it as a derivative IP using license tokens. @@ -70,8 +69,8 @@ interface IDerivativeWorkflows { /// @param royaltyContext The context for royalty module, should be empty for Royalty Policy LAP. /// @param maxRts The maximum number of royalty tokens that can be distributed to the external royalty policies. /// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP. - /// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module. - /// @param sigRegister Signature data for registerDerivativeWithLicenseTokens for the IP via the Licensing Module. + /// @param sigMetadataAndRegister Signature data for setAll (metadata) for the IP via the Core Metadata Module + /// and registerDerivativeWithLicenseTokens for the IP via the Licensing Module. /// @return ipId The ID of the newly registered IP. function registerIpAndMakeDerivativeWithLicenseTokens( address nftContract, @@ -80,8 +79,7 @@ interface IDerivativeWorkflows { bytes calldata royaltyContext, uint32 maxRts, WorkflowStructs.IPMetadata calldata ipMetadata, - WorkflowStructs.SignatureData calldata sigMetadata, - WorkflowStructs.SignatureData calldata sigRegister + WorkflowStructs.SignatureData calldata sigMetadataAndRegister ) external returns (address ipId); //////////////////////////////////////////////////////////////////////////// diff --git a/contracts/interfaces/workflows/IRoyaltyTokenDistributionWorkflows.sol b/contracts/interfaces/workflows/IRoyaltyTokenDistributionWorkflows.sol index 7125288..306b760 100644 --- a/contracts/interfaces/workflows/IRoyaltyTokenDistributionWorkflows.sol +++ b/contracts/interfaces/workflows/IRoyaltyTokenDistributionWorkflows.sol @@ -114,5 +114,4 @@ interface IRoyaltyTokenDistributionWorkflows { WorkflowStructs.SignatureData calldata sigMetadata, WorkflowStructs.SignatureData calldata sigAttach ) external returns (address ipId, uint256[] memory licenseTermsIds, address ipRoyaltyVault); - } diff --git a/contracts/workflows/DerivativeWorkflows.sol b/contracts/workflows/DerivativeWorkflows.sol index 1717363..f93d393 100644 --- a/contracts/workflows/DerivativeWorkflows.sol +++ b/contracts/workflows/DerivativeWorkflows.sol @@ -9,6 +9,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { MulticallUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import { ICoreMetadataModule } from "@storyprotocol/core/interfaces/modules/metadata/ICoreMetadataModule.sol"; import { ILicenseToken } from "@storyprotocol/core/interfaces/ILicenseToken.sol"; import { ILicensingModule } from "@storyprotocol/core/interfaces/modules/licensing/ILicensingModule.sol"; import { IRoyaltyModule } from "@storyprotocol/core/interfaces/modules/royalty/IRoyaltyModule.sol"; @@ -151,33 +152,33 @@ contract DerivativeWorkflows is /// @param tokenId The ID of the NFT. /// @param derivData The derivative data to be used for registerDerivative. /// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP. - /// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module. - /// @param sigRegister Signature data for registerDerivative for the IP via the Licensing Module. + /// @param sigMetadataAndRegister OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata + /// Module and registerDerivative for the IP via the Licensing Module. /// @return ipId The ID of the newly registered IP. function registerIpAndMakeDerivative( address nftContract, uint256 tokenId, WorkflowStructs.MakeDerivative calldata derivData, WorkflowStructs.IPMetadata calldata ipMetadata, - WorkflowStructs.SignatureData calldata sigMetadata, - WorkflowStructs.SignatureData calldata sigRegister + WorkflowStructs.SignatureData calldata sigMetadataAndRegister ) external returns (address ipId) { ipId = IP_ASSET_REGISTRY.register(block.chainid, nftContract, tokenId); - MetadataHelper.setMetadataWithSig( - ipId, - address(CORE_METADATA_MODULE), - address(ACCESS_CONTROLLER), - ipMetadata, - sigMetadata - ); - PermissionHelper.setPermissionForModule( - ipId, - address(LICENSING_MODULE), - address(ACCESS_CONTROLLER), - ILicensingModule.registerDerivative.selector, - sigRegister - ); + address[] memory modules = new address[](2); + bytes4[] memory selectors = new bytes4[](2); + modules[0] = address(CORE_METADATA_MODULE); + modules[1] = address(LICENSING_MODULE); + selectors[0] = ICoreMetadataModule.setAll.selector; + selectors[1] = ILicensingModule.registerDerivative.selector; + PermissionHelper.setBatchPermissionForModules({ + ipId: ipId, + accessController: address(ACCESS_CONTROLLER), + modules: modules, + selectors: selectors, + sigData: sigMetadataAndRegister + }); + + MetadataHelper.setMetadata(ipId, address(CORE_METADATA_MODULE), ipMetadata); LicensingHelper.collectMintFeesAndMakeDerivative( ipId, @@ -233,8 +234,8 @@ contract DerivativeWorkflows is /// @param royaltyContext The context for royalty module, should be empty for Royalty Policy LAP. /// @param maxRts The maximum number of royalty tokens that can be distributed to the external royalty policies. /// @param ipMetadata OPTIONAL. The desired metadata for the newly registered IP. - /// @param sigMetadata OPTIONAL. Signature data for setAll (metadata) for the IP via the Core Metadata Module. - /// @param sigRegister Signature data for registerDerivativeWithLicenseTokens for the IP via the Licensing Module. + /// @param sigMetadataAndRegister Signature data for setAll (metadata) for the IP via the Core Metadata Module + /// and registerDerivativeWithLicenseTokens for the IP via the Licensing Module. /// @return ipId The ID of the newly registered IP. function registerIpAndMakeDerivativeWithLicenseTokens( address nftContract, @@ -243,27 +244,26 @@ contract DerivativeWorkflows is bytes calldata royaltyContext, uint32 maxRts, WorkflowStructs.IPMetadata calldata ipMetadata, - WorkflowStructs.SignatureData calldata sigMetadata, - WorkflowStructs.SignatureData calldata sigRegister + WorkflowStructs.SignatureData calldata sigMetadataAndRegister ) external returns (address ipId) { _collectLicenseTokens(licenseTokenIds, address(LICENSE_TOKEN)); - ipId = IP_ASSET_REGISTRY.register(block.chainid, nftContract, tokenId); - MetadataHelper.setMetadataWithSig( - ipId, - address(CORE_METADATA_MODULE), - address(ACCESS_CONTROLLER), - ipMetadata, - sigMetadata - ); - PermissionHelper.setPermissionForModule( - ipId, - address(LICENSING_MODULE), - address(ACCESS_CONTROLLER), - ILicensingModule.registerDerivativeWithLicenseTokens.selector, - sigRegister - ); + address[] memory modules = new address[](2); + bytes4[] memory selectors = new bytes4[](2); + modules[0] = address(CORE_METADATA_MODULE); + modules[1] = address(LICENSING_MODULE); + selectors[0] = ICoreMetadataModule.setAll.selector; + selectors[1] = ILicensingModule.registerDerivativeWithLicenseTokens.selector; + PermissionHelper.setBatchPermissionForModules({ + ipId: ipId, + accessController: address(ACCESS_CONTROLLER), + modules: modules, + selectors: selectors, + sigData: sigMetadataAndRegister + }); + + MetadataHelper.setMetadata(ipId, address(CORE_METADATA_MODULE), ipMetadata); LICENSING_MODULE.registerDerivativeWithLicenseTokens(ipId, licenseTokenIds, royaltyContext, maxRts); } diff --git a/test/integration/BaseIntegration.t.sol b/test/integration/BaseIntegration.t.sol index 826644a..e34895b 100644 --- a/test/integration/BaseIntegration.t.sol +++ b/test/integration/BaseIntegration.t.sol @@ -134,6 +134,37 @@ contract BaseIntegration is Test, Script, StoryProtocolCoreAddressManager, Story /*////////////////////////////////////////////////////////////////////////// HELPERS //////////////////////////////////////////////////////////////////////////*/ + /// @dev Get the permission list for setting metadata and registering a derivative for the IP. + /// @param ipId The ID of the IP that the permissions are for. + /// @param to The address of the periphery contract to receive the permission. + /// @return permissionList The list of permissions for setting metadata and registering a derivative. + function _getMetadataAndDerivativeRegistrationPermissionList( + address ipId, + address to, + bool withLicenseToken + ) internal view returns (AccessPermission.Permission[] memory permissionList) { + address[] memory modules = new address[](2); + bytes4[] memory selectors = new bytes4[](2); + permissionList = new AccessPermission.Permission[](2); + modules[0] = coreMetadataModuleAddr; + modules[1] = licensingModuleAddr; + selectors[0] = ICoreMetadataModule.setAll.selector; + if (withLicenseToken) { + selectors[1] = ILicensingModule.registerDerivativeWithLicenseTokens.selector; + } else { + selectors[1] = ILicensingModule.registerDerivative.selector; + } + for (uint256 i = 0; i < 2; i++) { + permissionList[i] = AccessPermission.Permission({ + ipAccount: ipId, + signer: to, + to: modules[i], + func: selectors[i], + permission: AccessPermission.ALLOW + }); + } + } + /// @dev Get the permission list for attaching license terms and setting licensing config for the IP. /// @param ipId The ID of the IP that the permissions are for. /// @param to The address of the periphery contract to receive the permission. diff --git a/test/integration/workflows/DerivativeIntegration.t.sol b/test/integration/workflows/DerivativeIntegration.t.sol index e61ae3b..4420ce9 100644 --- a/test/integration/workflows/DerivativeIntegration.t.sol +++ b/test/integration/workflows/DerivativeIntegration.t.sol @@ -100,26 +100,18 @@ contract DerivativeIntegration is BaseIntegration { uint256 deadline = block.timestamp + 1000; - (bytes memory sigMetadata, bytes32 sigRegisterState, ) = _getSetPermissionSigForPeriphery({ + (bytes memory signatureMetadataAndRegister, bytes32 expectedState, ) = _getSetBatchPermissionSigForPeriphery({ ipId: childIpId, - to: derivativeWorkflowsAddr, - module: coreMetadataModuleAddr, - selector: ICoreMetadataModule.setAll.selector, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: testSenderSk }); - (bytes memory sigRegister, bytes32 expectedState, ) = _getSetPermissionSigForPeriphery({ - ipId: childIpId, - to: derivativeWorkflowsAddr, - module: licensingModuleAddr, - selector: ILicensingModule.registerDerivative.selector, - deadline: deadline, - state: sigRegisterState, - signerSk: testSenderSk - }); - StoryUSD.mint(testSender, testMintFee); StoryUSD.approve(derivativeWorkflowsAddr, testMintFee); // for derivative minting fee derivativeWorkflows.registerIpAndMakeDerivative({ @@ -135,15 +127,10 @@ contract DerivativeIntegration is BaseIntegration { maxRevenueShare: 0 }), ipMetadata: testIpMetadata, - sigMetadata: WorkflowStructs.SignatureData({ - signer: testSender, - deadline: deadline, - signature: sigMetadata - }), - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, - signature: sigRegister + signature: signatureMetadataAndRegister }) }); @@ -255,38 +242,17 @@ contract DerivativeIntegration is BaseIntegration { licenseTokenIds[0] = startLicenseTokenId; licenseToken.approve(derivativeWorkflowsAddr, startLicenseTokenId); - WorkflowStructs.SignatureData memory sigMetadata; - WorkflowStructs.SignatureData memory sigRegister; - { - (bytes memory signatureMetadata, bytes32 sigRegisterState, ) = _getSetPermissionSigForPeriphery({ - ipId: childIpId, - to: derivativeWorkflowsAddr, - module: coreMetadataModuleAddr, - selector: ICoreMetadataModule.setAll.selector, - deadline: deadline, - state: bytes32(0), - signerSk: testSenderSk - }); - (bytes memory signatureRegister, bytes32 expectedState, ) = _getSetPermissionSigForPeriphery({ - ipId: childIpId, - to: derivativeWorkflowsAddr, - module: licensingModuleAddr, - selector: ILicensingModule.registerDerivativeWithLicenseTokens.selector, - deadline: deadline, - state: sigRegisterState, - signerSk: testSenderSk - }); - sigMetadata = WorkflowStructs.SignatureData({ - signer: testSender, - deadline: deadline, - signature: signatureMetadata - }); - sigRegister = WorkflowStructs.SignatureData({ - signer: testSender, - deadline: deadline, - signature: signatureRegister - }); - } + (bytes memory signatureMetadataAndRegister, bytes32 expectedState, ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + true + ), + deadline: deadline, + state: bytes32(0), + signerSk: testSenderSk + }); derivativeWorkflows.registerIpAndMakeDerivativeWithLicenseTokens({ nftContract: address(spgNftContract), @@ -295,8 +261,11 @@ contract DerivativeIntegration is BaseIntegration { royaltyContext: "", maxRts: revShare, ipMetadata: testIpMetadata, - sigMetadata: sigMetadata, - sigRegister: sigRegister + sigMetadataAndRegister: WorkflowStructs.SignatureData({ + signer: testSender, + deadline: deadline, + signature: signatureMetadataAndRegister + }) }); assertTrue(ipAssetRegistry.isRegistered(childIpId)); diff --git a/test/integration/workflows/RoyaltyIntegration.t.sol b/test/integration/workflows/RoyaltyIntegration.t.sol index e46fa97..5141511 100644 --- a/test/integration/workflows/RoyaltyIntegration.t.sol +++ b/test/integration/workflows/RoyaltyIntegration.t.sol @@ -218,11 +218,14 @@ contract RoyaltyIntegration is BaseIntegration { // register childIpA as derivative of ancestorIp under Terms A { - (bytes memory sigRegister, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(spgNftContract), childTokenIdA), - to: derivativeWorkflowsAddr, - module: licensingModuleAddr, - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(spgNftContract), childTokenIdA); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: testSenderSk @@ -248,11 +251,10 @@ contract RoyaltyIntegration is BaseIntegration { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, - signature: sigRegister + signature: signatureMetadataAndRegister }) }); vm.label(childIpIdA, "ChildIpA"); @@ -260,11 +262,14 @@ contract RoyaltyIntegration is BaseIntegration { // register childIpB as derivative of ancestorIp under Terms A { - (bytes memory sigRegister, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(spgNftContract), childTokenIdB), - to: derivativeWorkflowsAddr, - module: licensingModuleAddr, - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(spgNftContract), childTokenIdB); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: testSenderSk @@ -290,11 +295,10 @@ contract RoyaltyIntegration is BaseIntegration { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, - signature: sigRegister + signature: signatureMetadataAndRegister }) }); vm.label(childIpIdB, "ChildIpB"); @@ -302,11 +306,14 @@ contract RoyaltyIntegration is BaseIntegration { /// register childIpC as derivative of ancestorIp under Terms C { - (bytes memory sigRegister, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(spgNftContract), childTokenIdC), - to: derivativeWorkflowsAddr, - module: licensingModuleAddr, - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(spgNftContract), childTokenIdC); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: testSenderSk @@ -332,11 +339,10 @@ contract RoyaltyIntegration is BaseIntegration { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, - signature: sigRegister + signature: signatureMetadataAndRegister }) }); vm.label(childIpIdC, "ChildIpC"); @@ -344,11 +350,14 @@ contract RoyaltyIntegration is BaseIntegration { // register grandChildIp as derivative for childIp A and B under Terms A { - (bytes memory sigRegister, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(spgNftContract), grandChildTokenId), - to: derivativeWorkflowsAddr, - module: address(licensingModule), - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(spgNftContract), grandChildTokenId); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: testSenderSk @@ -377,11 +386,10 @@ contract RoyaltyIntegration is BaseIntegration { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: testSender, deadline: deadline, - signature: sigRegister + signature: signatureMetadataAndRegister }) }); vm.label(grandChildIpId, "GrandChildIp"); diff --git a/test/utils/BaseTest.t.sol b/test/utils/BaseTest.t.sol index 4608ab3..ee8bc54 100644 --- a/test/utils/BaseTest.t.sol +++ b/test/utils/BaseTest.t.sol @@ -297,7 +297,8 @@ contract BaseTest is Test, DeployHelper { /// @return permissionList The list of permissions for setting metadata and registering a derivative. function _getMetadataAndDerivativeRegistrationPermissionList( address ipId, - address to + address to, + bool withLicenseToken ) internal view returns (AccessPermission.Permission[] memory permissionList) { address[] memory modules = new address[](2); bytes4[] memory selectors = new bytes4[](2); @@ -305,7 +306,11 @@ contract BaseTest is Test, DeployHelper { modules[0] = coreMetadataModuleAddr; modules[1] = licensingModuleAddr; selectors[0] = ICoreMetadataModule.setAll.selector; - selectors[1] = ILicensingModule.registerDerivative.selector; + if (withLicenseToken) { + selectors[1] = ILicensingModule.registerDerivativeWithLicenseTokens.selector; + } else { + selectors[1] = ILicensingModule.registerDerivative.selector; + } for (uint256 i = 0; i < 2; i++) { permissionList[i] = AccessPermission.Permission({ ipAccount: ipId, diff --git a/test/workflows/DerivativeWorkflows.t.sol b/test/workflows/DerivativeWorkflows.t.sol index 960c816..0381264 100644 --- a/test/workflows/DerivativeWorkflows.t.sol +++ b/test/workflows/DerivativeWorkflows.t.sol @@ -293,38 +293,17 @@ contract DerivativeWorkflowsTest is BaseTest { licenseTokenIds[0] = startLicenseTokenId; licenseToken.approve(address(derivativeWorkflows), startLicenseTokenId); - WorkflowStructs.SignatureData memory sigMetadata; - WorkflowStructs.SignatureData memory sigRegister; - { - (bytes memory signatureMetadata, bytes32 expectedState, ) = _getSetPermissionSigForPeriphery({ - ipId: ipIdChild, - to: address(derivativeWorkflows), - module: address(coreMetadataModule), - selector: ICoreMetadataModule.setAll.selector, - deadline: deadline, - state: bytes32(0), - signerSk: sk.alice - }); - (bytes memory signatureRegister, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipIdChild, - to: address(derivativeWorkflows), - module: address(licensingModule), - selector: ILicensingModule.registerDerivativeWithLicenseTokens.selector, - deadline: deadline, - state: expectedState, - signerSk: sk.alice - }); - sigMetadata = WorkflowStructs.SignatureData({ - signer: u.alice, - deadline: deadline, - signature: signatureMetadata - }); - sigRegister = WorkflowStructs.SignatureData({ - signer: u.alice, - deadline: deadline, - signature: signatureRegister - }); - } + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: ipIdChild, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + ipIdChild, + address(derivativeWorkflows), + true + ), + deadline: deadline, + state: bytes32(0), + signerSk: sk.alice + }); address ipIdChildActual = derivativeWorkflows.registerIpAndMakeDerivativeWithLicenseTokens({ nftContract: address(nftContract), @@ -333,8 +312,11 @@ contract DerivativeWorkflowsTest is BaseTest { royaltyContext: "", maxRts: revShare, ipMetadata: ipMetadataDefault, - sigMetadata: sigMetadata, - sigRegister: sigRegister + sigMetadataAndRegister: WorkflowStructs.SignatureData({ + signer: caller, + deadline: deadline, + signature: signatureMetadataAndRegister + }) }); assertEq(ipIdChildActual, ipIdChild); assertTrue(ipAssetRegistry.isRegistered(ipIdChild)); @@ -489,24 +471,17 @@ contract DerivativeWorkflowsTest is BaseTest { uint256 deadline = block.timestamp + 1000; - (bytes memory sigMetadata, bytes32 expectedState, ) = _getSetPermissionSigForPeriphery({ + (bytes memory signatureMetadataAndRegister, bytes32 expectedState, ) = _getSetBatchPermissionSigForPeriphery({ ipId: ipIdChild, - to: address(derivativeWorkflows), - module: address(coreMetadataModule), - selector: ICoreMetadataModule.setAll.selector, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + ipIdChild, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: sk.alice }); - (bytes memory sigRegister, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipIdChild, - to: address(derivativeWorkflows), - module: address(licensingModule), - selector: ILicensingModule.registerDerivative.selector, - deadline: deadline, - state: expectedState, - signerSk: sk.alice - }); address[] memory parentIpIds = new address[](1); parentIpIds[0] = ipIdParent; @@ -527,8 +502,11 @@ contract DerivativeWorkflowsTest is BaseTest { maxRevenueShare: 0 }), ipMetadata: ipMetadataDefault, - sigMetadata: WorkflowStructs.SignatureData({ signer: u.alice, deadline: deadline, signature: sigMetadata }), - sigRegister: WorkflowStructs.SignatureData({ signer: u.alice, deadline: deadline, signature: sigRegister }) + sigMetadataAndRegister: WorkflowStructs.SignatureData({ + signer: u.alice, + deadline: deadline, + signature: signatureMetadataAndRegister + }) }); assertEq(ipIdChildActual, ipIdChild); assertTrue(ipAssetRegistry.isRegistered(ipIdChild)); diff --git a/test/workflows/RoyaltyTokenDistributionWorkflows.t.sol b/test/workflows/RoyaltyTokenDistributionWorkflows.t.sol index f75d6fc..3a36645 100644 --- a/test/workflows/RoyaltyTokenDistributionWorkflows.t.sol +++ b/test/workflows/RoyaltyTokenDistributionWorkflows.t.sol @@ -181,7 +181,8 @@ contract RoyaltyTokenDistributionWorkflowsTest is BaseTest { ipId: expectedIpId, permissionList: _getMetadataAndDerivativeRegistrationPermissionList( expectedIpId, - address(royaltyTokenDistributionWorkflows) + address(royaltyTokenDistributionWorkflows), + false ), deadline: deadline, state: bytes32(0), diff --git a/test/workflows/RoyaltyWorkflows.t.sol b/test/workflows/RoyaltyWorkflows.t.sol index 3b9c2ed..3eb1518 100644 --- a/test/workflows/RoyaltyWorkflows.t.sol +++ b/test/workflows/RoyaltyWorkflows.t.sol @@ -236,11 +236,14 @@ contract RoyaltyWorkflowsTest is BaseTest { // register childIpA as derivative of ancestorIp under Terms A { - (bytes memory sigRegisterAlice, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(mockNft), childTokenIdA), - to: address(derivativeWorkflows), - module: address(licensingModule), - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(mockNft), childTokenIdA); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: sk.alice @@ -266,11 +269,10 @@ contract RoyaltyWorkflowsTest is BaseTest { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: u.alice, deadline: deadline, - signature: sigRegisterAlice + signature: signatureMetadataAndRegister }) }); vm.stopPrank(); @@ -279,11 +281,14 @@ contract RoyaltyWorkflowsTest is BaseTest { // register childIpB as derivative of ancestorIp under Terms A { - (bytes memory sigRegisterBob, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(mockNft), childTokenIdB), - to: address(derivativeWorkflows), - module: address(licensingModule), - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(mockNft), childTokenIdB); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: sk.bob @@ -309,11 +314,10 @@ contract RoyaltyWorkflowsTest is BaseTest { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: u.bob, deadline: deadline, - signature: sigRegisterBob + signature: signatureMetadataAndRegister }) }); vm.stopPrank(); @@ -322,11 +326,14 @@ contract RoyaltyWorkflowsTest is BaseTest { /// register childIpC as derivative of ancestorIp under Terms C { - (bytes memory sigRegisterCarl, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(mockNft), childTokenIdC), - to: address(derivativeWorkflows), - module: address(licensingModule), - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(mockNft), childTokenIdC); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: sk.carl @@ -352,11 +359,10 @@ contract RoyaltyWorkflowsTest is BaseTest { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: u.carl, deadline: deadline, - signature: sigRegisterCarl + signature: signatureMetadataAndRegister }) }); vm.stopPrank(); @@ -365,11 +371,14 @@ contract RoyaltyWorkflowsTest is BaseTest { // register grandChildIp as derivative for childIp A and B under Terms A { - (bytes memory sigRegisterDan, , ) = _getSetPermissionSigForPeriphery({ - ipId: ipAssetRegistry.ipId(block.chainid, address(mockNft), grandChildTokenId), - to: address(derivativeWorkflows), - module: address(licensingModule), - selector: licensingModule.registerDerivative.selector, + address childIpId = ipAssetRegistry.ipId(block.chainid, address(mockNft), grandChildTokenId); + (bytes memory signatureMetadataAndRegister, , ) = _getSetBatchPermissionSigForPeriphery({ + ipId: childIpId, + permissionList: _getMetadataAndDerivativeRegistrationPermissionList( + childIpId, + address(derivativeWorkflows), + false + ), deadline: deadline, state: bytes32(0), signerSk: sk.dan @@ -398,11 +407,10 @@ contract RoyaltyWorkflowsTest is BaseTest { maxRevenueShare: 0 }), ipMetadata: emptyIpMetadata, - sigMetadata: emptySigData, - sigRegister: WorkflowStructs.SignatureData({ + sigMetadataAndRegister: WorkflowStructs.SignatureData({ signer: u.dan, deadline: deadline, - signature: sigRegisterDan + signature: signatureMetadataAndRegister }) }); vm.stopPrank();