subsidy

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrEmptyProposalQueue

func ErrEmptyProposalQueue() sdk.Error

nolint

func ErrInvalidDescription

func ErrInvalidDescription() sdk.Error

nolint

func ErrInvalidOption

func ErrInvalidOption(msg string) sdk.Error

nolint

func ErrInvalidProposalID

func ErrInvalidProposalID(msg string) sdk.Error

nolint

func ErrInvalidTitle

func ErrInvalidTitle() sdk.Error

nolint

func ErrInvalidVotingWindow

func ErrInvalidVotingWindow(msg string) sdk.Error

nolint

func ErrMinimumDeposit

func ErrMinimumDeposit() sdk.Error

nolint

func ErrProposalNotFound

func ErrProposalNotFound(proposalID int64) sdk.Error

nolint

func ErrProposalQueueNotFound

func ErrProposalQueueNotFound() sdk.Error

nolint

func ErrVoteNotFound

func ErrVoteNotFound() sdk.Error

nolint

func ErrVotingPeriodClosed

func ErrVotingPeriodClosed() sdk.Error

nolint

func GenerateProposalKey

func GenerateProposalKey(proposalID int64) []byte

GenerateProposalKey creates a key of the form "proposals"|{proposalID}

func GenerateProposalVoteKey

func GenerateProposalVoteKey(proposalID int64, voterAddr sdk.Address) []byte

GenerateProposalVoteKey creates a key of the form "proposals"|{proposalID}|"votes"|{voterAddress}

func GenerateProposalVotesKey

func GenerateProposalVotesKey(proposalID int64) []byte

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

func NewHandler(k Keeper) sdk.Handler

NewHandler creates a new handler for all simple_gov type messages.

Types

type CodeType

type CodeType = sdk.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

func (k Keeper) GetProposal(ctx sdk.Context, proposalID int64) (Proposal, sdk.Error)

GetProposal gets the proposal with the given id from the context.

func (Keeper) GetVote

func (k Keeper) GetVote(ctx sdk.Context, proposalID int64, voter sdk.Address) (string, sdk.Error)

GetVote returns the given option of a proposal stored in the keeper Used to check if an address already voted

func (Keeper) NewProposalID

func (k Keeper) NewProposalID(ctx sdk.Context) int64

NewProposalID creates a new id for a proposal

func (Keeper) ProposalQueueHead

func (k Keeper) ProposalQueueHead(ctx sdk.Context) (Proposal, sdk.Error)

ProposalQueueHead returns the head of the FIFO Proposal queue

func (Keeper) ProposalQueuePop

func (k Keeper) ProposalQueuePop(ctx sdk.Context) (Proposal, sdk.Error)

ProposalQueuePop pops the head from the Proposal queue

func (Keeper) ProposalQueuePush

func (k Keeper) ProposalQueuePush(ctx sdk.Context, proposaID int64) sdk.Error

ProposalQueuePush pushes a proposal to the tail of the FIFO Proposal queue

func (Keeper) SetProposal

func (k Keeper) SetProposal(ctx sdk.Context, proposalID int64, proposal Proposal) sdk.Error

SetProposal sets a proposal to the context

func (Keeper) SetVote

func (k Keeper) SetVote(ctx sdk.Context, proposalID int64, voter sdk.Address, option string)

SetVote sets the vote option to the proposal stored in the context store

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

func (k KeeperRead) SetProposal(ctx sdk.Context, proposalID int64, proposal Proposal) sdk.Error

SetProposal sets a proposal to the context

func (KeeperRead) SetVote

func (k KeeperRead) SetVote(ctx sdk.Context, key []byte, option string) sdk.Error

SetVote sets the vote option to the proposal stored in the context store

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

func NewProposal

func NewProposal(
	title string,
	description string,
	submitter sdk.Address,
	blockHeight int64,
	deposit sdk.Coins) Proposal

NewProposal validates deposit and creates a new proposal

func (Proposal) IsOpen

func (p Proposal) IsOpen() bool

IsOpen checks if proposal is open for votations

type ProposalQueue

type ProposalQueue []int64

ProposalQueue stores the proposals IDs

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) Type

func (msg SubmitProposalMsg) Type() string

Implements Msg

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

func NewVoteMsg(proposalID int64, option string, voter sdk.Address) VoteMsg

NewVoteMsg creates a VoteMsg instance

func (VoteMsg) Get

func (msg VoteMsg) Get(key interface{}) (value interface{})

Implements Msg

func (VoteMsg) GetSignBytes

func (msg VoteMsg) GetSignBytes() []byte

Implements Msg

func (VoteMsg) GetSigners

func (msg VoteMsg) GetSigners() []sdk.Address

Implements Msg

func (VoteMsg) String

func (msg VoteMsg) String() string

Implements Msg

func (VoteMsg) Type

func (msg VoteMsg) Type() string

Implements Msg

func (VoteMsg) ValidateBasic

func (msg VoteMsg) ValidateBasic() sdk.Error

Implements Msg

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL