From 20b78ec00f008d28da050a62f0125f02f48fc05d Mon Sep 17 00:00:00 2001 From: Raul Date: Fri, 12 Apr 2024 20:24:23 -0300 Subject: [PATCH] fixes --- contracts/LicenseToken.sol | 3 +++ contracts/access/AccessController.sol | 3 +++ contracts/lib/Errors.sol | 15 +++++++++++++++ contracts/modules/dispute/DisputeModule.sol | 5 +++-- .../dispute/policies/ArbitrationPolicySP.sol | 5 +++-- contracts/modules/licensing/LicensingModule.sol | 3 +++ contracts/modules/royalty/RoyaltyModule.sol | 4 +++- contracts/registries/IPAssetRegistry.sol | 7 ++++++- contracts/registries/LicenseRegistry.sol | 3 +++ contracts/registries/ModuleRegistry.sol | 3 +++ 10 files changed, 45 insertions(+), 6 deletions(-) diff --git a/contracts/LicenseToken.sol b/contracts/LicenseToken.sol index ae5554e73..598c45cd9 100644 --- a/contracts/LicenseToken.sol +++ b/contracts/LicenseToken.sol @@ -51,6 +51,9 @@ contract LicenseToken is ILicenseToken, ERC721EnumerableUpgradeable, AccessManag /// @dev Initializes the LicenseToken contract function initialize(address accessManager, string memory imageUrl) public initializer { __ERC721_init("Programmable IP License Token", "PILicenseToken"); + if (accessManager == address(0)) { + revert Errors.LicenseToken__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __UUPSUpgradeable_init(); _getLicenseTokenStorage().imageUrl = imageUrl; diff --git a/contracts/access/AccessController.sol b/contracts/access/AccessController.sol index dbcaa14d1..5ba0b29e4 100644 --- a/contracts/access/AccessController.sol +++ b/contracts/access/AccessController.sol @@ -57,6 +57,9 @@ contract AccessController is IAccessController, AccessManagedUpgradeable, UUPSUp /// @notice initializer for this implementation contract /// @param accessManager The address of the protocol admin roles contract function initialize(address accessManager) external initializer { + if (accessManager == address(0)) { + revert Errors.AccessController__ZeroAccessManager(); + } __AccessManaged_init(accessManager); } diff --git a/contracts/lib/Errors.sol b/contracts/lib/Errors.sol index dd8efdf52..65b021f39 100644 --- a/contracts/lib/Errors.sol +++ b/contracts/lib/Errors.sol @@ -29,6 +29,9 @@ library Errors { // IPAssetRegistry // //////////////////////////////////////////////////////////////////////////// + /// @notice zero address provided for access manager in initializer. + error IPAssetRegistry__ZeroAccessManager(); + /// @notice The IP asset has already been registered. error IPAssetRegistry__AlreadyRegistered(); @@ -110,6 +113,7 @@ library Errors { // LicenseRegistry // //////////////////////////////////////////////////////////////////////////// + error LicenseRegistry__ZeroAccessManager(); error LicenseRegistry__CallerNotLicensingModule(); error LicenseRegistry__ZeroLicensingModule(); error LicensingModule__CallerNotLicenseRegistry(); @@ -140,6 +144,7 @@ library Errors { error LicenseToken__CallerNotLicensingModule(); error LicenseToken__ZeroLicensingModule(); error LicenseToken__ZeroDisputeModule(); + error LicenseToken__ZeroAccessManager(); error LicenseToken__RevokedLicense(uint256 tokenId); error LicenseToken__NotTransferable(); error LicenseToken__LicenseTokenExpired(uint256 tokenId, uint256 expiredAt, uint256 currentTimestamp); @@ -152,6 +157,7 @@ library Errors { // LicensingModule // //////////////////////////////////////////////////////////////////////////// + error LicensingModule__ZeroAccessManager(); error LicensingModule__IpAlreadyLinked(); error LicensingModule__PolicyAlreadySetForIpId(); error LicensingModule__FrameworkNotFound(); @@ -222,6 +228,7 @@ library Errors { // Dispute Module // //////////////////////////////////////////////////////////////////////////// + error DisputeModule__ZeroAccessManager(); error DisputeModule__ZeroArbitrationPolicy(); error DisputeModule__ZeroArbitrationRelayer(); error DisputeModule__ZeroDisputeTag(); @@ -242,6 +249,11 @@ library Errors { error DisputeModule__ZeroController(); error DisputeModule__ZeroAccessManager(); + //////////////////////////////////////////////////////////////////////////// + // ArbitrationPolicy SP // + //////////////////////////////////////////////////////////////////////////// + + error ArbitrationPolicySP__ZeroAccessManager(); error ArbitrationPolicySP__ZeroDisputeModule(); error ArbitrationPolicySP__ZeroPaymentToken(); error ArbitrationPolicySP__NotDisputeModule(); @@ -251,6 +263,7 @@ library Errors { // Royalty Module // //////////////////////////////////////////////////////////////////////////// + error RoyaltyModule__ZeroAccessManager(); error RoyaltyModule__ZeroRoyaltyPolicy(); error RoyaltyModule__NotWhitelistedRoyaltyPolicy(); error RoyaltyModule__ZeroRoyaltyToken(); @@ -294,6 +307,7 @@ library Errors { // ModuleRegistry // //////////////////////////////////////////////////////////////////////////// + error ModuleRegistry__ZeroAccessManager(); error ModuleRegistry__ModuleAddressZeroAddress(); error ModuleRegistry__ModuleAddressNotContract(); error ModuleRegistry__ModuleAlreadyRegistered(); @@ -311,6 +325,7 @@ library Errors { // AccessController // //////////////////////////////////////////////////////////////////////////// + error AccessController__ZeroAccessManager(); error AccessController__IPAccountIsZeroAddress(); error AccessController__IPAccountIsNotValid(address ipAccount); error AccessController__SignerIsZeroAddress(); diff --git a/contracts/modules/dispute/DisputeModule.sol b/contracts/modules/dispute/DisputeModule.sol index f4bc1ddba..70433cf8e 100644 --- a/contracts/modules/dispute/DisputeModule.sol +++ b/contracts/modules/dispute/DisputeModule.sol @@ -93,8 +93,9 @@ contract DisputeModule is /// @notice Initializer for this implementation contract /// @param accessManager The address of the protocol admin roles contract function initialize(address accessManager) external initializer { - if (accessManager == address(0)) revert Errors.DisputeModule__ZeroAccessManager(); - + if (accessManager == address(0)) { + revert Errors.DisputeModule__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __ReentrancyGuard_init(); __UUPSUpgradeable_init(); diff --git a/contracts/modules/dispute/policies/ArbitrationPolicySP.sol b/contracts/modules/dispute/policies/ArbitrationPolicySP.sol index 666f4c8f7..d5c93074e 100644 --- a/contracts/modules/dispute/policies/ArbitrationPolicySP.sol +++ b/contracts/modules/dispute/policies/ArbitrationPolicySP.sol @@ -52,8 +52,9 @@ contract ArbitrationPolicySP is IArbitrationPolicy, AccessManagedUpgradeable, UU /// @notice initializer for this implementation contract /// @param accessManager The address of the protocol admin roles contract function initialize(address accessManager) public initializer { - if (accessManager == address(0)) revert Errors.ArbitrationPolicySP__ZeroAccessManager(); - + if (accessManager == address(0)) { + revert Errors.ArbitrationPolicySP__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __UUPSUpgradeable_init(); } diff --git a/contracts/modules/licensing/LicensingModule.sol b/contracts/modules/licensing/LicensingModule.sol index 503f0288c..293c0a15a 100644 --- a/contracts/modules/licensing/LicensingModule.sol +++ b/contracts/modules/licensing/LicensingModule.sol @@ -99,6 +99,9 @@ contract LicensingModule is function initialize(address accessManager) public initializer { __ReentrancyGuard_init(); __UUPSUpgradeable_init(); + if (accessManager == address(0)) { + revert Errors.LicensingModule__ZeroAccessManager(); + } __AccessManaged_init(accessManager); } diff --git a/contracts/modules/royalty/RoyaltyModule.sol b/contracts/modules/royalty/RoyaltyModule.sol index 294feccfe..df328641a 100644 --- a/contracts/modules/royalty/RoyaltyModule.sol +++ b/contracts/modules/royalty/RoyaltyModule.sol @@ -58,7 +58,9 @@ contract RoyaltyModule is /// @notice Initializer for this implementation contract /// @param accessManager The address of the protocol admin roles contract function initialize(address accessManager) external initializer { - if (accessManager == address(0)) revert Errors.RoyaltyModule__ZeroAccessManager(); + if (accessManager == address(0)) { + revert Errors.RoyaltyModule__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __ReentrancyGuard_init(); __UUPSUpgradeable_init(); diff --git a/contracts/registries/IPAssetRegistry.sol b/contracts/registries/IPAssetRegistry.sol index a9ce6a64f..f69836dd9 100644 --- a/contracts/registries/IPAssetRegistry.sol +++ b/contracts/registries/IPAssetRegistry.sol @@ -41,11 +41,16 @@ contract IPAssetRegistry is IIPAssetRegistry, IPAccountRegistry, AccessManagedUp 0x987c61809af5a42943abd137c7acff8426aab6f7a1f5c967a03d1d718ba5cf00; /// @custom:oz-upgrades-unsafe-allow constructor - constructor(address erc6551Registry, address ipAccountImpl) IPAccountRegistry(erc6551Registry, ipAccountImpl) {} + constructor(address erc6551Registry, address ipAccountImpl) IPAccountRegistry(erc6551Registry, ipAccountImpl) { + _disableInitializers(); + } /// @notice Initializes the IPAssetRegistry contract. /// @param accessManager The address of the access manager. function initialize(address accessManager) public initializer { + if (accessManager == address(0)) { + revert Errors.IPAssetRegistry__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __UUPSUpgradeable_init(); } diff --git a/contracts/registries/LicenseRegistry.sol b/contracts/registries/LicenseRegistry.sol index 2701570f0..f56d9ad8e 100644 --- a/contracts/registries/LicenseRegistry.sol +++ b/contracts/registries/LicenseRegistry.sol @@ -80,6 +80,9 @@ contract LicenseRegistry is ILicenseRegistry, AccessManagedUpgradeable, UUPSUpgr /// @notice initializer for this implementation contract /// @param accessManager The address of the protocol admin roles contract function initialize(address accessManager) public initializer { + if (accessManager == address(0)) { + revert Errors.LicenseRegistry__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __UUPSUpgradeable_init(); } diff --git a/contracts/registries/ModuleRegistry.sol b/contracts/registries/ModuleRegistry.sol index ecdb67cfa..ec20cd6bf 100644 --- a/contracts/registries/ModuleRegistry.sol +++ b/contracts/registries/ModuleRegistry.sol @@ -41,6 +41,9 @@ contract ModuleRegistry is IModuleRegistry, AccessManagedUpgradeable, UUPSUpgrad /// @notice initializer for this implementation contract /// @param accessManager The address of the governance. function initialize(address accessManager) public initializer { + if (accessManager == address(0)) { + revert Errors.ModuleRegistry__ZeroAccessManager(); + } __AccessManaged_init(accessManager); __UUPSUpgradeable_init();