Skip to content

Commit

Permalink
separate merge logic
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown unknown committed Jun 19, 2024
1 parent 25f5294 commit b75456e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/v2/stf/stf_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

gogoproto "github.com/cosmos/gogoproto/proto"
"google.golang.org/protobuf/proto"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/runtime/protoiface"

appmodulev2 "cosmossdk.io/core/appmodule/v2"
Expand Down Expand Up @@ -137,10 +137,6 @@ func buildHandler(

// msgTypeURL returns the TypeURL of a proto message.
func msgTypeURL(msg gogoproto.Message) string {
if m, ok := msg.(proto.Message); ok {
return string(m.ProtoReflect().Descriptor().FullName())
}

return gogoproto.MessageName(msg)
}

Expand All @@ -164,10 +160,14 @@ func (r Router) InvokeTyped(ctx context.Context, req, resp protoiface.MessageV1)
if err != nil {
return err
}
gogoproto.Merge(resp, handlerResp)
merge(resp, handlerResp)
return nil
}

func merge(src protoiface.MessageV1, dst protoiface.MessageV1) {
proto.Merge(src, dst)
}

func (r Router) InvokeUntyped(ctx context.Context, req protoiface.MessageV1) (res protoiface.MessageV1, err error) {
typeName := msgTypeURL(req)
handler, exists := r.handlers[typeName]
Expand Down
6 changes: 6 additions & 0 deletions server/v2/stf/stf_router_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package stf

import "testing"

func TestMerge(t *testing.T) {
}

0 comments on commit b75456e

Please sign in to comment.