budget

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryProgram       = "program"
	QueryVotes         = "votes"
	QueryActiveList    = "active-list"
	QueryCandidateList = "candidate-list"
	QueryParams        = "params"
)

query endpoints supported by the governance Querier

View Source
const (
	RouterKey = "budget"

	// QuerierRoute is the querier route for budget
	QuerierRoute = "budget"
)

RouterKey is they name of the budget module

View Source
const StoreKey = "budget"

StoreKey is string representation of the store key for budget

Variables

View Source
var (
	KeyDelimiter         = []byte(":")
	PrefixProgram        = []byte("program")
	PrefixVote           = []byte("vote")
	KeyNextProgramID     = []byte("new-program-id")
	PrefixCandidateQueue = []byte("candidate-queue")
	ParamStoreKeyParams  = []byte("params")
	DefaultParamspace    = "budget"
)

nolint

Functions

func EndBlocker

func EndBlocker(ctx sdk.Context, k Keeper) (claims map[string]sdk.Int, resTags sdk.Tags)

EndBlocker is called at the end of every block

func ErrDepositDenom

func ErrDepositDenom() sdk.Error

nolint

func ErrEmptyProgramQueue

func ErrEmptyProgramQueue() sdk.Error

nolint

func ErrInvalidDescription

func ErrInvalidDescription() sdk.Error

nolint

func ErrInvalidOption

func ErrInvalidOption(msg string) sdk.Error

nolint

func ErrInvalidProgramID

func ErrInvalidProgramID(msg string) sdk.Error

nolint

func ErrInvalidSubmitter

func ErrInvalidSubmitter(submitter sdk.AccAddress) 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 ErrProgramNotFound

func ErrProgramNotFound(ProgramID uint64) sdk.Error

nolint

func ErrProgramQueueNotFound

func ErrProgramQueueNotFound() sdk.Error

nolint

func ErrVoteNotFound

func ErrVoteNotFound() sdk.Error

nolint

func ErrVotingPeriodClosed

func ErrVotingPeriodClosed() sdk.Error

nolint

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)

new oracle genesis

func KeyCandidate

func KeyCandidate(endTime time.Time, programID uint64) []byte

Returns the key for a programID in the activeprogramQueue

func KeyProgram

func KeyProgram(programID uint64) []byte

KeyProgram creates a key of the form "Programs"|{state}|{ProgramID}

func KeyVote

func KeyVote(programID uint64, voterAddr sdk.AccAddress) []byte

Key for getting a specific vote from the store

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler creates a new handler for all budget type messages.

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for budget module

func PrefixCandidateQueueTime

func PrefixCandidateQueueTime(endTime time.Time) []byte

Returns the key for a programID in the activeprogramQueue

func PrefixVoteForProgram

func PrefixVoteForProgram(programID uint64) []byte

Key for getting a specific vote from the store

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided oracle genesis state to ensure the expected invariants holds. (i.e. params in correct bounds, no duplicate validators)

Types

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace sdk.CodespaceType = "budget"

	// Budget errors
	CodeInvalidOption        CodeType = 1
	CodeInvalidProgramID     CodeType = 2
	CodeVotingPeriodClosed   CodeType = 3
	CodeEmptyProgramQueue    CodeType = 4
	CodeInvalidTitle         CodeType = 5
	CodeInvalidDescription   CodeType = 6
	CodeInvalidVotingWindow  CodeType = 7
	CodeProgramNotFound      CodeType = 8
	CodeVoteNotFound         CodeType = 9
	CodeProgramQueueNotFound CodeType = 10
	CodeInvalidDeposit       CodeType = 11
	CodeInvalidSubmitter     CodeType = 12
)

type GenesisState

type GenesisState struct {
	Params Params `json:"params"` // budget params
}

GenesisState - all distribution state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func ExportGenesis

func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState

ExportGenesis returns a GenesisState for a given context and keeper. The GenesisState will contain the pool, and validator/delegator distribution info's

func NewGenesisState

func NewGenesisState(params Params) GenesisState

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

nolint

func NewKeeper

func NewKeeper(key sdk.StoreKey,
	cdc *codec.Codec,
	bk bank.Keeper,
	codespace sdk.CodespaceType,
	valset sdk.ValidatorSet,
	paramspace params.Subspace) Keeper

NewKeeper crates a new keeper with write and read access

func (Keeper) CandidateQueueHas

func (k Keeper) CandidateQueueHas(ctx sdk.Context, program Program, programID uint64) (res bool)

CandidateQueueHas Checks if a progrma exists in accordance with the given parameters

func (Keeper) CandidateQueueInsert

func (k Keeper) CandidateQueueInsert(ctx sdk.Context, program Program, programID uint64)

CandidateQueueInsert Inserts a ProgramID into the Candidate Program queue at endTime

func (Keeper) CandidateQueueRemove

func (k Keeper) CandidateQueueRemove(ctx sdk.Context, program Program, programID uint64)

CandidateQueueRemove removes a ProgramID from the Candidate Program Queue

func (Keeper) ClearVotesForProgram

func (k Keeper) ClearVotesForProgram(ctx sdk.Context, programID uint64)

func (Keeper) DeleteProgram

func (k Keeper) DeleteProgram(ctx sdk.Context, programID uint64)

DeleteProgram deletes a program from the context

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) Params

GetParams get oralce params from the global param store

func (Keeper) GetProgram

func (k Keeper) GetProgram(ctx sdk.Context, programID uint64) (res Program, err sdk.Error)

GetProgram gets the Program with the given id from the context.

func (Keeper) GetVote

func (k Keeper) GetVote(ctx sdk.Context, programID uint64, voter sdk.AccAddress) (res bool, err sdk.Error)

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

func (Keeper) IterateActivePrograms

func (k Keeper) IterateActivePrograms(ctx sdk.Context, handler func(uint64, Program) (stop bool))

IteratePrograms iterates through programs in the store

func (Keeper) IterateMatureCandidates

func (k Keeper) IterateMatureCandidates(ctx sdk.Context, endTime time.Time, handler func(uint64, Program) (stop bool))

IterateMatureCandidates Returns an iterator for all the Programs in the Candidate Queue that expire by endTime

func (Keeper) NewProgramID

func (k Keeper) NewProgramID(ctx sdk.Context) (programID uint64)

Get the last used proposal ID

func (Keeper) RefundDeposit

func (k Keeper) RefundDeposit(ctx sdk.Context, programID uint64) (err sdk.Error)

RefundDeposit refunds the deposit

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params Params)

SetParams set oracle params from the global param store

func (Keeper) SetProgram

func (k Keeper) SetProgram(ctx sdk.Context, programID uint64, program Program)

SetProgram sets a Program to the context

func (Keeper) SetVote

func (k Keeper) SetVote(ctx sdk.Context, programID uint64, voter sdk.AccAddress, option bool)

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

type Params

type Params struct {
	ActiveThreshold sdk.Dec       `json:"active_threshold"` // threshold of vote that will transition a program open -> active budget queue
	LegacyThreshold sdk.Dec       `json:"legacy_threshold"` // threshold of vote that will transition a program active -> legacy budget queue
	VotePeriod      time.Duration `json:"vote_period"`      // vote period
	MinDeposit      sdk.Coin      `json:"min_deposit"`      // Minimum deposit in TerraSDR
}

Params oracle parameters

func DefaultParams

func DefaultParams() Params

DefaultParams creates default oracle module parameters

func NewParams

func NewParams(activeThreshold sdk.Dec, legacyThreshold sdk.Dec, votePeriod time.Duration, minDeposit sdk.Coin) Params

NewParams creates a new param instance

func (Params) String

func (params Params) String() string

type Program

type Program struct {
	Title       string         `json:"title"`       // Title of the Program
	Description string         `json:"description"` // Description of the Program
	Submitter   sdk.AccAddress `json:"submitter"`   // Validator address of the proposer
	Executor    sdk.AccAddress `json:"executor"`    // Account address of the executor
	SubmitTime  time.Time      `json:"submit_time"` // Block height from which the Program is open for votations
	Deposit     sdk.Coin       `json:"deposit"`     // Coins deposited in escrow
	Tally       sdk.Int        `json:"tally_result"`
}

Program defines the basic properties of a staking Program

func NewProgram

func NewProgram(
	title string,
	description string,
	submitter sdk.AccAddress,
	executor sdk.AccAddress,
	submitTime time.Time,
	deposit sdk.Coin) Program

NewProgram validates deposit and creates a new Program

func (Program) String

func (p Program) String() string

String implements fmt.Stringer

type QueryVotesParams

type QueryVotesParams struct {
	Voter     sdk.AccAddress
	ProgramID uint64
}

Params for query 'custom/oracle/votes'

func NewQueryVotesParams

func NewQueryVotesParams(voter sdk.AccAddress, programID uint64) QueryVotesParams

creates a new instance of QueryVoteParams

type SubmitProgramMsg

type SubmitProgramMsg struct {
	Title       string         // Title of the Program
	Description string         // Description of the Program
	Deposit     sdk.Coin       // Deposit paid by submitter. Must be > MinDeposit to enter voting period
	Submitter   sdk.AccAddress // Address of the submitter
	Executor    sdk.AccAddress // Address of the executor
}

SubmitProgramMsg defines a message to create a Program

func NewSubmitProgramMsg

func NewSubmitProgramMsg(title string, description string, deposit sdk.Coin,
	submitter sdk.AccAddress, executor sdk.AccAddress) SubmitProgramMsg

NewSubmitProgramMsg submits a message with a new Program

func (SubmitProgramMsg) GetSignBytes

func (msg SubmitProgramMsg) GetSignBytes() []byte

Implements Msg

func (SubmitProgramMsg) GetSigners

func (msg SubmitProgramMsg) GetSigners() []sdk.AccAddress

Implements Msg

func (SubmitProgramMsg) Route

func (msg SubmitProgramMsg) Route() string

Route Implements Msg

func (SubmitProgramMsg) String

func (msg SubmitProgramMsg) String() string

func (SubmitProgramMsg) Type

func (msg SubmitProgramMsg) Type() string

Type implements sdk.Msg

func (SubmitProgramMsg) ValidateBasic

func (msg SubmitProgramMsg) ValidateBasic() sdk.Error

Implements Msg

type VoteMsg

type VoteMsg struct {
	ProgramID uint64         // ID of the Program
	Option    bool           // Option chosen by voter
	Voter     sdk.AccAddress // Address of the voter
}

VoteMsg defines the msg of a staker containing the vote option to an specific Program

func NewVoteMsg

func NewVoteMsg(programID uint64, option bool, voter sdk.AccAddress) VoteMsg

NewVoteMsg creates a VoteMsg instance

func (VoteMsg) GetSignBytes

func (msg VoteMsg) GetSignBytes() []byte

Implements Msg

func (VoteMsg) GetSigners

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

Implements Msg

func (VoteMsg) Route

func (msg VoteMsg) Route() string

Route Implements Msg

func (VoteMsg) String

func (msg VoteMsg) String() string

Implements Msg

func (VoteMsg) Type

func (msg VoteMsg) Type() string

Type implements sdk.Msg

func (VoteMsg) ValidateBasic

func (msg VoteMsg) ValidateBasic() sdk.Error

Implements Msg

type WithdrawProgramMsg

type WithdrawProgramMsg struct {
	ProgramID uint64         // ID of the Program
	Submitter sdk.AccAddress // Address of the voter
}

WithdrawProgramMsg defines the msg of a staker containing the vote option to an specific Program

func NewWithdrawProgramMsg

func NewWithdrawProgramMsg(programID uint64, submitter sdk.AccAddress) WithdrawProgramMsg

NewVoteMsg creates a VoteMsg instance

func (WithdrawProgramMsg) GetSignBytes

func (msg WithdrawProgramMsg) GetSignBytes() []byte

Implements Msg

func (WithdrawProgramMsg) GetSigners

func (msg WithdrawProgramMsg) GetSigners() []sdk.AccAddress

Implements Msg

func (WithdrawProgramMsg) Route

func (msg WithdrawProgramMsg) Route() string

Route Implements Msg

func (WithdrawProgramMsg) String

func (msg WithdrawProgramMsg) String() string

Implements Msg

func (WithdrawProgramMsg) Type

func (msg WithdrawProgramMsg) Type() string

Type implements sdk.Msg

func (WithdrawProgramMsg) ValidateBasic

func (msg WithdrawProgramMsg) ValidateBasic() sdk.Error

Implements Msg

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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