diff --git a/baseapp/msg_service_router.go b/baseapp/msg_service_router.go index 22f76cbafa3c..ddbd3f8fe153 100644 --- a/baseapp/msg_service_router.go +++ b/baseapp/msg_service_router.go @@ -25,7 +25,7 @@ type MessageRouter interface { Handler(msg sdk.Msg) MsgServiceHandler HandlerByTypeURL(typeURL string) MsgServiceHandler - ResponseNameByRequestName(msgName string) string + ResponseNameByRequestName(requestName string) string HybridHandlerByMsgName(msgName string) func(ctx context.Context, req, resp protoiface.MessageV1) error } @@ -93,8 +93,8 @@ func (msr *MsgServiceRouter) HybridHandlerByMsgName(msgName string) func(ctx con return msr.hybridHandlers[msgName] } -func (msr *MsgServiceRouter) ResponseNameByRequestName(msgName string) string { - return msr.responseByRequest[msgName] +func (msr *MsgServiceRouter) ResponseNameByRequestName(requestName string) string { + return msr.responseByRequest[requestName] } func (msr *MsgServiceRouter) registerHybridHandler(sd *grpc.ServiceDesc, method grpc.MethodDesc, handler interface{}) error { diff --git a/runtime/router.go b/runtime/router.go index 03e73f5fdf1d..b2237be3d592 100644 --- a/runtime/router.go +++ b/runtime/router.go @@ -56,7 +56,10 @@ func (m *msgRouterService) InvokeUntyped(ctx context.Context, msg protoiface.Mes if typ == nil { return nil, fmt.Errorf("no message type found for %s", respName) } - msgResp := reflect.New(typ.Elem()).Interface().(protoiface.MessageV1) + msgResp, ok := reflect.New(typ.Elem()).Interface().(protoiface.MessageV1) + if !ok { + return nil, fmt.Errorf("could not create response message %s", respName) + } handler := m.router.HybridHandlerByMsgName(messageName) if handler == nil {