types

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeKeyDepositor = "depositor"
	AttributeKeyVoter     = "voter"
	AttributeTxHash       = "txhash"
)
View Source
const (
	// StatusNil is the nil status.
	StatusNil ProposalStatus = iota
	// StatusDepositPeriod is the deposit period status.
	StatusDepositPeriod
	// StatusCertifierVotingPeriod is the certifier voting period status.
	StatusCertifierVotingPeriod
	// StatusValidatorVotingPeriod is the validator voting period status.
	StatusValidatorVotingPeriod
	// StatusPassed is the passed status.
	StatusPassed
	// StatusRejected is the rejected status.
	StatusRejected
	// StatusFailed is the failed status.
	StatusFailed

	// DepositPeriod is the string of DepositPeriod.
	DepositPeriod = "DepositPeriod"
	// CertifierVotingPeriod is the string of CertifierVotingPeriod.
	CertifierVotingPeriod = "CertifierVotingPeriod"
	// ValidatorVotingPeriod is the string of ValidatorVotingPeriod.
	ValidatorVotingPeriod = "ValidatorVotingPeriod"
	// Passed is the string of Passed.
	Passed = "Passed"
	// Rejected is the string of Rejected.
	Rejected = "Rejected"
	// Failed is the string of Failed.
	Failed = "Failed"
)
View Source
const (
	ProposalTypeText            string = "Text"
	ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade"
)

Proposal types

Variables

View Source
var (
	ParamStoreKeyDepositParams = []byte("depositparams")
	ParamStoreKeyVotingParams  = []byte("votingparams")
	ParamStoreKeyTallyParams   = []byte("tallyparams")
)

parameter store keys

Functions

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable is the key declaration for parameters.

func ProposalHandler

func ProposalHandler(_ sdk.Context, c types.Content) error

ProposalHandler implements the Handler interface for governance module-based proposals (ie. TextProposal and SoftwareUpgradeProposal). Since these are merely signaling mechanisms at the moment and do not affect state, it performs a no-op.

func ValidProposalStatus

func ValidProposalStatus(status ProposalStatus) bool

ValidProposalStatus returns true if the proposal status is valid and false otherwise.

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates crisis genesis data.

Types

type CertKeeper

type CertKeeper interface {
	IsCertifier(ctx sdk.Context, addr sdk.AccAddress) bool
	GetAllCertifiers(ctx sdk.Context) (certifiers cert.Certifiers)
	GetCertifier(ctx sdk.Context, certifierAddress sdk.AccAddress) (cert.Certifier, error)
	HasCertifierAlias(ctx sdk.Context, alias string) bool
	IsCertified(ctx sdk.Context, requestContentType string, content string, certType string) bool
	GetCertifiedIdentities(ctx sdk.Context) []sdk.AccAddress
}

type Deposit

type Deposit struct {
	types.Deposit
	TxHash string `json:"txhash" yaml:"txhash"`
}

Deposit wraps the deposit made by an account address to an active proposal and corresponding txhash.

func NewDeposit

func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins, txhash string) Deposit

NewDeposit creates a new Deposit instance.

type DepositParams

type DepositParams struct {
	// Minimum initial deposit when users submitting a proposal
	MinInitialDeposit sdk.Coins `json:"min_initial_deposit,omitempty" yaml:"min_initial_deposit,omitempty"`
	// Minimum deposit for a proposal to enter voting period.
	MinDeposit sdk.Coins `json:"min_deposit,omitempty" yaml:"min_deposit,omitempty"`
	// Maximum period for CTK holders to deposit on a proposal. Initial value: 2 months
	MaxDepositPeriod time.Duration `json:"max_deposit_period,omitempty" yaml:"max_deposit_period,omitempty"`
}

DepositParams struct around deposits for governance

func NewDepositParams

func NewDepositParams(minInitialDeposit, minDeposit sdk.Coins, maxDepositPeriod time.Duration) DepositParams

NewDepositParams creates a new DepositParams object

func (DepositParams) Equal

func (dp DepositParams) Equal(dp2 DepositParams) bool

Equal checks equality of DepositParams

func (DepositParams) String

func (dp DepositParams) String() string

type Deposits

type Deposits []Deposit

Deposits is a collection of Deposit objects.

type GenesisState

type GenesisState struct {
	StartingProposalID uint64                `json:"starting_proposal_id" yaml:"starting_proposal_id"`
	Deposits           Deposits              `json:"deposits" yaml:"deposits"`
	Votes              Votes                 `json:"votes" yaml:"votes"`
	Proposals          Proposals             `json:"proposals" yaml:"proposals"`
	DepositParams      DepositParams         `json:"deposit_params" yaml:"deposit_params"`
	VotingParams       govTypes.VotingParams `json:"voting_params" yaml:"voting_params"`
	TallyParams        TallyParams           `json:"tally_params" yaml:"tally_params"`
}

GenesisState defines the governance genesis state.

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object.

func NewGenesisState

func NewGenesisState(startingProposalID uint64, dp DepositParams, vp govTypes.VotingParams, tp TallyParams) GenesisState

NewGenesisState creates a new GenesisState object.

type ParamSubspace

type ParamSubspace interface {
	Get(ctx sdk.Context, key []byte, ptr interface{})
	Set(ctx sdk.Context, key []byte, param interface{})
	WithKeyTable(table subspace.KeyTable) subspace.Subspace
}

type Params

type Params struct {
	VotingParams  govTypes.VotingParams `json:"voting_params" yaml:"voting_params"`
	TallyParams   TallyParams           `json:"tally_params" yaml:"tally_params"`
	DepositParams DepositParams         `json:"deposit_params" yaml:"deposit_parmas"`
}

Params returns all of the governance params

func NewParams

NewParams returns a Params structs including voting, deposit and tally params

func (Params) String

func (gp Params) String() string

type Proposal

type Proposal struct {
	// proposal content interface
	types.Content `json:"content" yaml:"content"`

	// ID of the proposal
	ProposalID uint64 `json:"id" yaml:"id"`
	// status of the Proposal {Pending, Active, Passed, Rejected}
	Status ProposalStatus `json:"proposal_status" yaml:"proposal_status"`
	// whether or not the proposer is a council member (validator or certifier)
	IsProposerCouncilMember bool `json:"is_proposer_council_member" yaml:"is_proposer_council_member"`
	// proposer address
	ProposerAddress sdk.AccAddress `json:"proposer_address" yaml:"proposer_address"`
	// result of Tally
	FinalTallyResult gov.TallyResult `json:"final_tally_result" yaml:"final_tally_result"`

	// time of the block where TxGovSubmitProposal was included
	SubmitTime time.Time `json:"submit_time" yaml:"submit_time"`
	// time that the Proposal would expire if deposit amount isn't met
	DepositEndTime time.Time `json:"deposit_end_time" yaml:"deposit_end_time"`
	// current deposit on this proposal
	TotalDeposit sdk.Coins `json:"total_deposit" yaml:"total_deposit"`

	// VotingStartTime is the time of the block where MinDeposit was reached.
	// It is set to -1 if MinDeposit is not reached.
	VotingStartTime time.Time `json:"voting_start_time" yaml:"voting_start_time"`
	// time that the VotingPeriodString for this proposal will end and votes will be tallied
	VotingEndTime time.Time `json:"voting_end_time" yaml:"voting_end_time"`
}

Proposal defines a struct used by the governance module to allow for voting on network changes.

func NewProposal

func NewProposal(content types.Content,
	id uint64,
	proposerAddress sdk.AccAddress,
	isProposerCouncilMember bool,
	submitTime time.Time,
	depositEndTime time.Time) Proposal

NewProposal returns a new proposal.

func (Proposal) HasSecurityVoting

func (p Proposal) HasSecurityVoting() bool

HasSecurityVoting returns true if the proposal needs to go through security (certifier) voting before stake (validator) voting.

func (Proposal) String

func (p Proposal) String() string

String returns proposal struct in string type.

type ProposalQueue

type ProposalQueue []uint64

ProposalQueue is a type alias that represents a list of proposal IDs.

type ProposalStatus

type ProposalStatus byte

ProposalStatus is a type alias that represents a proposal status as a byte

func ProposalStatusFromString

func ProposalStatusFromString(str string) (ProposalStatus, error)

ProposalStatusFromString turns a string into a ProposalStatus.

func (ProposalStatus) Format

func (status ProposalStatus) Format(s fmt.State, verb rune)

Format implements the fmt.Formatter interface.

func (ProposalStatus) Marshal

func (status ProposalStatus) Marshal() ([]byte, error)

Marshal implements the Marshal method for protobuf compatibility.

func (ProposalStatus) MarshalJSON

func (status ProposalStatus) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON using string.

func (ProposalStatus) String

func (status ProposalStatus) String() string

String implements the Stringer interface.

func (*ProposalStatus) Unmarshal

func (status *ProposalStatus) Unmarshal(data []byte) error

Unmarshal implements the Unmarshal method for protobuf compatibility.

func (*ProposalStatus) UnmarshalJSON

func (status *ProposalStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.

type Proposals

type Proposals []Proposal

Proposals is an array of proposals.

func (Proposals) String

func (p Proposals) String() string

String implements stringer interface.

type QueryProposalsParams

type QueryProposalsParams struct {
	Page           int
	Limit          int
	Voter          sdk.AccAddress
	Depositor      sdk.AccAddress
	ProposalStatus ProposalStatus
}

QueryProposalsParams defines data structure for querying 'custom/gov/proposals'.

func NewQueryProposalsParams

func NewQueryProposalsParams(page, limit int, status ProposalStatus, voter, depositor sdk.AccAddress) QueryProposalsParams

NewQueryProposalsParams creates a new instance of QueryProposalsParams.

type ShieldKeeper added in v1.0.0

type ShieldKeeper interface {
	GetPurchaseList(ctx sdk.Context, poolID uint64, purchaser sdk.AccAddress) (shield.PurchaseList, bool)
	GetClaimProposalParams(ctx sdk.Context) shield.ClaimProposalParams
	SecureCollaterals(ctx sdk.Context, poolID uint64, purchaser sdk.AccAddress, purchaseID uint64, loss sdk.Coins, lockPeriod time.Duration) error
	RestoreShield(ctx sdk.Context, poolID uint64, purchaser sdk.AccAddress, id uint64, loss sdk.Coins) error
	ClaimEnd(ctx sdk.Context, id, poolID uint64, loss sdk.Coins)
}

type StakingKeeper added in v1.1.0

type StakingKeeper interface {
	IterateBondedValidatorsByPower(sdk.Context, func(index int64, validator stakingexported.ValidatorI) (stop bool))
	TotalBondedTokens(sdk.Context) sdk.Int
	IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingexported.DelegationI) (stop bool))
	BondDenom(sdk.Context) string
	GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator staking.Validator, found bool)
}

type TallyParams

type TallyParams struct {
	DefaultTally                     govTypes.TallyParams
	CertifierUpdateSecurityVoteTally govTypes.TallyParams
	CertifierUpdateStakeVoteTally    govTypes.TallyParams
}

func (TallyParams) String

func (tp TallyParams) String() string

type UpgradeKeeper

type UpgradeKeeper interface {
	ValidatePlan(ctx sdk.Context, plan upgrade.Plan) error
}

type Vote

type Vote struct {
	types.Vote
	TxHash string `json:"txhash" yaml:"txhash"`
}

Vote wraps a vote and corresponding txhash.

func NewVote

func NewVote(proposalID uint64, voter sdk.AccAddress, option types.VoteOption, txhash string) Vote

NewVote creates a new Vote instance.

type Votes

type Votes []Vote

Votes is a collection of Vote objects.

Jump to

Keyboard shortcuts

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