feat(depinject/appconfig): support gogo proto module configs (#20540)
Co-authored-by: Marko <marko@baricevic.me> Co-authored-by: marbar3778 <marbar3778@yahoo.com>
This commit is contained in:
parent
5762b0b817
commit
0b35bcebef
@ -22,6 +22,10 @@ Each entry must include the Github issue reference in the following format:
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Features
|
||||
|
||||
- [#20540](https://github.com/cosmos/cosmos-sdk/pull/20540) add support for defining `appconfig` module configuration types using `github.com/cosmos/gogoproto/proto` in addition to `google.golang.org/protobuf` so that users can use gogo proto across their stack.
|
||||
|
||||
## 1.0.0-alpha.x
|
||||
|
||||
Depinject is still in alpha stage even though its API is already quite stable.
|
||||
|
||||
@ -2,17 +2,19 @@ package appconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-proto/anyutil"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
protov2 "google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
internal "cosmossdk.io/depinject/internal/appconfig"
|
||||
)
|
||||
@ -20,7 +22,9 @@ import (
|
||||
// LoadJSON loads an app config in JSON format.
|
||||
func LoadJSON(bz []byte) depinject.Config {
|
||||
config := &appv1alpha1.Config{}
|
||||
err := protojson.Unmarshal(bz, config)
|
||||
err := protojson.UnmarshalOptions{
|
||||
Resolver: dynamicTypeResolver{resolver: gogoproto.HybridResolver},
|
||||
}.Unmarshal(bz, config)
|
||||
if err != nil {
|
||||
return depinject.Error(err)
|
||||
}
|
||||
@ -55,6 +59,11 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config {
|
||||
depinject.Supply(appConfig),
|
||||
}
|
||||
|
||||
modules, err := internal.ModulesByModuleTypeName()
|
||||
if err != nil {
|
||||
return depinject.Error(err)
|
||||
}
|
||||
|
||||
for _, module := range appConfig.Modules {
|
||||
if module.Name == "" {
|
||||
return depinject.Error(fmt.Errorf("module is missing name"))
|
||||
@ -64,30 +73,38 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config {
|
||||
return depinject.Error(fmt.Errorf("module %q is missing a config object", module.Name))
|
||||
}
|
||||
|
||||
msgType, err := protoregistry.GlobalTypes.FindMessageByURL(module.Config.TypeUrl)
|
||||
if err != nil {
|
||||
return depinject.Error(err)
|
||||
msgName := module.Config.TypeUrl
|
||||
// strip type URL prefix
|
||||
if slashIdx := strings.LastIndex(msgName, "/"); slashIdx >= 0 {
|
||||
msgName = msgName[slashIdx+1:]
|
||||
}
|
||||
if msgName == "" {
|
||||
return depinject.Error(fmt.Errorf("module %q is missing a type URL", module.Name))
|
||||
}
|
||||
|
||||
modules, err := internal.ModulesByProtoMessageName()
|
||||
if err != nil {
|
||||
return depinject.Error(err)
|
||||
}
|
||||
|
||||
init, ok := modules[msgType.Descriptor().FullName()]
|
||||
init, ok := modules[msgName]
|
||||
if !ok {
|
||||
modDesc := proto.GetExtension(msgType.Descriptor().Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
|
||||
if modDesc == nil {
|
||||
return depinject.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s",
|
||||
module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules)))
|
||||
if msgDesc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(msgName)); err == nil {
|
||||
modDesc := protov2.GetExtension(msgDesc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
|
||||
if modDesc == nil {
|
||||
return depinject.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s",
|
||||
module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules)))
|
||||
}
|
||||
|
||||
return depinject.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s: find more information on how to make a module ready for app wiring: https://docs.cosmos.network/main/building-modules/depinject\n\n%s",
|
||||
module.Config.TypeUrl, modDesc.GoImport, dumpRegisteredModules(modules)))
|
||||
}
|
||||
|
||||
return depinject.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s: find more information on how to make a module ready for app wiring: https://docs.cosmos.network/main/building-modules/depinject\n\n%s",
|
||||
module.Config.TypeUrl, modDesc.GoImport, dumpRegisteredModules(modules)))
|
||||
}
|
||||
|
||||
config := init.ConfigProtoMessage.ProtoReflect().Type().New().Interface()
|
||||
err = anypb.UnmarshalTo(module.Config, config, proto.UnmarshalOptions{})
|
||||
var config gogoproto.Message
|
||||
if configInit, ok := init.ConfigProtoMessage.(protov2.Message); ok {
|
||||
config = configInit.ProtoReflect().Type().New().Interface().(gogoproto.Message)
|
||||
} else {
|
||||
config = reflect.New(init.ConfigGoType.Elem()).Interface().(gogoproto.Message)
|
||||
}
|
||||
// as of gogo v1.5.0 this should work with either gogoproto or golang v2 proto
|
||||
err = gogoproto.Unmarshal(module.Config.Value, config)
|
||||
if err != nil {
|
||||
return depinject.Error(err)
|
||||
}
|
||||
@ -114,10 +131,10 @@ func Compose(appConfig *appv1alpha1.Config) depinject.Config {
|
||||
return depinject.Configs(opts...)
|
||||
}
|
||||
|
||||
func dumpRegisteredModules(modules map[protoreflect.FullName]*internal.ModuleInitializer) string {
|
||||
func dumpRegisteredModules(modules map[string]*internal.ModuleInitializer) string {
|
||||
var mods []string
|
||||
for name := range modules {
|
||||
mods = append(mods, " "+string(name))
|
||||
mods = append(mods, " "+name)
|
||||
}
|
||||
return fmt.Sprintf("registered modules are:\n%s", strings.Join(mods, "\n"))
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"cosmossdk.io/depinject/appconfig"
|
||||
internal "cosmossdk.io/depinject/internal/appconfig"
|
||||
"cosmossdk.io/depinject/internal/appconfig/testpb"
|
||||
testpbgogo "cosmossdk.io/depinject/internal/appconfiggogo/testpb"
|
||||
)
|
||||
|
||||
func expectContainerErrorContains(t *testing.T, option depinject.Config, contains string) {
|
||||
@ -68,7 +69,10 @@ modules:
|
||||
"@type": testpb.TestModuleA
|
||||
- name: b
|
||||
config:
|
||||
"@type": testpb.TestModuleB
|
||||
"@type": /testpb.TestModuleB
|
||||
- name: c
|
||||
config:
|
||||
"@type": /testpb.TestModuleGogo
|
||||
`))
|
||||
assert.NilError(t, depinject.Inject(opt, &app))
|
||||
buf := &bytes.Buffer{}
|
||||
@ -137,6 +141,10 @@ func init() {
|
||||
appconfig.RegisterModule(&testpb.TestModuleB{},
|
||||
appconfig.Provide(ProvideModuleB),
|
||||
)
|
||||
|
||||
appconfig.RegisterModule(&testpbgogo.TestModuleGogo{},
|
||||
appconfig.Provide(ProvideModuleC),
|
||||
)
|
||||
}
|
||||
|
||||
func ProvideRuntimeState() *RuntimeState {
|
||||
@ -220,3 +228,18 @@ type KeeperB interface {
|
||||
}
|
||||
|
||||
func (k keeperB) isKeeperB() {}
|
||||
|
||||
func ProvideModuleC(key StoreKey, b KeeperB) KeeperC {
|
||||
return keeperC{key: key}
|
||||
}
|
||||
|
||||
type keeperC struct {
|
||||
key StoreKey
|
||||
b KeeperB
|
||||
}
|
||||
|
||||
type KeeperC interface {
|
||||
isKeeperC()
|
||||
}
|
||||
|
||||
func (k keeperC) isKeeperC() {}
|
||||
|
||||
80
depinject/appconfig/dynamic_resolver.go
Normal file
80
depinject/appconfig/dynamic_resolver.go
Normal file
@ -0,0 +1,80 @@
|
||||
package appconfig
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protodesc"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/types/dynamicpb"
|
||||
)
|
||||
|
||||
// dynamic resolver allows marshaling gogo proto messages from the gogoproto.HybridResolver as long as those
|
||||
// files have been imported before calling LoadJSON. There is similar code in autocli, this should probably
|
||||
// eventually be moved into a library.
|
||||
type dynamicTypeResolver struct {
|
||||
resolver protodesc.Resolver
|
||||
}
|
||||
|
||||
func (r dynamicTypeResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) {
|
||||
ext, err := protoregistry.GlobalTypes.FindExtensionByName(field)
|
||||
if err == nil {
|
||||
return ext, nil
|
||||
}
|
||||
|
||||
desc, err := r.resolver.FindDescriptorByName(field)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dynamicpb.NewExtensionType(desc.(protoreflect.ExtensionTypeDescriptor)), nil
|
||||
}
|
||||
|
||||
func (r dynamicTypeResolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) {
|
||||
ext, err := protoregistry.GlobalTypes.FindExtensionByNumber(message, field)
|
||||
if err == nil {
|
||||
return ext, nil
|
||||
}
|
||||
|
||||
desc, err := r.resolver.FindDescriptorByName(message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
messageDesc := desc.(protoreflect.MessageDescriptor)
|
||||
exts := messageDesc.Extensions()
|
||||
n := exts.Len()
|
||||
for i := 0; i < n; i++ {
|
||||
ext := exts.Get(i)
|
||||
if ext.Number() == field {
|
||||
return dynamicpb.NewExtensionType(ext), nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, protoregistry.NotFound
|
||||
}
|
||||
|
||||
func (r dynamicTypeResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) {
|
||||
typ, err := protoregistry.GlobalTypes.FindMessageByName(message)
|
||||
if err == nil {
|
||||
return typ, nil
|
||||
}
|
||||
|
||||
desc, err := r.resolver.FindDescriptorByName(message)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dynamicpb.NewMessageType(desc.(protoreflect.MessageDescriptor)), nil
|
||||
}
|
||||
|
||||
func (r dynamicTypeResolver) FindMessageByURL(url string) (protoreflect.MessageType, error) {
|
||||
if i := strings.LastIndexByte(url, '/'); i >= 0 {
|
||||
url = url[i+1:]
|
||||
}
|
||||
|
||||
return r.FindMessageByName(protoreflect.FullName(url))
|
||||
}
|
||||
|
||||
var _ protoregistry.MessageTypeResolver = dynamicTypeResolver{}
|
||||
var _ protoregistry.ExtensionTypeResolver = dynamicTypeResolver{}
|
||||
@ -1,9 +1,10 @@
|
||||
package appconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
internal "cosmossdk.io/depinject/internal/appconfig"
|
||||
)
|
||||
@ -19,10 +20,15 @@ var Register = RegisterModule
|
||||
// Protobuf message types used for module configuration should define the
|
||||
// cosmos.app.v1alpha.module option and must explicitly specify go_package
|
||||
// to make debugging easier for users.
|
||||
func RegisterModule(msg proto.Message, options ...Option) {
|
||||
ty := reflect.TypeOf(msg)
|
||||
func RegisterModule(config any, options ...Option) {
|
||||
protoConfig, ok := config.(proto.Message)
|
||||
if !ok {
|
||||
panic(fmt.Errorf("expected config to be a proto.Message, got %T", config))
|
||||
}
|
||||
|
||||
ty := reflect.TypeOf(config)
|
||||
init := &internal.ModuleInitializer{
|
||||
ConfigProtoMessage: msg,
|
||||
ConfigProtoMessage: protoConfig,
|
||||
ConfigGoType: ty,
|
||||
}
|
||||
internal.ModuleRegistry[ty] = init
|
||||
|
||||
@ -5,8 +5,9 @@ go 1.20
|
||||
require (
|
||||
cosmossdk.io/api v0.7.5
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.5
|
||||
github.com/cosmos/gogoproto v1.5.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
|
||||
google.golang.org/protobuf v1.34.2
|
||||
gotest.tools/v3 v3.5.1
|
||||
sigs.k8s.io/yaml v1.4.0
|
||||
|
||||
@ -2,9 +2,12 @@ cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ=
|
||||
cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
|
||||
github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o=
|
||||
github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
@ -23,8 +26,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA=
|
||||
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
|
||||
@ -2,7 +2,7 @@ version: v1
|
||||
managed:
|
||||
enabled: true
|
||||
go_package_prefix:
|
||||
default: cosmossdk.io/depinject/internal
|
||||
default: cosmossdk.io/depinject/internal/appconfig
|
||||
override:
|
||||
buf.build/cosmos/cosmos-sdk: cosmossdk.io/api
|
||||
plugins:
|
||||
|
||||
@ -4,10 +4,10 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
protov2 "google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// ModuleRegistry is the registry of module initializers indexed by their golang
|
||||
@ -17,40 +17,43 @@ var ModuleRegistry = map[reflect.Type]*ModuleInitializer{}
|
||||
// ModuleInitializer describes how to initialize a module.
|
||||
type ModuleInitializer struct {
|
||||
ConfigGoType reflect.Type
|
||||
ConfigProtoMessage proto.Message
|
||||
ConfigProtoMessage gogoproto.Message
|
||||
Error error
|
||||
Providers []interface{}
|
||||
Invokers []interface{}
|
||||
}
|
||||
|
||||
// ModulesByProtoMessageName should be used to retrieve modules by their protobuf name.
|
||||
// ModulesByModuleTypeName should be used to retrieve modules by their module type name.
|
||||
// This is done lazily after module registration to deal with non-deterministic issues
|
||||
// that can occur with respect to protobuf descriptor initialization.
|
||||
func ModulesByProtoMessageName() (map[protoreflect.FullName]*ModuleInitializer, error) {
|
||||
res := map[protoreflect.FullName]*ModuleInitializer{}
|
||||
func ModulesByModuleTypeName() (map[string]*ModuleInitializer, error) {
|
||||
res := map[string]*ModuleInitializer{}
|
||||
|
||||
for _, initializer := range ModuleRegistry {
|
||||
descriptor := initializer.ConfigProtoMessage.ProtoReflect().Descriptor()
|
||||
fullName := descriptor.FullName()
|
||||
// as of gogoproto v1.5.0 this should work with either gogoproto or golang v2 proto
|
||||
fullName := gogoproto.MessageName(initializer.ConfigProtoMessage)
|
||||
|
||||
if desc, err := gogoproto.HybridResolver.FindDescriptorByName(protoreflect.FullName(fullName)); err == nil {
|
||||
modDesc := protov2.GetExtension(desc.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
|
||||
if modDesc == nil {
|
||||
return nil, fmt.Errorf(
|
||||
"protobuf type %s registered as a module should have the option %s",
|
||||
fullName,
|
||||
appv1alpha1.E_Module.TypeDescriptor().FullName())
|
||||
}
|
||||
|
||||
if modDesc.GoImport == "" {
|
||||
return nil, fmt.Errorf(
|
||||
"protobuf type %s registered as a module should have ModuleDescriptor.go_import specified",
|
||||
fullName,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := res[fullName]; ok {
|
||||
return nil, fmt.Errorf("duplicate module registration for %s", fullName)
|
||||
}
|
||||
|
||||
modDesc := proto.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
|
||||
if modDesc == nil {
|
||||
return nil, fmt.Errorf(
|
||||
"protobuf type %s registered as a module should have the option %s",
|
||||
fullName,
|
||||
appv1alpha1.E_Module.TypeDescriptor().FullName())
|
||||
}
|
||||
|
||||
if modDesc.GoImport == "" {
|
||||
return nil, fmt.Errorf(
|
||||
"protobuf type %s registered as a module should have ModuleDescriptor.go_import specified",
|
||||
fullName,
|
||||
)
|
||||
}
|
||||
|
||||
res[fullName] = initializer
|
||||
}
|
||||
|
||||
|
||||
11
depinject/internal/appconfiggogo/buf.gen.yaml
Normal file
11
depinject/internal/appconfiggogo/buf.gen.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
version: v1
|
||||
managed:
|
||||
enabled: true
|
||||
go_package_prefix:
|
||||
default: cosmossdk.io/depinject/internal/appconfiggogo
|
||||
override:
|
||||
buf.build/cosmos/cosmos-sdk: cosmossdk.io/api
|
||||
plugins:
|
||||
- name: gocosmos
|
||||
out: .
|
||||
opt: paths=source_relative
|
||||
9
depinject/internal/appconfiggogo/buf.yaml
Normal file
9
depinject/internal/appconfiggogo/buf.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
version: v1
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
||||
except:
|
||||
- PACKAGE_VERSION_SUFFIX
|
||||
breaking:
|
||||
ignore:
|
||||
- testpb
|
||||
269
depinject/internal/appconfiggogo/testpb/test.pb.go
Normal file
269
depinject/internal/appconfiggogo/testpb/test.pb.go
Normal file
@ -0,0 +1,269 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: testpb/test.proto
|
||||
|
||||
package testpb
|
||||
|
||||
import (
|
||||
_ "cosmossdk.io/api/cosmos/app/v1alpha1"
|
||||
fmt "fmt"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type TestModuleGogo struct {
|
||||
}
|
||||
|
||||
func (m *TestModuleGogo) Reset() { *m = TestModuleGogo{} }
|
||||
func (m *TestModuleGogo) String() string { return proto.CompactTextString(m) }
|
||||
func (*TestModuleGogo) ProtoMessage() {}
|
||||
func (*TestModuleGogo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_41c67e33ca9d1f26, []int{0}
|
||||
}
|
||||
func (m *TestModuleGogo) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *TestModuleGogo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_TestModuleGogo.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *TestModuleGogo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TestModuleGogo.Merge(m, src)
|
||||
}
|
||||
func (m *TestModuleGogo) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *TestModuleGogo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TestModuleGogo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TestModuleGogo proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*TestModuleGogo)(nil), "testpb.TestModuleGogo")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("testpb/test.proto", fileDescriptor_41c67e33ca9d1f26) }
|
||||
|
||||
var fileDescriptor_41c67e33ca9d1f26 = []byte{
|
||||
// 240 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x49, 0x2d, 0x2e,
|
||||
0x29, 0x48, 0xd2, 0x07, 0x51, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x6c, 0x10, 0x21, 0x29,
|
||||
0x85, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xfd, 0xc4, 0x82, 0x02, 0xfd, 0x32, 0xc3, 0xc4, 0x9c,
|
||||
0x82, 0x8c, 0x44, 0x43, 0xfd, 0xdc, 0xfc, 0x94, 0xd2, 0x9c, 0x54, 0x88, 0x4a, 0x25, 0x6b, 0x2e,
|
||||
0xbe, 0x90, 0xd4, 0xe2, 0x12, 0x5f, 0xb0, 0x98, 0x7b, 0x7e, 0x7a, 0xbe, 0x95, 0xe6, 0xae, 0x03,
|
||||
0xd3, 0x6e, 0x31, 0x2a, 0x73, 0x29, 0x42, 0xf4, 0x16, 0xa7, 0x64, 0xeb, 0x65, 0xe6, 0xeb, 0x27,
|
||||
0xe7, 0x17, 0xa5, 0xea, 0x67, 0xe6, 0x95, 0xa4, 0x16, 0xe5, 0x25, 0xe6, 0xe8, 0x43, 0x8c, 0x77,
|
||||
0x9a, 0xcb, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e,
|
||||
0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x5c, 0x5c, 0xc9, 0xf9,
|
||||
0xb9, 0x7a, 0x50, 0x65, 0x9c, 0x20, 0x1b, 0x02, 0x40, 0xd6, 0x05, 0x30, 0x46, 0x99, 0xa0, 0x18,
|
||||
0x9b, 0x92, 0x5a, 0x90, 0x99, 0x97, 0x95, 0x9a, 0x5c, 0x82, 0x30, 0x3b, 0xb1, 0xa0, 0x20, 0x39,
|
||||
0x3f, 0x2f, 0x2d, 0x33, 0x3d, 0x3d, 0x3f, 0x3d, 0x1f, 0x6a, 0xd3, 0x22, 0x26, 0xe6, 0x90, 0x88,
|
||||
0x88, 0x55, 0x4c, 0x6c, 0x21, 0x60, 0xee, 0x29, 0x18, 0xe3, 0x11, 0x93, 0x10, 0x84, 0x11, 0xe3,
|
||||
0x1e, 0xe0, 0xe4, 0x9b, 0x5a, 0x92, 0x98, 0x92, 0x58, 0x92, 0xf8, 0x0a, 0x26, 0x9b, 0xc4, 0x06,
|
||||
0xf6, 0xa3, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x9f, 0x4d, 0x9e, 0x22, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *TestModuleGogo) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *TestModuleGogo) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *TestModuleGogo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTest(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTest(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *TestModuleGogo) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTest(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozTest(x uint64) (n int) {
|
||||
return sovTest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *TestModuleGogo) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTest
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: TestModuleGogo: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: TestModuleGogo: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTest(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTest
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTest(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTest
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTest
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTest
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthTest
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupTest
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthTest
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthTest = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTest = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTest = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
11
depinject/internal/appconfiggogo/testpb/test.proto
Normal file
11
depinject/internal/appconfiggogo/testpb/test.proto
Normal file
@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package testpb;
|
||||
|
||||
import "cosmos/app/v1alpha1/module.proto";
|
||||
|
||||
message TestModuleGogo {
|
||||
option (cosmos.app.v1alpha1.module) = {
|
||||
go_import: "cosmossdk.io/core/internal/appconfiggogo/testpb"
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user