forked from storyprotocol/protocol-core
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ERC165 check for external royalty policy registration (#319)
* add ERC165 check for external policy registration * fix lint
- Loading branch information
Showing
8 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
11 changes: 4 additions & 7 deletions
11
contracts/interfaces/modules/royalty/policies/IExternalRoyaltyPolicy.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.26; | ||
|
||
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
import { IExternalRoyaltyPolicyBase } from "./IExternalRoyaltyPolicyBase.sol"; | ||
|
||
/// @title IExternalRoyaltyPolicy interface | ||
interface IExternalRoyaltyPolicy { | ||
/// @notice Returns the amount of royalty tokens required to link a child to a given IP asset | ||
/// @param ipId The ipId of the IP asset | ||
/// @param licensePercent The percentage of the license | ||
/// @return The amount of royalty tokens required to link a child to a given IP asset | ||
function getPolicyRtsRequiredToLink(address ipId, uint32 licensePercent) external view returns (uint32); | ||
} | ||
interface IExternalRoyaltyPolicy is IExternalRoyaltyPolicyBase, IERC165 {} |
11 changes: 11 additions & 0 deletions
11
contracts/interfaces/modules/royalty/policies/IExternalRoyaltyPolicyBase.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.26; | ||
|
||
/// @title IExternalRoyaltyPolicyBase interface | ||
interface IExternalRoyaltyPolicyBase { | ||
/// @notice Returns the amount of royalty tokens required to link a child to a given IP asset | ||
/// @param ipId The ipId of the IP asset | ||
/// @param licensePercent The percentage of the license | ||
/// @return The amount of royalty tokens required to link a child to a given IP asset | ||
function getPolicyRtsRequiredToLink(address ipId, uint32 licensePercent) external view returns (uint32); | ||
} |
4 changes: 2 additions & 2 deletions
4
contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.26; | ||
|
||
import { IERC165, ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
|
||
// solhint-disable-next-line max-line-length | ||
import { IExternalRoyaltyPolicy } from "../../../../contracts/interfaces/modules/royalty/policies/IExternalRoyaltyPolicy.sol"; | ||
|
||
contract MockExternalRoyaltyPolicy1 is IExternalRoyaltyPolicy { | ||
contract MockExternalRoyaltyPolicy1 is ERC165, IExternalRoyaltyPolicy { | ||
function getPolicyRtsRequiredToLink(address ipId, uint32 licensePercent) external view returns (uint32) { | ||
return licensePercent * 2; | ||
} | ||
|
||
/// @notice IERC165 interface support | ||
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) { | ||
return interfaceId == this.getPolicyRtsRequiredToLink.selector || super.supportsInterface(interfaceId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.26; | ||
|
||
import { IERC165, ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
|
||
// solhint-disable-next-line max-line-length | ||
import { IExternalRoyaltyPolicy } from "../../../../contracts/interfaces/modules/royalty/policies/IExternalRoyaltyPolicy.sol"; | ||
|
||
contract MockExternalRoyaltyPolicy2 is IExternalRoyaltyPolicy { | ||
contract MockExternalRoyaltyPolicy2 is ERC165, IExternalRoyaltyPolicy { | ||
function getPolicyRtsRequiredToLink(address ipId, uint32 licensePercent) external view returns (uint32) { | ||
return 10 * 10 ** 6; | ||
} | ||
|
||
/// @notice IERC165 interface support | ||
function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) { | ||
return interfaceId == this.getPolicyRtsRequiredToLink.selector || super.supportsInterface(interfaceId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters