From f8684d94bc854e50d3327d8b45c10166e9abbcab Mon Sep 17 00:00:00 2001 From: Daniel Simon Date: Thu, 2 Jan 2025 14:03:13 +0700 Subject: [PATCH] refactor: expose constant that can be returned by public getter --- src/BribeInitiative.sol | 2 +- src/Governance.sol | 4 +--- src/interfaces/IGovernance.sol | 6 +++++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/BribeInitiative.sol b/src/BribeInitiative.sol index b115c23..b4d4637 100644 --- a/src/BribeInitiative.sol +++ b/src/BribeInitiative.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.24; import {IERC20} from "openzeppelin/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import {IGovernance} from "./interfaces/IGovernance.sol"; +import {IGovernance, UNREGISTERED_INITIATIVE} from "./interfaces/IGovernance.sol"; import {IInitiative} from "./interfaces/IInitiative.sol"; import {IBribeInitiative} from "./interfaces/IBribeInitiative.sol"; diff --git a/src/Governance.sol b/src/Governance.sol index b2dbf1d..9d656f0 100644 --- a/src/Governance.sol +++ b/src/Governance.sol @@ -5,7 +5,7 @@ import {IERC20} from "openzeppelin/contracts/interfaces/IERC20.sol"; import {SafeERC20} from "openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ReentrancyGuard} from "openzeppelin/contracts/utils/ReentrancyGuard.sol"; -import {IGovernance} from "./interfaces/IGovernance.sol"; +import {IGovernance, UNREGISTERED_INITIATIVE} from "./interfaces/IGovernance.sol"; import {IInitiative} from "./interfaces/IInitiative.sol"; import {ILQTYStaking} from "./interfaces/ILQTYStaking.sol"; @@ -73,8 +73,6 @@ contract Governance is MultiDelegateCall, UserProxyFactory, ReentrancyGuard, Own /// @inheritdoc IGovernance mapping(address => uint256) public override registeredInitiatives; - uint256 constant UNREGISTERED_INITIATIVE = type(uint256).max; - constructor( address _lqty, address _lusd, diff --git a/src/interfaces/IGovernance.sol b/src/interfaces/IGovernance.sol index 6a28608..1169178 100644 --- a/src/interfaces/IGovernance.sol +++ b/src/interfaces/IGovernance.sol @@ -7,6 +7,8 @@ import {ILQTYStaking} from "./ILQTYStaking.sol"; import {PermitParams} from "../utils/Types.sol"; +uint256 constant UNREGISTERED_INITIATIVE = type(uint256).max; + interface IGovernance { /// @notice Emitted when a user deposits LQTY /// @param user The account depositing LQTY @@ -216,7 +218,9 @@ interface IGovernance { /// @notice Returns when an initiative was registered /// @param _initiative Address of the initiative - /// @return atEpoch Epoch at which the initiative was registered + /// @return atEpoch If `_initiative` is an active initiative, returns the epoch at which it was registered. + /// If `_initiative` hasn't been registered, returns 0. + /// If `_initiative` has been unregistered, returns `UNREGISTERED_INITIATIVE`. function registeredInitiatives(address _initiative) external view returns (uint256 atEpoch); /*//////////////////////////////////////////////////////////////