budget

package
v0.2.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the budget module
	ModuleName = "budget"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// RouterKey is the msg router key for the budget module
	RouterKey = ModuleName

	// QuerierRoute is the query router key for the budget module
	QuerierRoute = ModuleName

	// DefaultParamspace is for the paramspace notation
	DefaultParamspace = ModuleName
)
View Source
const (
	// DefaultCodespace nolint
	DefaultCodespace sdk.CodespaceType = "budget"

	// Budget errors
	CodeInvalidProgramID         sdk.CodeType = 1
	CodeInvalidTitle             sdk.CodeType = 2
	CodeInvalidDescription       sdk.CodeType = 3
	CodeProgramNotFound          sdk.CodeType = 4
	CodeVoteNotFound             sdk.CodeType = 5
	CodeInvalidSubmitter         sdk.CodeType = 6
	CodeRefundFailed             sdk.CodeType = 7
	CodeInvalidSubmitBlockHeight sdk.CodeType = 8
	CodeDuplicateProgramID       sdk.CodeType = 9
)
View Source
const (
	QueryProgram       = "program"
	QueryVotes         = "votes"
	QueryActiveList    = "active-list"
	QueryCandidateList = "candidate-list"
	QueryParams        = "params"
)

query endpoints supported by the governance Querier

Variables

This section is empty.

Functions

func EndBlocker

func EndBlocker(ctx sdk.Context, k Keeper) (resTags sdk.Tags)

EndBlocker is called at the end of every block

func ErrDuplicateProgramID added in v0.2.0

func ErrDuplicateProgramID(programID uint64) sdk.Error

nolint

func ErrInvalidDescription

func ErrInvalidDescription() sdk.Error

nolint

func ErrInvalidProgramID

func ErrInvalidProgramID(ProgramID uint64) sdk.Error

nolint

func ErrInvalidSubmitBlockHeight added in v0.2.0

func ErrInvalidSubmitBlockHeight(submitBlock int64) sdk.Error

nolint

func ErrInvalidSubmitter

func ErrInvalidSubmitter(submitter sdk.AccAddress) sdk.Error

nolint

func ErrInvalidTitle

func ErrInvalidTitle() sdk.Error

nolint

func ErrProgramNotFound

func ErrProgramNotFound(ProgramID uint64) sdk.Error

nolint

func ErrRefundFailed added in v0.0.7

func ErrRefundFailed(submitter sdk.AccAddress, programID uint64) sdk.Error

nolint

func ErrVoteNotFound

func ErrVoteNotFound() sdk.Error

nolint

func InitGenesis

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

new oracle genesis

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 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 GenesisState

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

	ActivePrograms    Programs `json:"active_programs"`
	CandidatePrograms Programs `json:"candidate_programs"`

	Votes Votes `json:"votes"`
}

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, activePrograms,
	candidatePrograms Programs, votes Votes) GenesisState

type Keeper

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

nolint

func NewKeeper

func NewKeeper(cdc *codec.Codec,
	key sdk.StoreKey,
	mrk MarketKeeper,
	mk MintKeeper,
	tk TreasuryKeeper,
	valset sdk.ValidatorSet,
	paramspace params.Subspace) Keeper

NewKeeper crates a new keeper

func (Keeper) AddVote added in v0.0.7

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

AddVote adds the vote option to the store

func (Keeper) CandQueueHas added in v0.0.7

func (k Keeper) CandQueueHas(ctx sdk.Context, endBlock int64, programID uint64) (res bool)

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

func (Keeper) CandQueueInsert added in v0.0.7

func (k Keeper) CandQueueInsert(ctx sdk.Context, endBlock int64, programID uint64)

CandQueueInsert Inserts a ProgramID into the Candidate Program queue at endTime

func (Keeper) CandQueueIterate added in v0.0.7

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

CandQueueIterate iterate all the Programs in the candidate queue

func (Keeper) CandQueueIterateExpired added in v0.0.7

func (k Keeper) CandQueueIterateExpired(ctx sdk.Context, endBlock int64, handler func(uint64) (stop bool))

CandQueueIterateExpired iterate all the Programs in the candidate queue that have outspent their voteperiod

func (Keeper) CandQueueRemove added in v0.0.7

func (k Keeper) CandQueueRemove(ctx sdk.Context, endBlock int64, programID uint64)

CandQueueRemove removes a ProgramID from the Candidate Program Queue

func (Keeper) DeleteProgram

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

DeleteProgram deletes a program from the store

func (Keeper) DeleteVote added in v0.0.7

func (k Keeper) DeleteVote(ctx sdk.Context, programID uint64, voter sdk.AccAddress)

DeleteVote deletes the vote from the store

func (Keeper) DeleteVotesForProgram added in v0.2.0

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

DeleteVotesForProgram deletes the votes for the program from the store

func (Keeper) GetParams

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

GetParams get budget 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 store.

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

func (Keeper) IteratePrograms added in v0.0.7

func (k Keeper) IteratePrograms(ctx sdk.Context, filterInactive bool, handler func(Program) (stop bool))

IteratePrograms iterates programs in the store

func (Keeper) IterateVotes added in v0.0.7

func (k Keeper) IterateVotes(ctx sdk.Context, handler func(uint64, sdk.AccAddress, bool) (stop bool))

IterateVotes iterates votes in the store

func (Keeper) IterateVotesWithPrefix added in v0.0.7

func (k Keeper) IterateVotesWithPrefix(ctx sdk.Context, prefix []byte, handler func(uint64, sdk.AccAddress, bool) (stop bool))

IterateVotesWithPrefix iterates votes with given {prefix} in the store

func (Keeper) NewProgramID

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

NewProgramID generates a new program id; advances sequentially from 1; 0 conflits with vote querier

func (Keeper) PayDeposit added in v0.0.7

func (k Keeper) PayDeposit(ctx sdk.Context, submitter sdk.AccAddress) (err sdk.Error)

PayDeposit pays the deposit by withdrawing from the submitter's balance.

func (Keeper) RefundDeposit

func (k Keeper) RefundDeposit(ctx sdk.Context, submitter sdk.AccAddress) (err sdk.Error)

RefundDeposit refunds the deposit, by crediting the submitter's balance.

func (Keeper) SetParams

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

SetParams set budget params from the global param store

func (Keeper) StoreProgram added in v0.2.0

func (k Keeper) StoreProgram(ctx sdk.Context, program Program)

StoreProgram sets a Program to the store

type MarketKeeper added in v0.2.0

type MarketKeeper interface {
	GetSwapDecCoin(ctx sdk.Context, offerCoin sdk.DecCoin, askDenom string) (sdk.DecCoin, sdk.Error)
}

expected market keeper

type MintKeeper added in v0.2.0

type MintKeeper interface {
	Mint(ctx sdk.Context, recipient sdk.AccAddress, coin sdk.Coin) (err sdk.Error)
	Burn(ctx sdk.Context, payer sdk.AccAddress, coin sdk.Coin) (err sdk.Error)
	PeekEpochSeigniorage(ctx sdk.Context, epoch sdk.Int) (epochSeigniorage sdk.Int)
}

expected mint keeper

type MsgSubmitProgram added in v0.0.7

type MsgSubmitProgram struct {
	Title       string         `json:"title"`       // Title of the Program
	Description string         `json:"description"` // Description of the Program
	Submitter   sdk.AccAddress `json:"submitter"`   // Address of the submitter
	Executor    sdk.AccAddress `json:"executor"`    // Address of the executor
}

MsgSubmitProgram defines a message to create a Program

func NewMsgSubmitProgram added in v0.0.7

func NewMsgSubmitProgram(title string, description string,
	submitter sdk.AccAddress, executor sdk.AccAddress) MsgSubmitProgram

NewMsgSubmitProgram submits a message with a new Program

func (MsgSubmitProgram) GetSignBytes added in v0.0.7

func (msg MsgSubmitProgram) GetSignBytes() []byte

GetSignBytes returns sign byptes

func (MsgSubmitProgram) GetSigners added in v0.0.7

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

GetSigners returns signer

func (MsgSubmitProgram) Route added in v0.0.7

func (msg MsgSubmitProgram) Route() string

Route returns msg route

func (MsgSubmitProgram) String added in v0.0.7

func (msg MsgSubmitProgram) String() string

String stringify the msg

func (MsgSubmitProgram) Type added in v0.0.7

func (msg MsgSubmitProgram) Type() string

Type returns msg type

func (MsgSubmitProgram) ValidateBasic added in v0.0.7

func (msg MsgSubmitProgram) ValidateBasic() sdk.Error

ValidateBasic validate msg

type MsgVoteProgram added in v0.0.7

type MsgVoteProgram struct {
	ProgramID uint64         `json:"program_id"` // ID of the Program
	Option    bool           `json:"option"`     // Option chosen by voter
	Voter     sdk.AccAddress `json:"voter"`      // Address of the voter
}

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

func NewMsgVoteProgram added in v0.0.7

func NewMsgVoteProgram(programID uint64, option bool, voter sdk.AccAddress) MsgVoteProgram

NewMsgVoteProgram creates a MsgVoteProgram instance

func (MsgVoteProgram) GetSignBytes added in v0.0.7

func (msg MsgVoteProgram) GetSignBytes() []byte

GetSignBytes returns sign byptes

func (MsgVoteProgram) GetSigners added in v0.0.7

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

GetSigners returns signer

func (MsgVoteProgram) Route added in v0.0.7

func (msg MsgVoteProgram) Route() string

Route returns msg route

func (MsgVoteProgram) String added in v0.0.7

func (msg MsgVoteProgram) String() string

String stringify the msg

func (MsgVoteProgram) Type added in v0.0.7

func (msg MsgVoteProgram) Type() string

Type returns msg type

func (MsgVoteProgram) ValidateBasic added in v0.0.7

func (msg MsgVoteProgram) ValidateBasic() sdk.Error

ValidateBasic validate msg

type MsgWithdrawProgram added in v0.0.7

type MsgWithdrawProgram struct {
	ProgramID uint64         `json:"program_id"` // ID of the Program
	Submitter sdk.AccAddress `json:"submitter"`  // Address of the voter
}

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

func NewMsgWithdrawProgram added in v0.0.7

func NewMsgWithdrawProgram(programID uint64, submitter sdk.AccAddress) MsgWithdrawProgram

NewMsgWithdrawProgram creates a VoteMsg instance

func (MsgWithdrawProgram) GetSignBytes added in v0.0.7

func (msg MsgWithdrawProgram) GetSignBytes() []byte

GetSignBytes returns sign byptes

func (MsgWithdrawProgram) GetSigners added in v0.0.7

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

GetSigners returns signer

func (MsgWithdrawProgram) Route added in v0.0.7

func (msg MsgWithdrawProgram) Route() string

Route returns msg route

func (MsgWithdrawProgram) String added in v0.0.7

func (msg MsgWithdrawProgram) String() string

String stringify the msg

func (MsgWithdrawProgram) Type added in v0.0.7

func (msg MsgWithdrawProgram) Type() string

Type returns msg type

func (MsgWithdrawProgram) ValidateBasic added in v0.0.7

func (msg MsgWithdrawProgram) ValidateBasic() sdk.Error

ValidateBasic validate msg

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      int64    `json:"vote_period"`      // vote period
	Deposit         sdk.Coin `json:"deposit"`          // Minimum deposit in TerraSDR
}

Params budget parameters

func DefaultParams

func DefaultParams() Params

DefaultParams creates default budget module parameters

func NewParams

func NewParams(activeThreshold sdk.Dec, legacyThreshold sdk.Dec, votePeriod int64, deposit sdk.Coin) Params

NewParams creates a new param instance

func (Params) String

func (params Params) String() string

type Program

type Program struct {
	ProgramID   uint64         `json:"program_id"`  // ID of the Program
	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
	SubmitBlock int64          `json:"submit_time"` // Block height from which the Program is open for votations
}

Program defines the basic properties of a staking Program

func NewProgram

func NewProgram(
	programID uint64,
	title string,
	description string,
	submitter sdk.AccAddress,
	executor sdk.AccAddress,
	submitBlock int64) Program

NewProgram validates deposit and creates a new Program

func (Program) String

func (p Program) String() string

String implements fmt.Stringer

type Programs added in v0.0.7

type Programs []Program

Programs is a collection of Program

func (Programs) String added in v0.0.7

func (p Programs) String() (out string)

type QueryActiveListResponse added in v0.2.2

type QueryActiveListResponse struct {
	Actives Programs `json:"actives"`
}

JSON response format

func (QueryActiveListResponse) String added in v0.2.2

func (r QueryActiveListResponse) String() (out string)

type QueryCandidateListResponse added in v0.2.2

type QueryCandidateListResponse struct {
	Candidates Programs `json:"candidates"`
}

JSON response format

func (QueryCandidateListResponse) String added in v0.2.2

func (r QueryCandidateListResponse) String() (out string)

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 QueryVotesResponse added in v0.2.2

type QueryVotesResponse struct {
	Votes Votes `json:"votes"`
}

JSON response format

func (QueryVotesResponse) String added in v0.2.2

func (r QueryVotesResponse) String() (out string)

type TreasuryKeeper added in v0.2.0

type TreasuryKeeper interface {
	GetRewardWeight(ctx sdk.Context, epoch sdk.Int) (rewardWeight sdk.Dec)
	SetRewardWeight(ctx sdk.Context, weight sdk.Dec)
}

expected treasury keeper

type Vote added in v0.0.7

type Vote MsgVoteProgram

no-lint

func NewVote added in v0.0.7

func NewVote(programID uint64, option bool, voter sdk.AccAddress) Vote

NewMsgVoteProgram creates a MsgVoteProgram instance

func (Vote) String added in v0.0.7

func (v Vote) String() string

type Votes added in v0.0.7

type Votes []Vote

Votes is a collection of Vote

func (Votes) String added in v0.0.7

func (v Votes) String() (out string)

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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