Skip to content

Commit

Permalink
missing zeroaddress check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramarti committed Apr 13, 2024
1 parent 514a2a1 commit 8420118
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/LicenseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ 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();
}
__ERC721_init("Programmable IP License Token", "PILicenseToken");
__AccessManaged_init(accessManager);
__UUPSUpgradeable_init();
_getLicenseTokenStorage().imageUrl = imageUrl;
Expand Down
6 changes: 6 additions & 0 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ library Errors {
address licensorIpId
);

////////////////////////////////////////////////////////////////////////////
// PILicenseTemplate //
////////////////////////////////////////////////////////////////////////////

error PILicenseTemplate__ZeroAccessManager();

////////////////////////////////////////////////////////////////////////////
// LicensorApprovalChecker //
////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions contracts/modules/licensing/LicensingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ contract LicensingModule is
/// @notice initializer for this implementation contract
/// @param accessManager The address of the protocol admin roles contract
function initialize(address accessManager) public initializer {
__ReentrancyGuard_init();
__UUPSUpgradeable_init();
if (accessManager == address(0)) {
revert Errors.LicensingModule__ZeroAccessManager();
}
__ReentrancyGuard_init();
__UUPSUpgradeable_init();
__AccessManaged_init(accessManager);
}

Expand Down
4 changes: 4 additions & 0 deletions contracts/modules/licensing/PILicenseTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

// contracts
import { Errors } from "../../lib/Errors.sol";
import { IHookModule } from "../../interfaces/modules/base/IHookModule.sol";
import { ILicenseRegistry } from "../../interfaces/registries/ILicenseRegistry.sol";
import { IRoyaltyModule } from "../../interfaces/modules/royalty/IRoyaltyModule.sol";
Expand Down Expand Up @@ -66,6 +67,9 @@ contract PILicenseTemplate is
/// @param name The name of the license template
/// @param metadataURI The URL to the off chain metadata
function initialize(address accessManager, string memory name, string memory metadataURI) external initializer {
if (accessManager == address(0)) {
revert Errors.PILicenseTemplate__ZeroAccessManager();
}
__BaseLicenseTemplate_init(name, metadataURI);
__AccessManaged_init(accessManager);
__ReentrancyGuard_init();
Expand Down

0 comments on commit 8420118

Please sign in to comment.