Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultOriginalMintedPerBlock() sdk.Dec
- func ErrExtraProposalParams(desc string) sdk.Error
- func ErrTreasuresInternal(err error) sdk.EnvelopedErr
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func SortTreasures(treasures []Treasure)
- func ValidateGenesis(data GenesisState) error
- func ValidateMinter(minter Minter) error
- func ValidateMinterCustom(minter MinterCustom) error
- func ValidateTreasures(treasures []Treasure) error
- type ExtraProposal
- type GenesisState
- type GovKeeper
- type ManageTreasuresProposal
- func (mp ManageTreasuresProposal) GetDescription() string
- func (mp ManageTreasuresProposal) GetTitle() string
- func (mp ManageTreasuresProposal) ProposalRoute() string
- func (mp ManageTreasuresProposal) ProposalType() string
- func (mp ManageTreasuresProposal) String() string
- func (mp ManageTreasuresProposal) ValidateBasic() sdk.Error
- type MintedPerBlockParams
- type Minter
- type MinterCustom
- type NextBlockUpdateParams
- type Params
- type StakingKeeper
- type SupplyKeeper
- type Treasure
Constants ¶
const ( ManageTreasuresProposalName = system.Chain + "/mint/ManageTreasuresProposal" ExtraProposalName = system.Chain + "/mint/ExtraProposal" )
const ( EventTypeMint = ModuleName AttributeKeyBondedRatio = "bonded_ratio" AttributeKeyInflation = "inflation" AttributeKeyAnnualProvisions = "annual_provisions" )
Minting module event types
const ( // ModuleName ModuleName = "mint" // DefaultParamspace params keeper DefaultParamspace = ModuleName // StoreKey is the default store key for mint StoreKey = ModuleName // QuerierRoute is the querier route for the minting store. QuerierRoute = StoreKey // Query endpoints supported by the minting querier QueryParameters = "parameters" QueryInflation = "inflation" QueryAnnualProvisions = "annual_provisions" QueryTreasures = "treasures" QueryBlockRewards = "block_rewards" )
nolint
const ( // ProposalTypeExtra defines the type for a MintExtraProposal ProposalTypeExtra = "MintExtra" ActionNextBlockUpdate = "NextBlockUpdate" ActionMintedPerBlock = "MintedPerBlock" // RouterKey uses module name for routing RouterKey = ModuleName )
const (
DefaultCodespace string = ModuleName
)
NOTE: We can't use 1 since that error code is reserved for internal errors.
Variables ¶
var ( // ErrInvalidState returns an error resulting from an invalid Storage State. ErrEmptyTreasures = sdkerrors.Register(ModuleName, 2, "treasures is not empty") ErrDuplicatedTreasure = sdkerrors.Register(ModuleName, 3, "treasures can not be duplicate") ErrUnexpectedProposalType = sdkerrors.Register(ModuleName, 4, "unsupported proposal type of mint module") ErrProposerMustBeValidator = sdkerrors.Register(ModuleName, 5, "the proposal of proposer must be validator") ErrNextBlockUpdateTooLate = sdkerrors.Register(ModuleName, 7, "the next block to update is too late") ErrCodeInvalidHeight = sdkerrors.Register(ModuleName, 8, "height must be greater than current block") ErrHandleExtraProposal = sdkerrors.Register(ModuleName, 9, "handle extra proposal error") ErrUnknownExtraProposalAction = sdkerrors.Register(ModuleName, 10, "extra proposal's action unknown") )
var ( // MinterKey is used for the keeper store MinterKey = []byte{0x00} // TreasuresKey is used for the keeper store TreasuresKey = []byte{0x01} )
var ( KeyMintDenom = []byte("MintDenom") //KeyInflationRateChange = []byte("InflationRateChange") //KeyInflationMax = []byte("InflationMax") //KeyInflationMin = []byte("InflationMin") //KeyGoalBonded = []byte("GoalBonded") KeyBlocksPerYear = []byte("BlocksPerYear") KeyDeflationRate = []byte("DeflationRate") KeyDeflationEpoch = []byte("DeflationEpoch") )
Parameter store keys
var ModuleCdc *codec.Codec
ModuleCdc is a generic sealed codec to be used throughout this module
Functions ¶
func ErrExtraProposalParams ¶
func ErrTreasuresInternal ¶
func ErrTreasuresInternal(err error) sdk.EnvelopedErr
ErrTreasuresInternal returns an error when the length of address list in the proposal is larger than the max limitation
func RegisterCodec ¶
func SortTreasures ¶
func SortTreasures(treasures []Treasure)
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the provided genesis state to ensure the expected invariants holds.
func ValidateMinterCustom ¶
func ValidateMinterCustom(minter MinterCustom) error
ValidateMinterCustom validate minter
func ValidateTreasures ¶
Types ¶
type ExtraProposal ¶
type ExtraProposal struct { Title string `json:"title" yaml:"title"` Description string `json:"description" yaml:"description"` Action string `json:"action" yaml:"action"` Extra string `json:"extra" yaml:"extra"` }
func NewExtraProposal ¶
func NewExtraProposal(title, description, action, extra string) ExtraProposal
NewExtraProposal creates a new extra proposal.
func (ExtraProposal) GetDescription ¶
func (p ExtraProposal) GetDescription() string
GetDescription returns the description of a community pool spend proposal.
func (ExtraProposal) GetTitle ¶
func (p ExtraProposal) GetTitle() string
GetTitle returns the title of a community pool spend proposal.
func (ExtraProposal) ProposalRoute ¶
func (p ExtraProposal) ProposalRoute() string
GetDescription returns the routing key of a community pool spend proposal.
func (ExtraProposal) ProposalType ¶
func (p ExtraProposal) ProposalType() string
ProposalType returns the type of a community pool spend proposal.
func (ExtraProposal) String ¶
func (p ExtraProposal) String() string
String implements the Stringer interface.
func (ExtraProposal) ValidateBasic ¶
func (p ExtraProposal) ValidateBasic() error
ValidateBasic runs basic stateless validity checks
type GenesisState ¶
type GenesisState struct { Minter MinterCustom `json:"minter" yaml:"minter"` // minter object Params Params `json:"params" yaml:"params"` // inflation params Treasures []Treasure `json:"treasures,omitempty" yaml:"treasures,omitempty"` // treasures OriginalMintedPerBlock sdk.Dec `json:"original_minted_per_block" yaml:"original_minted_per_block"` }
GenesisState - minter state
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState creates a default GenesisState object
func NewGenesisState ¶
func NewGenesisState(minter MinterCustom, params Params, originalMintedPerBlock sdk.Dec) GenesisState
NewGenesisState creates a new GenesisState object
type GovKeeper ¶
type GovKeeper interface { GetDepositParams(ctx sdk.Context) govtypes.DepositParams GetVotingParams(ctx sdk.Context) govtypes.VotingParams }
GovKeeper defines the expected gov Keeper
type ManageTreasuresProposal ¶
type ManageTreasuresProposal struct { Title string `json:"title" yaml:"title"` Description string `json:"description" yaml:"description"` Treasures []Treasure `json:"treasures" yaml:"treasures"` IsAdded bool `json:"is_added" yaml:"is_added"` }
ManageTreasuresProposal - structure for the proposal to add or delete treasures
func NewManageTreasuresProposal ¶
func NewManageTreasuresProposal(title, description string, treasures []Treasure, isAdded bool, ) ManageTreasuresProposal
NewManageTreasuresProposal creates a new instance of ManageTreasuresProposal
func (ManageTreasuresProposal) GetDescription ¶
func (mp ManageTreasuresProposal) GetDescription() string
GetDescription returns description of a manage treasures proposal object
func (ManageTreasuresProposal) GetTitle ¶
func (mp ManageTreasuresProposal) GetTitle() string
GetTitle returns title of a manage treasures proposal object
func (ManageTreasuresProposal) ProposalRoute ¶
func (mp ManageTreasuresProposal) ProposalRoute() string
ProposalRoute returns route key of a manage treasures proposal object
func (ManageTreasuresProposal) ProposalType ¶
func (mp ManageTreasuresProposal) ProposalType() string
ProposalType returns type of a manage treasures proposal object
func (ManageTreasuresProposal) String ¶
func (mp ManageTreasuresProposal) String() string
String returns a human readable string representation of a ManageTreasuresProposal
func (ManageTreasuresProposal) ValidateBasic ¶
func (mp ManageTreasuresProposal) ValidateBasic() sdk.Error
ValidateBasic validates a manage treasures proposal
type MintedPerBlockParams ¶
type MintedPerBlockParams struct {
Coin sdk.SysCoin `json:"coin" yaml:"coin"` // minted per block on this proposal.
}
func NewMintedPerBlockParams ¶
func NewMintedPerBlockParams(jsonData string) (MintedPerBlockParams, error)
type Minter ¶
type Minter struct { Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"annual_provisions"` // current annual expected provisions }
Minter represents the minting state.
func DefaultInitialMinter ¶
func DefaultInitialMinter() Minter
DefaultInitialMinter returns a default initial Minter object for a new chain which uses an inflation rate of 13%.
func InitialMinter ¶
InitialMinter returns an initial Minter object with a given inflation value.
func NewMinter ¶
NewMinter returns a new Minter object with the given inflation and annual provisions values.
func (Minter) BlockProvision ¶
BlockProvision returns the provisions for a block based on the annual provisions rate.
func (Minter) NextAnnualProvisions ¶
NextAnnualProvisions returns the annual provisions based on current total supply and inflation rate.
type MinterCustom ¶
type MinterCustom struct { NextBlockToUpdate uint64 `json:"next_block_to_update" yaml:"next_block_to_update"` // record the block height for next year MintedPerBlock types.DecCoins `json:"minted_per_block" yaml:"minted_per_block"` // record the MintedPerBlock per block in this year }
func DefaultInitialMinterCustom ¶
func DefaultInitialMinterCustom() MinterCustom
DefaultInitialMinterCustom returns a default initial MinterCustom object for a new chain which uses an inflation rate of 1%.
func InitialMinterCustom ¶
func InitialMinterCustom() MinterCustom
InitialMinterCustom returns an initial Minter object with a given inflation value.
func NewMinterCustom ¶
func NewMinterCustom(nextBlockToUpdate uint64, mintedPerBlock sdk.DecCoins) MinterCustom
NewMinterCustom returns a new Minter object with the given inflation and annual provisions values.
type NextBlockUpdateParams ¶
type NextBlockUpdateParams struct {
BlockNum uint64 `json:"block_num" yaml:"block_num"`
}
func NewNextBlockUpdate ¶
func NewNextBlockUpdate(data string) (NextBlockUpdateParams, error)
type Params ¶
type Params struct { MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // Deprecated: maximum annual change in inflation rate InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // Deprecated: maximum inflation rate InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // Deprecated: minimum inflation rate GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // Deprecated: goal of percent bonded atoms BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // blocks per year according to one block per 3s DeflationRate sdk.Dec `json:"deflation_rate" yaml:"deflation_rate"` // deflation rate every DeflationEpoch DeflationEpoch uint64 `json:"deflation_epoch" yaml:"deflation_epoch"` // block number to deflate }
mint parameters
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
Implements params.ParamSet
type StakingKeeper ¶
type StakingKeeper interface { StakingTokenSupply(ctx sdk.Context) sdk.Dec BondedRatio(ctx sdk.Context) sdk.Dec IsValidator(ctx sdk.Context, addr sdk.AccAddress) bool }
StakingKeeper defines the expected staking keeper
type SupplyKeeper ¶
type SupplyKeeper interface { GetModuleAddress(name string) sdk.AccAddress // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 SetModuleAccount(sdk.Context, exported.ModuleAccountI) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error }
SupplyKeeper defines the expected supply keeper
type Treasure ¶
type Treasure struct { //Treasure Address Address sdk.AccAddress `json:"address" yaml:"address"` // proportion of minted for treasure Proportion sdk.Dec `json:"proportion" yaml:"proportion"` }
Treasure is the struct which has address and proportion of mint reward.
func DeleteTreasures ¶
func NewTreasure ¶
func NewTreasure(address sdk.AccAddress, proportion sdk.Dec) *Treasure