diff --git a/contracts/access-control/AccessControlSingleton.sol b/contracts/access-control/AccessControlSingleton.sol index 62a6171c..baf8e15b 100644 --- a/contracts/access-control/AccessControlSingleton.sol +++ b/contracts/access-control/AccessControlSingleton.sol @@ -16,8 +16,7 @@ contract AccessControlSingleton is UUPSUpgradeable, Multicall, IVersioned - { - +{ string public constant version = "0.1.0"; /** @@ -36,15 +35,18 @@ contract AccessControlSingleton is * @param role id of the new role. Should be keccak256(""). * @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) { - } - -} \ No newline at end of file + */ + function _authorizeUpgrade( + address newImplementation + ) internal virtual override onlyRole(UPGRADER_ROLE) {} +} diff --git a/contracts/access-control/AccessControlled.sol b/contracts/access-control/AccessControlled.sol index 6f2fc452..4e898ca9 100644 --- a/contracts/access-control/AccessControlled.sol +++ b/contracts/access-control/AccessControlled.sol @@ -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; @@ -41,7 +39,10 @@ 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); } @@ -49,11 +50,12 @@ abstract contract AccessControlled { * @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); } - -} \ No newline at end of file +} diff --git a/contracts/access-control/AccessControlledUpgradeable.sol b/contracts/access-control/AccessControlledUpgradeable.sol index 956664f6..3e676365 100644 --- a/contracts/access-control/AccessControlledUpgradeable.sol +++ b/contracts/access-control/AccessControlledUpgradeable.sol @@ -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); @@ -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. @@ -39,7 +38,9 @@ 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(); @@ -47,7 +48,11 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable { emit AccessControlUpdated(accessControl); } - function _getAccessControlledUpgradeable() private pure returns (AccessControlledStorage storage $) { + function _getAccessControlledUpgradeable() + private + pure + returns (AccessControlledStorage storage $) + { assembly { $.slot := _STORAGE_LOCATION } @@ -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); } @@ -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(); @@ -80,5 +90,4 @@ abstract contract AccessControlledUpgradeable is UUPSUpgradeable { AccessControlledStorage storage $ = _getAccessControlledUpgradeable(); return address($.accessControl); } - -} \ No newline at end of file +} diff --git a/contracts/access-control/ProtocolRoles.sol b/contracts/access-control/ProtocolRoles.sol index 35f781de..0be9725b 100644 --- a/contracts/access-control/ProtocolRoles.sol +++ b/contracts/access-control/ProtocolRoles.sol @@ -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"); \ No newline at end of file +bytes32 constant LICENSING_MANAGER_ROLE = keccak256("LICENSING_MANAGER_ROLE"); diff --git a/contracts/errors/General.sol b/contracts/errors/General.sol index 308b3631..a20ef42c 100644 --- a/contracts/errors/General.sol +++ b/contracts/errors/General.sol @@ -8,4 +8,4 @@ error UnsupportedInterface(string name); error Unauthorized(); error NonExistentID(uint256 id); error EmptyArray(); -error LengthMismatch(); \ No newline at end of file +error LengthMismatch(); diff --git a/contracts/interfaces/ICollectModule.sol b/contracts/interfaces/ICollectModule.sol index c8b836a5..1cbd3def 100644 --- a/contracts/interfaces/ICollectModule.sol +++ b/contracts/interfaces/ICollectModule.sol @@ -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. @@ -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); } diff --git a/contracts/interfaces/ICollectModuleEventsAndErrors.sol b/contracts/interfaces/ICollectModuleEventsAndErrors.sol index 8a2bc47e..107390b7 100644 --- a/contracts/interfaces/ICollectModuleEventsAndErrors.sol +++ b/contracts/interfaces/ICollectModuleEventsAndErrors.sol @@ -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(); @@ -21,5 +20,4 @@ interface ICollectModuleEventsAndErrors { /// @notice Collect module provided IP asset registry does not exist. error CollectModuleIPAssetRegistryNonExistent(); - } diff --git a/contracts/interfaces/ICollectNFT.sol b/contracts/interfaces/ICollectNFT.sol index 87fae861..850d59a9 100644 --- a/contracts/interfaces/ICollectNFT.sol +++ b/contracts/interfaces/ICollectNFT.sol @@ -10,13 +10,12 @@ 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; @@ -24,5 +23,8 @@ interface ICollectNFT is IERC721, ICollectNFTEventsAndErrors { /// @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); } diff --git a/contracts/interfaces/ICollectNFTEventsAndErrors.sol b/contracts/interfaces/ICollectNFTEventsAndErrors.sol index dd8ceb78..59d88fce 100644 --- a/contracts/interfaces/ICollectNFTEventsAndErrors.sol +++ b/contracts/interfaces/ICollectNFTEventsAndErrors.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.18; interface ICollectNFTEventsAndErrors { - /// @notice Collect NFT has already been initialized. error CollectNFTAlreadyInitialized(); @@ -14,5 +13,4 @@ interface ICollectNFTEventsAndErrors { /// @notice IP asset bound to the Collect NFT does not exist. error CollectNFTIPAssetNonExistent(); - } diff --git a/contracts/interfaces/ICollectPaymentModule.sol b/contracts/interfaces/ICollectPaymentModule.sol index 16a1a444..fee2a0ce 100644 --- a/contracts/interfaces/ICollectPaymentModule.sol +++ b/contracts/interfaces/ICollectPaymentModule.sol @@ -9,18 +9,25 @@ 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. @@ -28,10 +35,11 @@ interface ICollectPaymentModule is ICollectModule, ICollectPaymentModuleEventsAn /// 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); - } diff --git a/contracts/interfaces/ICollectPaymentModuleEventsAndErrors.sol b/contracts/interfaces/ICollectPaymentModuleEventsAndErrors.sol index 0b1caf50..80913a41 100644 --- a/contracts/interfaces/ICollectPaymentModuleEventsAndErrors.sol +++ b/contracts/interfaces/ICollectPaymentModuleEventsAndErrors.sol @@ -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(); @@ -35,5 +36,4 @@ interface ICollectPaymentModuleEventsAndErrors is ICollectModuleEventsAndErrors /// @notice The token provided for the payment collect is invalid. error CollectPaymentModuleTokenInvalid(); - } diff --git a/contracts/interfaces/IERC721Errors.sol b/contracts/interfaces/IERC721Errors.sol index 4a294e9b..9e80c847 100644 --- a/contracts/interfaces/IERC721Errors.sol +++ b/contracts/interfaces/IERC721Errors.sol @@ -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(); @@ -21,5 +20,4 @@ interface IERC721Errors { /// @notice NFT does not exist. error ERC721TokenNonExistent(); - } diff --git a/contracts/interfaces/IERC721Events.sol b/contracts/interfaces/IERC721Events.sol index 8be367d0..bb581866 100644 --- a/contracts/interfaces/IERC721Events.sol +++ b/contracts/interfaces/IERC721Events.sol @@ -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 + ); } diff --git a/contracts/ip-accounts/IERC6551Account.sol b/contracts/ip-accounts/IERC6551Account.sol index 0f1de74c..d1c3e1a1 100644 --- a/contracts/ip-accounts/IERC6551Account.sol +++ b/contracts/ip-accounts/IERC6551Account.sol @@ -25,11 +25,7 @@ interface IERC6551Account { function token() external view - returns ( - uint256 chainId, - address tokenContract, - uint256 tokenId - ); + returns (uint256 chainId, address tokenContract, uint256 tokenId); /** * @dev Returns a value that SHOULD be modified each time the account changes state @@ -54,8 +50,8 @@ interface IERC6551Account { * @param context Additional data used to determine whether the signer is valid * @return magicValue Magic value indicating whether the signer is valid */ - function isValidSigner(address signer, bytes calldata context) - external - view - returns (bytes4 magicValue); + function isValidSigner( + address signer, + bytes calldata context + ) external view returns (bytes4 magicValue); } diff --git a/contracts/ip-accounts/IIPAccount.sol b/contracts/ip-accounts/IIPAccount.sol index aac75513..5a7c05b7 100644 --- a/contracts/ip-accounts/IIPAccount.sol +++ b/contracts/ip-accounts/IIPAccount.sol @@ -1,11 +1,20 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; -import { IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; +import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import { IERC6551Account } from "./IERC6551Account.sol"; interface IIPAccount is IERC6551Account, IERC721Receiver, IERC1155Receiver { - function safeTransferFrom(address nftContract, address from, address to, uint256 tokenId) external; - function sendRoyaltyForDistribution(address distributor, address token) external; + function safeTransferFrom( + address nftContract, + address from, + address to, + uint256 tokenId + ) external; + + function sendRoyaltyForDistribution( + address distributor, + address token + ) external; } diff --git a/contracts/ip-accounts/IPAccountImpl.sol b/contracts/ip-accounts/IPAccountImpl.sol index 33934b4c..b3596313 100644 --- a/contracts/ip-accounts/IPAccountImpl.sol +++ b/contracts/ip-accounts/IPAccountImpl.sol @@ -15,11 +15,7 @@ import { IIPAccount } from "./IIPAccount.sol"; /** * @title IPAccountImpl */ -contract IPAccountImpl is - IERC165, - IIPAccount, - IERC1271 -{ +contract IPAccountImpl is IERC165, IIPAccount, IERC1271 { using SafeERC20 for IERC20; error CallerNotOwner(); @@ -32,7 +28,9 @@ contract IPAccountImpl is receive() external payable {} - function supportsInterface(bytes4 interfaceId) external pure returns (bool) { + function supportsInterface( + bytes4 interfaceId + ) external pure returns (bool) { return (interfaceId == type(IERC6551Account).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId || @@ -42,16 +40,7 @@ contract IPAccountImpl is /** * @dev {See IERC6551Account-token} */ - function token() - public - view - override - returns ( - uint256, - address, - uint256 - ) - { + function token() public view override returns (uint256, address, uint256) { bytes memory footer = new bytes(0x60); // 0x4d = 77 bytes (ERC-1167 Header, address, ERC-1167 Footer, salt) // 0x60 = 96 bytes (chainId, tokenContract, tokenId) @@ -69,12 +58,15 @@ contract IPAccountImpl is return abi.decode(footer, (uint256, address, uint256)); } - function isValidSignature(bytes32 hash, bytes memory signature) - external - view - returns (bytes4 magicValue) - { - bool isValid = SignatureChecker.isValidSignatureNow(owner(), hash, signature); + function isValidSignature( + bytes32 hash, + bytes memory signature + ) external view returns (bytes4 magicValue) { + bool isValid = SignatureChecker.isValidSignatureNow( + owner(), + hash, + signature + ); if (isValid) { return IERC1271.isValidSignature.selector; } @@ -85,7 +77,10 @@ contract IPAccountImpl is /** * @dev {See IERC6551Account-isValidSigner} */ - function isValidSigner(address signer, bytes calldata) external view returns (bytes4) { + function isValidSigner( + address signer, + bytes calldata + ) external view returns (bytes4) { if (_isValidSigner(signer)) { return IERC6551Account.isValidSigner.selector; } @@ -106,17 +101,27 @@ contract IPAccountImpl is /** * @dev {See IIPAccount-safeTransferFrom} */ - function safeTransferFrom(address nftContract, address from, address to, uint256 tokenId) external { - if (!_isValidSigner(msg.sender)) revert CallerNotOwner(); + function safeTransferFrom( + address nftContract, + address from, + address to, + uint256 tokenId + ) external { + if (!_isValidSigner(msg.sender)) revert CallerNotOwner(); ++state; IERC721(nftContract).safeTransferFrom(from, to, tokenId); } // TODO: authorization check that only the royaltyDistributor can call this function - function sendRoyaltyForDistribution(address distributor, address erc20) external { + function sendRoyaltyForDistribution( + address distributor, + address erc20 + ) external { IERC20(erc20).safeTransfer( distributor, - IERC20(erc20).balanceOf(address(this)) + withdrawn[erc20] - entitled[erc20] + IERC20(erc20).balanceOf(address(this)) + + withdrawn[erc20] - + entitled[erc20] ); } diff --git a/contracts/ip-accounts/IPAccountRegistry.sol b/contracts/ip-accounts/IPAccountRegistry.sol index 0cd672ae..1c029bae 100644 --- a/contracts/ip-accounts/IPAccountRegistry.sol +++ b/contracts/ip-accounts/IPAccountRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; -import { Create2} from "@openzeppelin/contracts/utils/Create2.sol"; +import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol"; import { IIPAccountRegistry } from "./IIPAccountRegistry.sol"; contract IPAccountRegistry is IIPAccountRegistry { @@ -28,11 +28,21 @@ contract IPAccountRegistry is IIPAccountRegistry { IP_ACCOUNT_SALT ); - address _account = Create2.computeAddress(bytes32(IP_ACCOUNT_SALT), keccak256(code)); + address _account = Create2.computeAddress( + bytes32(IP_ACCOUNT_SALT), + keccak256(code) + ); if (_account.code.length != 0) return _account; - emit AccountCreated(_account, IP_ACCOUNT_IMPL, chainId, tokenContract, tokenId, IP_ACCOUNT_SALT); + emit AccountCreated( + _account, + IP_ACCOUNT_IMPL, + chainId, + tokenContract, + tokenId, + IP_ACCOUNT_SALT + ); _account = Create2.deploy(0, bytes32(IP_ACCOUNT_SALT), code); @@ -74,7 +84,6 @@ contract IPAccountRegistry is IIPAccountRegistry { uint256 tokenId_, uint256 salt_ ) internal pure returns (bytes memory) { - return // Proxy that delegate call to IPAccountProxy // | 0x00000000 36 calldatasize cds // | 0x00000001 3d returndatasize 0 cds @@ -100,11 +109,12 @@ contract IPAccountRegistry is IIPAccountRegistry { // | | 0x0000002a fd revert // | `-> 0x0000002b 5b jumpdest 0 rds // \ 0x0000002c f3 return - abi.encodePacked( - hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73", - implementation_, - hex"5af43d82803e903d91602b57fd5bf3", - abi.encode(salt_, chainId_, tokenContract_, tokenId_) - ); + return + abi.encodePacked( + hex"3d60ad80600a3d3981f3363d3d373d3d3d363d73", + implementation_, + hex"5af43d82803e903d91602b57fd5bf3", + abi.encode(salt_, chainId_, tokenContract_, tokenId_) + ); } } diff --git a/contracts/ip-assets/IIPAssetRegistry.sol b/contracts/ip-assets/IIPAssetRegistry.sol index 37586f1c..0cdc1575 100644 --- a/contracts/ip-assets/IIPAssetRegistry.sol +++ b/contracts/ip-assets/IIPAssetRegistry.sol @@ -23,5 +23,4 @@ interface IIPAssetRegistry is address to, uint256 parentIpAssetId ) external returns (uint256); - } diff --git a/contracts/ip-assets/IPAssetRegistry.sol b/contracts/ip-assets/IPAssetRegistry.sol index 3fd435d5..f78e4817 100644 --- a/contracts/ip-assets/IPAssetRegistry.sol +++ b/contracts/ip-assets/IPAssetRegistry.sol @@ -9,7 +9,7 @@ import { IPAsset } from "contracts/IPAsset.sol"; import { InitCollectParams } from "contracts/lib/CollectModuleStructs.sol"; import { IIPAssetEventEmitter } from "./events/IIPAssetEventEmitter.sol"; import { IPAssetDataManager } from "./storage/IPAssetDataManager.sol"; -import { ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; +import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import { IERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; import { MulticallUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol"; import { RightsManager } from "../modules/licensing/RightsManager.sol"; @@ -45,8 +45,8 @@ contract IPAssetRegistry is address _eventEmitter, address _licensingModule, address _franchiseRegistry, - address _collectModule) - RightsManager(_franchiseRegistry) { + address _collectModule + ) RightsManager(_franchiseRegistry) { // TODO: should Franchise owner be able to change this? if (_eventEmitter == address(0)) revert ZeroAddress(); EVENT_EMITTER = IIPAssetEventEmitter(_eventEmitter); @@ -109,21 +109,17 @@ contract IPAssetRegistry is address to, uint256 parentIpAssetId, bytes calldata collectData - ) - public - returns (uint256) - { + ) public returns (uint256) { if (ipAssetType == IPAsset.UNDEFINED) revert InvalidBlockType(); uint256 ipAssetId = _mintBlock(to, ipAssetType); _writeIPAsset(ipAssetId, name, _description, mediaUrl); IPAssetRegistryStorage storage $ = _getIPAssetRegistryStorage(); uint256 _franchiseId = $.franchiseId; EVENT_EMITTER.emitIPAssetCreation(_franchiseId, ipAssetId); - // Non commercial - ILicensingModule.FranchiseConfig memory config = LICENSING_MODULE.getFranchiseConfig(_franchiseId); + ILicensingModule.FranchiseConfig memory config = LICENSING_MODULE + .getFranchiseConfig(_franchiseId); if (config.revoker == address(0)) revert LicensingNotConfigured(); - _setNonCommercialRights( ipAssetId, parentIpAssetId, @@ -147,12 +143,14 @@ contract IPAssetRegistry is ); } // TODO: Add collect NFT impl and data overrides - COLLECT_MODULE.initCollect(InitCollectParams({ - franchiseId: _franchiseId, - ipAssetId: ipAssetId, - collectNFTImpl: address(0), // Default collect module NFT impl - data: collectData - })); + COLLECT_MODULE.initCollect( + InitCollectParams({ + franchiseId: _franchiseId, + ipAssetId: ipAssetId, + collectNFTImpl: address(0), // Default collect module NFT impl + data: collectData + }) + ); return ipAssetId; } @@ -174,9 +172,9 @@ contract IPAssetRegistry is ILicensingModule.IpAssetConfig memory config, TermsProcessorConfig memory terms ) internal { - uint256 parentLicenseId = parentIpAssetId == 0 ? - config.franchiseRootLicenseId : - getLicenseIdByTokenId(parentIpAssetId, false); + uint256 parentLicenseId = parentIpAssetId == 0 + ? config.franchiseRootLicenseId + : getLicenseIdByTokenId(parentIpAssetId, false); _createLicense( ipAssetId, parentLicenseId, @@ -209,9 +207,9 @@ contract IPAssetRegistry is ILicensingModule.IpAssetConfig memory config, TermsProcessorConfig memory terms ) internal { - uint256 parentLicenseId = parentIpAssetId == _ROOT_IP_ASSET ? - config.franchiseRootLicenseId : - getLicenseIdByTokenId(parentIpAssetId, true); + uint256 parentLicenseId = parentIpAssetId == _ROOT_IP_ASSET + ? config.franchiseRootLicenseId + : getLicenseIdByTokenId(parentIpAssetId, true); _createLicense( ipAssetId, parentLicenseId, @@ -279,5 +277,4 @@ contract IPAssetRegistry is interfaceId == type(IIPAssetRegistry).interfaceId || super.supportsInterface(interfaceId); } - } diff --git a/contracts/ip-assets/IPAssetRegistryFactory.sol b/contracts/ip-assets/IPAssetRegistryFactory.sol index 936e2889..dadb3446 100644 --- a/contracts/ip-assets/IPAssetRegistryFactory.sol +++ b/contracts/ip-assets/IPAssetRegistryFactory.sol @@ -10,13 +10,17 @@ import { LicenseRegistry } from "../modules/licensing/LicenseRegistry.sol"; import { RevertingIPAssetRegistry } from "contracts/utils/RevertingIPAssetRegistry.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; +import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; contract IPAssetRegistryFactory is Ownable { using ERC165Checker for address; - event FranchiseCreated(address indexed collection, string name, string indexed symbol); + event FranchiseCreated( + address indexed collection, + string name, + string indexed symbol + ); event FranchisesUpgraded(address indexed newImplementation, string version); UpgradeableBeacon public immutable BEACON; @@ -33,7 +37,9 @@ contract IPAssetRegistryFactory is Ownable { string calldata description ) external returns (address) { bytes memory data = abi.encodeWithSelector( - bytes4(keccak256(bytes("initialize(uint256,string,string,string)"))), + bytes4( + keccak256(bytes("initialize(uint256,string,string,string)")) + ), franchiseId, name, symbol, @@ -46,15 +52,22 @@ contract IPAssetRegistryFactory is Ownable { string.concat("sl", symbol) ); IPAssetRegistry(proxy).setLicenseRegistry(address(licenseRegistry)); - emit FranchiseCreated(proxy, name, symbol); return proxy; } function upgradeFranchises(address newImplementation) external onlyOwner { - if (!newImplementation.supportsInterface(type(IIPAssetRegistry).interfaceId)) + if ( + !newImplementation.supportsInterface( + type(IIPAssetRegistry).interfaceId + ) + ) { revert UnsupportedInterface("IIPAssetRegistry"); + } BEACON.upgradeTo(newImplementation); - emit FranchisesUpgraded(address(newImplementation), IVersioned(newImplementation).version()); + emit FranchisesUpgraded( + address(newImplementation), + IVersioned(newImplementation).version() + ); } } diff --git a/contracts/ip-assets/LibIPAssetId.sol b/contracts/ip-assets/LibIPAssetId.sol index 1885ee04..ca943acb 100644 --- a/contracts/ip-assets/LibIPAssetId.sol +++ b/contracts/ip-assets/LibIPAssetId.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.13; import { IPAsset } from "contracts/IPAsset.sol"; library LibIPAssetId { - error InvalidIPAsset(IPAsset ipAsset); uint256 private constant _ID_RANGE = 10 ** 12; @@ -22,8 +21,8 @@ library LibIPAssetId { function _ipAssetTypeFor(uint256 id) internal pure returns (IPAsset) { // End of _ID_RANGE is zero (undefined) for each IPAsset // Also, we don't support ids higher than the last IPAsset enum item - if (id % _ID_RANGE == 0 || id > _ID_RANGE * (uint256(IPAsset.ITEM))) return IPAsset.UNDEFINED; + if (id % _ID_RANGE == 0 || id > _ID_RANGE * (uint256(IPAsset.ITEM))) + return IPAsset.UNDEFINED; return IPAsset((id / _ID_RANGE) + 1); } - -} \ No newline at end of file +} diff --git a/contracts/lib/CollectModuleStructs.sol b/contracts/lib/CollectModuleStructs.sol index 7e13a84b..9ca68481 100644 --- a/contracts/lib/CollectModuleStructs.sol +++ b/contracts/lib/CollectModuleStructs.sol @@ -3,26 +3,26 @@ pragma solidity ^0.8.18; /// @notice Parameters passed to initialize a collect module for an IP asset. struct InitCollectParams { - uint256 franchiseId; // The id of the franchise tied to the IP asset. - uint256 ipAssetId; // The id of the IP asset under the franchise. - address collectNFTImpl; // The address of the collect NFT impl to use. - bytes data; // Additional data to be used for initialization. + uint256 franchiseId; // The id of the franchise tied to the IP asset. + uint256 ipAssetId; // The id of the IP asset under the franchise. + address collectNFTImpl; // The address of the collect NFT impl to use. + bytes data; // Additional data to be used for initialization. } /// @notice Parameters passed for collect processing for an IP asset. struct CollectParams { - uint256 franchiseId; // The id of the franchise tied to the IP asset. - uint256 ipAssetId; // The id of the IP asset being collected. - address collector; // The address designated for NFT collection. - bytes collectData; // Additional data passed for module collection. - bytes collectNFTInitData; // Additional data passed for NFT initialization. - bytes collectNFTData; // Additional data passed for NFT collection. + uint256 franchiseId; // The id of the franchise tied to the IP asset. + uint256 ipAssetId; // The id of the IP asset being collected. + address collector; // The address designated for NFT collection. + bytes collectData; // Additional data passed for module collection. + bytes collectNFTInitData; // Additional data passed for NFT initialization. + bytes collectNFTData; // Additional data passed for NFT collection. } /// @notice Collect module settings saved for a franchise IP asset. /// @dev A zero address `collectNFTImpl` means to use a module default NFT impl. struct CollectInfo { - bool initialized; // Whether the collect module was initialized. - address collectNFT; // The collect NFT that an IP asset is bound to. + bool initialized; // Whether the collect module was initialized. + address collectNFT; // The collect NFT that an IP asset is bound to. address collectNFTImpl; // The collect NFT impl address being used. } diff --git a/contracts/lib/CollectNFTStructs.sol b/contracts/lib/CollectNFTStructs.sol index 02c262b0..e7409bab 100644 --- a/contracts/lib/CollectNFTStructs.sol +++ b/contracts/lib/CollectNFTStructs.sol @@ -4,6 +4,6 @@ pragma solidity ^0.8.18; /// @notice Parameters passed to initialize a collect NFT. struct InitCollectNFTParams { address ipAssetRegistry; // Address of the registry of the bound IP asset. - uint256 ipAssetId; // The id of the IP asset bound to the collect NFT. - bytes data; // Additional data used for NFT initialization. + uint256 ipAssetId; // The id of the IP asset bound to the collect NFT. + bytes data; // Additional data used for NFT initialization. } diff --git a/contracts/lib/CollectPaymentModuleEnums.sol b/contracts/lib/CollectPaymentModuleEnums.sol index b5e50872..5d814ca7 100644 --- a/contracts/lib/CollectPaymentModuleEnums.sol +++ b/contracts/lib/CollectPaymentModuleEnums.sol @@ -5,6 +5,5 @@ pragma solidity ^0.8.18; /// TODO: Add ERC-721 and ERC-1155 as configurable payment types. enum PaymentType { NATIVE, // Utilize the native token (e.g. ETH on Ethereum or OP on Optimism) - ERC20 // Utilize an ERC-20 token + ERC20 // Utilize an ERC-20 token } - diff --git a/contracts/lib/CollectPaymentModuleStructs.sol b/contracts/lib/CollectPaymentModuleStructs.sol index b03939f8..06b8797c 100644 --- a/contracts/lib/CollectPaymentModuleStructs.sol +++ b/contracts/lib/CollectPaymentModuleStructs.sol @@ -5,16 +5,16 @@ import { PaymentType } from "./CollectPaymentModuleEnums.sol"; /// @notice Payment collect module settings saved for a franchise IP asset. struct CollectPaymentInfo { - address paymentToken; // The payment token address (if not native). - PaymentType paymentType; // The type of payment being made. - uint256 paymentAmount; // The required amount of the payment token. + address paymentToken; // The payment token address (if not native). + PaymentType paymentType; // The type of payment being made. + uint256 paymentAmount; // The required amount of the payment token. address payable paymentRecipient; // Payment receipient address. } /// @notice Parameters passed for collect payment processing for an IP asset. /// TODO: Add a signature field to accept signature-relayed collects. struct CollectPaymentParams { - address paymentToken; // The payment token address (if not native). - PaymentType paymentType; // The type of payment being made. - uint256 paymentAmount; // The required amount of the payment token. + address paymentToken; // The payment token address (if not native). + PaymentType paymentType; // The type of payment being made. + uint256 paymentAmount; // The required amount of the payment token. }