Skip to content

Commit dd64816

Browse files
committed
refactor: reestructure and decouple right manager
1 parent 54b5a89 commit dd64816

92 files changed

Lines changed: 1376 additions & 2635 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44

55
MMC: 0x21173483074a46c302c4252e04c76fA90e6DdA6C
66

7+
8+
Cnv:
9+
guidelines for emitting events
10+
- Any function that can change a storage variable should emit an event.
11+
- The event should contain enough information for someone auditing the logs can determine what value the storage variable took at that time.
12+
- Any address parameters in the event should be indexed so that it is easy to drill down on the activity of a particular wallet.
13+
- View and pure functions should not contain events because they do not change the state.
14+
715
refs:
816

9-
https://github.com/crytic/building-secure-contracts/blob/master/development-guidelines/code_maturity.md#blockchain-maturity-evaluation
17+
https://github.com/crytic/building-secure-contracts/blob/master/development-guidelines/code_maturity.md
18+
1019
https://docs.soliditylang.org/en/latest/style-guide.html
1120

1221

contracts/RightsManager.sol

Lines changed: 0 additions & 390 deletions
This file was deleted.
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/ac
1010
import { ERC721EnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
1111

1212
import { GovernableUpgradeable } from "contracts/base/upgradeable/GovernableUpgradeable.sol";
13-
import { IReferendumVerifiable } from "contracts/interfaces/IReferendumVerifiable.sol";
14-
import { IOwnership } from "contracts/interfaces/IOwnership.sol";
13+
import { IContentVerifiable } from "contracts/interfaces/assets/IContentVerifiable.sol";
14+
import { IContentOwnership } from "contracts/interfaces/assets/IContentOwnership.sol";
1515

1616
// TODO imp ERC404
1717

1818
/// @title Ownership ERC721 Upgradeable
1919
/// @notice This abstract contract manages the ownership.
20-
contract Ownership is
20+
contract ContentOwnership is
2121
Initializable,
2222
UUPSUpgradeable,
23-
GovernableUpgradeable,
2423
ERC721Upgradeable,
24+
GovernableUpgradeable,
2525
ERC721EnumerableUpgradeable,
26-
IOwnership
26+
IContentOwnership
2727
{
28-
IReferendumVerifiable public referendum;
29-
event RegisteredContent(uint256 contentId);
28+
IContentVerifiable public contentReferendum;
29+
event RegisteredContent(address indexed owner, uint256 contentId);
3030
error InvalidNotApprovedContent();
3131
/// @notice Modifier to ensure content is approved before distribution.
3232
/// @param to The address attempting to distribute the content.
@@ -36,7 +36,7 @@ contract Ownership is
3636
/// It also ensures that the recipient is the one who initially submitted the content for approval.
3737
modifier onlyApprovedContent(address to, uint256 contentId) {
3838
// Revert if the content is not approved or if the recipient is not the original submitter
39-
if (!referendum.isApproved(to, contentId)) revert InvalidNotApprovedContent();
39+
if (!contentReferendum.isApproved(to, contentId)) revert InvalidNotApprovedContent();
4040
_;
4141
}
4242

@@ -58,15 +58,16 @@ contract Ownership is
5858
}
5959

6060
/// @notice Initializes the contract with the given dependencies, including the Referendum contract for governance-related verifications.
61-
/// @param referendum_ The address of the Referendum contract, which is responsible for verifying governance decisions related to content.
61+
/// @param contentReferendum_ The address of the Content Referendum contract, which is responsible for verifying governance decisions related to content.
6262
/// @dev This function can only be called once during the contract's deployment. It sets up UUPS upgradeability,
6363
/// ERC721 token functionality, and governance mechanisms. The Referendum contract is linked to handle governance verifications.
64-
function initialize(address referendum_) public initializer {
64+
function initialize(address contentReferendum_) public initializer {
6565
__UUPSUpgradeable_init();
6666
__ERC721Enumerable_init();
6767
__ERC721_init("Ownership", "OWN");
6868
__Governable_init(msg.sender);
69-
referendum = IReferendumVerifiable(referendum_);
69+
// we need to verify the status of each content before allow register it.
70+
contentReferendum = IContentVerifiable(contentReferendum_);
7071
}
7172

7273
/// @notice Checks if the contract supports a specific interface.
@@ -90,7 +91,7 @@ contract Ownership is
9091
/// @param contentId The content id of the NFT. This should be a unique identifier for the NFT.
9192
function registerContent(address to, uint256 contentId) external onlyApprovedContent(to, contentId) {
9293
_mint(to, contentId);
93-
emit RegisteredContent(contentId);
94+
emit RegisteredContent(to, contentId);
9495
}
9596

9697
/// @dev Internal function to update the ownership of a token.
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,30 @@ import { Address } from "@openzeppelin/contracts/utils/Address.sol";
1111

1212
import { GovernableUpgradeable } from "contracts/base/upgradeable/GovernableUpgradeable.sol";
1313
import { QuorumUpgradeable } from "contracts/base/upgradeable/QuorumUpgradeable.sol";
14-
import { IReferendum } from "contracts/interfaces/IReferendum.sol";
15-
import { IReferendumRoleManager } from "contracts/interfaces/IReferendumRoleManager.sol";
16-
import { IReferendumVerifiable } from "contracts/interfaces/IReferendumVerifiable.sol";
14+
import { IContentRegistrable } from "contracts/interfaces/assets/IContentRegistrable.sol";
15+
import { IContentRoleManager } from "contracts/interfaces/assets/IContentRoleManager.sol";
16+
import { IContentVerifiable } from "contracts/interfaces/assets/IContentVerifiable.sol";
1717

1818
import { C } from "contracts/libraries/Constants.sol";
1919
import { T } from "contracts/libraries/Types.sol";
2020

2121
/// @title Content curation contract.
2222
/// @notice This contract allows for the submission, voting, and approval/rejection of content.
23-
contract Referendum is
23+
contract ContentReferendum is
2424
Initializable,
2525
UUPSUpgradeable,
2626
GovernableUpgradeable,
2727
NoncesUpgradeable,
2828
EIP712Upgradeable,
2929
QuorumUpgradeable,
30-
IReferendum,
31-
IReferendumVerifiable,
32-
IReferendumRoleManager
30+
IContentRegistrable,
31+
IContentVerifiable,
32+
IContentRoleManager
3333
{
3434
using EnumerableSet for EnumerableSet.UintSet;
3535
mapping(address => EnumerableSet.UintSet) private submissions;
3636
// This role is granted to any representant trusted account. eg: Verified Accounts, etc.
3737
bytes32 private constant VERIFIED_ROLE = keccak256("VERIFIED_ROLE");
38-
39-
// Error to be thrown when the submission initiator is invalid.
40-
error InvalidSubmissionSignature();
41-
error InvalidSubmissionInitiator();
42-
4338
/// @dev Event emitted when a content is submitted for referendum.
4439
/// @param contentId The ID of the content submitted.
4540
/// @param initiator The address of the initiator who submitted the content.
@@ -51,6 +46,16 @@ contract Referendum is
5146
/// @dev Event emitted when a content is revoked.
5247
/// @param contentId The ID of the content revoked.
5348
event ContentRevoked(uint256 indexed contentId);
49+
/// @notice Emitted when the verified role is granted to an account.
50+
/// @param account The address of the account that has been granted the verified role.
51+
event VerifiedRoleGranted(address indexed account);
52+
53+
/// @notice Emitted when the verified role is revoked from an account.
54+
/// @param account The address of the account from which the verified role has been revoked.
55+
event VerifiedRoleRevoked(address indexed account);
56+
// Error to be thrown when the submission initiator is invalid.
57+
error InvalidSubmissionSignature();
58+
error InvalidSubmissionInitiator();
5459

5560
/// @dev Constructor that disables initializers to prevent the implementation contract from being initialized.
5661
/// @notice This constructor prevents the implementation contract from being initialized.
@@ -63,7 +68,6 @@ contract Referendum is
6368

6469
/// @notice Initializes the contract.
6570
function initialize() public initializer {
66-
__Quorum_init();
6771
__UUPSUpgradeable_init();
6872
__EIP712_init("Referendum", "1");
6973
__Governable_init(msg.sender);
@@ -74,15 +78,15 @@ contract Referendum is
7478
/// @dev Only governance is allowed to grant the role.
7579
function grantVerifiedRole(address account) external onlyGov {
7680
_grantRole(VERIFIED_ROLE, account);
77-
// TODO emit event
81+
emit VerifiedRoleGranted(account);
7882
}
7983

8084
/// @notice Revoke the verified role to a specific account.
8185
/// @param account The address of the account to revoke.
8286
/// @dev Only governance is allowed to revoke the role.
8387
function revokeVerifiedRole(address account) external onlyGov {
8488
_revokeRole(VERIFIED_ROLE, account);
85-
// TODO emit event
89+
emit VerifiedRoleRevoked(account);
8690
}
8791

8892
/// @notice Submits a content proposition for referendum.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils
55
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
66

77
import { GovernableUpgradeable } from "contracts/base/upgradeable/GovernableUpgradeable.sol";
8-
import { IOwnership } from "contracts/interfaces/IOwnership.sol";
9-
import { IContentVault } from "contracts/interfaces/IContentVault.sol";
8+
import { IContentOwnership } from "contracts/interfaces/assets/IContentOwnership.sol";
9+
import { IContentVault } from "contracts/interfaces/assets/IContentVault.sol";
1010

1111
/// @title ContentVault
1212
/// @notice This contract stores encrypted content and ensures only the rightful content holder
@@ -16,7 +16,7 @@ import { IContentVault } from "contracts/interfaces/IContentVault.sol";
1616
/// and inherits Governable for governance control.
1717
contract ContentVault is Initializable, UUPSUpgradeable, GovernableUpgradeable, IContentVault {
1818
/// @notice The Ownership contract that tracks content holders.
19-
IOwnership public ownership;
19+
IContentOwnership public ownership;
2020
/// @dev Mapping to store encrypted content, identified by content ID.
2121
mapping(uint256 => bytes) private secured;
2222
/// @notice Error thrown when a non-owner tries to modify or access the content.
@@ -46,7 +46,7 @@ contract ContentVault is Initializable, UUPSUpgradeable, GovernableUpgradeable,
4646
function initialize(address ownership_) public initializer {
4747
__UUPSUpgradeable_init();
4848
__Governable_init(msg.sender);
49-
ownership = IOwnership(ownership_);
49+
ownership = IContentOwnership(ownership_);
5050
}
5151

5252
/// @notice Retrieves the encrypted content for a given content ID.

contracts/base/upgradeable/CurrencyManagerUpgradeable.sol

Lines changed: 0 additions & 94 deletions
This file was deleted.

contracts/base/upgradeable/FeesManagerUpgradeable.sol

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)