Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: add interfaces for governance contracts #11878

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"name": "governanceToken",
"outputs": [
{
"internalType": "contract GovernanceToken",
"internalType": "contract IGovernanceToken",
"name": "",
"type": "address"
}
Expand Down
9 changes: 6 additions & 3 deletions packages/contracts-bedrock/src/governance/MintManager.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

// Contracts
import "@openzeppelin/contracts/access/Ownable.sol";
import "./GovernanceToken.sol";

// Interfaces
import { IGovernanceToken } from "src/governance/interfaces/IGovernanceToken.sol";

/// @title MintManager
/// @notice Set as `owner` of the governance token and responsible for the token inflation
Expand All @@ -11,7 +14,7 @@ import "./GovernanceToken.sol";
/// token supply. Upgradable to allow changes in the inflation schedule.
contract MintManager is Ownable {
/// @notice The GovernanceToken that the MintManager can mint tokens
GovernanceToken public immutable governanceToken;
IGovernanceToken public immutable governanceToken;

/// @notice The amount of tokens that can be minted per year.
/// The value is a fixed point number with 4 decimals.
Expand All @@ -32,7 +35,7 @@ contract MintManager is Ownable {
/// @param _governanceToken The governance token this contract can mint tokens of.
constructor(address _upgrader, address _governanceToken) {
transferOwnership(_upgrader);
governanceToken = GovernanceToken(_governanceToken);
governanceToken = IGovernanceToken(_governanceToken);
}

/// @notice Only the token owner is allowed to mint a certain amount of the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { ERC20Votes } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";

interface IGovernanceToken {
event Approval(address indexed owner, address indexed spender, uint256 value);
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Transfer(address indexed from, address indexed to, uint256 value);

function DOMAIN_SEPARATOR() external view returns (bytes32);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
function burn(uint256 amount) external;
function burnFrom(address account, uint256 amount) external;
function checkpoints(address account, uint32 pos) external view returns (ERC20Votes.Checkpoint memory);
function decimals() external view returns (uint8);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
function delegate(address delegatee) external;
function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
function delegates(address account) external view returns (address);
function getPastTotalSupply(uint256 blockNumber) external view returns (uint256);
function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);
function getVotes(address account) external view returns (uint256);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function mint(address _account, uint256 _amount) external;
function name() external view returns (string memory);
smartcontracts marked this conversation as resolved.
Show resolved Hide resolved
function nonces(address owner) external view returns (uint256);
function numCheckpoints(address account) external view returns (uint32);
function owner() external view returns (address);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
)
external;
function renounceOwnership() external;
function symbol() external view returns (string memory);
smartcontracts marked this conversation as resolved.
Show resolved Hide resolved
function totalSupply() external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transferOwnership(address newOwner) external;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IGovernanceToken } from "src/governance/interfaces/IGovernanceToken.sol";

interface IMintManager {
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

function DENOMINATOR() external view returns (uint256);
function MINT_CAP() external view returns (uint256);
function MINT_PERIOD() external view returns (uint256);
function governanceToken() external view returns (IGovernanceToken);
function mint(address _account, uint256 _amount) external;
function mintPermittedAfter() external view returns (uint256);
function owner() external view returns (address);
function renounceOwnership() external;
function transferOwnership(address newOwner) external;
function upgrade(address _newMintManager) external;
}
3 changes: 2 additions & 1 deletion packages/contracts-bedrock/test/Specs.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,12 @@ contract Specification_Test is CommonTest {

/// @notice Ensures that there's an auth spec for every L1 contract function.
function testContractAuth() public {
string[] memory pathExcludes = new string[](4);
string[] memory pathExcludes = new string[](5);
pathExcludes[0] = "src/dispute/interfaces/*";
pathExcludes[1] = "src/dispute/lib/*";
pathExcludes[2] = "src/Safe/SafeSigners.sol";
pathExcludes[3] = "src/L1/interfaces/*";
pathExcludes[4] = "src/governance/interfaces/*";
Abi[] memory abis = ForgeArtifacts.getContractFunctionAbis(
"src/{L1,dispute,governance,Safe,universal/ProxyAdmin.sol}", pathExcludes
);
Expand Down
18 changes: 10 additions & 8 deletions packages/contracts-bedrock/test/governance/MintManager.t.sol
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

// Testing utilities
// Testing
import { CommonTest } from "test/setup/CommonTest.sol";

// Target contract dependencies
// Contracts
import { GovernanceToken } from "src/governance/GovernanceToken.sol";

// Target contract
import { MintManager } from "src/governance/MintManager.sol";

// Interfaces
import { IGovernanceToken } from "src/governance/interfaces/IGovernanceToken.sol";
import { IMintManager } from "src/governance/interfaces/IMintManager.sol";

contract MintManager_Initializer is CommonTest {
address constant owner = address(0x1234);
address constant rando = address(0x5678);
GovernanceToken internal gov;
MintManager internal manager;
IGovernanceToken internal gov;
IMintManager internal manager;

/// @dev Sets up the test suite.
function setUp() public virtual override {
super.setUp();

vm.prank(owner);
gov = new GovernanceToken();
gov = IGovernanceToken(address(new GovernanceToken()));

vm.prank(owner);
manager = new MintManager(owner, address(gov));
manager = IMintManager(address(new MintManager(owner, address(gov))));

vm.prank(owner);
gov.transferOwnership(address(manager));
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/test/setup/Setup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { L1FeeVault } from "src/L2/L1FeeVault.sol";
import { GasPriceOracle } from "src/L2/GasPriceOracle.sol";
import { L1Block } from "src/L2/L1Block.sol";
import { LegacyMessagePasser } from "src/legacy/LegacyMessagePasser.sol";
import { GovernanceToken } from "src/governance/GovernanceToken.sol";
import { FeeVault } from "src/universal/FeeVault.sol";
import { WETH } from "src/L2/WETH.sol";
import { SuperchainWETH } from "src/L2/SuperchainWETH.sol";
Expand Down Expand Up @@ -52,6 +51,7 @@ import { IL1ERC721Bridge } from "src/L1/interfaces/IL1ERC721Bridge.sol";
import { IOptimismMintableERC20Factory } from "src/universal/interfaces/IOptimismMintableERC20Factory.sol";
import { IAddressManager } from "src/legacy/interfaces/IAddressManager.sol";
import { IOptimismERC20Factory } from "src/L2/interfaces/IOptimismERC20Factory.sol";
import { IGovernanceToken } from "src/governance/interfaces/IGovernanceToken.sol";

/// @title Setup
/// @dev This contact is responsible for setting up the contracts in state. It currently
Expand Down Expand Up @@ -105,7 +105,7 @@ contract Setup {
GasPriceOracle gasPriceOracle = GasPriceOracle(Predeploys.GAS_PRICE_ORACLE);
L1Block l1Block = L1Block(Predeploys.L1_BLOCK_ATTRIBUTES);
LegacyMessagePasser legacyMessagePasser = LegacyMessagePasser(Predeploys.LEGACY_MESSAGE_PASSER);
GovernanceToken governanceToken = GovernanceToken(Predeploys.GOVERNANCE_TOKEN);
IGovernanceToken governanceToken = IGovernanceToken(Predeploys.GOVERNANCE_TOKEN);
WETH weth = WETH(payable(Predeploys.WETH));
SuperchainWETH superchainWeth = SuperchainWETH(payable(Predeploys.SUPERCHAIN_WETH));
ETHLiquidity ethLiquidity = ETHLiquidity(Predeploys.ETH_LIQUIDITY);
Expand Down