Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into add-royalty-setting-flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Spablob authored Feb 4, 2024
2 parents b525022 + c5cc5a1 commit a9a7da9
Show file tree
Hide file tree
Showing 28 changed files with 917 additions and 476 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Run Forge tests
run: |
forge test -vvv --fork-url https://eth-sepolia.api.onfinality.io/public --fork-block-number 5196000
forge test -vvv --fork-url https://gateway.tenderly.co/public/sepolia --fork-block-number 5196000
id: forge-test

- name: Run solhint
Expand Down
25 changes: 0 additions & 25 deletions contracts/interfaces/licensing/ILinkParamVerifier.sol

This file was deleted.

18 changes: 0 additions & 18 deletions contracts/interfaces/licensing/IMintParamVerifier.sol

This file was deleted.

41 changes: 36 additions & 5 deletions contracts/interfaces/licensing/IPolicyFrameworkManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
pragma solidity ^0.8.23;

import { Licensing } from "contracts/lib/Licensing.sol";
import { IPolicyVerifier } from "contracts/interfaces/licensing/IPolicyVerifier.sol";
import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol";

/// @title IPolicyFrameworkManager
/// @notice Interface to define a policy framework contract, that will
/// register itself into the LicenseRegistry to format policy into the LicenseRegistry
interface IPolicyFrameworkManager is IPolicyVerifier {
// TODO: move here the interfaces for verification and sunset IPolicyVerifier
interface IPolicyFrameworkManager is IERC165 {
struct VerifyLinkResponse {
bool isLinkingAllowed;
bool isRoyaltyRequired;
address royaltyPolicy;
uint32 royaltyDerivativeRevShare;
}

/// @notice Name to be show in LNFT metadata
function name() external view returns (string memory);
Expand All @@ -23,7 +28,33 @@ interface IPolicyFrameworkManager is IPolicyVerifier {
function policyToJson(bytes memory policyData) external view returns (string memory);

function processInheritedPolicies(
bytes memory ipRights,
bytes memory aggregator,
uint256 policyId,
bytes memory policy
) external view returns (bool changedRights, bytes memory newRights);
) external view returns (bool changedAgg, bytes memory newAggregator);

function verifyMint(
address caller,
bool policyWasInherited,
address licensor,
address receiver,
uint256 mintAmount,
bytes memory policyData
) external returns (bool);

function verifyLink(
uint256 licenseId,
address caller,
address ipId,
address parentIpId,
bytes calldata policyData
) external returns (VerifyLinkResponse memory);

function verifyTransfer(
uint256 licenseId,
address from,
address to,
uint256 amount,
bytes memory policyData
) external returns (bool);
}
11 changes: 0 additions & 11 deletions contracts/interfaces/licensing/IPolicyVerifier.sol

This file was deleted.

18 changes: 0 additions & 18 deletions contracts/interfaces/licensing/ITransferParamVerifier.sol

This file was deleted.

23 changes: 19 additions & 4 deletions contracts/interfaces/licensing/IUMLPolicyFrameworkManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,27 @@ struct UMLPolicy {
uint32 derivativesRevShare;
string[] territories;
string[] distributionChannels;
string[] contentRestrictions;
address royaltyPolicy;
}

struct UMLRights {
/// @notice Struct that accumulates values of inherited policies
/// so we can verify compatibility when inheriting new policies
/// @param commercial Whether or not there is a policy that allows commercial use
/// @param derivatives Whether or not there is a policy that allows derivatives
/// @param derivativesReciprocal Whether or not there is a policy that requires derivatives to be licensed under the same terms
/// @param lastPolicyId The last policy ID that was added to the IP
/// @param territoriesAcc The last hash of the territories array
/// @param distributionChannelsAcc The last hash of the distributionChannels array
/// @param contentRestrictionsAcc The last hash of the contentRestrictions array
struct UMLAggregator {
bool commercial;
bool derivable;
bool reciprocalSet;
bool derivatives;
bool derivativesReciprocal;
uint256 lastPolicyId;
bytes32 territoriesAcc;
bytes32 distributionChannelsAcc;
bytes32 contentRestrictionsAcc;
}


Expand All @@ -58,5 +72,6 @@ interface IUMLPolicyFrameworkManager is IPolicyFrameworkManager {
/// @return policy The UMLPolicy struct
function getPolicy(uint256 policyId) external view returns (UMLPolicy memory policy);

function getRights(address ipId) external view returns (UMLRights memory rights);
/// @notice gets the aggregation data for inherited policies.
function getAggregator(address ipId) external view returns (UMLAggregator memory rights);
}
4 changes: 1 addition & 3 deletions contracts/interfaces/registries/ILicenseRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ interface ILicenseRegistry {
/// @param policy The encoded policy data
event PolicyRegistered(address indexed policyFrameworkManager, uint256 indexed policyId, bytes policy);

event IPRightsUpdated(address indexed ipId, bytes rights);

/// @notice Emitted when a policy is added to an IP
/// @param caller The address that called the function
/// @param ipId The id of the IP
Expand Down Expand Up @@ -145,7 +143,7 @@ interface ILicenseRegistry {
uint256 policyId
) external view returns (uint256 index, bool isInherited, bool active);

function rightsData(address framework, address ipId) external view returns (bytes memory);
function policyAggregatorData(address framework, address ipId) external view returns (bytes memory);

/// @notice True if holder is the licensee for the license (owner of the license NFT), or derivative IP owner if
/// the license was added to the IP by linking (burning a license)
Expand Down
1 change: 0 additions & 1 deletion contracts/lib/Licensing.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.20;
import { IPolicyVerifier } from "../interfaces/licensing/IPolicyVerifier.sol";
import { Errors } from "./Errors.sol";

/// @title Licensing
Expand Down
31 changes: 16 additions & 15 deletions contracts/lib/UMLFrameworkErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ library UMLFrameworkErrors {
// UMLPolicyFrameworkManager //
////////////////////////////////////////////////////////////////////////////

error UMLPolicyFrameworkManager_CommecialDisabled_CantAddAttribution();
error UMLPolicyFrameworkManager_CommecialDisabled_CantAddCommercializers();
error UMLPolicyFrameworkManager_CommecialDisabled_CantAddRevShare();
error UMLPolicyFrameworkManager_CommecialDisabled_CantAddDerivRevShare();
error UMLPolicyFrameworkManager_CommecialDisabled_CantAddRoyaltyPolicy();
error UMLPolicyFrameworkManager_CommecialEnabled_RoyaltyPolicyRequired();
error UMLPolicyFrameworkManager_DerivativesDisabled_CantAddAttribution();
error UMLPolicyFrameworkManager_DerivativesDisabled_CantAddApproval();
error UMLPolicyFrameworkManager_DerivativesDisabled_CantAddReciprocal();
error UMLPolicyFrameworkManager_DerivativesDisabled_CantAddRevShare();
error UMLPolicyFrameworkManager_RightsNotFound();

error UMLPolicyFrameworkManager_NewCommercialPolicyNotAccepted();
error UMLPolicyFrameworkManager_NewDerivativesPolicyNotAccepted();
error UMLPolicyFrameworkManager_ReciprocaConfiglNegatesNewPolicy();
error UMLPolicyFrameworkManager__CommecialDisabled_CantAddAttribution();
error UMLPolicyFrameworkManager__CommercialDisabled_CantAddCommercializers();
error UMLPolicyFrameworkManager__CommecialDisabled_CantAddRevShare();
error UMLPolicyFrameworkManager__CommecialDisabled_CantAddDerivRevShare();
error UMLPolicyFrameworkManager__DerivativesDisabled_CantAddAttribution();
error UMLPolicyFrameworkManager__DerivativesDisabled_CantAddApproval();
error UMLPolicyFrameworkManager__DerivativesDisabled_CantAddReciprocal();
error UMLPolicyFrameworkManager__DerivativesDisabled_CantAddRevShare();
error UMLPolicyFrameworkManager__RightsNotFound();
error UMLPolicyFrameworkManager__CommercialDisabled_CantAddRoyaltyPolicy();
error UMLPolicyFrameworkManager__CommecialEnabled_RoyaltyPolicyRequired();
error UMLPolicyFrameworkManager__ReciprocalButDifferentPolicyIds();
error UMLPolicyFrameworkManager__ReciprocalValueMismatch();
error UMLPolicyFrameworkManager__CommercialValueMismatch();
error UMLPolicyFrameworkManager__DerivativesValueMismatch();
error UMLPolicyFrameworkManager__StringArrayMismatch();
}
5 changes: 2 additions & 3 deletions contracts/modules/licensing/BasePolicyFrameworkManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pragma solidity ^0.8.23;

// contracts
import { IPolicyVerifier } from "contracts/interfaces/licensing/IPolicyVerifier.sol";
import { IPolicyFrameworkManager } from "contracts/interfaces/licensing/IPolicyFrameworkManager.sol";
import { LicenseRegistry } from "contracts/registries/LicenseRegistry.sol";
import { Licensing } from "contracts/lib/Licensing.sol";
Expand All @@ -16,7 +15,7 @@ import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol

/// @title BasePolicyFrameworkManager
/// @notice Base contract for policy framework managers.
abstract contract BasePolicyFrameworkManager is IPolicyVerifier, IPolicyFrameworkManager, ERC165, LicenseRegistryAware {
abstract contract BasePolicyFrameworkManager is IPolicyFrameworkManager, ERC165, LicenseRegistryAware {

string public override name;
string public override licenseTextUrl;
Expand All @@ -29,7 +28,7 @@ abstract contract BasePolicyFrameworkManager is IPolicyVerifier, IPolicyFramewor
}

/// @notice ERC165 interface identifier for the policy framework manager.
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IPolicyFrameworkManager).interfaceId || super.supportsInterface(interfaceId);
}

Expand Down
Loading

0 comments on commit a9a7da9

Please sign in to comment.