Documentation ¶
Index ¶
- func ModuleAccountInvariant(keeper *Keeper, bk types.BankKeeper) sdk.Invariant
- func NewLegacyMsgServerImpl(govAcct string, v1Server v1.MsgServer) v1beta1.MsgServer
- func NewLegacyQueryServer(k *Keeper) v1beta1.QueryServer
- func NewMsgServerImpl(keeper *Keeper) v1.MsgServer
- func NewQueryServer(k *Keeper) v1.QueryServer
- func RegisterInvariants(ir sdk.InvariantRegistry, keeper *Keeper, bk types.BankKeeper)
- type Keeper
- func (keeper Keeper) ActivateVotingPeriod(ctx context.Context, proposal v1.Proposal) error
- func (keeper Keeper) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr sdk.AccAddress, ...) (bool, error)
- func (keeper Keeper) AddVote(ctx context.Context, proposalID uint64, voterAddr sdk.AccAddress, ...) error
- func (keeper Keeper) CancelProposal(ctx context.Context, proposalID uint64, proposer string) error
- func (keeper Keeper) ChargeDeposit(ctx context.Context, proposalID uint64, destAddress, proposalCancelRate string) error
- func (keeper Keeper) DeleteAndBurnDeposits(ctx context.Context, proposalID uint64) error
- func (keeper Keeper) DeleteProposal(ctx context.Context, proposalID uint64) error
- func (k Keeper) GetAuthority() string
- func (keeper Keeper) GetDeposits(ctx context.Context, proposalID uint64) (deposits v1.Deposits, err error)
- func (k Keeper) GetGovernanceAccount(ctx context.Context) sdk.ModuleAccountI
- func (k *Keeper) Hooks() types.GovHooks
- func (keeper Keeper) IterateDeposits(ctx context.Context, proposalID uint64, ...) error
- func (k Keeper) LegacyRouter() v1beta1.Router
- func (k Keeper) Logger(ctx context.Context) log.Logger
- func (k Keeper) ModuleAccountAddress() sdk.AccAddress
- func (keeper Keeper) RefundAndDeleteDeposits(ctx context.Context, proposalID uint64) error
- func (k Keeper) Router() baseapp.MessageRouter
- func (keeper Keeper) SetDeposit(ctx context.Context, deposit v1.Deposit) error
- func (k *Keeper) SetHooks(gh types.GovHooks) *Keeper
- func (k *Keeper) SetLegacyRouter(router v1beta1.Router)
- func (keeper Keeper) SetProposal(ctx context.Context, proposal v1.Proposal) error
- func (keeper Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata, title, summary string, ...) (v1.Proposal, error)
- func (keeper Keeper) Tally(ctx context.Context, proposal v1.Proposal) (passes, burnDeposits bool, tallyResults v1.TallyResult, err error)
- type Migrator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶ added in v0.46.0
NewLegacyMsgServerImpl returns an implementation of the v1beta1 legacy MsgServer interface. It wraps around the current MsgServer
func NewLegacyQueryServer ¶ added in v0.46.0
func NewLegacyQueryServer(k *Keeper) v1beta1.QueryServer
NewLegacyQueryServer returns an implementation of the v1beta1 legacy QueryServer interface.
func NewMsgServerImpl ¶ added in v0.40.0
NewMsgServerImpl returns an implementation of the gov MsgServer interface for the provided Keeper.
func NewQueryServer ¶ added in v0.50.1
func NewQueryServer(k *Keeper) v1.QueryServer
func RegisterInvariants ¶
func RegisterInvariants(ir sdk.InvariantRegistry, keeper *Keeper, bk types.BankKeeper)
RegisterInvariants registers all governance invariants
Types ¶
type Keeper ¶
type Keeper struct { Schema collections.Schema Constitution collections.Item[string] Params collections.Item[v1.Params] Deposits collections.Map[collections.Pair[uint64, sdk.AccAddress], v1.Deposit] Votes collections.Map[collections.Pair[uint64, sdk.AccAddress], v1.Vote] ProposalID collections.Sequence Proposals collections.Map[uint64, v1.Proposal] ActiveProposalsQueue collections.Map[collections.Pair[time.Time, uint64], uint64] // TODO(tip): this should be simplified and go into an index. InactiveProposalsQueue collections.Map[collections.Pair[time.Time, uint64], uint64] // TODO(tip): this should be simplified and go into an index. VotingPeriodProposals collections.Map[uint64, []byte] // TODO(tip): this could be a keyset or index. // contains filtered or unexported fields }
Keeper defines the governance module Keeper
func NewKeeper ¶
func NewKeeper( cdc codec.Codec, storeService corestoretypes.KVStoreService, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, distrKeeper types.DistributionKeeper, router baseapp.MessageRouter, 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 ¶
ActivateVotingPeriod activates the voting period of a proposal
func (Keeper) AddDeposit ¶
func (keeper Keeper) AddDeposit(ctx context.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 context.Context, proposalID uint64, voterAddr sdk.AccAddress, options v1.WeightedVoteOptions, metadata string) error
AddVote adds a vote on a specific proposal
func (Keeper) CancelProposal ¶ added in v0.50.1
CancelProposal will cancel proposal before the voting period ends
func (Keeper) ChargeDeposit ¶ added in v0.50.1
func (keeper Keeper) ChargeDeposit(ctx context.Context, proposalID uint64, destAddress, proposalCancelRate string) error
ChargeDeposit will charge proposal cancellation fee (deposits * proposal_cancel_burn_rate) and send to a destAddress if defined or burn otherwise. Remaining funds are send back to the depositor.
func (Keeper) DeleteAndBurnDeposits ¶ added in v0.46.0
DeleteAndBurnDeposits deletes and burns all the deposits on a specific proposal.
func (Keeper) DeleteProposal ¶
DeleteProposal deletes a proposal from store.
func (Keeper) GetAuthority ¶ added in v0.47.0
GetAuthority returns the x/gov module's authority.
func (Keeper) GetDeposits ¶
func (keeper Keeper) GetDeposits(ctx context.Context, proposalID uint64) (deposits v1.Deposits, err error)
GetDeposits returns all the deposits of a proposal
func (Keeper) GetGovernanceAccount ¶
func (k Keeper) GetGovernanceAccount(ctx context.Context) sdk.ModuleAccountI
GetGovernanceAccount returns the governance ModuleAccount
func (Keeper) IterateDeposits ¶
func (keeper Keeper) IterateDeposits(ctx context.Context, proposalID uint64, cb func(key collections.Pair[uint64, sdk.AccAddress], value v1.Deposit) (bool, error)) error
IterateDeposits iterates over all the proposals deposits and performs a callback function
func (Keeper) LegacyRouter ¶ added in v0.46.0
LegacyRouter returns the gov keeper's legacy router
func (Keeper) ModuleAccountAddress ¶ added in v0.50.1
func (k Keeper) ModuleAccountAddress() sdk.AccAddress
ModuleAccountAddress returns gov module account address
func (Keeper) RefundAndDeleteDeposits ¶ added in v0.46.0
RefundAndDeleteDeposits refunds and deletes all the deposits on a specific proposal.
func (Keeper) Router ¶
func (k Keeper) Router() baseapp.MessageRouter
Router returns the gov keeper's router
func (Keeper) SetDeposit ¶
SetDeposit sets a Deposit to the gov store
func (*Keeper) SetLegacyRouter ¶ added in v0.47.0
SetLegacyRouter sets the legacy router for governance
func (Keeper) SetProposal ¶
SetProposal sets a proposal to store.
type Migrator ¶ added in v0.43.0
type Migrator struct {
// contains filtered or unexported fields
}
Migrator is a struct for handling in-place store migrations.
func NewMigrator ¶ added in v0.43.0
func NewMigrator(keeper *Keeper, legacySubspace exported.ParamSubspace) Migrator
NewMigrator returns a new Migrator.
func (Migrator) Migrate1to2 ¶ added in v0.43.0
Migrate1to2 migrates from version 1 to 2.
func (Migrator) Migrate2to3 ¶ added in v0.46.0
Migrate2to3 migrates from version 2 to 3.
func (Migrator) Migrate3to4 ¶ added in v0.47.0
Migrate3to4 migrates from version 3 to 4.