From 15fe95c6ec25a4d717c2df5789b9a7da0f8d83f6 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 25 Jan 2024 21:19:14 -0300 Subject: [PATCH] WIP --- .../licensing/ILinkParamVerifier.sol | 2 +- .../parameters/DerivativesParamVerifier.sol | 15 ++++++++-- contracts/registries/LicenseRegistry.sol | 30 +++++++++++++++++-- .../mocks/licensing/MintPaymentVerifier.sol | 2 +- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/contracts/interfaces/licensing/ILinkParamVerifier.sol b/contracts/interfaces/licensing/ILinkParamVerifier.sol index d2e906216..df13445bd 100644 --- a/contracts/interfaces/licensing/ILinkParamVerifier.sol +++ b/contracts/interfaces/licensing/ILinkParamVerifier.sol @@ -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, diff --git a/contracts/modules/licensing/parameters/DerivativesParamVerifier.sol b/contracts/modules/licensing/parameters/DerivativesParamVerifier.sol index 3e6dd832f..9083305a2 100644 --- a/contracts/modules/licensing/parameters/DerivativesParamVerifier.sol +++ b/contracts/modules/licensing/parameters/DerivativesParamVerifier.sol @@ -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); diff --git a/contracts/registries/LicenseRegistry.sol b/contracts/registries/LicenseRegistry.sol index 2607d04e5..018d941d6 100644 --- a/contracts/registries/LicenseRegistry.sol +++ b/contracts/registries/LicenseRegistry.sol @@ -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]; @@ -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(); diff --git a/test/foundry/mocks/licensing/MintPaymentVerifier.sol b/test/foundry/mocks/licensing/MintPaymentVerifier.sol index c4e03c21a..3844e12f9 100644 --- a/test/foundry/mocks/licensing/MintPaymentVerifier.sol +++ b/test/foundry/mocks/licensing/MintPaymentVerifier.sol @@ -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; }