PILPolicyFrameworkManager.sol

PIL Policy Framework Manager implements the PIL Policy Framework logic for encoding and decoding PIL
policies into the LicenseRegistry and verifying the licensing parameters for linking, minting, and transferring.

constructor

constructor(address accessController, address ipAccountRegistry, address licensing, string name_, string licenseUrl_) public

registerPolicy

function registerPolicy(struct RegisterPILPolicyParams params) external returns (uint256 policyId)

Registers a new policy to the registry

Internally, this function must generate a Licensing.Policy struct and call registerPolicy.

Parameters

NameTypeDescription
paramsstruct RegisterPILPolicyParamsparameters needed to register a PILPolicy

Return Values

NameTypeDescription
policyIduint256The ID of the newly registered policy

verifyLink

function verifyLink(uint256 licenseId, address licensee, address ipId, address parentIpId, bytes policyData) external returns (bool)

Verify policy parameters for linking a child IP to a parent IP (licensor) by burning a license NFT.

Enforced to be only callable by LicenseRegistry

Parameters

NameTypeDescription
licenseIduint256the license id to burn
licenseeaddressthe address that holds the license and is executing the linking
ipIdaddressthe IP id of the IP being linked
parentIpIdaddressthe IP id of the parent IP
policyDatabytesthe encoded framework policy data to verify

Return Values

NameTypeDescription
[0]boolverified True if the link is verified

verifyMint

function verifyMint(address licensee, bool mintingFromADerivative, address licensorIpId, address receiver, uint256 mintAmount, bytes policyData) external returns (bool)

Verify policy parameters for minting a license.

Enforced to be only callable by LicenseRegistry

Parameters

NameTypeDescription
licenseeaddressthe address that holds the license and is executing the mint
mintingFromADerivativebooltrue if the license is minting from a derivative IPA
licensorIpIdaddressthe IP id of the licensor
receiveraddressthe address receiving the license
mintAmountuint256the amount of licenses to mint
policyDatabytesthe encoded framework policy data to verify

Return Values

NameTypeDescription
[0]boolverified True if the link is verified

getAggregator

function getAggregator(address ipId) external view returns (struct PILAggregator rights)

Returns the aggregation data for inherited policies of an IP asset.

Parameters

NameTypeDescription
ipIdaddressThe ID of the IP asset to get the aggregator for

Return Values

NameTypeDescription
rightsstruct PILAggregatorThe PILAggregator struct

getPILPolicy

function getPILPolicy(uint256 policyId) external view returns (struct PILPolicy policy)

gets the PILPolicy for a given policy ID decoded from Licensing.Policy.frameworkData

Do not call this function from a smart contract, it is only for off-chain

Parameters

NameTypeDescription
policyIduint256The ID of the policy to get

Return Values

NameTypeDescription
policystruct PILPolicyThe PILPolicy struct

processInheritedPolicies

function processInheritedPolicies(bytes aggregator, uint256 policyId, bytes policy) external view returns (bool changedAgg, bytes newAggregator)

Verify compatibility of one or more policies when inheriting them from one or more parent IPs.

Enforced to be only callable by LicenseRegistry
The assumption in this method is that we can add parents later on, hence the need
for an aggregator, if not we will do this when linking to parents directly with an
array of policies.

Parameters

NameTypeDescription
aggregatorbytescommon state of the policies for the IP
policyIduint256the ID of the policy being inherited
policybytesthe policy to inherit

Return Values

NameTypeDescription
changedAggbooltrue if the aggregator was changed
newAggregatorbytesthe new aggregator

policyToJson

function policyToJson(bytes policyData) public pure returns (string)

Returns the stringified JSON policy data for the LicenseRegistry.uri(uint256) method.

Must return ERC1155 OpenSea standard compliant metadata.

Parameters

NameTypeDescription
policyDatabytesThe encoded licensing policy data to be decoded by the PFM

Return Values

NameTypeDescription
[0]stringjsonString The OpenSea-compliant metadata URI of the policy

_policyCommercialTraitsToJson

function _policyCommercialTraitsToJson(struct PILPolicy policy) internal pure returns (string)

Encodes the commercial traits of PIL policy into a JSON string for OpenSea

Parameters

NameTypeDescription
policystruct PILPolicyThe policy to encode

_policyDerivativeTraitsToJson

function _policyDerivativeTraitsToJson(struct PILPolicy policy) internal pure returns (string)

Encodes the derivative traits of PIL policy into a JSON string for OpenSea

Parameters

NameTypeDescription
policystruct PILPolicyThe policy to encode

_verifyComercialUse

function _verifyComercialUse(struct PILPolicy policy, address royaltyPolicy, uint256 mintingFee, address mintingFeeToken) internal view

Checks the configuration of commercial use and throws if the policy is not compliant

Parameters

NameTypeDescription
policystruct PILPolicyThe policy to verify
royaltyPolicyaddressThe address of the royalty policy
mintingFeeuint256
mintingFeeTokenaddress

_verifyDerivatives

function _verifyDerivatives(struct PILPolicy policy) internal pure

Checks the configuration of derivative parameters and throws if the policy is not compliant

Parameters

NameTypeDescription
policystruct PILPolicyThe policy to verify

_verifHashedParams

function _verifHashedParams(bytes32 oldHash, bytes32 newHash, bytes32 permissive) internal pure returns (bytes32 result)

Verifies compatibility for params where the valid options are either permissive value, or equal params

Parameters

NameTypeDescription
oldHashbytes32hash of the old param
newHashbytes32hash of the new param
permissivebytes32hash of the most permissive param

Return Values

NameTypeDescription
resultbytes32the hash that's different from the permissive hash