From fd3f3f942000198847066913ac48e7eeb93013af Mon Sep 17 00:00:00 2001 From: Paul Burke Date: Tue, 2 Jan 2024 06:33:52 -0500 Subject: [PATCH] chore: marks LensModuleRegistrant.registerModule() as ownerOnly TipActionModule now implements Ownable directly and calls the super constructor. This involved removing the constructor from LensModuleMetadata --- packages/hardhat/contracts/TipActionModule.sol | 7 ++++--- .../hardhat/contracts/base/LensModuleMetadata.sol | 4 ---- .../contracts/base/LensModuleRegistrant.sol | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/hardhat/contracts/TipActionModule.sol b/packages/hardhat/contracts/TipActionModule.sol index cbecf42..75b15d9 100644 --- a/packages/hardhat/contracts/TipActionModule.sol +++ b/packages/hardhat/contracts/TipActionModule.sol @@ -1,21 +1,21 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.19; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {Types} from "./libraries/Types.sol"; import {IPublicationActionModule} from "./interfaces/IPublicationActionModule.sol"; import {HubRestricted} from "./base/HubRestricted.sol"; -import {LensModule} from "./base/LensModule.sol"; import {IModuleRegistry} from "./interfaces/IModuleRegistry.sol"; import {LensModuleMetadata} from "./base/LensModuleMetadata.sol"; import {LensModuleRegistrant} from "./base/LensModuleRegistrant.sol"; contract TipActionModule is + Ownable, IPublicationActionModule, HubRestricted, - LensModule, LensModuleMetadata, LensModuleRegistrant, ReentrancyGuard @@ -51,8 +51,9 @@ contract TipActionModule is address hub, address moduleRegistry ) + Ownable() HubRestricted(hub) - LensModuleMetadata(msg.sender) + LensModuleMetadata() LensModuleRegistrant(moduleRegistry) {} diff --git a/packages/hardhat/contracts/base/LensModuleMetadata.sol b/packages/hardhat/contracts/base/LensModuleMetadata.sol index 899b388..2351049 100644 --- a/packages/hardhat/contracts/base/LensModuleMetadata.sol +++ b/packages/hardhat/contracts/base/LensModuleMetadata.sol @@ -7,10 +7,6 @@ import {LensModule} from "./LensModule.sol"; abstract contract LensModuleMetadata is LensModule, Ownable { string public metadataURI; - constructor(address owner_) Ownable() { - _transferOwnership(owner_); - } - function setModuleMetadataURI( string memory _metadataURI ) external onlyOwner { diff --git a/packages/hardhat/contracts/base/LensModuleRegistrant.sol b/packages/hardhat/contracts/base/LensModuleRegistrant.sol index 055be3c..f238bfa 100644 --- a/packages/hardhat/contracts/base/LensModuleRegistrant.sol +++ b/packages/hardhat/contracts/base/LensModuleRegistrant.sol @@ -1,11 +1,19 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ILensModuleRegistrant} from "../interfaces/IModuleRegistrant.sol"; import {IModuleRegistry} from "../interfaces/IModuleRegistry.sol"; import {Types} from "../libraries/Types.sol"; -abstract contract LensModuleRegistrant is ILensModuleRegistrant { +/** + * @title LensModuleRegistrant + * @author Paul Burke + * + * @notice This abstract contract adds a public `MODULE_REGISTRY` immutable field, and provides functions + * for registering a module in the registry and checking if a module is registered. + */ +abstract contract LensModuleRegistrant is ILensModuleRegistrant, Ownable { event ModuleRegistered(); error ModuleAlreadyRegistered(); @@ -16,11 +24,13 @@ abstract contract LensModuleRegistrant is ILensModuleRegistrant { MODULE_REGISTRY = IModuleRegistry(moduleRegistry); } + /// @inheritdoc ILensModuleRegistrant function isRegistered() public view override returns (bool) { return MODULE_REGISTRY.isModuleRegistered(address(this)); } - function registerModule() external override returns (bool) { + /// @inheritdoc ILensModuleRegistrant + function registerModule() external override onlyOwner returns (bool) { if (isRegistered()) { revert ModuleAlreadyRegistered(); }