Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose VotingFor and ClassLocksFor in ConvictionVoting precompile #2220

Merged
merged 6 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions precompiles/conviction-voting/ConvictionVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,136 @@ interface ConvictionVoting {
Locked6x
}

/// @dev Defines the class lock for an account.
struct ClassLock {
crystalin marked this conversation as resolved.
Show resolved Hide resolved
/// The track of this lock.
uint16 trackId;
/// The amount locked.
uint256 amount;
}

/// @dev Defines the voting information for an account and track,
struct VotingFor {
/// If the voting type is `Casting`, if `true` then `casting` field is significant.
bool isCasting;
/// If the voting type is `Delegating`, if `true` then `delegating` field is significant.
bool isDelegating;
/// Defines the voting information when `isCasting` is true.
Casting casting;
/// Defines the voting information when `isDelegating` is true.
Delegating delegating;
}

/// @dev Defines the casting vote type from an account.
struct Casting {
/// The votes registered.
PollAccountVote[] votes;
/// The delegation info.
Delegations delegations;
/// Any prior lock information.
PriorLock prior;
}

/// @dev Defines the delegating vote type from an account.
struct Delegating {
/// The delegated balance.
uint256 balance;
/// The deletegate account
address target;
/// The conviction type for the vote.
Conviction conviction;
/// The delegation info.
Delegations delegations;
/// Any prior lock information.
PriorLock prior;
}

/// @dev Defines the vote towards a poll from an account.
struct PollAccountVote {
/// The index of the poll.
uint32 pollIndex;
/// The vote registered for the poll from an account.
AccountVote accountVote;
}

/// @dev Defines the vote from an account.
struct AccountVote {
/// If `true` then the vote is a Standard vote and `standard` field is significant.
bool isStandard;
/// If `true` then the vote is a Split vote and `split` field is significant.
bool isSplit;
/// If `true` then the vote is a SplitAbstrain vote and `splitAbstain` field is significant.
bool isSplitAbstain;
/// Defines the standard vote, if `isStandard` is `true`.
StandardVote standard;
/// Defines the split vote, if `isSplit` is `true`.
SplitVote split;
/// Defines the split-abstain vote, if `isSplitAbstrain` is `true`.
SplitAbstainVote splitAbstain;
}

/// @dev Defines the standard vote.
struct StandardVote {
/// The vote information.
Vote vote;
/// The locked balance for the vote.
uint256 balance;
}

/// @dev Defines the vote parameters for a standard vote.
struct Vote {
/// `true` if the vote is an aye.
bool aye;
/// The conviction type for the vote.
Conviction conviction;
}

/// @dev Defines the standard vote.
struct SplitVote {
/// The amount locked towards aye.
uint256 aye;
/// The amount locked towards nay.
uint256 nay;
}

/// @dev Defines the standard vote.
struct SplitAbstainVote {
/// The amount locked towards aye.
uint256 aye;
/// The amount locked towards nay.
uint256 nay;
/// The amount locked towards abstain.
uint256 abstain;
}

/// @dev Defines the delegations for a vote.
struct Delegations {
/// Total number of votes.
uint256 votes;
/// Total capital locked.
uint256 capital;
}

/// @dev Defines any prior lock for a vote.
struct PriorLock {
/// Amount of balance locked.
uint256 balance;
}

/// @dev Retrieve votings for a given account and track.
/// @custom:selector 501447ee
/// @param who The requested account
/// @param trackId The requested track
function votingFor(
address who,
uint16 trackId
) external view returns (ClassLock[] memory);

/// @dev Retrieve class locks for a given account.
/// @custom:selector 7ae8ac92
/// @param who The requested account
function classLocksFor(address who) external view returns (uint256);

/// @dev Vote yes in a poll.
/// @custom:selector da9df518
/// @param pollIndex Index of poll
Expand Down
Loading