wormchain: tokenbridge: Check that the target chain is registered

Ensure that the destination chain has been registered in the tokenbridge
before allowing transfers to it.  This prevents users from accidentally
locking up their tokens in the token bridge by passing in an invalid
chain id.
This commit is contained in:
Chirantan Ekbote 2022-08-23 16:03:18 +09:00 committed by Chirantan Ekbote
parent d272eee7bc
commit b38180bf5d
1 changed files with 4 additions and 0 deletions

View File

@ -26,6 +26,10 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ
return nil, err
}
if _, found := k.GetChainRegistration(ctx, msg.ToChain); !found {
return nil, types.ErrInvalidTargetChain
}
meta, found := k.bankKeeper.GetDenomMetaData(ctx, msg.Amount.Denom)
if !found {
return nil, types.ErrNoDenomMetadata