Documentation
¶
Index ¶
- func ErrEmptyProposalQueue() sdk.Error
- func ErrInvalidDescription() sdk.Error
- func ErrInvalidOption(msg string) sdk.Error
- func ErrInvalidProposalID(msg string) sdk.Error
- func ErrInvalidTitle() sdk.Error
- func ErrInvalidVotingWindow(msg string) sdk.Error
- func ErrMinimumDeposit() sdk.Error
- func ErrProposalNotFound(proposalID int64) sdk.Error
- func ErrProposalQueueNotFound() sdk.Error
- func ErrVoteNotFound() sdk.Error
- func ErrVotingPeriodClosed() sdk.Error
- func GenerateProposalKey(proposalID int64) []byte
- func GenerateProposalVoteKey(proposalID int64, voterAddr sdk.Address) []byte
- func GenerateProposalVotesKey(proposalID int64) []byte
- func NewEndBlocker(k Keeper) sdk.EndBlocker
- func NewHandler(k Keeper) sdk.Handler
- type CodeType
- type Keeper
- func (k Keeper) GetProposal(ctx sdk.Context, proposalID int64) (Proposal, sdk.Error)
- func (k Keeper) GetVote(ctx sdk.Context, proposalID int64, voter sdk.Address) (string, sdk.Error)
- func (k Keeper) NewProposalID(ctx sdk.Context) int64
- func (k Keeper) ProposalQueueHead(ctx sdk.Context) (Proposal, sdk.Error)
- func (k Keeper) ProposalQueuePop(ctx sdk.Context) (Proposal, sdk.Error)
- func (k Keeper) ProposalQueuePush(ctx sdk.Context, proposaID int64) sdk.Error
- func (k Keeper) SetProposal(ctx sdk.Context, proposalID int64, proposal Proposal) sdk.Error
- func (k Keeper) SetVote(ctx sdk.Context, proposalID int64, voter sdk.Address, option string)
- type KeeperRead
- type Proposal
- type ProposalQueue
- type SubmitProposalMsg
- func (msg SubmitProposalMsg) Get(key interface{}) (value interface{})
- func (msg SubmitProposalMsg) GetSignBytes() []byte
- func (msg SubmitProposalMsg) GetSigners() []sdk.Address
- func (msg SubmitProposalMsg) String() string
- func (msg SubmitProposalMsg) Type() string
- func (msg SubmitProposalMsg) ValidateBasic() sdk.Error
- type VoteMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateProposalKey ¶
GenerateProposalKey creates a key of the form "proposals"|{proposalID}
func GenerateProposalVoteKey ¶
GenerateProposalVoteKey creates a key of the form "proposals"|{proposalID}|"votes"|{voterAddress}
func GenerateProposalVotesKey ¶
GenerateProposalVotesKey creates a key of the form "proposals"|{proposalID}|"votes"
func NewEndBlocker ¶
func NewEndBlocker(k Keeper) sdk.EndBlocker
NewEndBlocker checks proposals and generates a EndBlocker
func NewHandler ¶
NewHandler creates a new handler for all simple_gov type messages.
Types ¶
type CodeType ¶
const ( DefaultCodespace sdk.CodespaceType = "SUBSIDY" // Simple Gov errors reserve 700 ~ 799. CodeInvalidOption CodeType = 1 CodeInvalidProposalID CodeType = 2 CodeVotingPeriodClosed CodeType = 3 CodeEmptyProposalQueue CodeType = 4 CodeInvalidTitle CodeType = 5 CodeInvalidDescription CodeType = 6 CodeInvalidVotingWindow CodeType = 7 CodeProposalNotFound CodeType = 8 CodeVoteNotFound CodeType = 9 CodeProposalQueueNotFound CodeType = 10 CodeInvalidDeposit CodeType = 11 )
type Keeper ¶
type Keeper struct {
SimpleGov sdk.StoreKey // Key to our module's store
// contains filtered or unexported fields
}
nolint
func NewKeeper ¶
func NewKeeper(SimpleGov sdk.StoreKey, ck bank.Keeper, sm stake.Keeper, codespace sdk.CodespaceType) Keeper
NewKeeper crates a new keeper with write and read access
func (Keeper) GetProposal ¶
GetProposal gets the proposal with the given id from the context.
func (Keeper) GetVote ¶
GetVote returns the given option of a proposal stored in the keeper Used to check if an address already voted
func (Keeper) NewProposalID ¶
NewProposalID creates a new id for a proposal
func (Keeper) ProposalQueueHead ¶
ProposalQueueHead returns the head of the FIFO Proposal queue
func (Keeper) ProposalQueuePop ¶
ProposalQueuePop pops the head from the Proposal queue
func (Keeper) ProposalQueuePush ¶
ProposalQueuePush pushes a proposal to the tail of the FIFO Proposal queue
func (Keeper) SetProposal ¶
SetProposal sets a proposal to the context
type KeeperRead ¶
type KeeperRead struct {
Keeper
}
KeeperRead is a Keeper only with read access
func NewKeeperRead ¶
func NewKeeperRead(SimpleGov sdk.StoreKey, ck bank.Keeper, sm stake.Keeper, codespace sdk.CodespaceType) KeeperRead
NewKeeperRead crates a new keeper with read access
func (KeeperRead) NewProposalID ¶
func (k KeeperRead) NewProposalID(ctx sdk.Context) sdk.Error
NewProposalID creates a new id for a proposal
func (KeeperRead) SetProposal ¶
SetProposal sets a proposal to the context
type Proposal ¶
type Proposal struct {
Title string `json:"title"` // Title of the proposal
Description string `json:"description"` // Description of the proposal
Submitter sdk.Address `json:"submitter"` // Account address of the proposer
SubmitBlock int64 `json:"submit_block"` // Block height from which the proposal is open for votations
State string `json:"state"` // One of Open, Accepted, Rejected
Deposit sdk.Coins `json:"deposit"` // Coins deposited in escrow
YesVotes int64 `json:"yes_votes"` // Total Yes votes
NoVotes int64 `json:"no_votes"` // Total No votes
AbstainVotes int64 `json:"abstain_votes"` // Total Abstain votes
}
Proposal defines the basic propierties of a staking proposal
type SubmitProposalMsg ¶
type SubmitProposalMsg struct {
Title string // Title of the proposal
Description string // Description of the proposal
Deposit sdk.Coins // Deposit paid by submitter. Must be > MinDeposit to enter voting period
Submitter sdk.Address // Address of the submitter
}
SubmitProposalMsg defines a message to create a proposal
func NewSubmitProposalMsg ¶
func NewSubmitProposalMsg(title string, description string, votingWindow int64, deposit sdk.Coins, submitter sdk.Address) SubmitProposalMsg
NewSubmitProposalMsg submits a message with a new proposal
func (SubmitProposalMsg) Get ¶
func (msg SubmitProposalMsg) Get(key interface{}) (value interface{})
Implements Msg
func (SubmitProposalMsg) GetSignBytes ¶
func (msg SubmitProposalMsg) GetSignBytes() []byte
Implements Msg
func (SubmitProposalMsg) GetSigners ¶
func (msg SubmitProposalMsg) GetSigners() []sdk.Address
Implements Msg
func (SubmitProposalMsg) String ¶
func (msg SubmitProposalMsg) String() string
func (SubmitProposalMsg) ValidateBasic ¶
func (msg SubmitProposalMsg) ValidateBasic() sdk.Error
Implements Msg
type VoteMsg ¶
type VoteMsg struct {
ProposalID int64 // ID of the proposal
Option string // Option chosen by voter
Voter sdk.Address // Address of the voter
}
VoteMsg defines the msg of a staker containing the vote option to an specific proposal
func NewVoteMsg ¶
NewVoteMsg creates a VoteMsg instance