Skip to content

Commit

Permalink
introducing ipa registration module
Browse files Browse the repository at this point in the history
  • Loading branch information
Raul committed Nov 16, 2023
1 parent cd60614 commit ee00fec
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 33 deletions.
24 changes: 18 additions & 6 deletions contracts/StoryProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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_
Expand All @@ -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_,
Expand All @@ -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_,
Expand Down
20 changes: 10 additions & 10 deletions test/foundry/modules/licensing/BaseLicensingTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
);
}

Expand Down
22 changes: 11 additions & 11 deletions test/foundry/modules/licensing/LicenseCreatorModule.Terms.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 13 additions & 5 deletions test/foundry/utils/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 *;

Expand All @@ -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;
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit ee00fec

Please sign in to comment.