Skip to content

Commit

Permalink
refactor(x/staking): Use ValidatorAddrCodec (backport #17095) (#17097)
Browse files Browse the repository at this point in the history
Co-authored-by: Devon Bear <itsdevbear@berachain.com>
  • Loading branch information
mergify[bot] and itsdevbear authored Jul 23, 2023
1 parent 35492de commit d68a123
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var _ types.MsgServer = msgServer{}

// CreateValidator defines a method for creating a new validator
func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateValidator) (*types.MsgCreateValidatorResponse, error) {
valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress)
valAddr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err)
}
Expand Down Expand Up @@ -158,7 +158,7 @@ func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateVali

// EditValidator defines a method for editing an existing validator
func (k msgServer) EditValidator(ctx context.Context, msg *types.MsgEditValidator) (*types.MsgEditValidatorResponse, error) {
valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress)
valAddr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err)
}
Expand Down Expand Up @@ -304,12 +304,12 @@ func (k msgServer) Delegate(ctx context.Context, msg *types.MsgDelegate) (*types

// BeginRedelegate defines a method for performing a redelegation of coins from a source validator to a destination validator of given delegator
func (k msgServer) BeginRedelegate(ctx context.Context, msg *types.MsgBeginRedelegate) (*types.MsgBeginRedelegateResponse, error) {
valSrcAddr, err := sdk.ValAddressFromBech32(msg.ValidatorSrcAddress)
valSrcAddr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorSrcAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid source validator address: %s", err)
}

valDstAddr, err := sdk.ValAddressFromBech32(msg.ValidatorDstAddress)
valDstAddr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorDstAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid destination validator address: %s", err)
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func (k msgServer) BeginRedelegate(ctx context.Context, msg *types.MsgBeginRedel

// Undelegate defines a method for performing an undelegation from a delegate and a validator
func (k msgServer) Undelegate(ctx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) {
addr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress)
addr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err)
}
Expand Down Expand Up @@ -452,7 +452,7 @@ func (k msgServer) Undelegate(ctx context.Context, msg *types.MsgUndelegate) (*t
// CancelUnbondingDelegation defines a method for canceling the unbonding delegation
// and delegate back to the validator.
func (k msgServer) CancelUnbondingDelegation(ctx context.Context, msg *types.MsgCancelUnbondingDelegation) (*types.MsgCancelUnbondingDelegationResponse, error) {
valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress)
valAddr, err := k.validatorAddressCodec.StringToBytes(msg.ValidatorAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err)
}
Expand Down

0 comments on commit d68a123

Please sign in to comment.