Skip to content

Commit

Permalink
refactored configuration to be purely terms based, testing creating l…
Browse files Browse the repository at this point in the history
…icenses
  • Loading branch information
Raul committed Nov 12, 2023
1 parent e0891c0 commit bad9182
Show file tree
Hide file tree
Showing 13 changed files with 577 additions and 133 deletions.
8 changes: 6 additions & 2 deletions contracts/IPAssetRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ contract IPAssetRegistry is IIPAssetRegistry {
// TODO(ramarti): Add registration authorization via registration module.
// TODO(ramarti): Include module parameters and interfacing to registration.
function register(IPAsset.RegisterIpAssetParams calldata params_) public returns (uint256) {
uint256 ipAssetId = numIPAssets++;
uint256 ipAssetId = ++numIPAssets;
uint64 registrationDate = uint64(block.timestamp);

ipAssets[ipAssetId] = IPAsset.IPA({
name: params_.name,
ipAssetType: params_.ipAssetType,
status: 0, // TODO(ramarti): Define status types.
status: 1, // TODO(ramarti): Define status types.
owner: params_.owner,
initialRegistrant: params_.owner,
ipOrg: params_.ipOrg,
Expand Down Expand Up @@ -105,4 +105,8 @@ contract IPAssetRegistry is IIPAssetRegistry {
return ipAssets[ipAssetId_].ipOrg;
}

function getIpAsset(uint256 ipAssetId_) external view returns (IPAsset.IPA memory) {
return ipAssets[ipAssetId_];
}

}
30 changes: 30 additions & 0 deletions contracts/StoryProtocol.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,34 @@ contract StoryProtocol {
);
}

// Create a sublicense for an existing IPA (or license?)
// This can be:
// To make merch (tradeable, no IPA as result)
// To adapt/remix/extend (tradeable, IPA will be result)
// This method will set Activation terms (approvals, kyc, etc)
// How do we allow marketplaces for permissionless license?
// How can we differentiate a request for license, from a license?
// Something has to check that you have licenses for all the related characters to give you commercial rights (terms to check for a set of relationships)
// IpOrgs can set hooks on creation (token gating, etc), for commercial or non commercial
function createLicense(
address ipOrg_,
Licensing.LicenseCreationParams calldata params_,
bytes[] calldata preHooksData_,
bytes[] calldata postHooksData_
) external returns (uint256) {
return abi.decode(
MODULE_REGISTRY.execute(
IIPOrg(ipOrg_),
msg.sender,
ModuleRegistryKeys.LICENSING_MODULE,
abi.encode(params_),
preHooksData_,
postHooksData_
),
(uint256)
);
}



}
4 changes: 2 additions & 2 deletions contracts/hooks/licensing/TermsHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract TermsHook is SyncBaseHook {
// abi.decode still cannot be try/catched, so we cannot return meaningful errors.
// If config is correct, this will not revert
// See https://github.com/ethereum/solidity/issues/13869
if (ShortStringOps._equal(TermIds.SHARE_ALIKE, config.termsId)) {
if (ShortStringOps._equal(TermIds.SHARE_ALIKE, config.termId)) {
abi.decode(config.data, (TermsHooks.ShareAlike));
}
revert Errors.TermsHook_UnsupportedTermsId();
Expand All @@ -31,7 +31,7 @@ contract TermsHook is SyncBaseHook {
bytes memory hookParams_
) internal virtual override returns (bytes memory) {
Licensing.TermsConfig memory config = abi.decode(hookConfig_, (Licensing.TermsConfig));
if (ShortStringOps._equal(TermIds.SHARE_ALIKE, config.termsId)) {
if (ShortStringOps._equal(TermIds.SHARE_ALIKE, config.termId)) {
abi.decode(config.data, (TermsHooks.ShareAlike));
}
return "";
Expand Down
7 changes: 6 additions & 1 deletion contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,14 @@ library Errors {
error LicensingModule_NonExistentIPOrg();
error LicensingModule_CallerNotIpOrgOwner();
error LicensingModule_InvalidConfigType();
error LicensingModule_CommercialTermNotAllowed();
error LicensingModule_InvalidTermCommercialStatus();
error LicensingModule_IpOrgFrameworkAlreadySet();
error LicensingModule_DuplicateTermId();
error LicensingModule_InvalidIntent();
error LicensingModule_IPANotActive();
error LicensingModule_CommercialLicenseNotAllowed();
error LicensingModule_NonCommercialTermsRequired();
error LicensingModule_IpOrgNotConfigured();

////////////////////////////////////////////////////////////////////////////
// RelationshipModule //
Expand Down
34 changes: 22 additions & 12 deletions contracts/lib/modules/Licensing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ library Licensing {

struct License {
bool isCommercial;
bytes[] terms;
address[] activationHooks;
bytes[] activationHookParams;
address licensor;
address revoker;
TermsConfig[] termsConfig;
//

}

struct LicenseCreationParams {
uint256 parentLicenseId;
bool isCommercial;
uint256 ipaId;
// Intent intent;
}

enum Intent {
RootIpa, // No parent license
DerivativeIpa,// Parent license id needed, will become untradeable after completion
OffchainDerivative // Parent license id needed, need to log back
}

enum CommercialStatus {
Expand All @@ -28,21 +43,16 @@ library Licensing {
}

struct TermsConfig {
ShortString termsId;
ShortString termId;
bytes data;
}

struct FrameworkConfig {
bool isCommercialAllowed;
TermsConfig[] termsConfig;
TermsConfig[] comTermsConfig;
TermsConfig[] nonComTermsConfig;
}

// Available categories -> IPORg wide
// Excluded categories (IPORg wide? IPA wide?)
// Pure text terms
// Share alike == sublicensing on/off
//
// Attribution should point to a relationship Type

bytes32 constant LICENSING_FRAMEWORK_CONFIG = keccak256("LICENSING_FRAMEWORK_CONFIG");
}

Expand Down
25 changes: 4 additions & 21 deletions contracts/lib/modules/ProtocolRelationships.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,13 @@ import { LibRelationship } from "contracts/lib/modules/LibRelationship.sol";

library ProtocolRelationships {

string constant public IPORG_TERMS_REL_TYPE = "IPORG_TERMS";

function _getIpOrgTermsAddRelParams()
internal pure
returns (LibRelationship.AddRelationshipTypeParams memory) {
return LibRelationship.AddRelationshipTypeParams({
relType: IPORG_TERMS_REL_TYPE,
ipOrg: LibRelationship.PROTOCOL_LEVEL_RELATIONSHIP,
allowedElements: LibRelationship.RelatedElements({
src: LibRelationship.Relatables.ADDRESS,
dst: LibRelationship.Relatables.LICENSE
}),
allowedSrcs: new uint8[](0),
allowedDsts: new uint8[](0)
});
}

string constant public IPA_LICENSE_REL_TYPE = "IPA_LICENSE";
string constant public IPA_LICENSE = "IPA_LICENSE";

function _getIpLicenseAddRelPArams()
internal pure
returns (LibRelationship.AddRelationshipTypeParams memory) {
return LibRelationship.AddRelationshipTypeParams({
relType: IPA_LICENSE_REL_TYPE,
relType: IPA_LICENSE,
ipOrg: LibRelationship.PROTOCOL_LEVEL_RELATIONSHIP,
allowedElements: LibRelationship.RelatedElements({
src: LibRelationship.Relatables.IPA,
Expand All @@ -40,13 +23,13 @@ library ProtocolRelationships {
}


string constant public SUBLICENSE_REL_TYPE = "SUBLICENSE";
string constant public SUBLICENSE_OF = "SUBLICENSE_OF";

function _getSublicenseAddRelParams()
internal pure
returns (LibRelationship.AddRelationshipTypeParams memory) {
return LibRelationship.AddRelationshipTypeParams({
relType: SUBLICENSE_REL_TYPE,
relType: SUBLICENSE_OF,
ipOrg: LibRelationship.PROTOCOL_LEVEL_RELATIONSHIP,
allowedElements: LibRelationship.RelatedElements({
src: LibRelationship.Relatables.LICENSE,
Expand Down
Loading

0 comments on commit bad9182

Please sign in to comment.