Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stana-miric committed Jun 10, 2024
1 parent c750799 commit 01833c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
28 changes: 8 additions & 20 deletions x/staking/client/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import (
"fmt"
"os"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand Down Expand Up @@ -41,7 +39,6 @@ func parseAndValidateValidatorJSON(cdc codec.Codec, path string) (validator, err
CommissionRate string `json:"commission-rate"`
CommissionMaxRate string `json:"commission-max-rate"`
CommissionMaxChange string `json:"commission-max-change-rate"`
MinSelfDelegation string `json:"min-self-delegation"`
}

contents, err := os.ReadFile(path)
Expand Down Expand Up @@ -80,24 +77,15 @@ func parseAndValidateValidatorJSON(cdc codec.Codec, path string) (validator, err
return validator{}, err
}

if v.MinSelfDelegation == "" {
return validator{}, fmt.Errorf("must specify minimum self delegation")
}
minSelfDelegation, ok := math.NewIntFromString(v.MinSelfDelegation)
if !ok {
return validator{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer")
}

return validator{
Amount: amount,
PubKey: pk,
Moniker: v.Moniker,
Identity: v.Identity,
Website: v.Website,
Security: v.Security,
Details: v.Details,
CommissionRates: commissionRates,
MinSelfDelegation: minSelfDelegation,
Amount: amount,
PubKey: pk,
Moniker: v.Moniker,
Identity: v.Identity,
Website: v.Website,
Security: v.Security,
Details: v.Details,
CommissionRates: commissionRates,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (k msgServer) BeginRedelegate(ctx context.Context, msg *types.MsgBeginRedel
}
valDstAddr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorDstAddress)
if err != nil {
return nil, err
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid destination validator address: %s", err)
}

_, err = k.GetValidator(ctx, valSrcAddr)
Expand Down

0 comments on commit 01833c2

Please sign in to comment.