From 9db51da9d10877e4a5c5ce424406fee4be0730a0 Mon Sep 17 00:00:00 2001 From: romelukaku Date: Sat, 27 May 2023 14:06:29 +0700 Subject: [PATCH] update BeginRedelegate --- x/staking/keeper/msg_server.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index b55bf007f009..77809fd1a3eb 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -304,9 +304,15 @@ func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRed return nil, types.ErrNoValidatorFound } - if msg.Amount.Denom != validatorDst.BondDenom { + // lookup src val here to validate token early + validatorSrc, found := k.GetValidator(ctx, valSrcAddr) + if !found { + return nil, types.ErrNoValidatorFound + } + + if msg.Amount.Denom != validatorDst.BondDenom || msg.Amount.Denom != validatorSrc.BondDenom { return nil, sdkerrors.Wrapf( - sdkerrors.ErrInvalidRequest, "validator does not support redelegation with coin: got %s", msg.Amount.Denom, + sdkerrors.ErrInvalidRequest, "can't redelegate to validator with different bond denom", ) }