Solidity API
IRigoblockGovernance
RigoblockGovernance
constructor
constructor() public
Constructor has no inputs to guarantee same deterministic address across chains.
Setting high proposal threshold locks propose action, which also lock vote actions.
IGovernanceStrategy
assertValidInitParams
function assertValidInitParams(struct IRigoblockGovernanceFactory.Parameters params) external view
Reverts if initialization paramters are incorrect.
Only used at initialization, as params deleted from factory storage after setup.
Parameters
params
struct IRigoblockGovernanceFactory.Parameters
Tuple of factory parameters.
assertValidThresholds
function assertValidThresholds(uint256 proposalThreshold, uint256 quorumThreshold) external view
Reverts if thresholds are incorrect.
Parameters
proposalThreshold
uint256
Number of votes required to make a proposal.
quorumThreshold
uint256
Number of votes required for a proposal to succeed.
getProposalState
function getProposalState(struct IGovernanceState.Proposal proposal, uint256 minimumQuorum) external view returns (enum IGovernanceState.ProposalState)
Returns the state of a proposal for a required quorum.
Parameters
proposal
struct IGovernanceState.Proposal
Tuple of the proposal.
minimumQuorum
uint256
Number of votes required for a proposal to pass.
Return Values
[0]
enum IGovernanceState.ProposalState
Tuple of the proposal state.
votingPeriod
function votingPeriod() external view returns (uint256)
Return the voting period.
Return Values
[0]
uint256
Number of seconds of period duration.
votingTimestamps
function votingTimestamps() external view returns (uint256 startBlockOrTime, uint256 endBlockOrTime)
Returns the voting timestamps.
Return Values
startBlockOrTime
uint256
Timestamp when proposal starts.
endBlockOrTime
uint256
Timestamp when voting ends.
getVotingPower
function getVotingPower(address account) external view returns (uint256)
Return a user's voting power.
Parameters
account
address
Address to check votes for.
IRigoblockGovernanceFactory
GovernanceCreated
event GovernanceCreated(address governance)
Emitted when a governance is created.
Parameters
governance
address
Address of the governance proxy.
createGovernance
function createGovernance(address implementation, address governanceStrategy, uint256 proposalThreshold, uint256 quorumThreshold, enum IGovernanceState.TimeType timeType, string name) external returns (address governance)
Creates a new governance proxy.
Parameters
implementation
address
Address of the governance implementation contract.
governanceStrategy
address
Address of the voting strategy.
proposalThreshold
uint256
Number of votes required for creating a new proposal.
quorumThreshold
uint256
Number of votes required for execution.
timeType
enum IGovernanceState.TimeType
Enum of time type (block number or timestamp).
name
string
Human readable string of the name.
Return Values
governance
address
Address of the new governance.
Parameters
struct Parameters {
address implementation;
address governanceStrategy;
uint256 proposalThreshold;
uint256 quorumThreshold;
enum IGovernanceState.TimeType timeType;
string name;
}
parameters
function parameters() external view returns (struct IRigoblockGovernanceFactory.Parameters)
Returns the governance initialization parameters at proxy deploy.
Return Values
[0]
struct IRigoblockGovernanceFactory.Parameters
Tuple of the governance parameters.
IGovernanceEvents
ProposalCreated
event ProposalCreated(address proposer, uint256 proposalId, struct IGovernanceVoting.ProposedAction[] actions, uint256 startBlockOrTime, uint256 endBlockOrTime, string description)
Emitted when a new proposal is created.
Parameters
proposer
address
Address of the proposer.
proposalId
uint256
Number of the proposal.
actions
struct IGovernanceVoting.ProposedAction[]
Struct array of actions (targets, datas, values).
startBlockOrTime
uint256
Timestamp in seconds after which proposal can be voted on.
endBlockOrTime
uint256
Timestamp in seconds after which proposal can be executed.
description
string
String description of proposal.
ProposalExecuted
event ProposalExecuted(uint256 proposalId)
Emitted when a proposal is executed.
Parameters
proposalId
uint256
Number of the proposal.
StrategyUpgraded
event StrategyUpgraded(address newStrategy)
Emmited when the governance strategy is upgraded.
Parameters
newStrategy
address
Address of the new strategy contract.
ThresholdsUpdated
event ThresholdsUpdated(uint256 proposalThreshold, uint256 quorumThreshold)
Emitted when voting thresholds get updated.
Only governance can update thresholds.
Parameters
proposalThreshold
uint256
Number of votes required to add a proposal.
quorumThreshold
uint256
Number of votes required to execute a proposal.
Upgraded
event Upgraded(address newImplementation)
Emitted when implementation written to proxy storage.
Emitted also at first variable initialization.
Parameters
newImplementation
address
Address of the new implementation.
VoteCast
event VoteCast(address voter, uint256 proposalId, enum IGovernanceVoting.VoteType voteType, uint256 votingPower)
Emitted when a voter votes.
Parameters
voter
address
Address of the voter.
proposalId
uint256
Number of the proposal.
voteType
enum IGovernanceVoting.VoteType
Number of vote type.
votingPower
uint256
Number of votes.
IGovernanceInitializer
initializeGovernance
function initializeGovernance() external
Initializes the Rigoblock Governance.
Params are stored in factory and read from there.
IGovernanceState
ProposalState
enum ProposalState {
Pending,
Active,
Canceled,
Qualified,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
TimeType
enum TimeType {
Blocknumber,
Timestamp
}
Proposal
struct Proposal {
uint256 actionsLength;
uint256 startBlockOrTime;
uint256 endBlockOrTime;
uint256 votesFor;
uint256 votesAgainst;
uint256 votesAbstain;
bool executed;
}
ProposalWrapper
struct ProposalWrapper {
struct IGovernanceState.Proposal proposal;
struct IGovernanceVoting.ProposedAction[] proposedAction;
}
getActions
function getActions(uint256 proposalId) external view returns (struct IGovernanceVoting.ProposedAction[] proposedActions)
Returns the actions proposed for a given proposal.
Parameters
proposalId
uint256
Number of the proposal.
Return Values
proposedActions
struct IGovernanceVoting.ProposedAction[]
Array of tuple of proposed actions.
getProposalById
function getProposalById(uint256 proposalId) external view returns (struct IGovernanceState.ProposalWrapper proposalWrapper)
Returns a proposal for a given id.
Parameters
proposalId
uint256
The number of the proposal.
Return Values
proposalWrapper
struct IGovernanceState.ProposalWrapper
Tuple wrapper of the proposal and proposed actions tuples.
getProposalState
function getProposalState(uint256 proposalId) external view returns (enum IGovernanceState.ProposalState)
Returns the state of a proposal.
Parameters
proposalId
uint256
Number of the proposal.
Return Values
[0]
enum IGovernanceState.ProposalState
Number of proposal state.
Receipt
struct Receipt {
bool hasVoted;
uint96 votes;
enum IGovernanceVoting.VoteType voteType;
}
getReceipt
function getReceipt(uint256 proposalId, address voter) external view returns (struct IGovernanceState.Receipt)
Returns the receipt of a voter for a given proposal.
Parameters
proposalId
uint256
Number of the proposal.
voter
address
Address of the voter.
Return Values
[0]
struct IGovernanceState.Receipt
Tuple of voter receipt.
getVotingPower
function getVotingPower(address account) external view returns (uint256 votingPower)
Computes the current voting power of the given account.
Parameters
account
address
The address of the account.
Return Values
votingPower
uint256
The current voting power of the given account.
GovernanceParameters
struct GovernanceParameters {
address strategy;
uint256 proposalThreshold;
uint256 quorumThreshold;
enum IGovernanceState.TimeType timeType;
}
EnhancedParams
struct EnhancedParams {
struct IGovernanceState.GovernanceParameters params;
string name;
string version;
}
governanceParameters
function governanceParameters() external view returns (struct IGovernanceState.EnhancedParams)
Returns the governance parameters.
Return Values
[0]
struct IGovernanceState.EnhancedParams
Tuple of the governance parameters.
name
function name() external view returns (string)
Returns the name of the governace.
Return Values
[0]
string
Human readable string of the name.
proposalCount
function proposalCount() external view returns (uint256 count)
Returns the total number of proposals.
Return Values
count
uint256
The number of proposals.
proposals
function proposals() external view returns (struct IGovernanceState.ProposalWrapper[] proposalWrapper)
Returns all proposals ever made to the governance.
Return Values
proposalWrapper
struct IGovernanceState.ProposalWrapper[]
Tuple array of all governance proposals.
votingPeriod
function votingPeriod() external view returns (uint256)
Returns the voting period.
Return Values
[0]
uint256
Number of blocks or seconds.
IGovernanceUpgrade
updateThresholds
function updateThresholds(uint256 newProposalThreshold, uint256 newQuorumThreshold) external
Updates the proposal and quorum thresholds to the given values.
Only callable by the governance contract itself. Thresholds can only be updated via a successful governance proposal.
Parameters
newProposalThreshold
uint256
The new value for the proposal threshold.
newQuorumThreshold
uint256
The new value for the quorum threshold.
upgradeImplementation
function upgradeImplementation(address newImplementation) external
Updates the governance implementation address.
Only callable after successful voting.
Parameters
newImplementation
address
Address of the new governance implementation contract.
upgradeStrategy
function upgradeStrategy(address newStrategy) external
Updates the governance strategy plugin.
Only callable by the governance contract itself.
Parameters
newStrategy
address
Address of the new strategy contract.
IGovernanceVoting
VoteType
enum VoteType {
For,
Against,
Abstain
}
castVote
function castVote(uint256 proposalId, enum IGovernanceVoting.VoteType voteType) external
Casts a vote for the given proposal.
Only callable during the voting period for that proposal. One address can only vote once.
Parameters
proposalId
uint256
The ID of the proposal to vote on.
voteType
enum IGovernanceVoting.VoteType
Whether to support, not support or abstain.
castVoteBySignature
function castVoteBySignature(uint256 proposalId, enum IGovernanceVoting.VoteType voteType, uint8 v, bytes32 r, bytes32 s) external
Casts a vote for the given proposal, by signature.
Only callable during the voting period for that proposal. One voter can only vote once.
Parameters
proposalId
uint256
The ID of the proposal to vote on.
voteType
enum IGovernanceVoting.VoteType
Whether to support, not support or abstain.
v
uint8
the v field of the signature.
r
bytes32
the r field of the signature.
s
bytes32
the s field of the signature.
execute
function execute(uint256 proposalId) external payable
Executes a proposal that has passed and is currently executable.
Parameters
proposalId
uint256
The ID of the proposal to execute.
ProposedAction
struct ProposedAction {
address target;
bytes data;
uint256 value;
}
propose
function propose(struct IGovernanceVoting.ProposedAction[] actions, string description) external returns (uint256 proposalId)
Creates a proposal on the the given actions. Must have at least proposalThreshold
.
Must have at least proposalThreshold
of voting power to call this function.
Parameters
actions
struct IGovernanceVoting.ProposedAction[]
The proposed actions. An action specifies a contract call.
description
string
A text description for the proposal.
Return Values
proposalId
uint256
The ID of the newly created proposal.
MixinAbstract
_getProposalCount
function _getProposalCount() internal view virtual returns (uint256)
_getProposalState
function _getProposalState(uint256 proposalId) internal view virtual returns (enum IGovernanceState.ProposalState)
_getVotingPower
function _getVotingPower(address account) internal view virtual returns (uint256)
MixinConstants
Constants are copied in the bytecode and not assigned a storage slot, can safely be added to this contract.
VERSION
string VERSION
Contract version
PROPOSAL_MAX_OPERATIONS
uint256 PROPOSAL_MAX_OPERATIONS
Maximum operations per proposal
DOMAIN_TYPEHASH
bytes32 DOMAIN_TYPEHASH
The EIP-712 typehash for the contract's domain
VOTE_TYPEHASH
bytes32 VOTE_TYPEHASH
The EIP-712 typehash for the vote struct
_GOVERNANCE_PARAMS_SLOT
bytes32 _GOVERNANCE_PARAMS_SLOT
_IMPLEMENTATION_SLOT
bytes32 _IMPLEMENTATION_SLOT
_NAME_SLOT
bytes32 _NAME_SLOT
_PROPOSAL_SLOT
bytes32 _PROPOSAL_SLOT
_PROPOSAL_COUNT_SLOT
bytes32 _PROPOSAL_COUNT_SLOT
_PROPOSED_ACTION_SLOT
bytes32 _PROPOSED_ACTION_SLOT
_RECEIPT_SLOT
bytes32 _RECEIPT_SLOT
MixinImmutables
Immutables are copied in the bytecode and not assigned a storage slot
New immutables can safely be added to this contract without ordering.
constructor
constructor() internal
MixinInitializer
onlyUninitialized
modifier onlyUninitialized()
initializeGovernance
function initializeGovernance() external
Initializes the Rigoblock Governance.
Params are stored in factory and read from there.
MixinState
getActions
function getActions(uint256 proposalId) external view returns (struct IGovernanceVoting.ProposedAction[] proposedActions)
Returns the actions proposed for a given proposal.
Parameters
proposalId
uint256
Number of the proposal.
Return Values
proposedActions
struct IGovernanceVoting.ProposedAction[]
Array of tuple of proposed actions.
getProposalState
function getProposalState(uint256 proposalId) external view returns (enum IGovernanceState.ProposalState)
Returns the state of a proposal.
Parameters
proposalId
uint256
Number of the proposal.
Return Values
[0]
enum IGovernanceState.ProposalState
Number of proposal state.
getReceipt
function getReceipt(uint256 proposalId, address voter) external view returns (struct IGovernanceState.Receipt)
Returns the receipt of a voter for a given proposal.
Parameters
proposalId
uint256
Number of the proposal.
voter
address
Address of the voter.
Return Values
[0]
struct IGovernanceState.Receipt
Tuple of voter receipt.
getVotingPower
function getVotingPower(address account) external view returns (uint256)
Computes the current voting power of the given account.
Parameters
account
address
The address of the account.
Return Values
[0]
uint256
governanceParameters
function governanceParameters() external view returns (struct IGovernanceState.EnhancedParams)
Returns the governance parameters.
Return Values
[0]
struct IGovernanceState.EnhancedParams
Tuple of the governance parameters.
name
function name() external view returns (string)
Returns the name of the governace.
Return Values
[0]
string
Human readable string of the name.
proposalCount
function proposalCount() external view returns (uint256 count)
Returns the total number of proposals.
Return Values
count
uint256
The number of proposals.
proposals
function proposals() external view returns (struct IGovernanceState.ProposalWrapper[] proposalWrapper)
Returns all proposals ever made to the governance.
Return Values
proposalWrapper
struct IGovernanceState.ProposalWrapper[]
Tuple array of all governance proposals.
votingPeriod
function votingPeriod() external view returns (uint256)
Returns the voting period.
Return Values
[0]
uint256
Number of blocks or seconds.
getProposalById
function getProposalById(uint256 proposalId) public view returns (struct IGovernanceState.ProposalWrapper proposalWrapper)
Returns a proposal for a given id.
Parameters
proposalId
uint256
The number of the proposal.
Return Values
proposalWrapper
struct IGovernanceState.ProposalWrapper
Tuple wrapper of the proposal and proposed actions tuples.
_getProposalCount
function _getProposalCount() internal view returns (uint256 count)
_getProposalState
function _getProposalState(uint256 proposalId) internal view returns (enum IGovernanceState.ProposalState)
_getVotingPower
function _getVotingPower(address account) internal view returns (uint256)
MixinStorage
constructor
constructor() internal
_governanceParameters
function _governanceParameters() internal pure returns (struct IGovernanceState.GovernanceParameters s)
AddressSlot
struct AddressSlot {
address value;
}
_implementation
function _implementation() internal pure returns (struct MixinStorage.AddressSlot s)
StringSlot
struct StringSlot {
string value;
}
_name
function _name() internal pure returns (struct MixinStorage.StringSlot s)
ParamsWrapper
struct ParamsWrapper {
struct IGovernanceState.GovernanceParameters governanceParameters;
}
_paramsWrapper
function _paramsWrapper() internal pure returns (struct MixinStorage.ParamsWrapper s)
UintSlot
struct UintSlot {
uint256 value;
}
_proposalCount
function _proposalCount() internal pure returns (struct MixinStorage.UintSlot s)
ProposalByIndex
struct ProposalByIndex {
mapping(uint256 => struct IGovernanceState.Proposal) proposalById;
}
_proposal
function _proposal() internal pure returns (struct MixinStorage.ProposalByIndex s)
ActionByIndex
struct ActionByIndex {
mapping(uint256 => mapping(uint256 => struct IGovernanceVoting.ProposedAction)) proposedActionbyIndex;
}
_proposedAction
function _proposedAction() internal pure returns (struct MixinStorage.ActionByIndex s)
UserReceipt
struct UserReceipt {
mapping(uint256 => mapping(address => struct IGovernanceState.Receipt)) userReceiptByProposal;
}
_receipt
function _receipt() internal pure returns (struct MixinStorage.UserReceipt s)
MixinUpgrade
onlyGovernance
modifier onlyGovernance()
updateThresholds
function updateThresholds(uint256 newProposalThreshold, uint256 newQuorumThreshold) external
Updates the proposal and quorum thresholds to the given values.
Only callable by the governance contract itself. Thresholds can only be updated via a successful governance proposal.
Parameters
newProposalThreshold
uint256
The new value for the proposal threshold.
newQuorumThreshold
uint256
The new value for the quorum threshold.
upgradeImplementation
function upgradeImplementation(address newImplementation) external
Updates the governance implementation address.
Only callable after successful voting.
Parameters
newImplementation
address
Address of the new governance implementation contract.
upgradeStrategy
function upgradeStrategy(address newStrategy) external
Updates the governance strategy plugin.
Only callable by the governance contract itself.
Parameters
newStrategy
address
Address of the new strategy contract.
_isContract
function _isContract(address target) private view returns (bool)
Returns whether an address is a contract.
Return Values
[0]
bool
Bool target address has code.
MixinVoting
propose
function propose(struct IGovernanceVoting.ProposedAction[] actions, string description) external returns (uint256 proposalId)
Creates a proposal on the the given actions. Must have at least proposalThreshold
.
Must have at least proposalThreshold
of voting power to call this function.
Parameters
actions
struct IGovernanceVoting.ProposedAction[]
The proposed actions. An action specifies a contract call.
description
string
A text description for the proposal.
Return Values
proposalId
uint256
The ID of the newly created proposal.
castVote
function castVote(uint256 proposalId, enum IGovernanceVoting.VoteType voteType) external
Casts a vote for the given proposal.
Only callable during the voting period for that proposal. One address can only vote once.
Parameters
proposalId
uint256
The ID of the proposal to vote on.
voteType
enum IGovernanceVoting.VoteType
Whether to support, not support or abstain.
castVoteBySignature
function castVoteBySignature(uint256 proposalId, enum IGovernanceVoting.VoteType voteType, uint8 v, bytes32 r, bytes32 s) external
Casts a vote for the given proposal, by signature.
Only callable during the voting period for that proposal. One voter can only vote once.
Parameters
proposalId
uint256
The ID of the proposal to vote on.
voteType
enum IGovernanceVoting.VoteType
Whether to support, not support or abstain.
v
uint8
the v field of the signature.
r
bytes32
the r field of the signature.
s
bytes32
the s field of the signature.
execute
function execute(uint256 proposalId) external payable
Executes a proposal that has passed and is currently executable.
Parameters
proposalId
uint256
The ID of the proposal to execute.
_castVote
function _castVote(address voter, uint256 proposalId, enum IGovernanceVoting.VoteType voteType) private
Casts a vote for the given proposal.
Only callable during the voting period for that proposal.
RigoblockGovernanceFactory
_parameters
struct IRigoblockGovernanceFactory.Parameters _parameters
createGovernance
function createGovernance(address implementation, address governanceStrategy, uint256 proposalThreshold, uint256 quorumThreshold, enum IGovernanceState.TimeType timeType, string name) external returns (address governance)
Creates a new governance proxy.
Parameters
implementation
address
Address of the governance implementation contract.
governanceStrategy
address
Address of the voting strategy.
proposalThreshold
uint256
Number of votes required for creating a new proposal.
quorumThreshold
uint256
Number of votes required for execution.
timeType
enum IGovernanceState.TimeType
Enum of time type (block number or timestamp).
name
string
Human readable string of the name.
Return Values
governance
address
Address of the new governance.
parameters
function parameters() external view returns (struct IRigoblockGovernanceFactory.Parameters)
Returns the governance initialization parameters at proxy deploy.
Return Values
[0]
struct IRigoblockGovernanceFactory.Parameters
Tuple of the governance parameters.
_isContract
function _isContract(address target) private view returns (bool)
Returns whether an address is a contract.
Return Values
[0]
bool
Bool target address has code.
RigoblockGovernanceProxy
Upgraded
event Upgraded(address newImplementation)
Emitted when implementation written to proxy storage.
Emitted also at first variable initialization.
Parameters
newImplementation
address
Address of the new implementation.
_IMPLEMENTATION_SLOT
bytes32 _IMPLEMENTATION_SLOT
constructor
constructor() public payable
Sets address of implementation contract.
fallback
fallback() external payable
Fallback function forwards all transactions and returns all received return data.
receive
receive() external payable
Allows this contract to receive ether.
ImplementationSlot
struct ImplementationSlot {
address implementation;
}
_getImplementation
function _getImplementation() private pure returns (struct RigoblockGovernanceProxy.ImplementationSlot s)
Method to read/write from/to implementation slot.
Return Values
s
struct RigoblockGovernanceProxy.ImplementationSlot
Storage slot of the governance implementation.
RigoblockGovernanceStrategy
_stakingProxy
address _stakingProxy
_votingPeriod
uint256 _votingPeriod
constructor
constructor(address stakingProxy) public
assertValidInitParams
function assertValidInitParams(struct IRigoblockGovernanceFactory.Parameters params) external view
Reverts if initialization paramters are incorrect.
Only used at initialization, as params deleted from factory storage after setup.
Parameters
params
struct IRigoblockGovernanceFactory.Parameters
Tuple of factory parameters.
assertValidThresholds
function assertValidThresholds(uint256 proposalThreshold, uint256 quorumThreshold) public view
Reverts if thresholds are incorrect.
Parameters
proposalThreshold
uint256
Number of votes required to make a proposal.
quorumThreshold
uint256
Number of votes required for a proposal to succeed.
getProposalState
function getProposalState(struct IGovernanceState.Proposal proposal, uint256 minimumQuorum) external view returns (enum IGovernanceState.ProposalState)
Returns the state of a proposal for a required quorum.
Parameters
proposal
struct IGovernanceState.Proposal
Tuple of the proposal.
minimumQuorum
uint256
Number of votes required for a proposal to pass.
Return Values
[0]
enum IGovernanceState.ProposalState
Tuple of the proposal state.
_qualifiedConsensus
function _qualifiedConsensus(struct IGovernanceState.Proposal proposal, uint256 minimumQuorum) private view returns (bool)
getVotingPower
function getVotingPower(address account) public view returns (uint256)
Return a user's voting power.
Parameters
account
address
Address to check votes for.
votingPeriod
function votingPeriod() public view returns (uint256)
Return the voting period.
Return Values
[0]
uint256
Number of seconds of period duration.
votingTimestamps
function votingTimestamps() public view returns (uint256 startBlockOrTime, uint256 endBlockOrTime)
Returns the voting timestamps.
Return Values
startBlockOrTime
uint256
Timestamp when proposal starts.
endBlockOrTime
uint256
Timestamp when voting ends.
_assertValidProposalThreshold
function _assertValidProposalThreshold(uint256 proposalThreshold) private view
_assertValidQuorumThreshold
function _assertValidQuorumThreshold(uint256 quorumThreshold) private view
_getStakingProxy
function _getStakingProxy() private view returns (address)
It is more gas efficient at deploy to reading immutable from internal method.
Last updated