diff --git a/contracts/StoryProtocol.sol b/contracts/StoryProtocol.sol index a491e7a..327010c 100644 --- a/contracts/StoryProtocol.sol +++ b/contracts/StoryProtocol.sol @@ -83,10 +83,6 @@ contract StoryProtocol { bytes[] calldata preHooksData_, bytes[] calldata postHooksData_ ) public returns (uint256, uint256) { - bytes memory encodedParams = abi.encode( - Registration.REGISTER_IP_ASSET, - abi.encode(params_) - ); bytes memory result = MODULE_REGISTRY.execute( IIPOrg(ipOrg_), msg.sender, @@ -176,6 +172,9 @@ contract StoryProtocol { // Licensing // //////////////////////////////////////////////////////////////////////////// + /// Allows an IPOrg to configure its licensing framework (collection of commercial and non-commercial terms) + /// @param ipOrg_ the ipOrg address + /// @param framework_ licensing term id array, and matching term data array to configure them function configureIpOrgLicensing( address ipOrg_, Licensing.FrameworkConfig calldata framework_ @@ -188,6 +187,13 @@ contract StoryProtocol { ); } + /// Creates a tradeable License NFT in License Registry. + /// @param ipOrg_ the ipOrg address + /// @param params_ LicenseCreation params + /// @param licensee_ address of the licensee (and owner of the NFT) + /// @param preHooksData_ Hooks data to embed with the registration pre-call. + /// @param postHooksData_ Hooks data to embed with the registration post-call. + /// @return id of the created license function createLicenseNft( address ipOrg_, Licensing.LicenseCreation calldata params_, @@ -213,8 +219,14 @@ contract StoryProtocol { ); } - // This method is used to test the licensing module before merging with IPA registration - function testCreateIpaBoundLicense( + /// Creates a License bound to a certain IPA. It's not an NFT, the licensee will be the owner of the IPA. + /// @param ipOrg_ the ipOrg address + /// @param params_ LicenseCreation params + /// @param ipaId_ id of the bound IPA + /// @param preHooksData_ Hooks data to embed with the registration pre-call. + /// @param postHooksData_ Hooks data to embed with the registration post-call. + /// @return id of the created license + function createIpaBoundLicense( address ipOrg_, Licensing.LicenseCreation calldata params_, uint256 ipaId_, diff --git a/test/foundry/modules/licensing/BaseLicensingTest.sol b/test/foundry/modules/licensing/BaseLicensingTest.sol index 2a58fbf..646b39d 100644 --- a/test/foundry/modules/licensing/BaseLicensingTest.sol +++ b/test/foundry/modules/licensing/BaseLicensingTest.sol @@ -103,7 +103,7 @@ contract BaseLicensingTest is BaseTest { modifier withRootLicense(bool commercial) { vm.prank(ipOrg.owner()); - uint256 lId = spg.testCreateIpaBoundLicense( + uint256 lId = spg.createIpaBoundLicense( address(ipOrg), Licensing.LicenseCreation({ parentLicenseId: 0, @@ -129,16 +129,16 @@ contract BaseLicensingTest is BaseTest { nonCommTermData = [bytes(""), bytes("")]; commTermIds = [commTextTermId]; commTermData = [bytes("")]; - rootIpaId = registry.register( - IPAsset.RegisterIpAssetParams({ - name: "test", - ipAssetType: 2, + (uint256 rootIpaId, uint256 ignored) = spg.registerIPAsset( + address(ipOrg), + Registration.RegisterIPAssetParams({ owner: ipaOwner, - ipOrg: (address(ipOrg)), - hash: keccak256("test"), - url: "https://example.com", - data: "" - }) + name: "bob", + ipAssetType: 2, + hash: keccak256("test") + }), + new bytes[](0), + new bytes[](0) ); } diff --git a/test/foundry/modules/licensing/LicenseCreatorModule.Terms.sol b/test/foundry/modules/licensing/LicenseCreatorModule.Terms.sol index cb19b85..7df8ff8 100644 --- a/test/foundry/modules/licensing/LicenseCreatorModule.Terms.sol +++ b/test/foundry/modules/licensing/LicenseCreatorModule.Terms.sol @@ -29,19 +29,19 @@ contract LicensingCreatorModuleTermsTest is BaseLicensingTest { withRootLicense(false) { // TODO: This should be just creating an derivative IPA - uint256 ipaId2 = registry.register( - IPAsset.RegisterIpAssetParams({ - name: "derivative", + (uint256 ipaId2, uint256 ignored) = spg.registerIPAsset( + address(ipOrg), + Registration.RegisterIPAssetParams({ + owner: ipaOwner, + name: "bob", ipAssetType: 2, - owner: ipaOwner2, - ipOrg: (address(ipOrg)), - hash: keccak256("test2"), - url: "https://example2.com", - data: "" - }) + hash: keccak256("test") + }), + new bytes[](0), + new bytes[](0) ); vm.prank(ipaOwner2); - uint256 lId = spg.testCreateIpaBoundLicense( + uint256 lId = spg.createIpaBoundLicense( address(ipOrg), Licensing.LicenseCreation({ parentLicenseId: nonCommRootLicenseId, @@ -67,7 +67,7 @@ contract LicensingCreatorModuleTermsTest is BaseLicensingTest { // expect revert if share alike is off vm.startPrank(ipaOwner2); vm.expectRevert(Errors.LicensingModule_ShareAlikeDisabled.selector); - spg.testCreateIpaBoundLicense( + spg.createIpaBoundLicense( address(ipOrg), Licensing.LicenseCreation({ parentLicenseId: nonCommRootLicenseId, diff --git a/test/foundry/modules/licensing/LicensingCreatorModule.Licensing.sol b/test/foundry/modules/licensing/LicensingCreatorModule.Licensing.sol index dc63249..8ca4cd3 100644 --- a/test/foundry/modules/licensing/LicensingCreatorModule.Licensing.sol +++ b/test/foundry/modules/licensing/LicensingCreatorModule.Licensing.sol @@ -40,7 +40,7 @@ contract LicensingCreatorLicensingTest is BaseLicensingTest { { // TODO: this should be create root IPA vm.prank(ipOrg.owner()); - uint256 lId = spg.testCreateIpaBoundLicense( + uint256 lId = spg.createIpaBoundLicense( address(ipOrg), Licensing.LicenseCreation({ parentLicenseId: 0, diff --git a/test/foundry/utils/BaseTest.sol b/test/foundry/utils/BaseTest.sol index 54f6cdd..2a01c8b 100644 --- a/test/foundry/utils/BaseTest.sol +++ b/test/foundry/utils/BaseTest.sol @@ -21,12 +21,8 @@ import { ShortString, ShortStrings } from "@openzeppelin/contracts/utils/ShortSt import { ShortStringOps } from "contracts/utils/ShortStringOps.sol"; import { AccessControl } from "contracts/lib/AccessControl.sol"; import { ModuleRegistryKeys } from "contracts/lib/modules/ModuleRegistryKeys.sol"; -// On active refactor +import { RegistrationModule } from "contracts/modules/registration/RegistrationModule.sol"; -// import { Licensing } from "contracts/lib/modules/Licensing.sol"; - -// TODO: Commented out contracts in active refactor. -// Run tests from make lint, which will not run collect and license contract BaseTest is BaseTestUtils, ProxyHelper, AccessControlHelper { using ShortStrings for *; @@ -39,6 +35,7 @@ contract BaseTest is BaseTestUtils, ProxyHelper, AccessControlHelper { StoryProtocol public spg; LicenseCreatorModule public licensingModule; LicenseRegistry public licenseRegistry; + RegistrationModule public registrationModule; address public defaultCollectNftImpl; address public collectModuleImpl; @@ -88,6 +85,17 @@ contract BaseTest is BaseTestUtils, ProxyHelper, AccessControlHelper { ); moduleRegistry.registerProtocolModule(ModuleRegistryKeys.LICENSING_MODULE, licensingModule); + // Create Registration Module + registrationModule = new RegistrationModule( + BaseModule.ModuleConstruction({ + ipaRegistry: registry, + moduleRegistry: moduleRegistry, + licenseRegistry: licenseRegistry + }), + address(accessControl) + ); + moduleRegistry.registerProtocolModule(ModuleRegistryKeys.REGISTRATION_MODULE, registrationModule); + // Create Relationship Module relationshipModule = new RelationshipModule( BaseModule.ModuleConstruction({