github.com/cosmos/cosmos-sdk@v0.50.10/x/distribution/types/params.go (about)

     1  package types
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"cosmossdk.io/math"
     7  )
     8  
     9  // DefaultParams returns default distribution parameters
    10  func DefaultParams() Params {
    11  	return Params{
    12  		CommunityTax:        math.LegacyNewDecWithPrec(2, 2), // 2%
    13  		BaseProposerReward:  math.LegacyZeroDec(),            // deprecated
    14  		BonusProposerReward: math.LegacyZeroDec(),            // deprecated
    15  		WithdrawAddrEnabled: true,
    16  	}
    17  }
    18  
    19  // ValidateBasic performs basic validation on distribution parameters.
    20  func (p Params) ValidateBasic() error {
    21  	return validateCommunityTax(p.CommunityTax)
    22  }
    23  
    24  func validateCommunityTax(i interface{}) error {
    25  	v, ok := i.(math.LegacyDec)
    26  	if !ok {
    27  		return fmt.Errorf("invalid parameter type: %T", i)
    28  	}
    29  
    30  	if v.IsNil() {
    31  		return fmt.Errorf("community tax must be not nil")
    32  	}
    33  	if v.IsNegative() {
    34  		return fmt.Errorf("community tax must be positive: %s", v)
    35  	}
    36  	if v.GT(math.LegacyOneDec()) {
    37  		return fmt.Errorf("community tax too large: %s", v)
    38  	}
    39  
    40  	return nil
    41  }
    42  
    43  func validateWithdrawAddrEnabled(i interface{}) error {
    44  	_, ok := i.(bool)
    45  	if !ok {
    46  		return fmt.Errorf("invalid parameter type: %T", i)
    47  	}
    48  
    49  	return nil
    50  }