From 643f720774568d9e1878ed14c07e5a9b59d2e1a3 Mon Sep 17 00:00:00 2001 From: Aidan Salzmann Date: Sun, 17 Sep 2023 20:01:28 -0400 Subject: [PATCH] address sam comments --- .../tx_update_inner_redemption_rate_bounds.go | 19 ++----------------- ...ver_update_inner_redemption_rate_bounds.go | 6 ------ ...pdate_inner_redemption_rate_bounds_test.go | 1 + ...age_update_inner_redemption_rate_bounds.go | 4 ++++ 4 files changed, 7 insertions(+), 23 deletions(-) create mode 100644 x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds_test.go diff --git a/x/stakeibc/client/cli/tx_update_inner_redemption_rate_bounds.go b/x/stakeibc/client/cli/tx_update_inner_redemption_rate_bounds.go index ee732812ab..1c393de209 100644 --- a/x/stakeibc/client/cli/tx_update_inner_redemption_rate_bounds.go +++ b/x/stakeibc/client/cli/tx_update_inner_redemption_rate_bounds.go @@ -17,23 +17,8 @@ func CmdUpdateInnerRedemptionRateBounds() *cobra.Command { Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { argChainId := args[0] - minRedemptionRateStr := args[1] - maxRedemptionRateStr := args[2] - - minInnerRedemptionRate := sdk.ZeroDec() - if minRedemptionRateStr != "" { - minInnerRedemptionRate, err = sdk.NewDecFromStr(minRedemptionRateStr) - if err != nil { - return err - } - } - maxInnerRedemptionRate := sdk.ZeroDec() - if maxRedemptionRateStr != "" { - maxInnerRedemptionRate, err = sdk.NewDecFromStr(maxRedemptionRateStr) - if err != nil { - return err - } - } + minInnerRedemptionRate := sdk.MustNewDecFromStr(args[1]) + maxInnerRedemptionRate := sdk.MustNewDecFromStr(args[2]) clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds.go b/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds.go index 381d85dbdb..f7f5c65534 100644 --- a/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds.go +++ b/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds.go @@ -36,12 +36,6 @@ func (k msgServer) UpdateInnerRedemptionRateBounds(goCtx context.Context, msg *t return nil, types.ErrInvalidBounds } - // Confirm the max is greater than the min - if innerMaxSafetyThreshold.LTE(innerMinSafetyThreshold) { - k.Logger(ctx).Error(fmt.Sprintf("Inner max safety threshold (%s) is less than inner min safety threshold (%s)", innerMaxSafetyThreshold, innerMinSafetyThreshold)) - return nil, types.ErrInvalidBounds - } - // Set the inner bounds on the host zone zone.MinInnerRedemptionRate = innerMinSafetyThreshold zone.MaxInnerRedemptionRate = innerMaxSafetyThreshold diff --git a/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds_test.go b/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds_test.go new file mode 100644 index 0000000000..b55569d4a4 --- /dev/null +++ b/x/stakeibc/keeper/msg_server_update_inner_redemption_rate_bounds_test.go @@ -0,0 +1 @@ +package keeper diff --git a/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go b/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go index 9456b83dfc..eee348e7b2 100644 --- a/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go +++ b/x/stakeibc/types/message_update_inner_redemption_rate_bounds.go @@ -47,6 +47,10 @@ func (msg *MsgUpdateInnerRedemptionRateBounds) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } + // Confirm the max is greater than the min + if msg.MaxInnerRedemptionRate.LTE(msg.MaxInnerRedemptionRate) { + return errorsmod.Wrapf(ErrInvalidBounds, "Inner max safety threshold (%s) is less than inner min safety threshold (%s)", msg.MaxInnerRedemptionRate, msg.MinInnerRedemptionRate) + } if err := utils.ValidateAdminAddress(msg.Creator); err != nil { return err }