Skip to content

Commit

Permalink
Remove global codec
Browse files Browse the repository at this point in the history
  • Loading branch information
ulbqb committed Feb 6, 2024
1 parent c7dea67 commit c999a9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 0 additions & 4 deletions x/stakingplus/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ func (a CreateValidatorAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (foun
}

func (a CreateValidatorAuthorization) ValidateBasic() error {
if _, err := sdk.ValAddressFromBech32(a.ValidatorAddress); err != nil {
return err
}

return nil
}
10 changes: 7 additions & 3 deletions x/stakingplus/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package keeper
import (
"context"

addresscodec "cosmossdk.io/core/address"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
Expand All @@ -13,15 +15,17 @@ import (

type msgServer struct {
stakingtypes.MsgServer

fk stakingplus.FoundationKeeper
fk stakingplus.FoundationKeeper
valCodec addresscodec.Codec
}

// NewMsgServerImpl returns an implementation of the staking MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper *stakingkeeper.Keeper, fk stakingplus.FoundationKeeper) stakingtypes.MsgServer {
keeper.ValidatorAddressCodec()
return &msgServer{
MsgServer: stakingkeeper.NewMsgServerImpl(keeper),
valCodec: keeper.ValidatorAddressCodec(),
fk: fk,
}
}
Expand All @@ -31,7 +35,7 @@ var _ stakingtypes.MsgServer = msgServer{}
func (k msgServer) CreateValidator(goCtx context.Context, msg *stakingtypes.MsgCreateValidator) (*stakingtypes.MsgCreateValidatorResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

valAddr, err := sdk.ValAddressFromBech32(msg.ValidatorAddress)
valAddr, err := k.valCodec.StringToBytes(msg.ValidatorAddress)
if err != nil {
return nil, errors.ErrInvalidAddress.Wrapf("invalid validator address: %s", msg.ValidatorAddress)
}
Expand Down

0 comments on commit c999a9a

Please sign in to comment.