From 2cd4bd81a1c409bf9c2115d6f8835c93e5a1d540 Mon Sep 17 00:00:00 2001 From: Hans Lee <38912532+0xHansLee@users.noreply.github.com> Date: Fri, 18 Oct 2024 16:38:05 -0700 Subject: [PATCH] feat(distr): add set ubi keeper func (#10) --- x/distribution/keeper/params.go | 12 ++++++++++++ x/staking/keeper/msg_server.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/x/distribution/keeper/params.go b/x/distribution/keeper/params.go index 9428ae4253a4..f071d1a4a757 100644 --- a/x/distribution/keeper/params.go +++ b/x/distribution/keeper/params.go @@ -16,6 +16,18 @@ func (k Keeper) GetUbi(ctx context.Context) (math.LegacyDec, error) { return params.Ubi, nil } +// SetUbi sets new ubi +func (k Keeper) SetUbi(ctx context.Context, newUbi math.LegacyDec) error { + params, err := k.Params.Get(ctx) + if err != nil { + return err + } + + params.Ubi = newUbi + + return k.Params.Set(ctx, params) +} + // GetWithdrawAddrEnabled returns the current distribution withdraw address // enabled parameter. func (k Keeper) GetWithdrawAddrEnabled(ctx context.Context) (enabled bool, err error) { diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 1c3e8e013114..d8805145a11b 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -241,7 +241,7 @@ func (k msgServer) EditValidator(ctx context.Context, msg *types.MsgEditValidato } if msg.MinSelfDelegation != nil { - if !msg.MinSelfDelegation.GT(validator.MinSelfDelegation) { + if !msg.MinSelfDelegation.GTE(validator.MinSelfDelegation) { return nil, types.ErrMinSelfDelegationDecreased }