keeper

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(keeper *Keeper, bk types.BankKeeper) sdk.Invariant

AllInvariants runs all invariants of the governance module

func ModuleAccountInvariant

func ModuleAccountInvariant(keeper *Keeper, bk types.BankKeeper) sdk.Invariant

ModuleAccountInvariant checks that the module account coins reflects the sum of deposit amounts held on store.

func NewLegacyMsgServerImpl

func NewLegacyMsgServerImpl(govAcct string, v1Server v1.MsgServer) v1beta1.MsgServer

NewLegacyMsgServerImpl returns an implementation of the v1beta1 legacy MsgServer interface. It wraps around the current MsgServer

func NewLegacyQueryServer

func NewLegacyQueryServer(k *Keeper) v1beta1.QueryServer

NewLegacyQueryServer returns an implementation of the v1beta1 legacy QueryServer interface.

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) v1.MsgServer

NewMsgServerImpl returns an implementation of the gov MsgServer interface for the provided Keeper.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper *Keeper, bk types.BankKeeper)

RegisterInvariants registers all governance invariants

Types

type Keeper

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

Keeper defines the governance module Keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key storetypes.StoreKey, authKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper, sk types.StakingKeeper,
	router *baseapp.MsgServiceRouter, config types.Config, authority string,
) *Keeper

NewKeeper returns a governance keeper. It handles: - submitting governance proposals - depositing funds into proposals, and activating upon sufficient funds being deposited - users voting on proposals, with weight proportional to stake in the system - and tallying the result of the vote.

CONTRACT: the parameter Subspace must have the param key table already initialized

func (Keeper) ActivateVotingPeriod

func (keeper Keeper) ActivateVotingPeriod(ctx sdk.Context, proposal v1.Proposal)

ActivateVotingPeriod activates the voting period of a proposal

func (Keeper) ActiveProposalQueueIterator

func (keeper Keeper) ActiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

ActiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Active Queue that expire by endTime

func (Keeper) AddDeposit

func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (bool, error)

AddDeposit adds or updates a deposit of a specific depositor on a specific proposal. Activates voting period when appropriate and returns true in that case, else returns false.

func (Keeper) AddVote

func (keeper Keeper) AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, options v1.WeightedVoteOptions, metadata string) error

AddVote adds a vote on a specific proposal

func (Keeper) ApplyConstitutionAmendment

func (k Keeper) ApplyConstitutionAmendment(ctx sdk.Context, amendment string) (updatedConstitution string, err error)

ApplyConstitutionAmendment applies the amendment as a patch against the current constitution and returns the updated constitution. If the amendment cannot be applied cleanly, an error is returned.

func (Keeper) DeleteAndBurnDeposits

func (keeper Keeper) DeleteAndBurnDeposits(ctx sdk.Context, proposalID uint64)

DeleteAndBurnDeposits deletes and burns all the deposits on a specific proposal.

func (Keeper) DeleteProposal

func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64)

DeleteProposal deletes a proposal from store. Panics if the proposal doesn't exist.

func (Keeper) Deposit

Deposit queries single deposit information based on proposalID, depositAddr.

func (Keeper) Deposits

Deposits returns single proposal's all deposits

func (Keeper) GetAllDeposits

func (keeper Keeper) GetAllDeposits(ctx sdk.Context) (deposits v1.Deposits)

GetAllDeposits returns all the deposits from the store

func (Keeper) GetAllVotes

func (keeper Keeper) GetAllVotes(ctx sdk.Context) (votes v1.Votes)

GetAllVotes returns all the votes from the store

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the x/gov module's authority.

func (Keeper) GetConstitution

func (keeper Keeper) GetConstitution(ctx sdk.Context) (constitution string)

func (Keeper) GetDeposit

func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) (deposit v1.Deposit, found bool)

GetDeposit gets the deposit of a specific depositor on a specific proposal

func (Keeper) GetDeposits

func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) (deposits v1.Deposits)

GetDeposits returns all the deposits of a proposal

func (Keeper) GetGovernanceAccount

func (keeper Keeper) GetGovernanceAccount(ctx sdk.Context) authtypes.ModuleAccountI

GetGovernanceAccount returns the governance ModuleAccount

func (Keeper) GetParams

func (k Keeper) GetParams(clientCtx sdk.Context) (params v1.Params)

GetParams gets the gov module's parameters.

func (Keeper) GetProposal

func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (v1.Proposal, bool)

GetProposal gets a proposal from store by ProposalID. Panics if can't unmarshal the proposal.

func (Keeper) GetProposalID

func (keeper Keeper) GetProposalID(ctx sdk.Context) (proposalID uint64, err error)

GetProposalID gets the highest proposal ID

func (Keeper) GetProposals

func (keeper Keeper) GetProposals(ctx sdk.Context) (proposals v1.Proposals)

GetProposals returns all the proposals from store

func (Keeper) GetProposalsFiltered

func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, params v1.QueryProposalsParams) v1.Proposals

GetProposalsFiltered retrieves proposals filtered by a given set of params which include pagination parameters along with voter and depositor addresses and a proposal status. The voter address will filter proposals by whether or not that address has voted on proposals. The depositor address will filter proposals by whether or not that address has deposited to them. Finally, status will filter proposals by status.

NOTE: If no filters are provided, all proposals will be returned in paginated form.

func (Keeper) GetVote

func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) (vote v1.Vote, found bool)

GetVote gets the vote from an address on a specific proposal

func (Keeper) GetVotes

func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) (votes v1.Votes)

GetVotes returns all the votes from a proposal

func (Keeper) HasReachedQuorum

func (keeper Keeper) HasReachedQuorum(ctx sdk.Context, proposal v1.Proposal) (quorumPassed bool, err error)

HasReachedQuorum returns whether or not a proposal has reached quorum this is just a stripped down version of the Tally function above

func (*Keeper) Hooks

func (keeper *Keeper) Hooks() types.GovHooks

Hooks gets the hooks for governance *Keeper {

func (Keeper) InactiveProposalQueueIterator

func (keeper Keeper) InactiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

InactiveProposalQueueIterator returns an sdk.Iterator for all the proposals in the Inactive Queue that expire by endTime

func (Keeper) InsertActiveProposalQueue

func (keeper Keeper) InsertActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)

InsertActiveProposalQueue inserts a proposalID into the active proposal queue at endTime

func (Keeper) InsertInactiveProposalQueue

func (keeper Keeper) InsertInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)

InsertInactiveProposalQueue inserts a proposalID into the inactive proposal queue at endTime

func (Keeper) InsertQuorumCheckQueue

func (keeper Keeper) InsertQuorumCheckQueue(ctx sdk.Context, proposalID uint64, endTime time.Time, q v1.QuorumCheckQueueEntry)

InsertQuorumCheckQueue inserts a QuorumCheckEntry into the quorum check queue.

func (Keeper) IterateActiveProposalsQueue

func (keeper Keeper) IterateActiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1.Proposal) (stop bool))

IterateActiveProposalsQueue iterates over the proposals in the active proposal queue and performs a callback function

func (Keeper) IterateAllDeposits

func (keeper Keeper) IterateAllDeposits(ctx sdk.Context, cb func(deposit v1.Deposit) (stop bool))

IterateAllDeposits iterates over all the stored deposits and performs a callback function.

func (Keeper) IterateAllVotes

func (keeper Keeper) IterateAllVotes(ctx sdk.Context, cb func(vote v1.Vote) (stop bool))

IterateAllVotes iterates over all the stored votes and performs a callback function

func (Keeper) IterateDeposits

func (keeper Keeper) IterateDeposits(ctx sdk.Context, proposalID uint64, cb func(deposit v1.Deposit) (stop bool))

IterateDeposits iterates over all the proposals deposits and performs a callback function

func (Keeper) IterateInactiveProposalsQueue

func (keeper Keeper) IterateInactiveProposalsQueue(ctx sdk.Context, endTime time.Time, cb func(proposal v1.Proposal) (stop bool))

IterateInactiveProposalsQueue iterates over the proposals in the inactive proposal queue and performs a callback function

func (Keeper) IterateProposals

func (keeper Keeper) IterateProposals(ctx sdk.Context, cb func(proposal v1.Proposal) (stop bool))

IterateProposals iterates over all the proposals and performs a callback function. Panics when the iterator encounters a proposal which can't be unmarshaled.

func (Keeper) IterateQuorumCheckQueue

func (keeper Keeper) IterateQuorumCheckQueue(ctx sdk.Context, endTime time.Time, cb func(v1.Proposal, time.Time, v1.QuorumCheckQueueEntry) (stop bool))

IterateQuorumCheckQueue iterates over the proposals in the quorum check queue and performs a callback function

func (Keeper) IterateVotes

func (keeper Keeper) IterateVotes(ctx sdk.Context, proposalID uint64, cb func(vote v1.Vote) (stop bool))

IterateVotes iterates over all the proposals votes and performs a callback function

func (Keeper) LegacyRouter

func (keeper Keeper) LegacyRouter() v1beta1.Router

LegacyRouter returns the gov keeper's legacy router

func (Keeper) Logger

func (keeper Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MarshalProposal

func (keeper Keeper) MarshalProposal(proposal v1.Proposal) ([]byte, error)

MarshalProposal marshals the proposal and returns binary encoded bytes.

func (Keeper) Params

Params queries all params

func (Keeper) Proposal

Proposal returns proposal details based on ProposalID

func (Keeper) Proposals

Proposals implements the Query/Proposals gRPC method

func (Keeper) QuorumCheckQueueIterator

func (keeper Keeper) QuorumCheckQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

QuorumCheckQueueIterator returns an sdk.Iterator for all the proposals in the QuorumCheck Queue that expire by endTime

func (Keeper) RefundAndDeleteDeposits

func (keeper Keeper) RefundAndDeleteDeposits(ctx sdk.Context, proposalID uint64)

RefundAndDeleteDeposits refunds and deletes all the deposits on a specific proposal.

func (Keeper) RemoveFromActiveProposalQueue

func (keeper Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)

RemoveFromActiveProposalQueue removes a proposalID from the Active Proposal Queue

func (Keeper) RemoveFromInactiveProposalQueue

func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)

RemoveFromInactiveProposalQueue removes a proposalID from the Inactive Proposal Queue

func (Keeper) RemoveFromQuorumCheckQueue

func (keeper Keeper) RemoveFromQuorumCheckQueue(ctx sdk.Context, proposalID uint64, endTime time.Time)

RemoveFromQuorumCheckQueue removes from the quorum check queue.

func (Keeper) Router

func (keeper Keeper) Router() *baseapp.MsgServiceRouter

Router returns the gov keeper's router

func (Keeper) SetConstitution

func (keeper Keeper) SetConstitution(ctx sdk.Context, constitution string)

func (Keeper) SetDeposit

func (keeper Keeper) SetDeposit(ctx sdk.Context, deposit v1.Deposit)

SetDeposit sets a Deposit to the gov store

func (*Keeper) SetHooks

func (keeper *Keeper) SetHooks(gh types.GovHooks) *Keeper

SetHooks sets the hooks for governance

func (*Keeper) SetLegacyRouter

func (keeper *Keeper) SetLegacyRouter(router v1beta1.Router)

SetLegacyRouter sets the legacy router for governance

func (Keeper) SetParams

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

SetParams sets the gov module's parameters.

func (Keeper) SetProposal

func (keeper Keeper) SetProposal(ctx sdk.Context, proposal v1.Proposal)

SetProposal sets a proposal to store. Panics if can't marshal the proposal.

func (Keeper) SetProposalID

func (keeper Keeper) SetProposalID(ctx sdk.Context, proposalID uint64)

SetProposalID sets the new proposal ID to the store

func (Keeper) SetVote

func (keeper Keeper) SetVote(ctx sdk.Context, vote v1.Vote)

SetVote sets a Vote to the gov store

func (Keeper) SubmitProposal

func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadata, title, summary string, proposer sdk.AccAddress) (v1.Proposal, error)

SubmitProposal creates a new proposal given an array of messages

func (Keeper) Tally

func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool, burnDeposits bool, tallyResults v1.TallyResult)

Tally iterates over the votes and updates the tally of a proposal based on the voting power of the voters

func (Keeper) TallyResult

TallyResult queries the tally of a proposal vote

func (Keeper) UnmarshalProposal

func (keeper Keeper) UnmarshalProposal(bz []byte, proposal *v1.Proposal) error

UnmarshalProposal unmarshals the proposal.

func (Keeper) Vote

Vote returns Voted information based on proposalID, voterAddr

func (Keeper) Votes

Votes returns single proposal's votes

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper *Keeper, legacySubspace exported.ParamSubspace) Migrator

NewMigrator returns a new Migrator.

Jump to

Keyboard shortcuts

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