Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prettier errors #115

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions contracts/access-control/AccessControlSingleton.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ contract AccessControlSingleton is
UUPSUpgradeable,
Multicall,
IVersioned
{

{
string public constant version = "0.1.0";

/**
Expand All @@ -36,15 +35,18 @@ contract AccessControlSingleton is
* @param role id of the new role. Should be keccak256("<ROLE_NAME>").
* @param admin role id that will be the role admin for the new role.
*/
function setRoleAdmin(bytes32 role, bytes32 admin) external onlyRole(PROTOCOL_ADMIN_ROLE) {
function setRoleAdmin(
bytes32 role,
bytes32 admin
) external onlyRole(PROTOCOL_ADMIN_ROLE) {
_setRoleAdmin(role, admin);
}

/**
* @notice Access control for the upgrade process (UPGRADER_ROLE)
* @param newImplementation address of the new deployed implementation.
*/
function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(UPGRADER_ROLE) {
}

}
*/
function _authorizeUpgrade(
address newImplementation
) internal virtual override onlyRole(UPGRADER_ROLE) {}
}
16 changes: 9 additions & 7 deletions contracts/access-control/AccessControlled.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
pragma solidity ^0.8.9;

import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
import { ERC165CheckerUpgradeable }
from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165CheckerUpgradeable.sol";
import { ERC165CheckerUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165CheckerUpgradeable.sol";
import { PROTOCOL_ADMIN_ROLE } from "./ProtocolRoles.sol";
import { UnsupportedInterface } from "../errors/General.sol";

abstract contract AccessControlled {

using ERC165CheckerUpgradeable for address;

IAccessControl private _accessControl;
Expand Down Expand Up @@ -41,19 +39,23 @@ abstract contract AccessControlled {
* @param account the address to be tested for the role.
* @return return true if account has role, false otherwise.
*/
function hasRole(bytes32 role, address account) internal view returns (bool) {
function hasRole(
bytes32 role,
address account
) internal view returns (bool) {
return _accessControl.hasRole(role, account);
}

/**
* @notice Sets AccessManager instance. Restricted to PROTOCOL_ADMIN_ROLE
* @param accessControl address of the new instance of AccessControlSingleton.
*/
function setAccessControl(address accessControl) public onlyRole(PROTOCOL_ADMIN_ROLE) {
function setAccessControl(
address accessControl
) public onlyRole(PROTOCOL_ADMIN_ROLE) {
if (!accessControl.supportsInterface(type(IAccessControl).interfaceId))
revert UnsupportedInterface("IAccessControl");
_accessControl = IAccessControl(accessControl);
emit AccessControlUpdated(accessControl);
}

}
}
29 changes: 19 additions & 10 deletions contracts/access-control/AccessControlledUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ pragma solidity ^0.8.9;

import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { ERC165CheckerUpgradeable }
from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165CheckerUpgradeable.sol";
import { ERC165CheckerUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165CheckerUpgradeable.sol";
import { PROTOCOL_ADMIN_ROLE } from "./ProtocolRoles.sol";
import { UnsupportedInterface } from "../errors/General.sol";

abstract contract AccessControlledUpgradeable is UUPSUpgradeable {

using ERC165CheckerUpgradeable for address;

event AccessControlUpdated(address indexed accessControl);
Expand All @@ -22,7 +20,8 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable {
}

// keccak256(bytes.concat(bytes32(uint256(keccak256("story-protocol.access-controlled-upgradeable.storage")) - 1)))
bytes32 private constant _STORAGE_LOCATION = 0x06c308ca3b780cede1217f5877d0c7fbf50796d93f836cb3b60e6457b0cf03b6;
bytes32 private constant _STORAGE_LOCATION =
0x06c308ca3b780cede1217f5877d0c7fbf50796d93f836cb3b60e6457b0cf03b6;

/**
* @notice Checks if msg.sender has `role`, reverts if not.
Expand All @@ -39,15 +38,21 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable {
* @notice Initializer method, access point to initialize inheritance tree.
* @param accessControl address of AccessManager.
*/
function __AccessControlledUpgradeable_init(address accessControl) internal initializer {
function __AccessControlledUpgradeable_init(
address accessControl
) internal initializer {
if (!accessControl.supportsInterface(type(IAccessControl).interfaceId))
revert UnsupportedInterface("IAccessControl");
AccessControlledStorage storage $ = _getAccessControlledUpgradeable();
$.accessControl = IAccessControl(accessControl);
emit AccessControlUpdated(accessControl);
}

function _getAccessControlledUpgradeable() private pure returns (AccessControlledStorage storage $) {
function _getAccessControlledUpgradeable()
private
pure
returns (AccessControlledStorage storage $)
{
assembly {
$.slot := _STORAGE_LOCATION
}
Expand All @@ -59,7 +64,10 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable {
* @param account the address to be tested for the role.
* @return return true if account has role, false otherwise.
*/
function hasRole(bytes32 role, address account) internal view returns (bool) {
function hasRole(
bytes32 role,
address account
) internal view returns (bool) {
AccessControlledStorage storage $ = _getAccessControlledUpgradeable();
return $.accessControl.hasRole(role, account);
}
Expand All @@ -68,7 +76,9 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable {
* @notice Sets AccessManager instance. Restricted to PROTOCOL_ADMIN_ROLE
* @param accessControl address of the new instance of AccessControlSingleton.
*/
function setAccessControl(address accessControl) public onlyRole(PROTOCOL_ADMIN_ROLE) {
function setAccessControl(
address accessControl
) public onlyRole(PROTOCOL_ADMIN_ROLE) {
if (!accessControl.supportsInterface(type(IAccessControl).interfaceId))
revert UnsupportedInterface("IAccessControl");
AccessControlledStorage storage $ = _getAccessControlledUpgradeable();
Expand All @@ -80,5 +90,4 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable {
AccessControlledStorage storage $ = _getAccessControlledUpgradeable();
return address($.accessControl);
}

}
}
6 changes: 4 additions & 2 deletions contracts/access-control/ProtocolRoles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ bytes32 constant PROTOCOL_ADMIN_ROLE = bytes32(0);
// Role that can upgrade UUPS contracts or Beacon Proxies
bytes32 constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
// Role that can perform admin tasks on the Protocol Relationship Module contract (e.g. adding new protocol-wide links)
bytes32 constant RELATIONSHIP_MANAGER_ROLE = keccak256("RELATIONSHIP_MANAGER_ROLE");
bytes32 constant RELATIONSHIP_MANAGER_ROLE = keccak256(
"RELATIONSHIP_MANAGER_ROLE"
);
// Role that can perform admin tasks on the Licensing Module contracts (setNonCommercialLicenseURI)
bytes32 constant LICENSING_MANAGER_ROLE = keccak256("LICENSING_MANAGER_ROLE");
bytes32 constant LICENSING_MANAGER_ROLE = keccak256("LICENSING_MANAGER_ROLE");
2 changes: 1 addition & 1 deletion contracts/errors/General.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ error UnsupportedInterface(string name);
error Unauthorized();
error NonExistentID(uint256 id);
error EmptyArray();
error LengthMismatch();
error LengthMismatch();
14 changes: 7 additions & 7 deletions contracts/interfaces/ICollectModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ICollectModuleEventsAndErrors } from "./ICollectModuleEventsAndErrors.s
/// @notice The collect module enables IP assets to be minted as NFTs mirroring
/// their binding IP assets in a franchise-configurable format.
interface ICollectModule is ICollectModuleEventsAndErrors {

/// @notice Initializes the collect module for a specific IP asset.
/// @param initCollectParams Collect module init data, including IP asset
/// id, collect NFT impl address, and generic unformatted init data.
Expand All @@ -19,15 +18,16 @@ interface ICollectModule is ICollectModuleEventsAndErrors {
/// collector address, and generic unformatted collect and NFT data.
/// @return collectNFT The address of the collected NFT.
/// @return collectNFTId The id of the collected collect NFT.
function collect(CollectParams calldata collectParams)
external
payable
returns (address collectNFT, uint256 collectNFTId);
function collect(
CollectParams calldata collectParams
) external payable returns (address collectNFT, uint256 collectNFTId);

/// @notice Returns the collect NFT address associated with an IP asset.
/// @param franchiseId The id of the franchise of the specified IP asset.
/// @param ipAssetId The id of the specified IP asset within the franchise.
/// @return The Collect NFT address if it exists, else the zero address.
function getCollectNFT(uint256 franchiseId, uint256 ipAssetId) external returns (address);

function getCollectNFT(
uint256 franchiseId,
uint256 ipAssetId
) external returns (address);
}
2 changes: 0 additions & 2 deletions contracts/interfaces/ICollectModuleEventsAndErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.18;

/// @title Collect Module Events & Errors Interface
interface ICollectModuleEventsAndErrors {

/// @notice Collect module caller is unauthorized.
error CollectModuleCallerUnauthorized();

Expand All @@ -21,5 +20,4 @@ interface ICollectModuleEventsAndErrors {

/// @notice Collect module provided IP asset registry does not exist.
error CollectModuleIPAssetRegistryNonExistent();

}
8 changes: 5 additions & 3 deletions contracts/interfaces/ICollectNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import { InitCollectNFTParams } from "contracts/lib/CollectNFTStructs.sol";
/// @notice Contracts implementing the Collect NFT interface may be collected
/// through a collect module for a bound franchise IP asset.
interface ICollectNFT is IERC721, ICollectNFTEventsAndErrors {

/// @notice Returns the total # of collect NFTs that exist for an IP asset.
/// @return The total number of collect NFTs in the collection.
function totalSupply() external view returns (uint256);

/// @notice Initializes a collect NFT for subsequent collection.
/// @param initParams Collect NFT init data, including bound franchise IP
/// @param initParams Collect NFT init data, including bound franchise IP
/// asset registry, IP asset id, and generic unformatted init data.
function initialize(InitCollectNFTParams calldata initParams) external;

/// @notice Performs a collect, minting the NFT to address `collector`.
/// @param collector The address of the target designated for collection.
/// @param data Additional unformatted bytes data for optional processing.
/// @return tokenId The id of the minted collect NFT.
function collect(address collector, bytes calldata data) external returns (uint256);
function collect(
address collector,
bytes calldata data
) external returns (uint256);
}
2 changes: 0 additions & 2 deletions contracts/interfaces/ICollectNFTEventsAndErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.18;

interface ICollectNFTEventsAndErrors {

/// @notice Collect NFT has already been initialized.
error CollectNFTAlreadyInitialized();

Expand All @@ -14,5 +13,4 @@ interface ICollectNFTEventsAndErrors {

/// @notice IP asset bound to the Collect NFT does not exist.
error CollectNFTIPAssetNonExistent();

}
20 changes: 14 additions & 6 deletions contracts/interfaces/ICollectPaymentModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,37 @@ import { ICollectPaymentModuleEventsAndErrors } from "./ICollectPaymentModuleEve
/// @title Collect Payment Module Interface
/// @notice The collect payment module enables IP assets to be bound to NFTs
/// that can be minted for a configurable fee.
interface ICollectPaymentModule is ICollectModule, ICollectPaymentModuleEventsAndErrors {

interface ICollectPaymentModule is
ICollectModule,
ICollectPaymentModuleEventsAndErrors
{
/// @notice Returns the collect payment info associated with an IP asset.
/// @param franchiseId The id of the franchise of the specified IP asset.
/// @param ipAssetId The id of the specified IP asset within the franchise.
/// @return Payment info associated with the configured IP asset collect.
function getPaymentInfo(uint256 franchiseId, uint256 ipAssetId) external view returns (CollectPaymentInfo memory);
function getPaymentInfo(
uint256 franchiseId,
uint256 ipAssetId
) external view returns (CollectPaymentInfo memory);

/// @notice Initializes the collect payment module for a specific IP asset.
/// @param initCollectParams Collect module init data, including IP asset
/// id, collect NFT impl address, and payment module init data.
function initCollect(InitCollectParams calldata initCollectParams) external override(ICollectModule);
function initCollect(
InitCollectParams calldata initCollectParams
) external override(ICollectModule);

/// @notice Performs a collect on a specific IP asset, processing the module
/// configured payment in the process.
/// @param collectParams Collect module collect data, including IP asset id,
/// collector address, and collect payment module processing data.
/// @return collectNFT The address of the collected NFT.
/// @return collectNFTId The id of the collected collect NFT.
function collect(CollectParams calldata collectParams)
function collect(
CollectParams calldata collectParams
)
external
payable
override(ICollectModule)
returns (address collectNFT, uint256 collectNFTId);

}
6 changes: 3 additions & 3 deletions contracts/interfaces/ICollectPaymentModuleEventsAndErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ pragma solidity ^0.8.18;
import { ICollectModuleEventsAndErrors } from "contracts/interfaces/ICollectModuleEventsAndErrors.sol";

/// @title Collect Payment Module Events & Errors Interface
interface ICollectPaymentModuleEventsAndErrors is ICollectModuleEventsAndErrors {

interface ICollectPaymentModuleEventsAndErrors is
ICollectModuleEventsAndErrors
{
/// @notice The configured collect module payment amount is invalid.
error CollectPaymentModuleAmountInvalid();

Expand Down Expand Up @@ -35,5 +36,4 @@ interface ICollectPaymentModuleEventsAndErrors is ICollectModuleEventsAndErrors

/// @notice The token provided for the payment collect is invalid.
error CollectPaymentModuleTokenInvalid();

}
2 changes: 0 additions & 2 deletions contracts/interfaces/IERC721Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.18;

/// @title ERC-721 Errors Interface
interface IERC721Errors {

/// @notice Originating address does not own the NFT.
error ERC721OwnerInvalid();

Expand All @@ -21,5 +20,4 @@ interface IERC721Errors {

/// @notice NFT does not exist.
error ERC721TokenNonExistent();

}
20 changes: 15 additions & 5 deletions contracts/interfaces/IERC721Events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@ pragma solidity ^0.8.18;

/// @title ERC-721 Events Interface
interface IERC721Events {

/// @notice Emits when `tokenId` is transferred from address `from` to `to`.
/// @param from The address of the original NFT owner.
/// @param to The address of the new NFT owner.
/// @param tokenId The id of the NFT being transferred.
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);

/// @notice Emits when `owner` approves `approved` to operate on `tokenId`.
/// @param owner The address of the current NFT owner.
/// @param approved The address approved to operate on `tokenId`.
/// @param tokenId The id of the NFT being approved.
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event Approval(
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);

/// @notice Emits when `owner` approves `operator` to operate on their NFTs.
/// @param owner The address of the current NFT owner.
/// @param operator The address of the new NFT operator.
/// @param approved Whether operator can operate on NFTs of owner.
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
}
Loading