# IAUT\_EXT\_VotingRoles\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/authorizer/role/interfaces/IAUT_EXT_VotingRoles_v1.sol)

### Functions

#### MAX\_VOTING\_DURATION

The maximum voting duration.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
function addVoter(address who) external;
```

**Parameters**

| Name  | Type      | Description         |
| ----- | --------- | ------------------- |
| `who` | `address` | The address to add. |

#### addVoterAndUpdateThreshold

Adds a voter and updates the threshold.

```solidity
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.

```solidity
function removeVoter(address who) external;
```

**Parameters**

| Name  | Type      | Description            |
| ----- | --------- | ---------------------- |
| `who` | `address` | The address to remove. |

#### removeVoterAndUpdateThreshold

Removes a voter and updates the threshold.

```solidity
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.

```solidity
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.

```solidity
function motionCount() external view returns (uint);
```

**Returns**

| Name     | Type      | Description            |
| -------- | --------- | ---------------------- |
| `<none>` | `uint256` | The number of motions. |

#### voterCount

Gets the number of voters.

```solidity
function voterCount() external view returns (uint);
```

**Returns**

| Name     | Type      | Description           |
| -------- | --------- | --------------------- |
| `<none>` | `uint256` | The number of voters. |

#### threshold

Gets the threshold.

```solidity
function threshold() external view returns (uint);
```

**Returns**

| Name     | Type      | Description    |
| -------- | --------- | -------------- |
| `<none>` | `uint256` | The threshold. |

#### getReceipt

Gets the receipt of a voter for a motion.

```solidity
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.

```solidity
function voteDuration() external view returns (uint);
```

**Returns**

| Name     | Type      | Description          |
| -------- | --------- | -------------------- |
| `<none>` | `uint256` | The voting duration. |

#### setThreshold

Sets the threshold.

```solidity
function setThreshold(uint newThreshold) external;
```

**Parameters**

| Name           | Type      | Description        |
| -------------- | --------- | ------------------ |
| `newThreshold` | `uint256` | The new threshold. |

#### setVotingDuration

Sets the voting duration.

```solidity
function setVotingDuration(uint newVoteDuration) external;
```

**Parameters**

| Name              | Type      | Description              |
| ----------------- | --------- | ------------------------ |
| `newVoteDuration` | `uint256` | The new voting duration. |

#### createMotion

Creates a motion.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
event VoterAdded(address indexed who);
```

**Parameters**

| Name  | Type      | Description        |
| ----- | --------- | ------------------ |
| `who` | `address` | The added address. |

#### VoterRemoved

Event emitted when a voter address gets removed.

```solidity
event VoterRemoved(address indexed who);
```

**Parameters**

| Name  | Type      | Description          |
| ----- | --------- | -------------------- |
| `who` | `address` | The removed address. |

#### ThresholdUpdated

Event emitted when the required threshold changes.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
error Module__VotingRoleManager__EmptyVoters();
```

#### Module\_\_VotingRoleManager\_\_InvalidVoterAddress

The supplied voter address is invalid.

```solidity
error Module__VotingRoleManager__InvalidVoterAddress();
```

#### Module\_\_VotingRoleManager\_\_InvalidThreshold

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

```solidity
error Module__VotingRoleManager__InvalidThreshold();
```

#### Module\_\_VotingRoleManager\_\_InvalidVotingDuration

The supplied voting duration is invalid.

```solidity
error Module__VotingRoleManager__InvalidVotingDuration();
```

#### Module\_\_VotingRoleManager\_\_CallerNotVoter

The function can only be called by a voter.

```solidity
error Module__VotingRoleManager__CallerNotVoter();
```

#### Module\_\_VotingRoleManager\_\_IsAlreadyVoter

The address is already a voter.

```solidity
error Module__VotingRoleManager__IsAlreadyVoter();
```

#### Module\_\_VotingRoleManager\_\_InvalidSupport

The value given as vote is invalid.

```solidity
error Module__VotingRoleManager__InvalidSupport();
```

#### Module\_\_VotingRoleManager\_\_InvalidMotionId

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

```solidity
error Module__VotingRoleManager__InvalidMotionId();
```

#### Module\_\_VotingRoleManager\_\_AttemptedDoubleVote

A user cannot vote twice.

```solidity
error Module__VotingRoleManager__AttemptedDoubleVote();
```

#### Module\_\_VotingRoleManager\_\_MotionInVotingPhase

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

```solidity
error Module__VotingRoleManager__MotionInVotingPhase();
```

#### Module\_\_VotingRoleManager\_\_MotionVotingPhaseClosed

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

```solidity
error Module__VotingRoleManager__MotionVotingPhaseClosed();
```

#### Module\_\_VotingRoleManager\_\_MotionAlreadyExecuted

A motion cannot be executed twice.

```solidity
error Module__VotingRoleManager__MotionAlreadyExecuted();
```

#### Module\_\_VotingRoleManager\_\_ThresholdNotReached

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

```solidity
error Module__VotingRoleManager__ThresholdNotReached();
```

### Structs

#### Motion

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

```solidity
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.

```solidity
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. |
