github.com/cosmos/cosmos-sdk@v0.50.10/x/gov/types/v1beta1/params.go (about) 1 package v1beta1 2 3 import ( 4 "time" 5 6 "cosmossdk.io/math" 7 8 sdk "github.com/cosmos/cosmos-sdk/types" 9 ) 10 11 // Default period for deposits & voting 12 const ( 13 DefaultPeriod time.Duration = time.Hour * 24 * 2 // 2 days 14 ) 15 16 // Default governance params 17 var ( 18 DefaultMinDepositTokens = math.NewInt(10000000) 19 DefaultQuorum = math.LegacyNewDecWithPrec(334, 3) 20 DefaultThreshold = math.LegacyNewDecWithPrec(5, 1) 21 DefaultVetoThreshold = math.LegacyNewDecWithPrec(334, 3) 22 ) 23 24 // NewDepositParams creates a new DepositParams object 25 func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) DepositParams { 26 return DepositParams{ 27 MinDeposit: minDeposit, 28 MaxDepositPeriod: maxDepositPeriod, 29 } 30 } 31 32 // DefaultDepositParams returns the default parameters for deposits 33 func DefaultDepositParams() DepositParams { 34 return NewDepositParams( 35 sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMinDepositTokens)), 36 DefaultPeriod, 37 ) 38 } 39 40 // Equal checks equality of DepositParams 41 func (dp DepositParams) Equal(dp2 DepositParams) bool { 42 return dp.MinDeposit.Equal(dp2.MinDeposit) && dp.MaxDepositPeriod == dp2.MaxDepositPeriod 43 } 44 45 // NewTallyParams creates a new TallyParams object 46 func NewTallyParams(quorum, threshold, vetoThreshold math.LegacyDec) TallyParams { 47 return TallyParams{ 48 Quorum: quorum, 49 Threshold: threshold, 50 VetoThreshold: vetoThreshold, 51 } 52 } 53 54 // DefaultTallyParams returns default parameters for tallying 55 func DefaultTallyParams() TallyParams { 56 return NewTallyParams(DefaultQuorum, DefaultThreshold, DefaultVetoThreshold) 57 } 58 59 // Equal checks equality of TallyParams 60 func (tp TallyParams) Equal(other TallyParams) bool { 61 return tp.Quorum.Equal(other.Quorum) && tp.Threshold.Equal(other.Threshold) && tp.VetoThreshold.Equal(other.VetoThreshold) 62 } 63 64 // NewVotingParams creates a new VotingParams object 65 func NewVotingParams(votingPeriod time.Duration) VotingParams { 66 return VotingParams{ 67 VotingPeriod: votingPeriod, 68 } 69 } 70 71 // DefaultVotingParams default parameters for voting 72 func DefaultVotingParams() VotingParams { 73 return NewVotingParams(DefaultPeriod) 74 } 75 76 // Equal checks equality of TallyParams 77 func (vp VotingParams) Equal(other VotingParams) bool { 78 return vp.VotingPeriod == other.VotingPeriod 79 } 80 81 // Params returns all of the governance params 82 type Params struct { 83 VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` 84 TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` 85 DepositParams DepositParams `json:"deposit_params" yaml:"deposit_params"` 86 } 87 88 // String implements stringer interface 89 func (gp Params) String() string { 90 return gp.VotingParams.String() + "\n" + 91 gp.TallyParams.String() + "\n" + gp.DepositParams.String() 92 } 93 94 // NewParams creates a new gov Params instance 95 func NewParams(vp VotingParams, tp TallyParams, dp DepositParams) Params { 96 return Params{ 97 VotingParams: vp, 98 DepositParams: dp, 99 TallyParams: tp, 100 } 101 } 102 103 // DefaultParams returns the default governance params 104 func DefaultParams() Params { 105 return NewParams(DefaultVotingParams(), DefaultTallyParams(), DefaultDepositParams()) 106 }