v0.50.4 Latest Latest

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 29 Imported by: 1,001




This section is empty.


This section is empty.


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

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

func NewMsgServerImpl(keeper *Keeper) v1.MsgServer

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


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

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

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

func (keeper Keeper) CancelProposal(ctx context.Context, proposalID uint64, proposer string) error

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

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

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

func (Keeper) DeleteProposal

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

DeleteProposal deletes a proposal from store.

func (Keeper) GetAuthority added in v0.47.0

func (k Keeper) GetAuthority() string

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) Hooks added in v0.47.0

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

Hooks gets the hooks for governance *Keeper {

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

func (k Keeper) LegacyRouter() v1beta1.Router

LegacyRouter returns the gov keeper's legacy router

func (Keeper) Logger

func (k Keeper) Logger(ctx context.Context) log.Logger

Logger returns a module-specific logger.

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

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

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

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

SetDeposit sets a Deposit to the gov store

func (*Keeper) SetHooks added in v0.43.0

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

SetHooks sets the hooks for governance

func (*Keeper) SetLegacyRouter added in v0.47.0

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

SetLegacyRouter sets the legacy router for governance

func (Keeper) SetProposal

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

SetProposal sets a proposal to store.

func (Keeper) SubmitProposal

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

SubmitProposal creates a new proposal given an array of messages

func (Keeper) Tally

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

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

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

func (m Migrator) Migrate1to2(ctx sdk.Context) error

Migrate1to2 migrates from version 1 to 2.

func (Migrator) Migrate2to3 added in v0.46.0

func (m Migrator) Migrate2to3(ctx sdk.Context) error

Migrate2to3 migrates from version 2 to 3.

func (Migrator) Migrate3to4 added in v0.47.0

func (m Migrator) Migrate3to4(ctx sdk.Context) error

Migrate3to4 migrates from version 3 to 4.

func (Migrator) Migrate4to5 added in v0.50.1

func (m Migrator) Migrate4to5(ctx sdk.Context) error

Migrate4to5 migrates from version 4 to 5.

Jump to

Keyboard shortcuts

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