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

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Raul committed Jan 26, 2024
1 parent f57adfb commit 15fe95c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/interfaces/licensing/ILinkParamVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.23;

import { IParamVerifier } from "contracts/interfaces/licensing/IParamVerifier.sol";

interface ILinkParentParamVerifier is IParamVerifier {
interface ILinkParamVerifier is IParamVerifier {
function verifyLink(
address licenseId,
address caller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ pragma solidity ^0.8.23;

import { IParamVerifier } from "contracts/interfaces/licensing/IParamVerifier.sol";
import { IMintParamVerifier } from "contracts/interfaces/licensing/IMintParamVerifier.sol";
import { ILinkParentParamVerifier } from "contracts/interfaces/licensing/ILinkParamVerifier.sol";
import { ILinkParamVerifier } from "contracts/interfaces/licensing/ILinkParamVerifier.sol";
import { BaseParamVerifier } from "contracts/modules/licensing/parameters/BaseParamVerifier.sol";
import { Errors } from "contracts/lib/Errors.sol";

contract DerivativesParamVerifier is BaseParamVerifier, IMintParamVerifier, ILinkParentParamVerifier {
/// This corresponds with 1 term in UML text, but it's actually 5 interconnected parameters (hooks if you will)
/*
| Parameter | On chain | Can be enabled if | Can be enabled if | Incompatibility with other policy | Side effect | |
|----------------------------|-----------------------|--------------------|-------------------|------------------------------------------|--------------------------------------|---|
| Derivatives | yes | - | - | - | - | |
| Deriv With Attribution | Yes (verify offchain) | Derivatives = true | - | - | - | |
| Deriv With Approval | yes | Derivatives = true | - | - | – | |
| Deriv With Reciprocal | yes | Derivatives = true | - | Disallow different policies on same IpId | Address other than licensor can mint | |
| Deriv With Revenue Share | yes | Derivatives = true | Commercial = true | - | Royalties set on linking | |
| Deriv With Revenue Ceiling | no | Derivatives = true | Commercial = true | - | - | |
*/
contract DerivativesParamVerifier is BaseParamVerifier, IMintParamVerifier, ILinkParamVerifier {

event DerivativeApproved(address indexed licenseId, address indexed ipId, address indexed licensor, bool licensorApproval, bool approved);

Expand Down
30 changes: 27 additions & 3 deletions contracts/registries/LicenseRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ contract LicenseRegistry is ERC1155, ILicenseRegistry {
super._update(from, to, ids, values);
}

function _verifyLinkParams(uint256 licenseId, address holder, address childIpId, address parentIpId, bytes memory data) {

}

function _verifyParams(Licensing.ParamVerifierType pvt, Licensing.Policy memory pol, address holder, uint256 amount) internal {
Licensing.Framework storage fw = _framework(pol.frameworkId);
Licensing.Parameter[] storage params = fw.parameters[pvt];
Expand All @@ -429,11 +433,31 @@ contract LicenseRegistry is ERC1155, ILicenseRegistry {
bytes memory data = values[i].length == 0 ? param.defaultValue : values[i];
bool verificationOk = false;
if (pvt == Licensing.ParamVerifierType.Mint) {
verificationOk = param.verifier.verifyMinting(holder, amount, data);
verificationOk = param.verifier.function verifyMint(
address caller,
uint256 policyId,
bool policyAddedByLinking,
address[] memory licensors,
address receiver,
uint256 amount,
bytes memory data
) external view returns (bool)
} else if (pvt == Licensing.ParamVerifierType.LinkParent) {
verificationOk = param.verifier.verifyLinkParent(holder, data);
verificationOk = param.verifier.verifyLink(
address licenseId,
address licenseHolder,
address ipId,
address parentIpId,
bytes calldata data
)
} else if (pvt == Licensing.ParamVerifierType.Transfer) {
verificationOk = param.verifier.verifyTransfer(holder, amount, data);
verificationOk = param.verifier.verifyTransfer(
uint256 licenseId,
address from,
address to,
uint256 amount,
bytes memory data
);
} else {
// This should never happen since getValues checks for pvt validity
revert Errors.LicenseRegistry__InvalidParamVerifierType();
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/mocks/licensing/MintPaymentVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract MintPaymentVerifier is IParamVerifier {
return "";
}

function allowsOtherPolicyOnSameIp(bytes memory data) external view returns (bool) {
function allowsOtherPolicyOnSameIp(bytes memory data) external pure returns (bool) {
return true;
}

Expand Down

0 comments on commit 15fe95c

Please sign in to comment.