48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package keeper
|
|
|
|
import (
|
|
"cosmossdk.io/math"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
)
|
|
|
|
// GetParams returns the total set of distribution parameters.
|
|
func (k Keeper) GetParams(clientCtx sdk.Context) (params types.Params) {
|
|
store := clientCtx.KVStore(k.storeKey)
|
|
bz := store.Get(types.ParamsKey)
|
|
if bz == nil {
|
|
return params
|
|
}
|
|
|
|
k.cdc.MustUnmarshal(bz, ¶ms)
|
|
return params
|
|
}
|
|
|
|
// SetParams sets the distribution parameters to the param space.
|
|
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
|
|
if err := params.ValidateBasic(); err != nil {
|
|
return err
|
|
}
|
|
|
|
store := ctx.KVStore(k.storeKey)
|
|
bz, err := k.cdc.Marshal(¶ms)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
store.Set(types.ParamsKey, bz)
|
|
|
|
return nil
|
|
}
|
|
|
|
// GetCommunityTax returns the current distribution community tax.
|
|
func (k Keeper) GetCommunityTax(ctx sdk.Context) math.LegacyDec {
|
|
return k.GetParams(ctx).CommunityTax
|
|
}
|
|
|
|
// GetWithdrawAddrEnabled returns the current distribution withdraw address
|
|
// enabled parameter.
|
|
func (k Keeper) GetWithdrawAddrEnabled(ctx sdk.Context) (enabled bool) {
|
|
return k.GetParams(ctx).WithdrawAddrEnabled
|
|
}
|