Skip to content

Commit

Permalink
feat: organize interfaces and add events (storyprotocol#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdubpark authored Jan 23, 2024
1 parent 5f78dd7 commit 285dbbb
Show file tree
Hide file tree
Showing 19 changed files with 381 additions and 77 deletions.
4 changes: 1 addition & 3 deletions contracts/AccessController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ contract AccessController is IAccessController {
}
permissions[ipAccount_][signer_][to_][func_] = permission_;

// TODO: emit event
emit PermissionSet(ipAccount_, signer_, to_, func_, permission_);
}

/// @notice Returns the permission level for a specific function call.
Expand Down Expand Up @@ -154,7 +154,5 @@ contract AccessController is IAccessController {
return false;
}
return false;

// TODO: emit event
}
}
8 changes: 8 additions & 0 deletions contracts/interfaces/IAccessController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
pragma solidity ^0.8.23;

interface IAccessController {
event PermissionSet(
address indexed ipAccount,
address indexed signer,
address indexed to,
bytes4 func,
uint8 permission
);

/// @notice Sets the permission for a specific function call
/// @dev Each policy is represented as a mapping from an IP account address to a signer address to a recipient
///// address to a function selector to a permission level.
Expand Down
19 changes: 19 additions & 0 deletions contracts/interfaces/modules/IRegistrationModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

interface IRegistrationModule {
event RootIPRegistered(address indexed caller, address indexed ipId, uint256 indexed policyId);

event DerivativeIPRegistered(address indexed caller, address indexed ipId, uint256 licenseId);

function registerRootIp(uint256 policyId, address tokenContract, uint256 tokenId) external returns (address);

function registerDerivativeIp(
uint256 licenseId,
address tokenContract,
uint256 tokenId,
string memory ipName,
string memory ipDescription,
bytes32 hash
) external;
}
60 changes: 60 additions & 0 deletions contracts/interfaces/modules/dispute/IDisputeModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

/// @title Dispute Module Interface
interface IDisputeModule {
/// @notice Whitelists a dispute tag
/// @param tag The dispute tag
/// @param allowed Indicates if the dispute tag is whitelisted or not
function whitelistDisputeTags(bytes32 tag, bool allowed) external;

/// @notice Whitelists an arbitration policy
/// @param arbitrationPolicy The address of the arbitration policy
/// @param allowed Indicates if the arbitration policy is whitelisted or not
function whitelistArbitrationPolicy(address arbitrationPolicy, bool allowed) external;

/// @notice Whitelists an arbitration relayer for a given arbitration policy
/// @param arbitrationPolicy The address of the arbitration policy
/// @param arbPolicyRelayer The address of the arbitration relayer
/// @param allowed Indicates if the arbitration relayer is whitelisted or not
function whitelistArbitrationRelayer(address arbitrationPolicy, address arbPolicyRelayer, bool allowed) external;

/// @notice Raises a dispute
/// @param ipId The ipId
/// @param arbitrationPolicy The address of the arbitration policy
/// @param linkToDisputeSummary The link of the dispute summary
/// @param targetTag The target tag of the dispute
/// @param data The data to initialize the policy
/// @return disputeId The dispute id
function raiseDispute(
address ipId,
address arbitrationPolicy,
string memory linkToDisputeSummary,
bytes32 targetTag,
bytes calldata data
) external returns (uint256 disputeId);

/// @notice Sets the dispute judgement
/// @param disputeId The dispute id
/// @param decision The decision of the dispute
/// @param data The data to set the dispute judgement
function setDisputeJudgement(uint256 disputeId, bool decision, bytes calldata data) external;

/// @notice Cancels an ongoing dispute
/// @param disputeId The dispute id
/// @param data The data to cancel the dispute
function cancelDispute(uint256 disputeId, bytes calldata data) external;

/// @notice Resolves a dispute after it has been judged
/// @param disputeId The dispute id
function resolveDispute(uint256 disputeId) external;

/// @notice Gets the dispute struct characteristics
function disputes(uint256 disputeId) external view returns (
address ipId,
address disputeInitiator,
address arbitrationPolicy,
bytes32 linkToDisputeSummary,
bytes32 tag
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

/// @title ArbitrationPolicy interface
interface IArbitrationPolicy {
/// @notice Executes custom logic on raise dispute
/// @param caller Address of the caller
function onRaiseDispute(address caller, bytes calldata data) external;

/// @notice Executes custom logic on dispute judgement
/// @param disputeId The dispute id
/// @param decision The decision of the dispute
function onDisputeJudgement(uint256 disputeId, bool decision, bytes calldata data) external;

/// @notice Executes custom logic on dispute cancel
function onDisputeCancel(address caller, uint256 disputeId, bytes calldata data) external;
}
25 changes: 25 additions & 0 deletions contracts/interfaces/modules/royalty/IRoyaltyModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

/// @title RoyaltyModule interface
interface IRoyaltyModule {
/// @notice Whitelist a royalty policy
/// @param royaltyPolicy The address of the royalty policy
/// @param allowed Indicates if the royalty policy is whitelisted or not
function whitelistRoyaltyPolicy(address royaltyPolicy, bool allowed) external;

/// @notice Sets the royalty policy for an ipId
/// @param ipId The ipId
/// @param royaltyPolicy The address of the royalty policy
/// @param data The data to initialize the policy
function setRoyaltyPolicy(address ipId, address royaltyPolicy, bytes calldata data) external;

/// @notice Allows an IPAccount to pay royalties
/// @param ipId The ipId
/// @param token The token to pay the royalties in
/// @param amount The amount to pay
function payRoyalty(address ipId, address token, uint256 amount) external;

/// @notice Gets the royalty policy for a given ipId
function royaltyPolicies(address ipId) external view returns (address royaltyPolicy);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

/// @title LiquidSplitClone interface
interface ILiquidSplitClone {
/// @notice Distributes funds to the accounts in the LiquidSplitClone contract
/// @param token The token to distribute
/// @param accounts The accounts to distribute to
/// @param distributorAddress The distributor address
function distributeFunds(address token, address[] calldata accounts, address distributorAddress) external;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

/// @title LiquidSplitFactory interface
interface ILiquidSplitFactory {
/// @notice Creates a new LiquidSplitClone contract
/// @param accounts The accounts to initialize the LiquidSplitClone contract with
/// @param initAllocations The initial allocations
/// @param _distributorFee The distributor fee
/// @param owner The owner of the LiquidSplitClone contract
function createLiquidSplitClone(
address[] calldata accounts,
uint32[] calldata initAllocations,
uint32 _distributorFee,
address owner
) external returns (address);
}
17 changes: 17 additions & 0 deletions contracts/interfaces/modules/royalty/policies/ILiquidSplitMain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/// @title LiquidSplitMain interface
interface ILiquidSplitMain {
/// @notice Allows an account to withdraw their accrued and distributed pending amount
/// @param account The account to withdraw from
/// @param withdrawETH The amount of ETH to withdraw
/// @param tokens The tokens to withdraw
function withdraw(
address account,
uint256 withdrawETH,
ERC20[] calldata tokens
) external;
}
17 changes: 17 additions & 0 deletions contracts/interfaces/modules/royalty/policies/IRoyaltyPolicy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

/// @title RoyaltyPolicy interface
interface IRoyaltyPolicy {
/// @notice Initializes the royalty policy
/// @param ipId The ipId
/// @param data The data to initialize the policy
function initPolicy(address ipId, bytes calldata data) external;

/// @notice Allows to pay a royalty
/// @param caller The caller
/// @param ipId The ipId
/// @param token The token to pay
/// @param amount The amount to pay
function onRoyaltyPayment(address caller, address ipId, address token, uint256 amount) external;
}
79 changes: 79 additions & 0 deletions contracts/interfaces/registries/ILicenseRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import { Licensing } from "contracts/lib/Licensing.sol";

interface ILicenseRegistry {
event LicenseFrameworkCreated(
address indexed creator,
uint256 indexed frameworkId,
Licensing.FrameworkCreationParams frameworkCreationParams
);

event PolicyCreated(address indexed creator, uint256 indexed policyId, Licensing.Policy policy);

event PolicyAddedToIpId(address indexed caller, address indexed ipId, uint256 indexed policyId);

event LicenseMinted(
address indexed creator,
address indexed receiver,
uint256 indexed licenseId,
uint256 amount,
Licensing.License licenseData
);

event IpIdLinkedToParent(address indexed caller, address indexed ipId, address indexed parentIpId);

function addLicenseFramework(
Licensing.FrameworkCreationParams calldata fwCreation
) external returns (uint256 frameworkId);

function addPolicyToIp(
address ipId,
Licensing.Policy memory pol
) external returns (uint256 policyId, bool isNew, uint256 indexOnIpId);

function addPolicyToIp(address ipId, uint256 polId) external returns (uint256 indexOnIpId);

function addPolicy(Licensing.Policy memory pol) external returns (uint256 policyId, bool isNew);

function mintLicense(
Licensing.License calldata licenseData,
uint256 amount,
address receiver
) external returns (uint256 licenseId);

function linkIpToParent(uint256 licenseId, address childIpId, address holder) external;

///
/// Getters
///

function totalFrameworks() external view returns (uint256);

function framework(uint256 frameworkId) external view returns (Licensing.Framework memory fw);

function totalPolicies() external view returns (uint256);

function policy(uint256 policyId) external view returns (Licensing.Policy memory pol);

function isPolicyDefined(uint256 policyId) external view returns (bool);

function policyIdsForIp(address ipId) external view returns (uint256[] memory policyIds);

function totalPoliciesForIp(address ipId) external view returns (uint256);

function isPolicyIdSetForIp(address ipId, uint256 policyId) external view returns (bool);

function policyIdForIpAtIndex(address ipId, uint256 index) external view returns (uint256 policyId);

function policyForIpAtIndex(address ipId, uint256 index) external view returns (Licensing.Policy memory);

function isLicensee(uint256 licenseId, address holder) external view returns (bool);

function isParent(address parentIpId, address childIpId) external view returns (bool);

function parentIpIds(address ipId) external view returns (address[] memory);

function totalParentsForIpId(address ipId) external view returns (uint256);
}
10 changes: 9 additions & 1 deletion contracts/interfaces/resolvers/IIPMetadataResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import { IP } from "contracts/lib/IP.sol";

/// @notice Resolver Interface
interface IIPMetadataResolver is IResolver {
event IPMetadataResolverSetRecord(address indexed ipId, IP.MetadataRecord data);

event IPMetadataResolverSetName(address indexed ipId, string name);

event IPMetadataResolverSetDescription(address indexed ipId, string description);

event IPMetadataResolverSetHash(address indexed ipId, bytes32 hash);

event IPMetadataResolverSetURI(address indexed ipId, string uri);

/// @notice Fetches core metadata attributed to a specific IP.
function metadata(address ipId) external view returns (IP.Metadata memory);
Expand Down Expand Up @@ -64,5 +73,4 @@ interface IIPMetadataResolver is IResolver {
/// @notice Sets an IP owner defined URI to associate with the IP.
/// @param ipId The canonical ID of the specified IP.
function setURI(address ipId, string calldata uri) external;

}
Loading

0 comments on commit 285dbbb

Please sign in to comment.