AUT_EXT_VotingRoles_v1.sol

Git Source

Inherits: IAUT_EXT_VotingRoles_v1, Module_v1

Author: Inverter Network

Facilitates voting and motion management within the Inverter Network, allowing designated voters to participate in governance through proposals, voting, and execution of decisions.

Supports setting thresholds for decision-making, managing voter lists, creating motions, casting votes, and executing actions based on collective decisions. This structure enhances governance transparency and efficacy.

State Variables

MAX_VOTING_DURATION

The maximum voting duration.

uint public constant MAX_VOTING_DURATION = 2 weeks;

MIN_VOTING_DURATION

The minimum voting duration.

uint public constant MIN_VOTING_DURATION = 1 days;

isVoter

Checks whether an address is a voter.

mapping(address => bool) public isVoter;

motions

Gets the motion data.

mapping(bytes32 => Motion) public motions;

motionCount

Gets the number of motions.

uint public motionCount;

voterCount

Gets the number of voters.

uint public voterCount;

threshold

Gets the threshold.

uint public threshold;

voteDuration

Gets the voting duration.

uint public voteDuration;

__gap

Storage gap for future upgrades.

uint[50] private __gap;

Functions

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(Module_v1)
    returns (bool);

onlySelf

Reverts if caller is not the module itself.

modifier onlySelf();

onlyVoter

Reverts if caller is not a voter.

modifier onlyVoter();

isValidVoterAddress

Reverts if voter address is invalid.

modifier isValidVoterAddress(address voter);

Parameters

Name
Type
Description

voter

address

The address to check.

init

function init(
    IOrchestrator_v1 orchestrator_,
    Metadata memory metadata,
    bytes memory configData
) external override initializer;

getReceipt

Gets the receipt of a voter for a motion.

function getReceipt(bytes32 _ID, address voter)
    public
    view
    returns (Receipt memory);

Parameters

Name
Type
Description

_ID

bytes32

The ID of the motion.

voter

address

The address of the voter.

Returns

Name
Type
Description

<none>

Receipt

The receipt of the voter.

setThreshold

Sets the threshold.

function setThreshold(uint newThreshold) public onlySelf;

Parameters

Name
Type
Description

newThreshold

uint256

The new threshold.

setVotingDuration

Sets the voting duration.

function setVotingDuration(uint newVoteDuration) external onlySelf;

Parameters

Name
Type
Description

newVoteDuration

uint256

The new voting duration.

addVoter

Adds a voter.

function addVoter(address who) public onlySelf isValidVoterAddress(who);

Parameters

Name
Type
Description

who

address

The address to add.

addVoterAndUpdateThreshold

Adds a voter and updates the threshold.

function addVoterAndUpdateThreshold(address who, uint newThreshold) external;

Parameters

Name
Type
Description

who

address

The address to add.

newThreshold

uint256

The new threshold.

removeVoter

Removes a voter.

function removeVoter(address who) public onlySelf;

Parameters

Name
Type
Description

who

address

The address to remove.

removeVoterAndUpdateThreshold

Removes a voter and updates the threshold.

function removeVoterAndUpdateThreshold(address who, uint newThreshold)
    external
    onlySelf;

Parameters

Name
Type
Description

who

address

The address to remove.

newThreshold

uint256

The new threshold.

_removeVoter

Removes a voter from the list of voters.

function _removeVoter(address who) internal;

Parameters

Name
Type
Description

who

address

The address of the voter to remove.

createMotion

Creates a motion.

function createMotion(address target, bytes calldata action)
    external
    onlyVoter
    returns (bytes32);

Parameters

Name
Type
Description

target

address

The address of the contract to execute the action on.

action

bytes

The action data to execute on the target contract.

Returns

Name
Type
Description

<none>

bytes32

The ID of the created motion.

castVote

Casts a vote for a motion.

function castVote(bytes32 motionId, uint8 support) external onlyVoter;

Parameters

Name
Type
Description

motionId

bytes32

The ID of the motion.

support

uint8

The value that indicates wether the voter supports the motion.

executeMotion

Executes a motion.

function executeMotion(bytes32 motionId) external;

Parameters

Name
Type
Description

motionId

bytes32

The ID of the motion.

_validateThreshold

Internal function to validate the threshold.

function _validateThreshold(uint _voters, uint _threshold) internal pure;

Parameters

Name
Type
Description

_voters

uint256

The number of voters.

_threshold

uint256

The threshold.

Last updated