Skip to content

Commit

Permalink
chore: marks LensModuleRegistrant.registerModule() as ownerOnly
Browse files Browse the repository at this point in the history
TipActionModule now implements Ownable directly and calls the super constructor. This involved removing the constructor from LensModuleMetadata
  • Loading branch information
iPaulPro committed Jan 2, 2024
1 parent fa561d8 commit fd3f3f9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
7 changes: 4 additions & 3 deletions packages/hardhat/contracts/TipActionModule.sol
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -51,8 +51,9 @@ contract TipActionModule is
address hub,
address moduleRegistry
)
Ownable()
HubRestricted(hub)
LensModuleMetadata(msg.sender)
LensModuleMetadata()
LensModuleRegistrant(moduleRegistry)
{}

Expand Down
4 changes: 0 additions & 4 deletions packages/hardhat/contracts/base/LensModuleMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 12 additions & 2 deletions packages/hardhat/contracts/base/LensModuleRegistrant.sol
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit fd3f3f9

Please sign in to comment.