StartupGovernor

Git Source

Inherits: MezzGovernor, MezzEIP712, NoncesUpgradeable, IStartupGovernor

Author: Daniel Yamagata

A governance contract that enables the execution of arbitrary transactions by a super-majority of a treasury's signers. A super majority is counted as two-thirds of the signers rounded upwards. Below is a table with a few examples.

SignersSuper Majority

2

2

3

2

4

3

5

4

6

4

The execution of transactions requires an arbitrary deadline. If this deadline passes, the transaction will revert even if provided the correct number of signatures.

State Variables

EXECUTE_TYPEHASH

bytes32 public constant EXECUTE_TYPEHASH =
    keccak256("Execute(address target,uint256 value,bytes data,uint256 deadline,uint256 nonce)");

Functions

constructor

constructor(address _mezzHub, address _mezzMigrator) MezzGovernor(_mezzHub, _mezzMigrator);

init

Intializes the Governor's state

function init(address initTreasury, bytes memory) external virtual override initializer;

Parameters

NameTypeDescription

initTreasury

address

The address of the Treasury that the Governor is in charge of

<none>

bytes

__Startup_Governor_init

The 'params' argument is maintained in case future versions require additional initialization parameters

function __Startup_Governor_init(address initTreasury, bytes memory) internal virtual onlyInitializing;

executeTx

Executes an arbitrary transaction. Requires a super majority of board members to sign off

Signatures must be packed in ascending order of the public addresses of the signers and must be packed into a single variable.

function executeTx(address target, uint256 value, bytes memory data, bytes memory signatures, uint256 deadline)
    public
    virtual
    freezable
    returns (bytes memory);

Parameters

NameTypeDescription

target

address

The target address to execute the transaction on

value

uint256

The amount of native currency to send with the transaction

data

bytes

The calldata of the transaction

signatures

bytes

The signatures of the board members

deadline

uint256

Returns

NameTypeDescription

<none>

bytes

The return data of the transaction

_checkNSignatures

Validates the 'signatures' and the number of required signatures for 'safeCache', '_hash', and '_hashData'

function _checkNSignatures(address safeCache, bytes32 dataHash, bytes memory signatures, uint256 requiredSigs)
    internal
    view
    virtual;

_execute

Executes a call on a given 'target' with 'data' and 'value'. Reverts if the call fails or the target's code length is zero

function _execute(address target, uint256 value, bytes memory data) internal virtual returns (bytes memory);

getExecuteTransactionHash

Returns the transaction hash of the encoded execute data.

This hash is the one to be signed by a private key. Signatures should then be packed in ascending order by the public keys of the owners when calling executeTx()

function getExecuteTransactionHash(DataTypes.StartupGovernorExecute memory execute)
    public
    view
    virtual
    returns (bytes32);

Parameters

NameTypeDescription

execute

DataTypes.StartupGovernorExecute

The StartupGovernorExecute struct to hash

encodeExecuteData

Encodes a StartupGovernorExecute struct hash following the EIP-191 signed typed data standard

Reference: https://eips.ethereum.org/EIPS/eip-191

function encodeExecuteData(DataTypes.StartupGovernorExecute memory execute)
    public
    view
    virtual
    returns (bytes memory);

Parameters

NameTypeDescription

execute

DataTypes.StartupGovernorExecute

The StartupGovernorExecute struct to hash and subsequently encode

getExecuteStructHash

Returns the hash of a StartupGovernorExecute struct following the EIP-712 encoding standards

Reference: https://eips.ethereum.org/EIPS/eip-712

function getExecuteStructHash(DataTypes.StartupGovernorExecute memory execute) public view virtual returns (bytes32);

Parameters

NameTypeDescription

execute

DataTypes.StartupGovernorExecute

The StartupGovernorExecute struct to hash

coreId

Returns the coreId of the implementation as a bytes32

The core ID is the keccak256 hash of the contract name followed by a version under the following syntax: "mezzanine.coreId.ContractName.vX" For example, the core ID of the 2nd version of the Treasury would be the following: keccak256(abi.encodePacked("mezzanine.coreId.Treasury.v2"))

function coreId() public pure virtual override(Credentialed, ICredentialed) returns (bytes32);

version

Returns the version of the implementation as a uint256

function version() public pure virtual override(Credentialed, ICredentialed) returns (uint256);

onERC721Received

Reference: https://eips.ethereum.org/EIPS/eip-721

function onERC721Received(address, address, uint256, bytes memory) public view virtual returns (bytes4);

onERC1155Received

Reference: https://eips.ethereum.org/EIPS/eip-1155

function onERC1155Received(address, address, uint256, uint256, bytes memory) public view virtual returns (bytes4);

onERC1155BatchReceived

Reference: https://eips.ethereum.org/EIPS/eip-1155

function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
    public
    view
    virtual
    returns (bytes4);

supportsInterface

ERC165 support

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(MezzEIP712, MezzUUPSUpgradeable, IERC165)
    returns (bool);

Last updated