Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Jul 19, 2024
1 parent c17de01 commit 702115b
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions depinject/appconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"reflect"
"strings"

"github.com/cosmos/cosmos-proto/anyutil"
gogoproto "github.com/cosmos/gogoproto/proto"
"google.golang.org/protobuf/encoding/protojson"
protov2 "google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -53,26 +52,14 @@ func LoadYAML(bz []byte) depinject.Config {

// WrapAny marshals a proto message into a proto Any instance
func WrapAny(config gogoproto.Message) *anypb.Any {
switch cfg := config.(type) {
case protoreflect.ProtoMessage:
cfg, err := anyutil.New(cfg)
if err != nil {
panic(err)
}

return cfg.(*anypb.Any)
case gogoproto.Message:
pbz, err := gogoproto.Marshal(cfg)
if err != nil {
panic(err)
}
pbz, err := gogoproto.Marshal(config)
if err != nil {
panic(err)
}

return &anypb.Any{
TypeUrl: "/" + gogoproto.MessageName(cfg),
Value: pbz,
}
default:
panic(fmt.Errorf("unexpected type %T", config))
return &anypb.Any{
TypeUrl: "/" + gogoproto.MessageName(config),
Value: pbz,
}
}

Expand Down

0 comments on commit 702115b

Please sign in to comment.