IAUT_EXT_VotingRoles_v1.sol

Git Source

Functions

MAX_VOTING_DURATION

The maximum voting duration.

function MAX_VOTING_DURATION() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

The maximum voting duration.

MIN_VOTING_DURATION

The minimum voting duration.

function MIN_VOTING_DURATION() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

The minimum voting duration.

isVoter

Checks whether an address is a voter.

function isVoter(address who) external view returns (bool);

Parameters

Name
Type
Description

who

address

The address to check.

Returns

Name
Type
Description

<none>

bool

Whether the address is a voter.

addVoter

Adds a voter.

function addVoter(address who) external;

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) external;

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;

Parameters

Name
Type
Description

who

address

The address to remove.

newThreshold

uint256

The new threshold.

motions

Gets the motion data.

function motions(bytes32 motionId)
    external
    view
    returns (
        address,
        bytes memory,
        uint,
        uint,
        uint,
        uint,
        uint,
        uint,
        uint,
        bool,
        bytes memory
    );

Parameters

Name
Type
Description

motionId

bytes32

The ID of the motion.

Returns

Name
Type
Description

<none>

address

target The address of the contract to execute the action on.

<none>

bytes

action The action data to execute on the target contract.

<none>

uint256

startTimestamp The timestamp at which the motion starts.

<none>

uint256

endTimestamp The timestamp at which the motion ends.

<none>

uint256

requiredThreshold The required threshold of votes to pass the motion.

<none>

uint256

forVotes The number of votes in favor of the motion.

<none>

uint256

againstVotes The number of votes against the motion.

<none>

uint256

abstainVotes The number of votes abstaining from the motion.

<none>

uint256

executedAt The timestamp at which the motion was executed.

<none>

bool

executionResult The result of the execution.

<none>

bytes

executionReturnData The return data of the execution.

motionCount

Gets the number of motions.

function motionCount() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

The number of motions.

voterCount

Gets the number of voters.

function voterCount() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

The number of voters.

threshold

Gets the threshold.

function threshold() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

The threshold.

getReceipt

Gets the receipt of a voter for a motion.

function getReceipt(bytes32 _ID, address voter)
    external
    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.

voteDuration

Gets the voting duration.

function voteDuration() external view returns (uint);

Returns

Name
Type
Description

<none>

uint256

The voting duration.

setThreshold

Sets the threshold.

function setThreshold(uint newThreshold) external;

Parameters

Name
Type
Description

newThreshold

uint256

The new threshold.

setVotingDuration

Sets the voting duration.

function setVotingDuration(uint newVoteDuration) external;

Parameters

Name
Type
Description

newVoteDuration

uint256

The new voting duration.

createMotion

Creates a motion.

function createMotion(address target, bytes calldata action)
    external
    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;

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.

Events

VoterAdded

Event emitted when a new voter address gets added.

event VoterAdded(address indexed who);

Parameters

Name
Type
Description

who

address

The added address.

VoterRemoved

Event emitted when a voter address gets removed.

event VoterRemoved(address indexed who);

Parameters

Name
Type
Description

who

address

The removed address.

ThresholdUpdated

Event emitted when the required threshold changes.

event ThresholdUpdated(uint oldThreshold, uint newThreshold);

Parameters

Name
Type
Description

oldThreshold

uint256

The old threshold.

newThreshold

uint256

The new threshold.

VoteDurationUpdated

Event emitted when the voting duration changes.

event VoteDurationUpdated(uint oldVotingDuration, uint newVotingDuration);

Parameters

Name
Type
Description

oldVotingDuration

uint256

The old voting duration.

newVotingDuration

uint256

The new voting duration.

MotionCreated

Event emitted when a motion is created.

event MotionCreated(bytes32 indexed motionId);

Parameters

Name
Type
Description

motionId

bytes32

The motion ID.

VoteCast

Event emitted when a vote is cast for a motion.

event VoteCast(
    bytes32 indexed motionId, address indexed voter, uint8 indexed support
);

Parameters

Name
Type
Description

motionId

bytes32

The motion ID.

voter

address

The address of a voter.

support

uint8

MotionExecuted

Event emitted when a motion is executed.

event MotionExecuted(bytes32 indexed motionId);

Parameters

Name
Type
Description

motionId

bytes32

The motion ID.

Errors

Module__VotingRoleManager__EmptyVoters

The action would leave an empty voter list.

error Module__VotingRoleManager__EmptyVoters();

Module__VotingRoleManager__InvalidVoterAddress

The supplied voter address is invalid.

error Module__VotingRoleManager__InvalidVoterAddress();

Module__VotingRoleManager__InvalidThreshold

The threshold cannot exceed the amount of voters. or be too low to be considered safe.

error Module__VotingRoleManager__InvalidThreshold();

Module__VotingRoleManager__InvalidVotingDuration

The supplied voting duration is invalid.

error Module__VotingRoleManager__InvalidVotingDuration();

Module__VotingRoleManager__CallerNotVoter

The function can only be called by a voter.

error Module__VotingRoleManager__CallerNotVoter();

Module__VotingRoleManager__IsAlreadyVoter

The address is already a voter.

error Module__VotingRoleManager__IsAlreadyVoter();

Module__VotingRoleManager__InvalidSupport

The value given as vote is invalid.

error Module__VotingRoleManager__InvalidSupport();

Module__VotingRoleManager__InvalidMotionId

The supplied ID is referencing a motion that doesn't exist.

error Module__VotingRoleManager__InvalidMotionId();

Module__VotingRoleManager__AttemptedDoubleVote

A user cannot vote twice.

error Module__VotingRoleManager__AttemptedDoubleVote();

Module__VotingRoleManager__MotionInVotingPhase

A motion cannot be executed if the voting duration hasn't passed.

error Module__VotingRoleManager__MotionInVotingPhase();

Module__VotingRoleManager__MotionVotingPhaseClosed

A motion cannot be voted on if the duration has been exceeded.

error Module__VotingRoleManager__MotionVotingPhaseClosed();

Module__VotingRoleManager__MotionAlreadyExecuted

A motion cannot be executed twice.

error Module__VotingRoleManager__MotionAlreadyExecuted();

Module__VotingRoleManager__ThresholdNotReached

A motion cannot be executed if it didn't reach the threshold.

error Module__VotingRoleManager__ThresholdNotReached();

Structs

Motion

A motion is a proposal to execute an action on a target contract.

struct Motion {
    address target;
    bytes action;
    uint startTimestamp;
    uint endTimestamp;
    uint requiredThreshold;
    uint forVotes;
    uint againstVotes;
    uint abstainVotes;
    mapping(address => Receipt) receipts;
    uint executedAt;
    bool executionResult;
    bytes executionReturnData;
}

Properties

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.

startTimestamp

uint256

The timestamp at which the motion starts.

endTimestamp

uint256

The timestamp at which the motion ends.

requiredThreshold

uint256

The required threshold of votes to pass the motion.

forVotes

uint256

The number of votes in favor of the motion.

againstVotes

uint256

The number of votes against the motion.

abstainVotes

uint256

The number of votes abstaining from the motion.

receipts

mapping(address => Receipt)

The receipts of votes for the motion address => Receipt

executedAt

uint256

The timestamp at which the motion was executed.

executionResult

bool

The result of the execution.

executionReturnData

bytes

The return data of the execution.

Receipt

A receipt is a vote cast for a motion.

struct Receipt {
    bool hasVoted;
    uint8 support;
}

Properties

Name
Type
Description

hasVoted

bool

Whether the voter has already voted.

support

uint8

The value that indicates wether the voter supports the motion.

Last updated