From e06226f4e07ea2fefd876d324a4cee49d5ae1ed1 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 12 Jan 2024 11:44:17 +0100 Subject: [PATCH 1/8] refactor(appconfig)!: simplify app config --- api/cosmos/app/v1alpha1/config.pulsar.go | 2090 ---------------------- api/cosmos/app/v1alpha1/query.pulsar.go | 999 ----------- api/cosmos/app/v1alpha1/query_grpc.pb.go | 111 -- baseapp/utils_test.go | 5 +- depinject/appconfig/config.go | 56 +- depinject/internal/appconfig/registry.go | 2 +- docs/architecture/adr-057-app-wiring.md | 17 +- go.mod | 1 + go.sum | 2 - proto/cosmos/app/v1alpha1/config.proto | 55 - proto/cosmos/app/v1alpha1/query.proto | 22 - runtime/app.go | 4 +- runtime/autocli.go | 8 - runtime/module.go | 4 +- runtime/services.go | 2 - runtime/services/app.go | 23 - simapp/app_config.go | 5 +- testutil/configurator/configurator.go | 51 +- 18 files changed, 97 insertions(+), 3360 deletions(-) delete mode 100644 api/cosmos/app/v1alpha1/config.pulsar.go delete mode 100644 api/cosmos/app/v1alpha1/query.pulsar.go delete mode 100644 api/cosmos/app/v1alpha1/query_grpc.pb.go delete mode 100644 proto/cosmos/app/v1alpha1/config.proto delete mode 100644 proto/cosmos/app/v1alpha1/query.proto delete mode 100644 runtime/services/app.go diff --git a/api/cosmos/app/v1alpha1/config.pulsar.go b/api/cosmos/app/v1alpha1/config.pulsar.go deleted file mode 100644 index 34dfc0d7459c..000000000000 --- a/api/cosmos/app/v1alpha1/config.pulsar.go +++ /dev/null @@ -1,2090 +0,0 @@ -// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. -package appv1alpha1 - -import ( - fmt "fmt" - runtime "github.com/cosmos/cosmos-proto/runtime" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoiface "google.golang.org/protobuf/runtime/protoiface" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - io "io" - reflect "reflect" - sync "sync" -) - -var _ protoreflect.List = (*_Config_1_list)(nil) - -type _Config_1_list struct { - list *[]*ModuleConfig -} - -func (x *_Config_1_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_Config_1_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_Config_1_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*ModuleConfig) - (*x.list)[i] = concreteValue -} - -func (x *_Config_1_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*ModuleConfig) - *x.list = append(*x.list, concreteValue) -} - -func (x *_Config_1_list) AppendMutable() protoreflect.Value { - v := new(ModuleConfig) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_Config_1_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_Config_1_list) NewElement() protoreflect.Value { - v := new(ModuleConfig) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_Config_1_list) IsValid() bool { - return x.list != nil -} - -var _ protoreflect.List = (*_Config_2_list)(nil) - -type _Config_2_list struct { - list *[]*GolangBinding -} - -func (x *_Config_2_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_Config_2_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_Config_2_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*GolangBinding) - (*x.list)[i] = concreteValue -} - -func (x *_Config_2_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*GolangBinding) - *x.list = append(*x.list, concreteValue) -} - -func (x *_Config_2_list) AppendMutable() protoreflect.Value { - v := new(GolangBinding) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_Config_2_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_Config_2_list) NewElement() protoreflect.Value { - v := new(GolangBinding) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_Config_2_list) IsValid() bool { - return x.list != nil -} - -var ( - md_Config protoreflect.MessageDescriptor - fd_Config_modules protoreflect.FieldDescriptor - fd_Config_golang_bindings protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_app_v1alpha1_config_proto_init() - md_Config = File_cosmos_app_v1alpha1_config_proto.Messages().ByName("Config") - fd_Config_modules = md_Config.Fields().ByName("modules") - fd_Config_golang_bindings = md_Config.Fields().ByName("golang_bindings") -} - -var _ protoreflect.Message = (*fastReflection_Config)(nil) - -type fastReflection_Config Config - -func (x *Config) ProtoReflect() protoreflect.Message { - return (*fastReflection_Config)(x) -} - -func (x *Config) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_Config_messageType fastReflection_Config_messageType -var _ protoreflect.MessageType = fastReflection_Config_messageType{} - -type fastReflection_Config_messageType struct{} - -func (x fastReflection_Config_messageType) Zero() protoreflect.Message { - return (*fastReflection_Config)(nil) -} -func (x fastReflection_Config_messageType) New() protoreflect.Message { - return new(fastReflection_Config) -} -func (x fastReflection_Config_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_Config -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_Config) Descriptor() protoreflect.MessageDescriptor { - return md_Config -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_Config) Type() protoreflect.MessageType { - return _fastReflection_Config_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_Config) New() protoreflect.Message { - return new(fastReflection_Config) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_Config) Interface() protoreflect.ProtoMessage { - return (*Config)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_Config) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.Modules) != 0 { - value := protoreflect.ValueOfList(&_Config_1_list{list: &x.Modules}) - if !f(fd_Config_modules, value) { - return - } - } - if len(x.GolangBindings) != 0 { - value := protoreflect.ValueOfList(&_Config_2_list{list: &x.GolangBindings}) - if !f(fd_Config_golang_bindings, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_Config) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.app.v1alpha1.Config.modules": - return len(x.Modules) != 0 - case "cosmos.app.v1alpha1.Config.golang_bindings": - return len(x.GolangBindings) != 0 - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Config) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.Config.modules": - x.Modules = nil - case "cosmos.app.v1alpha1.Config.golang_bindings": - x.GolangBindings = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_Config) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.app.v1alpha1.Config.modules": - if len(x.Modules) == 0 { - return protoreflect.ValueOfList(&_Config_1_list{}) - } - listValue := &_Config_1_list{list: &x.Modules} - return protoreflect.ValueOfList(listValue) - case "cosmos.app.v1alpha1.Config.golang_bindings": - if len(x.GolangBindings) == 0 { - return protoreflect.ValueOfList(&_Config_2_list{}) - } - listValue := &_Config_2_list{list: &x.GolangBindings} - return protoreflect.ValueOfList(listValue) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Config) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.Config.modules": - lv := value.List() - clv := lv.(*_Config_1_list) - x.Modules = *clv.list - case "cosmos.app.v1alpha1.Config.golang_bindings": - lv := value.List() - clv := lv.(*_Config_2_list) - x.GolangBindings = *clv.list - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Config) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.Config.modules": - if x.Modules == nil { - x.Modules = []*ModuleConfig{} - } - value := &_Config_1_list{list: &x.Modules} - return protoreflect.ValueOfList(value) - case "cosmos.app.v1alpha1.Config.golang_bindings": - if x.GolangBindings == nil { - x.GolangBindings = []*GolangBinding{} - } - value := &_Config_2_list{list: &x.GolangBindings} - return protoreflect.ValueOfList(value) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_Config) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.Config.modules": - list := []*ModuleConfig{} - return protoreflect.ValueOfList(&_Config_1_list{list: &list}) - case "cosmos.app.v1alpha1.Config.golang_bindings": - list := []*GolangBinding{} - return protoreflect.ValueOfList(&_Config_2_list{list: &list}) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_Config) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.Config", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_Config) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Config) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_Config) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_Config) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*Config) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if len(x.Modules) > 0 { - for _, e := range x.Modules { - l = options.Size(e) - n += 1 + l + runtime.Sov(uint64(l)) - } - } - if len(x.GolangBindings) > 0 { - for _, e := range x.GolangBindings { - l = options.Size(e) - n += 1 + l + runtime.Sov(uint64(l)) - } - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*Config) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if len(x.GolangBindings) > 0 { - for iNdEx := len(x.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.GolangBindings[iNdEx]) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x12 - } - } - if len(x.Modules) > 0 { - for iNdEx := len(x.Modules) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.Modules[iNdEx]) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0xa - } - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*Config) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Config: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Config: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Modules", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Modules = append(x.Modules, &ModuleConfig{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Modules[len(x.Modules)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.GolangBindings = append(x.GolangBindings, &GolangBinding{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.GolangBindings[len(x.GolangBindings)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -var _ protoreflect.List = (*_ModuleConfig_3_list)(nil) - -type _ModuleConfig_3_list struct { - list *[]*GolangBinding -} - -func (x *_ModuleConfig_3_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_ModuleConfig_3_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_ModuleConfig_3_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*GolangBinding) - (*x.list)[i] = concreteValue -} - -func (x *_ModuleConfig_3_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*GolangBinding) - *x.list = append(*x.list, concreteValue) -} - -func (x *_ModuleConfig_3_list) AppendMutable() protoreflect.Value { - v := new(GolangBinding) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_ModuleConfig_3_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_ModuleConfig_3_list) NewElement() protoreflect.Value { - v := new(GolangBinding) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_ModuleConfig_3_list) IsValid() bool { - return x.list != nil -} - -var ( - md_ModuleConfig protoreflect.MessageDescriptor - fd_ModuleConfig_name protoreflect.FieldDescriptor - fd_ModuleConfig_config protoreflect.FieldDescriptor - fd_ModuleConfig_golang_bindings protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_app_v1alpha1_config_proto_init() - md_ModuleConfig = File_cosmos_app_v1alpha1_config_proto.Messages().ByName("ModuleConfig") - fd_ModuleConfig_name = md_ModuleConfig.Fields().ByName("name") - fd_ModuleConfig_config = md_ModuleConfig.Fields().ByName("config") - fd_ModuleConfig_golang_bindings = md_ModuleConfig.Fields().ByName("golang_bindings") -} - -var _ protoreflect.Message = (*fastReflection_ModuleConfig)(nil) - -type fastReflection_ModuleConfig ModuleConfig - -func (x *ModuleConfig) ProtoReflect() protoreflect.Message { - return (*fastReflection_ModuleConfig)(x) -} - -func (x *ModuleConfig) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_ModuleConfig_messageType fastReflection_ModuleConfig_messageType -var _ protoreflect.MessageType = fastReflection_ModuleConfig_messageType{} - -type fastReflection_ModuleConfig_messageType struct{} - -func (x fastReflection_ModuleConfig_messageType) Zero() protoreflect.Message { - return (*fastReflection_ModuleConfig)(nil) -} -func (x fastReflection_ModuleConfig_messageType) New() protoreflect.Message { - return new(fastReflection_ModuleConfig) -} -func (x fastReflection_ModuleConfig_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_ModuleConfig -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_ModuleConfig) Descriptor() protoreflect.MessageDescriptor { - return md_ModuleConfig -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_ModuleConfig) Type() protoreflect.MessageType { - return _fastReflection_ModuleConfig_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_ModuleConfig) New() protoreflect.Message { - return new(fastReflection_ModuleConfig) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_ModuleConfig) Interface() protoreflect.ProtoMessage { - return (*ModuleConfig)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_ModuleConfig) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Name != "" { - value := protoreflect.ValueOfString(x.Name) - if !f(fd_ModuleConfig_name, value) { - return - } - } - if x.Config != nil { - value := protoreflect.ValueOfMessage(x.Config.ProtoReflect()) - if !f(fd_ModuleConfig_config, value) { - return - } - } - if len(x.GolangBindings) != 0 { - value := protoreflect.ValueOfList(&_ModuleConfig_3_list{list: &x.GolangBindings}) - if !f(fd_ModuleConfig_golang_bindings, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_ModuleConfig) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.app.v1alpha1.ModuleConfig.name": - return x.Name != "" - case "cosmos.app.v1alpha1.ModuleConfig.config": - return x.Config != nil - case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": - return len(x.GolangBindings) != 0 - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_ModuleConfig) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.ModuleConfig.name": - x.Name = "" - case "cosmos.app.v1alpha1.ModuleConfig.config": - x.Config = nil - case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": - x.GolangBindings = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_ModuleConfig) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.app.v1alpha1.ModuleConfig.name": - value := x.Name - return protoreflect.ValueOfString(value) - case "cosmos.app.v1alpha1.ModuleConfig.config": - value := x.Config - return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": - if len(x.GolangBindings) == 0 { - return protoreflect.ValueOfList(&_ModuleConfig_3_list{}) - } - listValue := &_ModuleConfig_3_list{list: &x.GolangBindings} - return protoreflect.ValueOfList(listValue) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_ModuleConfig) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.ModuleConfig.name": - x.Name = value.Interface().(string) - case "cosmos.app.v1alpha1.ModuleConfig.config": - x.Config = value.Message().Interface().(*anypb.Any) - case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": - lv := value.List() - clv := lv.(*_ModuleConfig_3_list) - x.GolangBindings = *clv.list - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_ModuleConfig) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.ModuleConfig.config": - if x.Config == nil { - x.Config = new(anypb.Any) - } - return protoreflect.ValueOfMessage(x.Config.ProtoReflect()) - case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": - if x.GolangBindings == nil { - x.GolangBindings = []*GolangBinding{} - } - value := &_ModuleConfig_3_list{list: &x.GolangBindings} - return protoreflect.ValueOfList(value) - case "cosmos.app.v1alpha1.ModuleConfig.name": - panic(fmt.Errorf("field name of message cosmos.app.v1alpha1.ModuleConfig is not mutable")) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_ModuleConfig) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.ModuleConfig.name": - return protoreflect.ValueOfString("") - case "cosmos.app.v1alpha1.ModuleConfig.config": - m := new(anypb.Any) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": - list := []*GolangBinding{} - return protoreflect.ValueOfList(&_ModuleConfig_3_list{list: &list}) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_ModuleConfig) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.ModuleConfig", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_ModuleConfig) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_ModuleConfig) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_ModuleConfig) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_ModuleConfig) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*ModuleConfig) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - l = len(x.Name) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.Config != nil { - l = options.Size(x.Config) - n += 1 + l + runtime.Sov(uint64(l)) - } - if len(x.GolangBindings) > 0 { - for _, e := range x.GolangBindings { - l = options.Size(e) - n += 1 + l + runtime.Sov(uint64(l)) - } - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*ModuleConfig) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if len(x.GolangBindings) > 0 { - for iNdEx := len(x.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.GolangBindings[iNdEx]) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x1a - } - } - if x.Config != nil { - encoded, err := options.Marshal(x.Config) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x12 - } - if len(x.Name) > 0 { - i -= len(x.Name) - copy(dAtA[i:], x.Name) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*ModuleConfig) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ModuleConfig: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ModuleConfig: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if x.Config == nil { - x.Config = &anypb.Any{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Config); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.GolangBindings = append(x.GolangBindings, &GolangBinding{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.GolangBindings[len(x.GolangBindings)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -var ( - md_GolangBinding protoreflect.MessageDescriptor - fd_GolangBinding_interface_type protoreflect.FieldDescriptor - fd_GolangBinding_implementation protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_app_v1alpha1_config_proto_init() - md_GolangBinding = File_cosmos_app_v1alpha1_config_proto.Messages().ByName("GolangBinding") - fd_GolangBinding_interface_type = md_GolangBinding.Fields().ByName("interface_type") - fd_GolangBinding_implementation = md_GolangBinding.Fields().ByName("implementation") -} - -var _ protoreflect.Message = (*fastReflection_GolangBinding)(nil) - -type fastReflection_GolangBinding GolangBinding - -func (x *GolangBinding) ProtoReflect() protoreflect.Message { - return (*fastReflection_GolangBinding)(x) -} - -func (x *GolangBinding) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_GolangBinding_messageType fastReflection_GolangBinding_messageType -var _ protoreflect.MessageType = fastReflection_GolangBinding_messageType{} - -type fastReflection_GolangBinding_messageType struct{} - -func (x fastReflection_GolangBinding_messageType) Zero() protoreflect.Message { - return (*fastReflection_GolangBinding)(nil) -} -func (x fastReflection_GolangBinding_messageType) New() protoreflect.Message { - return new(fastReflection_GolangBinding) -} -func (x fastReflection_GolangBinding_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_GolangBinding -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_GolangBinding) Descriptor() protoreflect.MessageDescriptor { - return md_GolangBinding -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_GolangBinding) Type() protoreflect.MessageType { - return _fastReflection_GolangBinding_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_GolangBinding) New() protoreflect.Message { - return new(fastReflection_GolangBinding) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_GolangBinding) Interface() protoreflect.ProtoMessage { - return (*GolangBinding)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_GolangBinding) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.InterfaceType != "" { - value := protoreflect.ValueOfString(x.InterfaceType) - if !f(fd_GolangBinding_interface_type, value) { - return - } - } - if x.Implementation != "" { - value := protoreflect.ValueOfString(x.Implementation) - if !f(fd_GolangBinding_implementation, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_GolangBinding) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.app.v1alpha1.GolangBinding.interface_type": - return x.InterfaceType != "" - case "cosmos.app.v1alpha1.GolangBinding.implementation": - return x.Implementation != "" - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GolangBinding) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.GolangBinding.interface_type": - x.InterfaceType = "" - case "cosmos.app.v1alpha1.GolangBinding.implementation": - x.Implementation = "" - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_GolangBinding) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.app.v1alpha1.GolangBinding.interface_type": - value := x.InterfaceType - return protoreflect.ValueOfString(value) - case "cosmos.app.v1alpha1.GolangBinding.implementation": - value := x.Implementation - return protoreflect.ValueOfString(value) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GolangBinding) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.GolangBinding.interface_type": - x.InterfaceType = value.Interface().(string) - case "cosmos.app.v1alpha1.GolangBinding.implementation": - x.Implementation = value.Interface().(string) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GolangBinding) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.GolangBinding.interface_type": - panic(fmt.Errorf("field interface_type of message cosmos.app.v1alpha1.GolangBinding is not mutable")) - case "cosmos.app.v1alpha1.GolangBinding.implementation": - panic(fmt.Errorf("field implementation of message cosmos.app.v1alpha1.GolangBinding is not mutable")) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_GolangBinding) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.GolangBinding.interface_type": - return protoreflect.ValueOfString("") - case "cosmos.app.v1alpha1.GolangBinding.implementation": - return protoreflect.ValueOfString("") - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_GolangBinding) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.GolangBinding", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_GolangBinding) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_GolangBinding) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_GolangBinding) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_GolangBinding) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*GolangBinding) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - l = len(x.InterfaceType) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - l = len(x.Implementation) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*GolangBinding) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if len(x.Implementation) > 0 { - i -= len(x.Implementation) - copy(dAtA[i:], x.Implementation) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Implementation))) - i-- - dAtA[i] = 0x12 - } - if len(x.InterfaceType) > 0 { - i -= len(x.InterfaceType) - copy(dAtA[i:], x.InterfaceType) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.InterfaceType))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*GolangBinding) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GolangBinding: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GolangBinding: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field InterfaceType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.InterfaceType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Implementation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Implementation = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.0 -// protoc (unknown) -// source: cosmos/app/v1alpha1/config.proto - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Config represents the configuration for a Cosmos SDK ABCI app. -// It is intended that all state machine logic including the version of -// baseapp and tx handlers (and possibly even Tendermint) that an app needs -// can be described in a config object. For compatibility, the framework should -// allow a mixture of declarative and imperative app wiring, however, apps -// that strive for the maximum ease of maintainability should be able to describe -// their state machine with a config object alone. -type Config struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // modules are the module configurations for the app. - Modules []*ModuleConfig `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"` - // golang_bindings specifies explicit interface to implementation type bindings which - // depinject uses to resolve interface inputs to provider functions. The scope of this - // field's configuration is global (not module specific). - GolangBindings []*GolangBinding `protobuf:"bytes,2,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` -} - -func (x *Config) Reset() { - *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Config) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Config) ProtoMessage() {} - -// Deprecated: Use Config.ProtoReflect.Descriptor instead. -func (*Config) Descriptor() ([]byte, []int) { - return file_cosmos_app_v1alpha1_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Config) GetModules() []*ModuleConfig { - if x != nil { - return x.Modules - } - return nil -} - -func (x *Config) GetGolangBindings() []*GolangBinding { - if x != nil { - return x.GolangBindings - } - return nil -} - -// ModuleConfig is a module configuration for an app. -type ModuleConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // name is the unique name of the module within the app. It should be a name - // that persists between different versions of a module so that modules - // can be smoothly upgraded to new versions. - // - // For example, for the module cosmos.bank.module.v1.Module, we may chose - // to simply name the module "bank" in the app. When we upgrade to - // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same - // and the framework knows that the v2 module should receive all the same state - // that the v1 module had. Note: modules should provide info on which versions - // they can migrate from in the ModuleDescriptor.can_migration_from field. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // config is the config object for the module. Module config messages should - // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. - Config *anypb.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` - // golang_bindings specifies explicit interface to implementation type bindings which - // depinject uses to resolve interface inputs to provider functions. The scope of this - // field's configuration is module specific. - GolangBindings []*GolangBinding `protobuf:"bytes,3,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` -} - -func (x *ModuleConfig) Reset() { - *x = ModuleConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ModuleConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ModuleConfig) ProtoMessage() {} - -// Deprecated: Use ModuleConfig.ProtoReflect.Descriptor instead. -func (*ModuleConfig) Descriptor() ([]byte, []int) { - return file_cosmos_app_v1alpha1_config_proto_rawDescGZIP(), []int{1} -} - -func (x *ModuleConfig) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ModuleConfig) GetConfig() *anypb.Any { - if x != nil { - return x.Config - } - return nil -} - -func (x *ModuleConfig) GetGolangBindings() []*GolangBinding { - if x != nil { - return x.GolangBindings - } - return nil -} - -// GolangBinding is an explicit interface type to implementing type binding for dependency injection. -type GolangBinding struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // interface_type is the interface type which will be bound to a specific implementation type - InterfaceType string `protobuf:"bytes,1,opt,name=interface_type,json=interfaceType,proto3" json:"interface_type,omitempty"` - // implementation is the implementing type which will be supplied when an input of type interface is requested - Implementation string `protobuf:"bytes,2,opt,name=implementation,proto3" json:"implementation,omitempty"` -} - -func (x *GolangBinding) Reset() { - *x = GolangBinding{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GolangBinding) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GolangBinding) ProtoMessage() {} - -// Deprecated: Use GolangBinding.ProtoReflect.Descriptor instead. -func (*GolangBinding) Descriptor() ([]byte, []int) { - return file_cosmos_app_v1alpha1_config_proto_rawDescGZIP(), []int{2} -} - -func (x *GolangBinding) GetInterfaceType() string { - if x != nil { - return x.InterfaceType - } - return "" -} - -func (x *GolangBinding) GetImplementation() string { - if x != nil { - return x.Implementation - } - return "" -} - -var File_cosmos_app_v1alpha1_config_proto protoreflect.FileDescriptor - -var file_cosmos_app_v1alpha1_config_proto_rawDesc = []byte{ - 0x0a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, - 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x92, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, - 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x4b, 0x0a, 0x0f, 0x67, 0x6f, - 0x6c, 0x61, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x6f, 0x6c, 0x61, 0x6e, 0x67, - 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x0e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x42, - 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x9d, 0x01, 0x0a, 0x0c, 0x4d, 0x6f, 0x64, 0x75, - 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x06, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, - 0x6e, 0x79, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4b, 0x0a, 0x0f, 0x67, 0x6f, - 0x6c, 0x61, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x6f, 0x6c, 0x61, 0x6e, 0x67, - 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x0e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x42, - 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x5e, 0x0a, 0x0d, 0x47, 0x6f, 0x6c, 0x61, 0x6e, - 0x67, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x26, 0x0a, 0x0e, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xc6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, - 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, - 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, - 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_cosmos_app_v1alpha1_config_proto_rawDescOnce sync.Once - file_cosmos_app_v1alpha1_config_proto_rawDescData = file_cosmos_app_v1alpha1_config_proto_rawDesc -) - -func file_cosmos_app_v1alpha1_config_proto_rawDescGZIP() []byte { - file_cosmos_app_v1alpha1_config_proto_rawDescOnce.Do(func() { - file_cosmos_app_v1alpha1_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_app_v1alpha1_config_proto_rawDescData) - }) - return file_cosmos_app_v1alpha1_config_proto_rawDescData -} - -var file_cosmos_app_v1alpha1_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_cosmos_app_v1alpha1_config_proto_goTypes = []interface{}{ - (*Config)(nil), // 0: cosmos.app.v1alpha1.Config - (*ModuleConfig)(nil), // 1: cosmos.app.v1alpha1.ModuleConfig - (*GolangBinding)(nil), // 2: cosmos.app.v1alpha1.GolangBinding - (*anypb.Any)(nil), // 3: google.protobuf.Any -} -var file_cosmos_app_v1alpha1_config_proto_depIdxs = []int32{ - 1, // 0: cosmos.app.v1alpha1.Config.modules:type_name -> cosmos.app.v1alpha1.ModuleConfig - 2, // 1: cosmos.app.v1alpha1.Config.golang_bindings:type_name -> cosmos.app.v1alpha1.GolangBinding - 3, // 2: cosmos.app.v1alpha1.ModuleConfig.config:type_name -> google.protobuf.Any - 2, // 3: cosmos.app.v1alpha1.ModuleConfig.golang_bindings:type_name -> cosmos.app.v1alpha1.GolangBinding - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_cosmos_app_v1alpha1_config_proto_init() } -func file_cosmos_app_v1alpha1_config_proto_init() { - if File_cosmos_app_v1alpha1_config_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_cosmos_app_v1alpha1_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_app_v1alpha1_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ModuleConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_app_v1alpha1_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GolangBinding); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_cosmos_app_v1alpha1_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_cosmos_app_v1alpha1_config_proto_goTypes, - DependencyIndexes: file_cosmos_app_v1alpha1_config_proto_depIdxs, - MessageInfos: file_cosmos_app_v1alpha1_config_proto_msgTypes, - }.Build() - File_cosmos_app_v1alpha1_config_proto = out.File - file_cosmos_app_v1alpha1_config_proto_rawDesc = nil - file_cosmos_app_v1alpha1_config_proto_goTypes = nil - file_cosmos_app_v1alpha1_config_proto_depIdxs = nil -} diff --git a/api/cosmos/app/v1alpha1/query.pulsar.go b/api/cosmos/app/v1alpha1/query.pulsar.go deleted file mode 100644 index 7de26bd84a94..000000000000 --- a/api/cosmos/app/v1alpha1/query.pulsar.go +++ /dev/null @@ -1,999 +0,0 @@ -// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. -package appv1alpha1 - -import ( - fmt "fmt" - runtime "github.com/cosmos/cosmos-proto/runtime" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoiface "google.golang.org/protobuf/runtime/protoiface" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" - reflect "reflect" - sync "sync" -) - -var ( - md_QueryConfigRequest protoreflect.MessageDescriptor -) - -func init() { - file_cosmos_app_v1alpha1_query_proto_init() - md_QueryConfigRequest = File_cosmos_app_v1alpha1_query_proto.Messages().ByName("QueryConfigRequest") -} - -var _ protoreflect.Message = (*fastReflection_QueryConfigRequest)(nil) - -type fastReflection_QueryConfigRequest QueryConfigRequest - -func (x *QueryConfigRequest) ProtoReflect() protoreflect.Message { - return (*fastReflection_QueryConfigRequest)(x) -} - -func (x *QueryConfigRequest) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_QueryConfigRequest_messageType fastReflection_QueryConfigRequest_messageType -var _ protoreflect.MessageType = fastReflection_QueryConfigRequest_messageType{} - -type fastReflection_QueryConfigRequest_messageType struct{} - -func (x fastReflection_QueryConfigRequest_messageType) Zero() protoreflect.Message { - return (*fastReflection_QueryConfigRequest)(nil) -} -func (x fastReflection_QueryConfigRequest_messageType) New() protoreflect.Message { - return new(fastReflection_QueryConfigRequest) -} -func (x fastReflection_QueryConfigRequest_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_QueryConfigRequest -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_QueryConfigRequest) Descriptor() protoreflect.MessageDescriptor { - return md_QueryConfigRequest -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_QueryConfigRequest) Type() protoreflect.MessageType { - return _fastReflection_QueryConfigRequest_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_QueryConfigRequest) New() protoreflect.Message { - return new(fastReflection_QueryConfigRequest) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_QueryConfigRequest) Interface() protoreflect.ProtoMessage { - return (*QueryConfigRequest)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_QueryConfigRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_QueryConfigRequest) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigRequest) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_QueryConfigRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_QueryConfigRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_QueryConfigRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.QueryConfigRequest", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_QueryConfigRequest) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigRequest) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_QueryConfigRequest) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_QueryConfigRequest) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*QueryConfigRequest) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*QueryConfigRequest) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*QueryConfigRequest) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -var ( - md_QueryConfigResponse protoreflect.MessageDescriptor - fd_QueryConfigResponse_config protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_app_v1alpha1_query_proto_init() - md_QueryConfigResponse = File_cosmos_app_v1alpha1_query_proto.Messages().ByName("QueryConfigResponse") - fd_QueryConfigResponse_config = md_QueryConfigResponse.Fields().ByName("config") -} - -var _ protoreflect.Message = (*fastReflection_QueryConfigResponse)(nil) - -type fastReflection_QueryConfigResponse QueryConfigResponse - -func (x *QueryConfigResponse) ProtoReflect() protoreflect.Message { - return (*fastReflection_QueryConfigResponse)(x) -} - -func (x *QueryConfigResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_QueryConfigResponse_messageType fastReflection_QueryConfigResponse_messageType -var _ protoreflect.MessageType = fastReflection_QueryConfigResponse_messageType{} - -type fastReflection_QueryConfigResponse_messageType struct{} - -func (x fastReflection_QueryConfigResponse_messageType) Zero() protoreflect.Message { - return (*fastReflection_QueryConfigResponse)(nil) -} -func (x fastReflection_QueryConfigResponse_messageType) New() protoreflect.Message { - return new(fastReflection_QueryConfigResponse) -} -func (x fastReflection_QueryConfigResponse_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_QueryConfigResponse -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_QueryConfigResponse) Descriptor() protoreflect.MessageDescriptor { - return md_QueryConfigResponse -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_QueryConfigResponse) Type() protoreflect.MessageType { - return _fastReflection_QueryConfigResponse_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_QueryConfigResponse) New() protoreflect.Message { - return new(fastReflection_QueryConfigResponse) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_QueryConfigResponse) Interface() protoreflect.ProtoMessage { - return (*QueryConfigResponse)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_QueryConfigResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Config != nil { - value := protoreflect.ValueOfMessage(x.Config.ProtoReflect()) - if !f(fd_QueryConfigResponse_config, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_QueryConfigResponse) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.app.v1alpha1.QueryConfigResponse.config": - return x.Config != nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigResponse) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.QueryConfigResponse.config": - x.Config = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_QueryConfigResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.app.v1alpha1.QueryConfigResponse.config": - value := x.Config - return protoreflect.ValueOfMessage(value.ProtoReflect()) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.app.v1alpha1.QueryConfigResponse.config": - x.Config = value.Message().Interface().(*Config) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.QueryConfigResponse.config": - if x.Config == nil { - x.Config = new(Config) - } - return protoreflect.ValueOfMessage(x.Config.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_QueryConfigResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.app.v1alpha1.QueryConfigResponse.config": - m := new(Config) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) - } - panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_QueryConfigResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.QueryConfigResponse", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_QueryConfigResponse) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryConfigResponse) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_QueryConfigResponse) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_QueryConfigResponse) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*QueryConfigResponse) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if x.Config != nil { - l = options.Size(x.Config) - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*QueryConfigResponse) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if x.Config != nil { - encoded, err := options.Marshal(x.Config) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*QueryConfigResponse) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if x.Config == nil { - x.Config = &Config{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Config); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.0 -// protoc (unknown) -// source: cosmos/app/v1alpha1/query.proto - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// QueryConfigRequest is the Query/Config request type. -type QueryConfigRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *QueryConfigRequest) Reset() { - *x = QueryConfigRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueryConfigRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueryConfigRequest) ProtoMessage() {} - -// Deprecated: Use QueryConfigRequest.ProtoReflect.Descriptor instead. -func (*QueryConfigRequest) Descriptor() ([]byte, []int) { - return file_cosmos_app_v1alpha1_query_proto_rawDescGZIP(), []int{0} -} - -// QueryConfigRequest is the Query/Config response type. -type QueryConfigResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // config is the current app config. - Config *Config `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` -} - -func (x *QueryConfigResponse) Reset() { - *x = QueryConfigResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueryConfigResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueryConfigResponse) ProtoMessage() {} - -// Deprecated: Use QueryConfigResponse.ProtoReflect.Descriptor instead. -func (*QueryConfigResponse) Descriptor() ([]byte, []int) { - return file_cosmos_app_v1alpha1_query_proto_rawDescGZIP(), []int{1} -} - -func (x *QueryConfigResponse) GetConfig() *Config { - if x != nil { - return x.Config - } - return nil -} - -var File_cosmos_app_v1alpha1_query_proto protoreflect.FileDescriptor - -var file_cosmos_app_v1alpha1_query_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, - 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, - 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, - 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0x66, 0x0a, 0x05, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x12, 0x5d, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x27, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, - 0x68, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, - 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, - 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, - 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, - 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_cosmos_app_v1alpha1_query_proto_rawDescOnce sync.Once - file_cosmos_app_v1alpha1_query_proto_rawDescData = file_cosmos_app_v1alpha1_query_proto_rawDesc -) - -func file_cosmos_app_v1alpha1_query_proto_rawDescGZIP() []byte { - file_cosmos_app_v1alpha1_query_proto_rawDescOnce.Do(func() { - file_cosmos_app_v1alpha1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_app_v1alpha1_query_proto_rawDescData) - }) - return file_cosmos_app_v1alpha1_query_proto_rawDescData -} - -var file_cosmos_app_v1alpha1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_cosmos_app_v1alpha1_query_proto_goTypes = []interface{}{ - (*QueryConfigRequest)(nil), // 0: cosmos.app.v1alpha1.QueryConfigRequest - (*QueryConfigResponse)(nil), // 1: cosmos.app.v1alpha1.QueryConfigResponse - (*Config)(nil), // 2: cosmos.app.v1alpha1.Config -} -var file_cosmos_app_v1alpha1_query_proto_depIdxs = []int32{ - 2, // 0: cosmos.app.v1alpha1.QueryConfigResponse.config:type_name -> cosmos.app.v1alpha1.Config - 0, // 1: cosmos.app.v1alpha1.Query.Config:input_type -> cosmos.app.v1alpha1.QueryConfigRequest - 1, // 2: cosmos.app.v1alpha1.Query.Config:output_type -> cosmos.app.v1alpha1.QueryConfigResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_cosmos_app_v1alpha1_query_proto_init() } -func file_cosmos_app_v1alpha1_query_proto_init() { - if File_cosmos_app_v1alpha1_query_proto != nil { - return - } - file_cosmos_app_v1alpha1_config_proto_init() - if !protoimpl.UnsafeEnabled { - file_cosmos_app_v1alpha1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryConfigRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_app_v1alpha1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryConfigResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_cosmos_app_v1alpha1_query_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_cosmos_app_v1alpha1_query_proto_goTypes, - DependencyIndexes: file_cosmos_app_v1alpha1_query_proto_depIdxs, - MessageInfos: file_cosmos_app_v1alpha1_query_proto_msgTypes, - }.Build() - File_cosmos_app_v1alpha1_query_proto = out.File - file_cosmos_app_v1alpha1_query_proto_rawDesc = nil - file_cosmos_app_v1alpha1_query_proto_goTypes = nil - file_cosmos_app_v1alpha1_query_proto_depIdxs = nil -} diff --git a/api/cosmos/app/v1alpha1/query_grpc.pb.go b/api/cosmos/app/v1alpha1/query_grpc.pb.go deleted file mode 100644 index c8d56e6cbe6e..000000000000 --- a/api/cosmos/app/v1alpha1/query_grpc.pb.go +++ /dev/null @@ -1,111 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: cosmos/app/v1alpha1/query.proto - -package appv1alpha1 - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - Query_Config_FullMethodName = "/cosmos.app.v1alpha1.Query/Config" -) - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type QueryClient interface { - // Config returns the current app config. - Config(ctx context.Context, in *QueryConfigRequest, opts ...grpc.CallOption) (*QueryConfigResponse, error) -} - -type queryClient struct { - cc grpc.ClientConnInterface -} - -func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Config(ctx context.Context, in *QueryConfigRequest, opts ...grpc.CallOption) (*QueryConfigResponse, error) { - out := new(QueryConfigResponse) - err := c.cc.Invoke(ctx, Query_Config_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -// All implementations must embed UnimplementedQueryServer -// for forward compatibility -type QueryServer interface { - // Config returns the current app config. - Config(context.Context, *QueryConfigRequest) (*QueryConfigResponse, error) - mustEmbedUnimplementedQueryServer() -} - -// UnimplementedQueryServer must be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (UnimplementedQueryServer) Config(context.Context, *QueryConfigRequest) (*QueryConfigResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") -} -func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} - -// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to QueryServer will -// result in compilation errors. -type UnsafeQueryServer interface { - mustEmbedUnimplementedQueryServer() -} - -func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { - s.RegisterService(&Query_ServiceDesc, srv) -} - -func _Query_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryConfigRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Config(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Query_Config_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Config(ctx, req.(*QueryConfigRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Query_ServiceDesc is the grpc.ServiceDesc for Query service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Query_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.app.v1alpha1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Config", - Handler: _Query_Config_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/app/v1alpha1/query.proto", -} diff --git a/baseapp/utils_test.go b/baseapp/utils_test.go index 160ecac8a98d..afb08bae1cf2 100644 --- a/baseapp/utils_test.go +++ b/baseapp/utils_test.go @@ -19,7 +19,6 @@ import ( "github.com/stretchr/testify/require" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/address" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" @@ -94,8 +93,8 @@ func makeMinimalConfig() depinject.Config { return depinject.Configs( depinject.Supply(mempoolOpt, addressCodec, validatorAddressCodec, consensusAddressCodec), - appconfig.Compose(&appv1alpha1.Config{ - Modules: []*appv1alpha1.ModuleConfig{ + appconfig.Compose(&appconfig.AppConfig{ + Modules: []*appconfig.ModuleConfig{ { Name: "runtime", Config: appconfig.WrapAny(&runtimev1alpha1.Module{ diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index 4bc44f6ace0b..6dd5c7d7d99b 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -1,11 +1,11 @@ package appconfig import ( + "encoding/json" "fmt" "strings" "github.com/cosmos/cosmos-proto/anyutil" - "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" @@ -17,10 +17,56 @@ import ( internal "cosmossdk.io/depinject/internal/appconfig" ) +// Config represents the configuration for a Cosmos SDK ABCI app. +// It is intended that all state machine logic including the version of +// baseapp and tx handlers (and possibly even Tendermint) that an app needs +// can be described in a config object. For compatibility, the framework should +// allow a mixture of declarative and imperative app wiring, however, apps +// that strive for the maximum ease of maintainability should be able to describe +// their state machine with a config object alone. +type AppConfig struct { + // Modules are the module configurations for the app. + Modules []*ModuleConfig `json:"modules,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is global (not module specific). + GolangBindings []*GolangBinding `json:"golang_bindings,omitempty"` +} + +// ModuleConfig is a module configuration for an app. +type ModuleConfig struct { + // Name is the unique name of the module within the app. It should be a name + // that persists between different versions of a module so that modules + // can be smoothly upgraded to new versions. + // + // For example, for the module cosmos.bank.module.v1.Module, we may chose + // to simply name the module "bank" in the app. When we upgrade to + // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + // and the framework knows that the v2 module should receive all the same state + // that the v1 module had. Note: modules should provide info on which versions + // they can migrate from in the ModuleDescriptor.can_migration_from field. + Name string `json:"name,omitempty"` + // Config is the config object for the module. Module config messages should + // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + Config *anypb.Any `json:"config,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is module specific. + GolangBindings []*GolangBinding `json:"golang_bindings,omitempty"` +} + +// GolangBinding is an explicit interface type to implementing type binding for dependency injection. +type GolangBinding struct { + // InterfaceType is the interface type which will be bound to a specific implementation type + InterfaceType string `json:"interface_type,omitempty"` + // Implementation is the implementing type which will be supplied when an input of type interface is requested + Implementation string `json:"implementation,omitempty"` +} + // LoadJSON loads an app config in JSON format. func LoadJSON(bz []byte) depinject.Config { - config := &appv1alpha1.Config{} - err := protojson.Unmarshal(bz, config) + config := &AppConfig{} + err := json.Unmarshal(bz, config) if err != nil { return depinject.Error(err) } @@ -48,9 +94,9 @@ func WrapAny(config protoreflect.ProtoMessage) *anypb.Any { return cfg } -// Compose composes a v1alpha1 app config into a container option by resolving +// Compose composes an app config into a container option by resolving // the required modules and composing their options. -func Compose(appConfig *appv1alpha1.Config) depinject.Config { +func Compose(appConfig *AppConfig) depinject.Config { opts := []depinject.Config{ depinject.Supply(appConfig), } diff --git a/depinject/internal/appconfig/registry.go b/depinject/internal/appconfig/registry.go index ce8dbb203f17..c79a50b4d29a 100644 --- a/depinject/internal/appconfig/registry.go +++ b/depinject/internal/appconfig/registry.go @@ -33,7 +33,7 @@ func ModulesByProtoMessageName() (map[protoreflect.FullName]*ModuleInitializer, descriptor := initializer.ConfigProtoMessage.ProtoReflect().Descriptor() fullName := descriptor.FullName() if _, ok := res[fullName]; ok { - return nil, fmt.Errorf("duplicate module registratio for %s", fullName) + return nil, fmt.Errorf("duplicate module registration for %s", fullName) } modDesc := proto.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) diff --git a/docs/architecture/adr-057-app-wiring.md b/docs/architecture/adr-057-app-wiring.md index ba1774c43125..a5524fe6b9bf 100644 --- a/docs/architecture/adr-057-app-wiring.md +++ b/docs/architecture/adr-057-app-wiring.md @@ -4,6 +4,7 @@ * 2022-05-04: Initial Draft * 2022-08-19: Updates +* 2024-01-11: Less protobuf-centric (TODO update) ## Status @@ -291,6 +292,8 @@ With the approach proposed here, hooks registration will be obviously observable ### Code Generation +> Not yet implemented + The `depinject` framework will optionally allow the app configuration and dependency injection wiring to be code generated. This will allow: @@ -303,15 +306,17 @@ Code generation requires that all providers and invokers and their parameters ar When we start creating semantically versioned SDK modules that are in standalone go modules, a state machine breaking change to a module should be handled as follows: -- the semantic major version should be incremented, and -- a new semantically versioned module config protobuf type should be created. + +* the semantic major version should be incremented, and +* a new semantically versioned module config protobuf type should be created. For instance, if we have the SDK module for bank in the go module `cosmossdk.io/x/bank` with the module config type `cosmos.bank.module.v1.Module`, and we want to make a state machine breaking change to the module, we would: -- create a new go module `cosmossdk.io/x/bank/v2`, -- with the module config protobuf type `cosmos.bank.module.v2.Module`. -This _does not_ mean that we need to increment the protobuf API version for bank. Both modules can support +* create a new go module `cosmossdk.io/x/bank/v2`, +* with the module config protobuf type `cosmos.bank.module.v2.Module`. + +This *does not* mean that we need to increment the protobuf API version for bank. Both modules can support `cosmos.bank.v1`, but `cosmossdk.io/x/bank/v2` will be a separate go module with a separate module config type. This practice will eventually allow us to use appconfig to load new versions of a module via a configuration change. @@ -320,7 +325,7 @@ Effectively, there should be a 1:1 correspondence between a semantically version versioned module config protobuf type, and major versioning bumps should occur whenever state machine breaking changes are made to a module. -NOTE: SDK modules that are standalone go modules _should not_ adopt semantic versioning until the concerns described in +NOTE: SDK modules that are standalone go modules *should not* adopt semantic versioning until the concerns described in [ADR 054: Module Semantic Versioning](./adr-054-semver-compatible-modules.md) are addressed. The short-term solution for this issue was left somewhat unresolved. However, the easiest tactic is likely to use a standalone API go module and follow the guidelines described in this comment: https://github.com/cosmos/cosmos-sdk/pull/11802#issuecomment-1406815181. For the time-being, it is recommended that diff --git a/go.mod b/go.mod index 76010ef9a948..764e80ae8b1b 100644 --- a/go.mod +++ b/go.mod @@ -178,6 +178,7 @@ require ( // ) // TODO remove after all modules have their own go.mods replace ( + cosmossdk.io/api => ./api cosmossdk.io/depinject => ./depinject cosmossdk.io/x/auth => ./x/auth cosmossdk.io/x/bank => ./x/bank diff --git a/go.sum b/go.sum index 1d78a39ebbd9..c7a0cbd54eea 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cosmossdk.io/api v0.7.3-0.20231113122742-912390d5fc4a h1:Zr++x1RCJWi+K8bTZsQKdjtL4SzyHBLGM3Fcn75iWf0= -cosmossdk.io/api v0.7.3-0.20231113122742-912390d5fc4a/go.mod h1:7B/5XWh1HYwJk3DzWeNoxOSI+nGx1m5UyYfHLFuKzkw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= diff --git a/proto/cosmos/app/v1alpha1/config.proto b/proto/cosmos/app/v1alpha1/config.proto deleted file mode 100644 index ee3e70659e4b..000000000000 --- a/proto/cosmos/app/v1alpha1/config.proto +++ /dev/null @@ -1,55 +0,0 @@ -syntax = "proto3"; - -package cosmos.app.v1alpha1; - -import "google/protobuf/any.proto"; - -// Config represents the configuration for a Cosmos SDK ABCI app. -// It is intended that all state machine logic including the version of -// baseapp and tx handlers (and possibly even Tendermint) that an app needs -// can be described in a config object. For compatibility, the framework should -// allow a mixture of declarative and imperative app wiring, however, apps -// that strive for the maximum ease of maintainability should be able to describe -// their state machine with a config object alone. -message Config { - // modules are the module configurations for the app. - repeated ModuleConfig modules = 1; - - // golang_bindings specifies explicit interface to implementation type bindings which - // depinject uses to resolve interface inputs to provider functions. The scope of this - // field's configuration is global (not module specific). - repeated GolangBinding golang_bindings = 2; -} - -// ModuleConfig is a module configuration for an app. -message ModuleConfig { - // name is the unique name of the module within the app. It should be a name - // that persists between different versions of a module so that modules - // can be smoothly upgraded to new versions. - // - // For example, for the module cosmos.bank.module.v1.Module, we may chose - // to simply name the module "bank" in the app. When we upgrade to - // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same - // and the framework knows that the v2 module should receive all the same state - // that the v1 module had. Note: modules should provide info on which versions - // they can migrate from in the ModuleDescriptor.can_migration_from field. - string name = 1; - - // config is the config object for the module. Module config messages should - // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. - google.protobuf.Any config = 2; - - // golang_bindings specifies explicit interface to implementation type bindings which - // depinject uses to resolve interface inputs to provider functions. The scope of this - // field's configuration is module specific. - repeated GolangBinding golang_bindings = 3; -} - -// GolangBinding is an explicit interface type to implementing type binding for dependency injection. -message GolangBinding { - // interface_type is the interface type which will be bound to a specific implementation type - string interface_type = 1; - - // implementation is the implementing type which will be supplied when an input of type interface is requested - string implementation = 2; -} \ No newline at end of file diff --git a/proto/cosmos/app/v1alpha1/query.proto b/proto/cosmos/app/v1alpha1/query.proto deleted file mode 100644 index efec9c81ad71..000000000000 --- a/proto/cosmos/app/v1alpha1/query.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -package cosmos.app.v1alpha1; - -import "cosmos/app/v1alpha1/config.proto"; - -// Query is the app module query service. -service Query { - - // Config returns the current app config. - rpc Config(QueryConfigRequest) returns (QueryConfigResponse) {} -} - -// QueryConfigRequest is the Query/Config request type. -message QueryConfigRequest {} - -// QueryConfigRequest is the Query/Config response type. -message QueryConfigResponse { - - // config is the current app config. - Config config = 1; -} diff --git a/runtime/app.go b/runtime/app.go index 9b07970ff428..bd8b5684403f 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -8,8 +8,8 @@ import ( "golang.org/x/exp/slices" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject/appconfig" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtx "cosmossdk.io/x/auth/tx" @@ -50,7 +50,7 @@ type App struct { basicManager module.BasicManager baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter - appConfig *appv1alpha1.Config + appConfig *appconfig.AppConfig logger log.Logger // initChainer is the init chainer function defined by the app config. // this is only required if the chain wants to add special InitChainer logic. diff --git a/runtime/autocli.go b/runtime/autocli.go index 49ff9619115f..a942a3bee2fa 100644 --- a/runtime/autocli.go +++ b/runtime/autocli.go @@ -1,7 +1,6 @@ package runtime import ( - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" ) @@ -9,13 +8,6 @@ import ( func (m appModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ - Service: appv1alpha1.Query_ServiceDesc.ServiceName, - RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - { - RpcMethod: "Config", - Short: "Query the current app config", - }, - }, SubCommands: map[string]*autocliv1.ServiceCommandDescriptor{ "autocli": { Service: autocliv1.Query_ServiceDesc.ServiceName, diff --git a/runtime/module.go b/runtime/module.go index 0c4cbda7da7a..677a0f0a4f52 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -9,7 +9,6 @@ import ( "google.golang.org/protobuf/reflect/protoregistry" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/core/address" @@ -18,6 +17,7 @@ import ( "cosmossdk.io/core/genesis" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -122,7 +122,7 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( type AppInputs struct { depinject.In - AppConfig *appv1alpha1.Config + AppConfig *appconfig.AppConfig Config *runtimev1alpha1.Module AppBuilder *AppBuilder Modules map[string]appmodule.AppModule diff --git a/runtime/services.go b/runtime/services.go index 0b9223d92a29..e73ed94f3819 100644 --- a/runtime/services.go +++ b/runtime/services.go @@ -1,7 +1,6 @@ package runtime import ( - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" @@ -10,7 +9,6 @@ import ( ) func (a *App) registerRuntimeServices(cfg module.Configurator) error { - appv1alpha1.RegisterQueryServer(cfg.QueryServer(), services.NewAppQueryService(a.appConfig)) autocliv1.RegisterQueryServer(cfg.QueryServer(), services.NewAutoCLIQueryService(a.ModuleManager.Modules)) reflectionSvc, err := services.NewReflectionService() diff --git a/runtime/services/app.go b/runtime/services/app.go deleted file mode 100644 index fa80a281025e..000000000000 --- a/runtime/services/app.go +++ /dev/null @@ -1,23 +0,0 @@ -package services - -import ( - "context" - - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" -) - -// AppQueryService implements the cosmos.app.v1alpha1.Query service -type AppQueryService struct { - appv1alpha1.UnimplementedQueryServer - appConfig *appv1alpha1.Config -} - -func NewAppQueryService(appConfig *appv1alpha1.Config) *AppQueryService { - return &AppQueryService{appConfig: appConfig} -} - -func (a *AppQueryService) Config(context.Context, *appv1alpha1.QueryConfigRequest) (*appv1alpha1.QueryConfigResponse, error) { - return &appv1alpha1.QueryConfigResponse{Config: a.appConfig}, nil -} - -var _ appv1alpha1.QueryServer = &AppQueryService{} diff --git a/simapp/app_config.go b/simapp/app_config.go index ce7cb08bae7f..71061cf1c668 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -6,7 +6,6 @@ import ( "google.golang.org/protobuf/types/known/durationpb" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" @@ -97,8 +96,8 @@ var ( } // application configuration (used by depinject) - AppConfig = depinject.Configs(appconfig.Compose(&appv1alpha1.Config{ - Modules: []*appv1alpha1.ModuleConfig{ + AppConfig = depinject.Configs(appconfig.Compose(&appconfig.AppConfig{ + Modules: []*appconfig.ModuleConfig{ { Name: runtime.ModuleName, Config: appconfig.WrapAny(&runtimev1alpha1.Module{ diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index b6e13d8e7da6..cdfa7d3e57b6 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -2,7 +2,6 @@ package configurator import ( runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" @@ -31,7 +30,7 @@ import ( // Config should never need to be instantiated manually and is solely used for ModuleOption. type Config struct { - ModuleConfigs map[string]*appv1alpha1.ModuleConfig + ModuleConfigs map[string]*appconfig.ModuleConfig PreBlockersOrder []string BeginBlockersOrder []string EndBlockersOrder []string @@ -41,7 +40,7 @@ type Config struct { func defaultConfig() *Config { return &Config{ - ModuleConfigs: make(map[string]*appv1alpha1.ModuleConfig), + ModuleConfigs: make(map[string]*appconfig.ModuleConfig), PreBlockersOrder: []string{ testutil.UpgradeModuleName, }, @@ -139,7 +138,7 @@ func WithCustomInitGenesisOrder(initGenesisOrder ...string) ModuleOption { func BankModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.BankModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.BankModuleName] = &appconfig.ModuleConfig{ Name: testutil.BankModuleName, Config: appconfig.WrapAny(&bankmodulev1.Module{}), } @@ -148,7 +147,7 @@ func BankModule() ModuleOption { func AuthModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.AuthModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.AuthModuleName] = &appconfig.ModuleConfig{ Name: testutil.AuthModuleName, Config: appconfig.WrapAny(&authmodulev1.Module{ Bech32Prefix: "cosmos", @@ -169,7 +168,7 @@ func AuthModule() ModuleOption { func ParamsModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.ParamsModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.ParamsModuleName] = &appconfig.ModuleConfig{ Name: testutil.ParamsModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), } @@ -178,7 +177,7 @@ func ParamsModule() ModuleOption { func TxModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.TxModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.TxModuleName] = &appconfig.ModuleConfig{ Name: testutil.TxModuleName, Config: appconfig.WrapAny(&txconfigv1.Config{}), } @@ -187,7 +186,7 @@ func TxModule() ModuleOption { func StakingModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.StakingModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.StakingModuleName] = &appconfig.ModuleConfig{ Name: testutil.StakingModuleName, Config: appconfig.WrapAny(&stakingmodulev1.Module{}), } @@ -196,7 +195,7 @@ func StakingModule() ModuleOption { func SlashingModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.SlashingModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.SlashingModuleName] = &appconfig.ModuleConfig{ Name: testutil.SlashingModuleName, Config: appconfig.WrapAny(&slashingmodulev1.Module{}), } @@ -205,7 +204,7 @@ func SlashingModule() ModuleOption { func GenutilModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["genutil"] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs["genutil"] = &appconfig.ModuleConfig{ Name: "genutil", Config: appconfig.WrapAny(&genutilmodulev1.Module{}), } @@ -214,7 +213,7 @@ func GenutilModule() ModuleOption { func DistributionModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.DistributionModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.DistributionModuleName] = &appconfig.ModuleConfig{ Name: testutil.DistributionModuleName, Config: appconfig.WrapAny(&distrmodulev1.Module{}), } @@ -223,7 +222,7 @@ func DistributionModule() ModuleOption { func FeegrantModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.FeegrantModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.FeegrantModuleName] = &appconfig.ModuleConfig{ Name: testutil.FeegrantModuleName, Config: appconfig.WrapAny(&feegrantmodulev1.Module{}), } @@ -232,7 +231,7 @@ func FeegrantModule() ModuleOption { func VestingModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["vesting"] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs["vesting"] = &appconfig.ModuleConfig{ Name: "vesting", Config: appconfig.WrapAny(&vestingmodulev1.Module{}), } @@ -241,7 +240,7 @@ func VestingModule() ModuleOption { func GovModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.GovModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.GovModuleName] = &appconfig.ModuleConfig{ Name: testutil.GovModuleName, Config: appconfig.WrapAny(&govmodulev1.Module{}), } @@ -250,7 +249,7 @@ func GovModule() ModuleOption { func ConsensusModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["consensus"] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs["consensus"] = &appconfig.ModuleConfig{ Name: "consensus", Config: appconfig.WrapAny(&consensusmodulev1.Module{}), } @@ -259,10 +258,10 @@ func ConsensusModule() ModuleOption { func MintModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.MintModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.MintModuleName] = &appconfig.ModuleConfig{ Name: testutil.MintModuleName, Config: appconfig.WrapAny(&mintmodulev1.Module{}), - GolangBindings: []*appv1alpha1.GolangBinding{ + GolangBindings: []*appconfig.GolangBinding{ { InterfaceType: "cosmossdk.io/x/mint/types/types.StakingKeeper", Implementation: "cosmossdk.io/x/staking/keeper/*keeper.Keeper", @@ -274,7 +273,7 @@ func MintModule() ModuleOption { func EvidenceModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.EvidenceModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.EvidenceModuleName] = &appconfig.ModuleConfig{ Name: testutil.EvidenceModuleName, Config: appconfig.WrapAny(&evidencemodulev1.Module{}), } @@ -283,7 +282,7 @@ func EvidenceModule() ModuleOption { func AuthzModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.AuthzModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.AuthzModuleName] = &appconfig.ModuleConfig{ Name: testutil.AuthzModuleName, Config: appconfig.WrapAny(&authzmodulev1.Module{}), } @@ -292,7 +291,7 @@ func AuthzModule() ModuleOption { func GroupModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.GroupModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.GroupModuleName] = &appconfig.ModuleConfig{ Name: testutil.GroupModuleName, Config: appconfig.WrapAny(&groupmodulev1.Module{}), } @@ -301,7 +300,7 @@ func GroupModule() ModuleOption { func NFTModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.NFTModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.NFTModuleName] = &appconfig.ModuleConfig{ Name: testutil.NFTModuleName, Config: appconfig.WrapAny(&nftmodulev1.Module{}), } @@ -310,7 +309,7 @@ func NFTModule() ModuleOption { func CircuitModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.CircuitModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.CircuitModuleName] = &appconfig.ModuleConfig{ Name: testutil.CircuitModuleName, Config: appconfig.WrapAny(&circuitmodulev1.Module{}), } @@ -319,7 +318,7 @@ func CircuitModule() ModuleOption { func ProtocolPoolModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.ProtocolPoolModuleName] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs[testutil.ProtocolPoolModuleName] = &appconfig.ModuleConfig{ Name: testutil.ProtocolPoolModuleName, Config: appconfig.WrapAny(&poolmodulev1.Module{}), } @@ -328,7 +327,7 @@ func ProtocolPoolModule() ModuleOption { func CounterModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["counter"] = &appv1alpha1.ModuleConfig{ + config.ModuleConfigs["counter"] = &appconfig.ModuleConfig{ Name: "counter", Config: appconfig.WrapAny(&countermodulev1.Module{}), } @@ -392,7 +391,7 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config { runtimeConfig.InitGenesis = initGenesis } - modules := []*appv1alpha1.ModuleConfig{{ + modules := []*appconfig.ModuleConfig{{ Name: "runtime", Config: appconfig.WrapAny(runtimeConfig), }} @@ -401,5 +400,5 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config { modules = append(modules, m) } - return appconfig.Compose(&appv1alpha1.Config{Modules: modules}) + return appconfig.Compose(&appconfig.AppConfig{Modules: modules}) } From 3200d8c46755962789ee6e446f67c29cb76a5f05 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 12 Jan 2024 12:44:19 +0100 Subject: [PATCH 2/8] extract depinject config --- UPGRADING.md | 3 +- core/appmodule/README.md | 3 +- depinject/README.md | 102 ++++++------- depinject/{appmodule => appconfig}/README.md | 26 ++-- depinject/appconfig/config_test.go | 17 +-- .../option.go => appconfig/module.go} | 37 ++++- depinject/appmodule/register.go | 34 ----- docs/build/building-modules/11-structure.md | 1 + orm/model/ormdb/module_test.go | 6 +- orm/orm.go | 9 +- runtime/module.go | 7 +- x/accounts/depinject.go | 8 + x/accounts/module.go | 2 - x/auth/depinject.go | 76 ++++++++++ x/auth/module.go | 69 --------- x/auth/tx/config/{config.go => depinject.go} | 8 +- x/auth/vesting/depinject.go | 40 +++++ x/auth/vesting/module.go | 35 ----- x/authz/module/abci.go | 2 +- x/authz/module/abci_test.go | 2 +- x/authz/module/autocli.go | 2 +- x/authz/module/depinject.go | 51 +++++++ x/authz/module/module.go | 44 +----- x/bank/depinject.go | 92 +++++++++++ x/bank/module.go | 84 ---------- x/circuit/depinject.go | 67 ++++++++ x/circuit/module.go | 58 ------- x/consensus/depinject.go | 64 ++++++++ x/consensus/module.go | 55 ------- x/counter/depinject.go | 48 ++++++ x/counter/module.go | 40 ----- x/crisis/depinject.go | 85 +++++++++++ x/crisis/module.go | 77 ---------- x/distribution/depinject.go | 78 ++++++++++ x/distribution/module.go | 73 --------- x/evidence/depinject.go | 49 ++++++ x/evidence/module.go | 43 ------ x/feegrant/module/depinject.go | 63 ++++++++ x/feegrant/module/module.go | 52 ------- x/genutil/depinject.go | 37 +++++ x/genutil/module.go | 27 ---- x/gov/depinject.go | 133 ++++++++++++++++ x/gov/module.go | 120 --------------- x/group/module/depinject.go | 61 ++++++++ x/group/module/module.go | 55 ------- x/mint/depinject.go | 78 ++++++++++ x/mint/module.go | 73 --------- x/nft/module/depinject.go | 49 ++++++ x/nft/module/module.go | 42 ----- x/params/depinject.go | 70 +++++++++ x/params/module.go | 65 -------- x/protocolpool/depinject.go | 88 +++++++++++ x/protocolpool/module.go | 81 ---------- x/slashing/depinject.go | 72 +++++++++ x/slashing/module.go | 63 -------- x/staking/depinject.go | 143 ++++++++++++++++++ x/staking/module.go | 129 ---------------- x/upgrade/depinject.go | 91 +++++++++++ x/upgrade/module.go | 83 ---------- 59 files changed, 1670 insertions(+), 1502 deletions(-) rename depinject/{appmodule => appconfig}/README.md (94%) rename depinject/{appmodule/option.go => appconfig/module.go} (51%) delete mode 100644 depinject/appmodule/register.go create mode 100644 x/accounts/depinject.go create mode 100644 x/auth/depinject.go rename x/auth/tx/config/{config.go => depinject.go} (97%) create mode 100644 x/auth/vesting/depinject.go create mode 100644 x/authz/module/depinject.go create mode 100644 x/bank/depinject.go create mode 100644 x/circuit/depinject.go create mode 100644 x/consensus/depinject.go create mode 100644 x/counter/depinject.go create mode 100644 x/crisis/depinject.go create mode 100644 x/distribution/depinject.go create mode 100644 x/evidence/depinject.go create mode 100644 x/feegrant/module/depinject.go create mode 100644 x/genutil/depinject.go create mode 100644 x/gov/depinject.go create mode 100644 x/group/module/depinject.go create mode 100644 x/mint/depinject.go create mode 100644 x/nft/module/depinject.go create mode 100644 x/params/depinject.go create mode 100644 x/protocolpool/depinject.go create mode 100644 x/slashing/depinject.go create mode 100644 x/staking/depinject.go create mode 100644 x/upgrade/depinject.go diff --git a/UPGRADING.md b/UPGRADING.md index 8713095acb3c..3441625bf276 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -118,7 +118,8 @@ Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a l ##### Dependency Injection -Previously `cosmossdk.io/core` held functions `Invoke`, `Provide` and `Register` were moved to `cosmossdk.io/depinject/appmodule`. All modules using dependency injection must update their imports. +Previously `cosmossdk.io/core` held functions `Invoke`, `Provide` and `Register` were moved to `cosmossdk.io/depinject/appconfig`. +All modules using dependency injection must update their imports. ##### Genesis Interface diff --git a/core/appmodule/README.md b/core/appmodule/README.md index 5d02cc25bdb3..f41dd41a9d64 100644 --- a/core/appmodule/README.md +++ b/core/appmodule/README.md @@ -4,5 +4,4 @@ This package defines what is needed for an module to be used in the Cosmos SDK. - -If you are looking at integrating Dependency injection into your module please see [depinject appmodule documentation](../../depinject/appmodule/README.md) +If you are looking at integrating Dependency injection into your module please see [depinject appconfig documentation](../../depinject/appconfig/README.md) \ No newline at end of file diff --git a/depinject/README.md b/depinject/README.md index e9ba563e6def..de58b49e28e0 100644 --- a/depinject/README.md +++ b/depinject/README.md @@ -12,15 +12,15 @@ sidebar_position: 1 `depinject` is particularly useful for developing blockchain applications: -* With multiple interdependent components, modules, or services. Helping manage their dependencies effectively. -* That require decoupling of these components, making it easier to test, modify, or replace individual parts without affecting the entire system. -* That are wanting to simplify the setup and initialisation of modules and their dependencies by reducing boilerplate code and automating dependency management. +* With multiple interdependent components, modules, or services. Helping manage their dependencies effectively. +* That require decoupling of these components, making it easier to test, modify, or replace individual parts without affecting the entire system. +* That are wanting to simplify the setup and initialisation of modules and their dependencies by reducing boilerplate code and automating dependency management. By using `depinject`, developers can achieve: -* Cleaner and more organised code. -* Improved modularity and maintainability. -* A more maintainable and modular structure for their blockchain applications, ultimately enhancing development velocity and code quality. +* Cleaner and more organised code. +* Improved modularity and maintainability. +* A more maintainable and modular structure for their blockchain applications, ultimately enhancing development velocity and code quality. * [Go Doc](https://pkg.go.dev/cosmossdk.io/depinject) @@ -38,9 +38,9 @@ Example: package main import ( - "fmt" + "fmt" - "cosmossdk.io/depinject" + "cosmossdk.io/depinject" ) type AnotherInt int @@ -49,21 +49,21 @@ func GetInt() int { return 1 } func GetAnotherInt() AnotherInt { return 2 } func main() { - var ( - x int - y AnotherInt - ) - - fmt.Printf("Before (%v, %v)\n", x, y) - depinject.Inject( - depinject.Provide( - GetInt, - GetAnotherInt, - ), - &x, - &y, - ) - fmt.Printf("After (%v, %v)\n", x, y) + var ( + x int + y AnotherInt + ) + + fmt.Printf("Before (%v, %v)\n", x, y) + depinject.Inject( + depinject.Provide( + GetInt, + GetAnotherInt, + ), + &x, + &y, + ) + fmt.Printf("After (%v, %v)\n", x, y) } ``` @@ -83,11 +83,11 @@ Consider the following example: package duck type Duck interface { - quack() + quack() } type AlsoDuck interface { - quack() + quack() } type Mallard struct{} @@ -97,7 +97,7 @@ func (duck Mallard) quack() {} func (duck Canvasback) quack() {} type Pond struct { - Duck AlsoDuck + Duck AlsoDuck } ``` @@ -105,15 +105,15 @@ And the following provider functions: ```go func GetMallard() duck.Mallard { - return Mallard{} + return Mallard{} } func GetPond(duck Duck) Pond { - return Pond{Duck: duck} + return Pond{Duck: duck} } func GetCanvasback() Canvasback { - return Canvasback{} + return Canvasback{} } ``` @@ -124,9 +124,9 @@ var pond Pond depinject.Inject( depinject.Provide( - GetMallard, - GetPond, - ), + GetMallard, + GetPond, + ), &pond) ``` @@ -138,12 +138,12 @@ However, if there are multiple implementations of the `Duck` interface, as in th var pond Pond depinject.Inject( - depinject.Provide( - GetMallard, - GetCanvasback, - GetPond, - ), - &pond) + depinject.Provide( + GetMallard, + GetCanvasback, + GetPond, + ), + &pond) ``` A specific binding preference for `Duck` is required. @@ -154,21 +154,21 @@ In the above situation registering a binding for a given interface binding may l ```go depinject.Inject( - depinject.Configs( - depinject.BindInterface( - "duck/duck.Duck", - "duck/duck.Mallard", - ), - depinject.Provide( - GetMallard, - GetCanvasback, - GetPond, - ), - ), - &pond) + depinject.Configs( + depinject.BindInterface( + "duck/duck.Duck", + "duck/duck.Mallard", + ), + depinject.Provide( + GetMallard, + GetCanvasback, + GetPond, + ), + ), + &pond) ``` -Now `depinject` has enough information to provide `Mallard` as an input to `APond`. +Now `depinject` has enough information to provide `Mallard` as an input to `APond`. ### Full example in real app diff --git a/depinject/appmodule/README.md b/depinject/appconfig/README.md similarity index 94% rename from depinject/appmodule/README.md rename to depinject/appconfig/README.md index ebcdeaf74c3e..b95f3e8ebc0a 100644 --- a/depinject/appmodule/README.md +++ b/depinject/appconfig/README.md @@ -37,11 +37,11 @@ message Module { Once we have a module config object, we need to register depinject providers and invokers for the module using the `cosmossdk.io/core/appmodule` package. -At the most basic level, we must define an `init` function in the package listed as the `go_import` in the module descriptor. This `init` function must call `appmodule.Register` with an empty instance of the config object and some options for initializing the module, ex: +At the most basic level, we must define an `init` function in the package listed as the `go_import` in the module descriptor. This `init` function must call `appconfig.RegisterModule` with an empty instance of the config object and some options for initializing the module, ex: ```go func init() { - appmodule.Register(&modulev1.Module{}, + appconfig.RegisterModule(&modulev1.Module{}, // options ) } @@ -53,14 +53,14 @@ A `depinject` "provider" is a function which takes dependencies from other modul other modules to use as dependencies. A `depinject` "invoker" is function which takes optional dependencies as inputs, returns no outputs, and is run at the end of initializing the dependency graph. Providers are much more common than invokers and should be the preferred method of wiring up modules when possible. Providers and invokers can be registered -for modules by using `appmodule.Provide` and `appmodule.Invoke` to create options which get passed -to `appmodule.Register` in the module `init` function, ex: +for modules by using `appconfig.Provide` and `appconfig.Invoke` to create options which get passed +to `appconfig.RegisterModule` in the module `init` function, ex: ```go func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(provideSomething, provideSomethingElse), - appmodule.Invoke(invokeSomething), + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(provideSomething, provideSomethingElse), + appconfig.Invoke(invokeSomething), ) } ``` @@ -79,7 +79,7 @@ func init() { #### Regular Golang Types Regular golang types (besides the special cases described above) can be provided as both input and output parameters -to providers and invokers. For `depinject` to match an output parameter of one provider to an input parameter of +to providers and invokers. For `depinject` to match an output parameter of one provider to an input parameter of another, there must be an exact match for the type unless the input parameter is an input type. For instance, if a provider defines a dependency on `Foo` and some module provides `*Foo`, these two types will not match and there will be an error. @@ -133,7 +133,7 @@ bet. If `depinject.ModuleKey` is used as input parameter for a provider, the provider function will be treated as a "module-scoped provider" which means that the provider function will be called exactly once every time one of its outputs is needed by a module so that the provider can provide a unique instance of the dependency to -each module. +each module. Module-scoped dependencies should be used to provide dependencies which are private and unique to each module. Examples of these are store keys and param subspaces. @@ -177,7 +177,7 @@ when ordering *really* doesn't matter (which is rare). ### Resolving Circular Dependencies -Circular dependencies are inevitable to crop up and there are ways to avoid them. While `depinject` cannot handle +Circular dependencies are inevitable to crop up and there are ways to avoid them. While `depinject` cannot handle circular dependency graphs of providers, many of the above tools are designed to enable satisfying circular dependencies between modules. @@ -193,7 +193,7 @@ the staking module can define an invoker which depends on `map[string]StakingHoo satisfy this dependency graph which allows staking and slashing to depend on each other in this order: * provide staking keeper -> slashing keeper -* provide slashing keeper wrapped as `StakingHooksWrapper` +* provide slashing keeper wrapped as `StakingHooksWrapper` * get `map[string]StakingHooksWrapper` and the staking keeper and wire them together ## 3. Testing and Debugging The Module @@ -212,8 +212,8 @@ var appConfig []byte var AppConfig = appconfig.LoadYAML(appConfig) func TestModule(t *testing.T) { - var keeper Keeper - assert.NilError(t, depinject.Inject(AppConfig, &keeper)) + var keeper Keeper + assert.NilError(t, depinject.Inject(AppConfig, &keeper)) } ``` diff --git a/depinject/appconfig/config_test.go b/depinject/appconfig/config_test.go index 8595f96b5722..1bb799749d70 100644 --- a/depinject/appconfig/config_test.go +++ b/depinject/appconfig/config_test.go @@ -12,7 +12,6 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" - "cosmossdk.io/depinject/appmodule" internal "cosmossdk.io/depinject/internal/appconfig" "cosmossdk.io/depinject/internal/appconfig/testpb" ) @@ -102,7 +101,7 @@ modules: assert.NilError(t, depinject.Inject(opt)) // module registration failures: - appmodule.Register(&testpb.TestNoModuleOptionModule{}) + appconfig.RegisterModule(&testpb.TestNoModuleOptionModule{}) opt = appconfig.LoadYAML([]byte(` modules: - name: a @@ -112,7 +111,7 @@ modules: expectContainerErrorContains(t, opt, "module should have the option cosmos.app.v1alpha1.module") internal.ModuleRegistry = map[reflect.Type]*internal.ModuleInitializer{} // reset module registry - appmodule.Register(&testpb.TestNoGoImportModule{}) + appconfig.RegisterModule(&testpb.TestNoGoImportModule{}) opt = appconfig.LoadYAML([]byte(` modules: - name: a @@ -127,16 +126,16 @@ modules: // func init() { - appmodule.Register(&testpb.TestRuntimeModule{}, - appmodule.Provide(ProvideRuntimeState, ProvideStoreKey, ProvideApp), + appconfig.RegisterModule(&testpb.TestRuntimeModule{}, + appconfig.Provide(ProvideRuntimeState, ProvideStoreKey, ProvideApp), ) - appmodule.Register(&testpb.TestModuleA{}, - appmodule.Provide(ProvideModuleA), + appconfig.RegisterModule(&testpb.TestModuleA{}, + appconfig.Provide(ProvideModuleA), ) - appmodule.Register(&testpb.TestModuleB{}, - appmodule.Provide(ProvideModuleB), + appconfig.RegisterModule(&testpb.TestModuleB{}, + appconfig.Provide(ProvideModuleB), ) } diff --git a/depinject/appmodule/option.go b/depinject/appconfig/module.go similarity index 51% rename from depinject/appmodule/option.go rename to depinject/appconfig/module.go index df8f0c499469..fc4f62cbd525 100644 --- a/depinject/appmodule/option.go +++ b/depinject/appconfig/module.go @@ -1,9 +1,40 @@ -package appmodule +package appconfig import ( + "reflect" + + "google.golang.org/protobuf/proto" + internal "cosmossdk.io/depinject/internal/appconfig" ) +var Register = RegisterModule + +// Register registers a module with the global module registry. The provided +// protobuf message is used only to uniquely identify the protobuf module config +// type. The instance of the protobuf message used in the actual configuration +// will be injected into the container and can be requested by a provider +// function. All module initialization should be handled by the provided options. +// +// 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) + init := &internal.ModuleInitializer{ + ConfigProtoMessage: msg, + ConfigGoType: ty, + } + internal.ModuleRegistry[ty] = init + + for _, option := range options { + init.Error = option.apply(init) + if init.Error != nil { + return + } + } +} + // Option is a functional option for implementing modules. type Option interface { apply(*internal.ModuleInitializer) error @@ -16,7 +47,7 @@ func (f funcOption) apply(initializer *internal.ModuleInitializer) error { } // Provide registers providers with the dependency injection system that will be -// run within the module scope. See cosmossdk.io/depinject for +// run within the module scope (depinject.ProvideInModule). See cosmossdk.io/depinject for // documentation on the dependency injection system. func Provide(providers ...interface{}) Option { return funcOption(func(initializer *internal.ModuleInitializer) error { @@ -25,7 +56,7 @@ func Provide(providers ...interface{}) Option { }) } -// Invoke registers invokers to run with depinject. Each invoker will be called +// Invoke registers invokers to run with depinject (depinject.InvokeInModule). Each invoker will be called // at the end of dependency graph configuration in the order in which it was defined. Invokers may not define output // parameters, although they may return an error, and all of their input parameters will be marked as optional so that // invokers impose no additional constraints on the dependency graph. Invoker functions should nil-check all inputs. diff --git a/depinject/appmodule/register.go b/depinject/appmodule/register.go deleted file mode 100644 index ed68ebfcefef..000000000000 --- a/depinject/appmodule/register.go +++ /dev/null @@ -1,34 +0,0 @@ -package appmodule - -import ( - "reflect" - - "google.golang.org/protobuf/proto" - - internal "cosmossdk.io/depinject/internal/appconfig" -) - -// Register registers a module with the global module registry. The provided -// protobuf message is used only to uniquely identify the protobuf module config -// type. The instance of the protobuf message used in the actual configuration -// will be injected into the container and can be requested by a provider -// function. All module initialization should be handled by the provided options. -// -// 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 Register(msg proto.Message, options ...Option) { - ty := reflect.TypeOf(msg) - init := &internal.ModuleInitializer{ - ConfigProtoMessage: msg, - ConfigGoType: ty, - } - internal.ModuleRegistry[ty] = init - - for _, option := range options { - init.Error = option.apply(init) - if init.Error != nil { - return - } - } -} diff --git a/docs/build/building-modules/11-structure.md b/docs/build/building-modules/11-structure.md index d8f4027d3350..9a40d4e55393 100644 --- a/docs/build/building-modules/11-structure.md +++ b/docs/build/building-modules/11-structure.md @@ -54,6 +54,7 @@ x/{module_name} │   └── module.go │   └── abci.go │   └── autocli.go +│   └── depinject.go ├── simulation │   ├── decoder.go │   ├── genesis.go diff --git a/orm/model/ormdb/module_test.go b/orm/model/ormdb/module_test.go index a146aa78b825..b60116ce24b1 100644 --- a/orm/model/ormdb/module_test.go +++ b/orm/model/ormdb/module_test.go @@ -13,14 +13,12 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/golden" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" ormmodulev1alpha1 "cosmossdk.io/api/cosmos/orm/module/v1alpha1" ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1" "cosmossdk.io/core/genesis" "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" - am "cosmossdk.io/depinject/appmodule" _ "cosmossdk.io/orm" // required for ORM module registration "cosmossdk.io/orm/internal/testkv" "cosmossdk.io/orm/internal/testpb" @@ -400,8 +398,8 @@ func ProvideTestRuntime() store.KVStoreService { } func TestAppConfigModule(t *testing.T) { - appCfg := appconfig.Compose(&appv1alpha1.Config{ - Modules: []*appv1alpha1.ModuleConfig{ + appCfg := appconfig.Compose(&appconfig.AppConfig{ + Modules: []*appconfig.ModuleConfig{ {Name: "bank", Config: appconfig.WrapAny(&testpb.Module{})}, {Name: "orm", Config: appconfig.WrapAny(&ormmodulev1alpha1.Module{})}, }, diff --git a/orm/orm.go b/orm/orm.go index c9d7872508b3..3e81e1f8e7f2 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -7,19 +7,18 @@ import ( "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoregistry" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" modulev1alpha1 "cosmossdk.io/api/cosmos/orm/module/v1alpha1" ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1" "cosmossdk.io/core/store" "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" + "cosmossdk.io/depinject/appconfig" "cosmossdk.io/orm/model/ormdb" "cosmossdk.io/orm/model/ormtable" ) func init() { - am.Register(&modulev1alpha1.Module{}, - am.Provide(ProvideModuleDB), + appconfig.RegisterModule(&modulev1alpha1.Module{}, + appconfig.Provide(ProvideModuleDB), ) } @@ -27,7 +26,7 @@ func init() { type ModuleDBInputs struct { depinject.In - AppConfig *appv1alpha1.Config + AppConfig *appconfig.AppConfig KVStoreService store.KVStoreService MemoryStoreService store.MemoryStoreService `optional:"true"` TransientStoreService store.TransientStoreService `optional:"true"` diff --git a/runtime/module.go b/runtime/module.go index 677a0f0a4f52..6029439d7e24 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -18,7 +18,6 @@ import ( "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" - am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/tx/signing" @@ -59,8 +58,8 @@ type BaseAppOption func(*baseapp.BaseApp) func (b BaseAppOption) IsManyPerContainerType() {} func init() { - am.Register(&runtimev1alpha1.Module{}, - am.Provide( + appconfig.RegisterModule(&runtimev1alpha1.Module{}, + appconfig.Provide( ProvideApp, ProvideInterfaceRegistry, ProvideKVStoreKey, @@ -75,7 +74,7 @@ func init() { ProvideAppVersionModifier, ProvideAddressCodec, ), - am.Invoke(SetupAppBuilder), + appconfig.Invoke(SetupAppBuilder), ) } diff --git a/x/accounts/depinject.go b/x/accounts/depinject.go new file mode 100644 index 000000000000..bef3dd4208cf --- /dev/null +++ b/x/accounts/depinject.go @@ -0,0 +1,8 @@ +package accounts + +import "cosmossdk.io/depinject" + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} diff --git a/x/accounts/module.go b/x/accounts/module.go index 4d00f15ed345..e3d55155760f 100644 --- a/x/accounts/module.go +++ b/x/accounts/module.go @@ -47,8 +47,6 @@ type AppModule struct { k Keeper } -func (m AppModule) IsOnePerModuleType() {} - func (m AppModule) IsAppModule() {} func (m AppModule) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} diff --git a/x/auth/depinject.go b/x/auth/depinject.go new file mode 100644 index 000000000000..0f1837281888 --- /dev/null +++ b/x/auth/depinject.go @@ -0,0 +1,76 @@ +package auth + +import ( + modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/x/auth/keeper" + "cosmossdk.io/x/auth/simulation" + "cosmossdk.io/x/auth/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService store.KVStoreService + Cdc codec.Codec + + AddressCodec address.Codec + RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` + AccountI func() sdk.AccountI `optional:"true"` +} + +type ModuleOutputs struct { + depinject.Out + + AccountKeeper keeper.AccountKeeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + maccPerms := map[string][]string{} + for _, permission := range in.Config.ModuleAccountPermissions { + maccPerms[permission.Account] = permission.Permissions + } + + // default to governance authority if not provided + authority := types.NewModuleAddress(GovModuleName) + if in.Config.Authority != "" { + authority = types.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + if in.RandomGenesisAccountsFn == nil { + in.RandomGenesisAccountsFn = simulation.RandomGenesisAccounts + } + + if in.AccountI == nil { + in.AccountI = types.ProtoBaseAccount + } + + auth, err := in.AddressCodec.BytesToString(authority) + if err != nil { + panic(err) + } + + k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth) + m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn) + + return ModuleOutputs{AccountKeeper: k, Module: m} +} diff --git a/x/auth/module.go b/x/auth/module.go index 534bcd43e018..1421f8ffd652 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -7,12 +7,8 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/auth/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/simulation" "cosmossdk.io/x/auth/types" @@ -20,7 +16,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -36,7 +31,6 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -92,9 +86,6 @@ type AppModule struct { randGenAccountsFn types.RandomGenesisAccountsFn } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -169,63 +160,3 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec - - AddressCodec address.Codec - RandomGenesisAccountsFn types.RandomGenesisAccountsFn `optional:"true"` - AccountI func() sdk.AccountI `optional:"true"` -} - -type ModuleOutputs struct { - depinject.Out - - AccountKeeper keeper.AccountKeeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - maccPerms := map[string][]string{} - for _, permission := range in.Config.ModuleAccountPermissions { - maccPerms[permission.Account] = permission.Permissions - } - - // default to governance authority if not provided - authority := types.NewModuleAddress(GovModuleName) - if in.Config.Authority != "" { - authority = types.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - if in.RandomGenesisAccountsFn == nil { - in.RandomGenesisAccountsFn = simulation.RandomGenesisAccounts - } - - if in.AccountI == nil { - in.AccountI = types.ProtoBaseAccount - } - - auth, err := in.AddressCodec.BytesToString(authority) - if err != nil { - panic(err) - } - - k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.AddressCodec, in.Config.Bech32Prefix, auth) - m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn) - - return ModuleOutputs{AccountKeeper: k, Module: m} -} diff --git a/x/auth/tx/config/config.go b/x/auth/tx/config/depinject.go similarity index 97% rename from x/auth/tx/config/config.go rename to x/auth/tx/config/depinject.go index 30397e33a91e..dff980a5a790 100644 --- a/x/auth/tx/config/config.go +++ b/x/auth/tx/config/depinject.go @@ -12,7 +12,7 @@ import ( txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" "cosmossdk.io/core/address" "cosmossdk.io/depinject" - "cosmossdk.io/depinject/appmodule" + "cosmossdk.io/depinject/appconfig" "cosmossdk.io/x/auth/ante" "cosmossdk.io/x/auth/posthandler" "cosmossdk.io/x/auth/tx" @@ -30,9 +30,9 @@ import ( ) func init() { - appmodule.Register(&txconfigv1.Config{}, - appmodule.Provide(ProvideModule), - appmodule.Provide(ProvideProtoRegistry), + appconfig.RegisterModule(&txconfigv1.Config{}, + appconfig.Provide(ProvideModule), + appconfig.Provide(ProvideProtoRegistry), ) } diff --git a/x/auth/vesting/depinject.go b/x/auth/vesting/depinject.go new file mode 100644 index 000000000000..c2f346f03207 --- /dev/null +++ b/x/auth/vesting/depinject.go @@ -0,0 +1,40 @@ +package vesting + +import ( + modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/x/auth/keeper" + "cosmossdk.io/x/auth/vesting/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + AccountKeeper keeper.AccountKeeper + BankKeeper types.BankKeeper +} + +type ModuleOutputs struct { + depinject.Out + + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + m := NewAppModule(in.AccountKeeper, in.BankKeeper) + + return ModuleOutputs{Module: m} +} diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 085ef6138713..5075184d4192 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -8,10 +8,7 @@ import ( "github.com/spf13/cobra" "google.golang.org/grpc" - modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/vesting/client/cli" "cosmossdk.io/x/auth/vesting/types" @@ -86,9 +83,6 @@ func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -108,32 +102,3 @@ func (am AppModule) ExportGenesis(_ context.Context, cdc codec.JSONCodec) json.R // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 1 } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - AccountKeeper keeper.AccountKeeper - BankKeeper types.BankKeeper -} - -type ModuleOutputs struct { - depinject.Out - - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - m := NewAppModule(in.AccountKeeper, in.BankKeeper) - - return ModuleOutputs{Module: m} -} diff --git a/x/authz/module/abci.go b/x/authz/module/abci.go index 395508c7462f..5e1b3038c9d6 100644 --- a/x/authz/module/abci.go +++ b/x/authz/module/abci.go @@ -1,4 +1,4 @@ -package authz +package module import ( "context" diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index 13265d97bd63..f4a82573886a 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -1,4 +1,4 @@ -package authz_test +package module_test import ( "testing" diff --git a/x/authz/module/autocli.go b/x/authz/module/autocli.go index dbcf85c371f3..0ce9d4968e6d 100644 --- a/x/authz/module/autocli.go +++ b/x/authz/module/autocli.go @@ -1,4 +1,4 @@ -package authz +package module import ( "fmt" diff --git a/x/authz/module/depinject.go b/x/authz/module/depinject.go new file mode 100644 index 000000000000..29d5a347d428 --- /dev/null +++ b/x/authz/module/depinject.go @@ -0,0 +1,51 @@ +package module + +import ( + modulev1 "cosmossdk.io/api/cosmos/authz/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/x/authz" + "cosmossdk.io/x/authz/keeper" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Cdc codec.Codec + AccountKeeper authz.AccountKeeper + BankKeeper authz.BankKeeper + Registry cdctypes.InterfaceRegistry + MsgServiceRouter baseapp.MessageRouter + StoreService store.KVStoreService +} + +type ModuleOutputs struct { + depinject.Out + + AuthzKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + k := keeper.NewKeeper(in.StoreService, in.Cdc, in.MsgServiceRouter, in.AccountKeeper) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) + return ModuleOutputs{AuthzKeeper: k, Module: m} +} diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 62156ebe8739..089b7e2c55dc 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -1,4 +1,4 @@ -package authz +package module import ( "context" @@ -8,18 +8,13 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/authz/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/errors" "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/client/cli" "cosmossdk.io/x/authz/keeper" "cosmossdk.io/x/authz/simulation" - "github.com/cosmos/cosmos-sdk/baseapp" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -32,7 +27,6 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -119,9 +113,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak authz.AccountKeeper, } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -148,39 +139,6 @@ func (am AppModule) BeginBlock(ctx context.Context) error { return BeginBlocker(ctx, am.keeper) } -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Cdc codec.Codec - AccountKeeper authz.AccountKeeper - BankKeeper authz.BankKeeper - Registry cdctypes.InterfaceRegistry - MsgServiceRouter baseapp.MessageRouter - StoreService store.KVStoreService -} - -type ModuleOutputs struct { - depinject.Out - - AuthzKeeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.StoreService, in.Cdc, in.MsgServiceRouter, in.AccountKeeper) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) - return ModuleOutputs{AuthzKeeper: k, Module: m} -} - -// ____________________________________________________________________________ - // AppModuleSimulation functions // GenerateGenesisState creates a randomized GenState of the authz module. diff --git a/x/bank/depinject.go b/x/bank/depinject.go new file mode 100644 index 000000000000..ea805a4614b8 --- /dev/null +++ b/x/bank/depinject.go @@ -0,0 +1,92 @@ +package bank + +import ( + modulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/bank/keeper" + "cosmossdk.io/x/bank/types" + + "github.com/cosmos/cosmos-sdk/codec" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + Cdc codec.Codec + StoreService store.KVStoreService + Logger log.Logger + + AccountKeeper types.AccountKeeper +} + +type ModuleOutputs struct { + depinject.Out + + BankKeeper keeper.BaseKeeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // Configure blocked module accounts. + // + // Default behavior for blockedAddresses is to regard any module mentioned in + // AccountKeeper's module account permissions as blocked. + blockedAddresses := make(map[string]bool) + if len(in.Config.BlockedModuleAccountsOverride) > 0 { + for _, moduleName := range in.Config.BlockedModuleAccountsOverride { + addrStr, err := in.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(moduleName)) + if err != nil { + panic(err) + } + blockedAddresses[addrStr] = true + } + } else { + for _, permission := range in.AccountKeeper.GetModulePermissions() { + addrStr, err := in.AccountKeeper.AddressCodec().BytesToString(permission.GetAddress()) + if err != nil { + panic(err) + } + blockedAddresses[addrStr] = true + } + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + authStr, err := in.AccountKeeper.AddressCodec().BytesToString(authority) + if err != nil { + panic(err) + } + + bankKeeper := keeper.NewBaseKeeper( + in.Cdc, + in.StoreService, + in.AccountKeeper, + blockedAddresses, + authStr, + in.Logger, + ) + m := NewAppModule(in.Cdc, bankKeeper, in.AccountKeeper) + + return ModuleOutputs{BankKeeper: bankKeeper, Module: m} +} diff --git a/x/bank/module.go b/x/bank/module.go index 1d0c56ee76bb..3b5541e0101f 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -9,13 +9,7 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/bank/module/v1" "cosmossdk.io/core/appmodule" - corestore "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - "cosmossdk.io/log" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/bank/client/cli" "cosmossdk.io/x/bank/keeper" "cosmossdk.io/x/bank/simulation" @@ -39,7 +33,6 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} _ module.HasInvariants = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -98,9 +91,6 @@ type AppModule struct { accountKeeper types.AccountKeeper } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -185,77 +175,3 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp simState.AppParams, simState.Cdc, simState.TxConfig, am.accountKeeper, am.keeper, ) } - -// App Wiring Setup - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - Cdc codec.Codec - StoreService corestore.KVStoreService - Logger log.Logger - - AccountKeeper types.AccountKeeper -} - -type ModuleOutputs struct { - depinject.Out - - BankKeeper keeper.BaseKeeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - // Configure blocked module accounts. - // - // Default behavior for blockedAddresses is to regard any module mentioned in - // AccountKeeper's module account permissions as blocked. - blockedAddresses := make(map[string]bool) - if len(in.Config.BlockedModuleAccountsOverride) > 0 { - for _, moduleName := range in.Config.BlockedModuleAccountsOverride { - addrStr, err := in.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(moduleName)) - if err != nil { - panic(err) - } - blockedAddresses[addrStr] = true - } - } else { - for _, permission := range in.AccountKeeper.GetModulePermissions() { - addrStr, err := in.AccountKeeper.AddressCodec().BytesToString(permission.GetAddress()) - if err != nil { - panic(err) - } - blockedAddresses[addrStr] = true - } - } - - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - authStr, err := in.AccountKeeper.AddressCodec().BytesToString(authority) - if err != nil { - panic(err) - } - - bankKeeper := keeper.NewBaseKeeper( - in.Cdc, - in.StoreService, - in.AccountKeeper, - blockedAddresses, - authStr, - in.Logger, - ) - m := NewAppModule(in.Cdc, bankKeeper, in.AccountKeeper) - - return ModuleOutputs{BankKeeper: bankKeeper, Module: m} -} diff --git a/x/circuit/depinject.go b/x/circuit/depinject.go new file mode 100644 index 000000000000..6bb20c27457b --- /dev/null +++ b/x/circuit/depinject.go @@ -0,0 +1,67 @@ +package circuit + +import ( + modulev1 "cosmossdk.io/api/cosmos/circuit/module/v1" + "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/circuit/keeper" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + Cdc codec.Codec + StoreService store.KVStoreService + + AddressCodec address.Codec +} + +type ModuleOutputs struct { + depinject.Out + + CircuitKeeper keeper.Keeper + Module appmodule.AppModule + BaseappOptions runtime.BaseAppOption +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress("gov") + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + circuitkeeper := keeper.NewKeeper( + in.Cdc, + in.StoreService, + authority.String(), + in.AddressCodec, + ) + m := NewAppModule(in.Cdc, circuitkeeper) + + baseappOpt := func(app *baseapp.BaseApp) { + app.SetCircuitBreaker(&circuitkeeper) + } + + return ModuleOutputs{CircuitKeeper: circuitkeeper, Module: m, BaseappOptions: baseappOpt} +} diff --git a/x/circuit/module.go b/x/circuit/module.go index 667a1fd9700a..b2e61cb19548 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -8,21 +8,13 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/circuit/module/v1" - "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/circuit/keeper" "cosmossdk.io/x/circuit/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/telemetry" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -85,9 +77,6 @@ type AppModule struct { keeper keeper.Keeper } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -125,50 +114,3 @@ func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json gs := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - Cdc codec.Codec - StoreService store.KVStoreService - - AddressCodec address.Codec -} - -type ModuleOutputs struct { - depinject.Out - - CircuitKeeper keeper.Keeper - Module appmodule.AppModule - BaseappOptions runtime.BaseAppOption -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - // default to governance authority if not provided - authority := authtypes.NewModuleAddress("gov") - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - circuitkeeper := keeper.NewKeeper( - in.Cdc, - in.StoreService, - authority.String(), - in.AddressCodec, - ) - m := NewAppModule(in.Cdc, circuitkeeper) - - baseappOpt := func(app *baseapp.BaseApp) { - app.SetCircuitBreaker(&circuitkeeper) - } - - return ModuleOutputs{CircuitKeeper: circuitkeeper, Module: m, BaseappOptions: baseappOpt} -} diff --git a/x/consensus/depinject.go b/x/consensus/depinject.go new file mode 100644 index 000000000000..f53ce425fdce --- /dev/null +++ b/x/consensus/depinject.go @@ -0,0 +1,64 @@ +package consensus + +import ( + modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/event" + storetypes "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/cosmos/cosmos-sdk/x/consensus/keeper" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + Cdc codec.Codec + StoreService storetypes.KVStoreService + EventManager event.Service +} + +type ModuleOutputs struct { + depinject.Out + + Keeper keeper.Keeper + Module appmodule.AppModule + BaseAppOption runtime.BaseAppOption +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress("gov") + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + k := keeper.NewKeeper(in.Cdc, in.StoreService, authority.String(), in.EventManager) + m := NewAppModule(in.Cdc, k) + baseappOpt := func(app *baseapp.BaseApp) { + app.SetParamStore(k.ParamsStore) + } + + return ModuleOutputs{ + Keeper: k, + Module: m, + BaseAppOption: baseappOpt, + } +} diff --git a/x/consensus/module.go b/x/consensus/module.go index 03c5edc1106a..a0fcc9b161fe 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -6,19 +6,11 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" - modulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/event" - storetypes "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/consensus/keeper" "github.com/cosmos/cosmos-sdk/x/consensus/types" @@ -65,9 +57,6 @@ type AppModule struct { keeper keeper.Keeper } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -88,47 +77,3 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - Cdc codec.Codec - StoreService storetypes.KVStoreService - EventManager event.Service -} - -type ModuleOutputs struct { - depinject.Out - - Keeper keeper.Keeper - Module appmodule.AppModule - BaseAppOption runtime.BaseAppOption -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - // default to governance authority if not provided - authority := authtypes.NewModuleAddress("gov") - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper(in.Cdc, in.StoreService, authority.String(), in.EventManager) - m := NewAppModule(in.Cdc, k) - baseappOpt := func(app *baseapp.BaseApp) { - app.SetParamStore(k.ParamsStore) - } - - return ModuleOutputs{ - Keeper: k, - Module: m, - BaseAppOption: baseappOpt, - } -} diff --git a/x/counter/depinject.go b/x/counter/depinject.go new file mode 100644 index 000000000000..51d6ecff17dc --- /dev/null +++ b/x/counter/depinject.go @@ -0,0 +1,48 @@ +package counter + +import ( + modulev1 "cosmossdk.io/api/cosmos/counter/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/event" + storetypes "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/x/counter/keeper" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService storetypes.KVStoreService + EventManager event.Service +} + +type ModuleOutputs struct { + depinject.Out + + Keeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + k := keeper.NewKeeper(in.StoreService, in.EventManager) + m := NewAppModule(k) + + return ModuleOutputs{ + Keeper: k, + Module: m, + } +} diff --git a/x/counter/module.go b/x/counter/module.go index fae00c214081..1a4a97befe8b 100644 --- a/x/counter/module.go +++ b/x/counter/module.go @@ -4,12 +4,7 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" - modulev1 "cosmossdk.io/api/cosmos/counter/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/event" - storetypes "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -49,9 +44,6 @@ type AppModule struct { keeper keeper.Keeper } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -72,35 +64,3 @@ func NewAppModule(keeper keeper.Keeper) AppModule { // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 1 } - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - StoreService storetypes.KVStoreService - EventManager event.Service -} - -type ModuleOutputs struct { - depinject.Out - - Keeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.StoreService, in.EventManager) - m := NewAppModule(k) - - return ModuleOutputs{ - Keeper: k, - Module: m, - } -} diff --git a/x/crisis/depinject.go b/x/crisis/depinject.go new file mode 100644 index 000000000000..e81a89418807 --- /dev/null +++ b/x/crisis/depinject.go @@ -0,0 +1,85 @@ +package crisis + +import ( + modulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" + "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/server" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/x/crisis/keeper" + "github.com/cosmos/cosmos-sdk/x/crisis/types" + "github.com/spf13/cast" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService store.KVStoreService + Codec codec.Codec + AppOpts servertypes.AppOptions `optional:"true"` + + BankKeeper types.SupplyKeeper + AddressCodec address.Codec +} + +type ModuleOutputs struct { + depinject.Out + + Module appmodule.AppModule + CrisisKeeper *keeper.Keeper +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + var invalidCheckPeriod uint + if in.AppOpts != nil { + invalidCheckPeriod = cast.ToUint(in.AppOpts.Get(server.FlagInvCheckPeriod)) + } + + feeCollectorName := in.Config.FeeCollectorName + if feeCollectorName == "" { + feeCollectorName = authtypes.FeeCollectorName + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + k := keeper.NewKeeper( + in.Codec, + in.StoreService, + invalidCheckPeriod, + in.BankKeeper, + feeCollectorName, + authority.String(), + in.AddressCodec, + ) + + var skipGenesisInvariants bool + if in.AppOpts != nil { + skipGenesisInvariants = cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) + } + + m := NewAppModule(k, skipGenesisInvariants) + + return ModuleOutputs{CrisisKeeper: k, Module: m} +} diff --git a/x/crisis/module.go b/x/crisis/module.go index 6fee91a29ffb..a82b9ab3ff4d 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -7,22 +7,13 @@ import ( "time" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cast" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" - "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/server" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/telemetry" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/crisis/keeper" @@ -109,9 +100,6 @@ func NewAppModule(keeper *keeper.Keeper, skipGenesisInvariants bool) AppModule { } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -160,68 +148,3 @@ func (am AppModule) EndBlock(ctx context.Context) error { EndBlocker(ctx, *am.keeper) return nil } - -// App Wiring Setup - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec - AppOpts servertypes.AppOptions `optional:"true"` - - BankKeeper types.SupplyKeeper - AddressCodec address.Codec -} - -type ModuleOutputs struct { - depinject.Out - - Module appmodule.AppModule - CrisisKeeper *keeper.Keeper -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - var invalidCheckPeriod uint - if in.AppOpts != nil { - invalidCheckPeriod = cast.ToUint(in.AppOpts.Get(server.FlagInvCheckPeriod)) - } - - feeCollectorName := in.Config.FeeCollectorName - if feeCollectorName == "" { - feeCollectorName = authtypes.FeeCollectorName - } - - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper( - in.Cdc, - in.StoreService, - invalidCheckPeriod, - in.BankKeeper, - feeCollectorName, - authority.String(), - in.AddressCodec, - ) - - var skipGenesisInvariants bool - if in.AppOpts != nil { - skipGenesisInvariants = cast.ToBool(in.AppOpts.Get(FlagSkipGenesisInvariants)) - } - - m := NewAppModule(k, skipGenesisInvariants) - - return ModuleOutputs{CrisisKeeper: k, Module: m} -} diff --git a/x/distribution/depinject.go b/x/distribution/depinject.go new file mode 100644 index 000000000000..07383b2cb59a --- /dev/null +++ b/x/distribution/depinject.go @@ -0,0 +1,78 @@ +package distribution + +import ( + modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/distribution/keeper" + "cosmossdk.io/x/distribution/types" + staking "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService store.KVStoreService + Cdc codec.Codec + + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + StakingKeeper types.StakingKeeper + PoolKeeper types.PoolKeeper +} + +type ModuleOutputs struct { + depinject.Out + + DistrKeeper keeper.Keeper + Module appmodule.AppModule + Hooks staking.StakingHooksWrapper +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + feeCollectorName := in.Config.FeeCollectorName + if feeCollectorName == "" { + feeCollectorName = authtypes.FeeCollectorName + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + k := keeper.NewKeeper( + in.Cdc, + in.StoreService, + in.AccountKeeper, + in.BankKeeper, + in.StakingKeeper, + in.PoolKeeper, + feeCollectorName, + authority.String(), + ) + + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.PoolKeeper) + + return ModuleOutputs{ + DistrKeeper: k, + Module: m, + Hooks: staking.StakingHooksWrapper{StakingHooks: k.Hooks()}, + } +} diff --git a/x/distribution/module.go b/x/distribution/module.go index 690ed300d2e7..d5fa23d054c1 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -8,17 +8,11 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/distribution/client/cli" "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/simulation" "cosmossdk.io/x/distribution/types" - staking "cosmossdk.io/x/staking/types" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -37,7 +31,6 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} _ module.HasInvariants = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -117,9 +110,6 @@ func NewAppModule( } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -195,66 +185,3 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp am.accountKeeper, am.bankKeeper, am.keeper, am.stakingKeeper, ) } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec - - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - StakingKeeper types.StakingKeeper - PoolKeeper types.PoolKeeper -} - -type ModuleOutputs struct { - depinject.Out - - DistrKeeper keeper.Keeper - Module appmodule.AppModule - Hooks staking.StakingHooksWrapper -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - feeCollectorName := in.Config.FeeCollectorName - if feeCollectorName == "" { - feeCollectorName = authtypes.FeeCollectorName - } - - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper( - in.Cdc, - in.StoreService, - in.AccountKeeper, - in.BankKeeper, - in.StakingKeeper, - in.PoolKeeper, - feeCollectorName, - authority.String(), - ) - - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.PoolKeeper) - - return ModuleOutputs{ - DistrKeeper: k, - Module: m, - Hooks: staking.StakingHooksWrapper{StakingHooks: k.Hooks()}, - } -} diff --git a/x/evidence/depinject.go b/x/evidence/depinject.go new file mode 100644 index 000000000000..e1de03c10924 --- /dev/null +++ b/x/evidence/depinject.go @@ -0,0 +1,49 @@ +package evidence + +import ( + modulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" + "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/x/evidence/keeper" + "cosmossdk.io/x/evidence/types" + "github.com/cosmos/cosmos-sdk/codec" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + StoreService store.KVStoreService + Cdc codec.Codec + + StakingKeeper types.StakingKeeper + SlashingKeeper types.SlashingKeeper + AddressCodec address.Codec +} + +type ModuleOutputs struct { + depinject.Out + + EvidenceKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + k := keeper.NewKeeper(in.Cdc, in.StoreService, in.StakingKeeper, in.SlashingKeeper, in.AddressCodec) + m := NewAppModule(*k) + + return ModuleOutputs{EvidenceKeeper: *k, Module: m} +} diff --git a/x/evidence/module.go b/x/evidence/module.go index 3f5ff820a6ad..fdd897b16483 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -9,12 +9,7 @@ import ( "github.com/spf13/cobra" "google.golang.org/grpc" - modulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" - "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - store "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" eviclient "cosmossdk.io/x/evidence/client" "cosmossdk.io/x/evidence/client/cli" "cosmossdk.io/x/evidence/keeper" @@ -120,9 +115,6 @@ func NewAppModule(keeper keeper.Keeper) AppModule { } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -174,38 +166,3 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { return nil } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - StoreService store.KVStoreService - Cdc codec.Codec - - StakingKeeper types.StakingKeeper - SlashingKeeper types.SlashingKeeper - AddressCodec address.Codec -} - -type ModuleOutputs struct { - depinject.Out - - EvidenceKeeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.Cdc, in.StoreService, in.StakingKeeper, in.SlashingKeeper, in.AddressCodec) - m := NewAppModule(*k) - - return ModuleOutputs{EvidenceKeeper: *k, Module: m} -} diff --git a/x/feegrant/module/depinject.go b/x/feegrant/module/depinject.go new file mode 100644 index 000000000000..f611ef8d3805 --- /dev/null +++ b/x/feegrant/module/depinject.go @@ -0,0 +1,63 @@ +package module + +import ( + modulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/x/feegrant" + "cosmossdk.io/x/feegrant/keeper" + "cosmossdk.io/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type FeegrantInputs struct { + depinject.In + + StoreService store.KVStoreService + Cdc codec.Codec + AccountKeeper feegrant.AccountKeeper + BankKeeper feegrant.BankKeeper + Registry cdctypes.InterfaceRegistry +} + +func ProvideModule(in FeegrantInputs) (keeper.Keeper, appmodule.AppModule) { + k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper) + m := NewAppModule(in.Cdc, in.AccountKeeper, in.BankKeeper, k, in.Registry) + return k, m +} + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the feegrant module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// RegisterStoreDecoder registers a decoder for feegrant module's types +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { + sdr[feegrant.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations returns all the feegrant module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return simulation.WeightedOperations( + am.registry, simState.AppParams, simState.Cdc, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, am.accountKeeper.AddressCodec(), + ) +} diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index a76a0f835bd3..82f1f52a2e8f 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -8,22 +8,16 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/errors" "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/client/cli" "cosmossdk.io/x/feegrant/keeper" - "cosmossdk.io/x/feegrant/simulation" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) var ( @@ -31,7 +25,6 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasServices = AppModule{} _ module.HasGenesis = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -126,9 +119,6 @@ func NewAppModule(cdc codec.Codec, ak feegrant.AccountKeeper, bk feegrant.BankKe } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -163,45 +153,3 @@ func (AppModule) ConsensusVersion() uint64 { return 2 } func (am AppModule) EndBlock(ctx context.Context) error { return EndBlocker(ctx, am.keeper) } - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type FeegrantInputs struct { - depinject.In - - StoreService store.KVStoreService - Cdc codec.Codec - AccountKeeper feegrant.AccountKeeper - BankKeeper feegrant.BankKeeper - Registry cdctypes.InterfaceRegistry -} - -func ProvideModule(in FeegrantInputs) (keeper.Keeper, appmodule.AppModule) { - k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper) - m := NewAppModule(in.Cdc, in.AccountKeeper, in.BankKeeper, k, in.Registry) - return k, m -} - -// AppModuleSimulation functions - -// GenerateGenesisState creates a randomized GenState of the feegrant module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) -} - -// RegisterStoreDecoder registers a decoder for feegrant module's types -func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { - sdr[feegrant.StoreKey] = simulation.NewDecodeStore(am.cdc) -} - -// WeightedOperations returns all the feegrant module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations( - am.registry, simState.AppParams, simState.Cdc, simState.TxConfig, - am.accountKeeper, am.bankKeeper, am.keeper, am.accountKeeper.AddressCodec(), - ) -} diff --git a/x/genutil/depinject.go b/x/genutil/depinject.go new file mode 100644 index 000000000000..4cbe7f64c7fe --- /dev/null +++ b/x/genutil/depinject.go @@ -0,0 +1,37 @@ +package genutil + +import ( + modulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/genesis" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/x/genutil/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +// ModuleInputs defines the inputs needed for the genutil module. +type ModuleInputs struct { + depinject.In + + AccountKeeper types.AccountKeeper + StakingKeeper types.StakingKeeper + DeliverTx genesis.TxHandler + Config client.TxConfig +} + +func ProvideModule(in ModuleInputs) appmodule.AppModule { + m := NewAppModule(in.AccountKeeper, in.StakingKeeper, in.DeliverTx, in.Config) + return m +} diff --git a/x/genutil/module.go b/x/genutil/module.go index 403838dddae9..6029f5b45acc 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -8,11 +8,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -94,9 +91,6 @@ func NewAppModule(accountKeeper types.AccountKeeper, }) } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (AppModule) IsAppModule() {} @@ -119,24 +113,3 @@ func (am AppModule) ExportGenesis(_ context.Context, cdc codec.JSONCodec) json.R // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 1 } - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -// ModuleInputs defines the inputs needed for the genutil module. -type ModuleInputs struct { - depinject.In - - AccountKeeper types.AccountKeeper - StakingKeeper types.StakingKeeper - DeliverTx genesis.TxHandler - Config client.TxConfig -} - -func ProvideModule(in ModuleInputs) appmodule.AppModule { - m := NewAppModule(in.AccountKeeper, in.StakingKeeper, in.DeliverTx, in.Config) - return m -} diff --git a/x/gov/depinject.go b/x/gov/depinject.go new file mode 100644 index 000000000000..3fb8bd4883c1 --- /dev/null +++ b/x/gov/depinject.go @@ -0,0 +1,133 @@ +package gov + +import ( + "fmt" + "sort" + "strings" + + modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" + "cosmossdk.io/core/appmodule" + store "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/gov/keeper" + govtypes "cosmossdk.io/x/gov/types" + "cosmossdk.io/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + "golang.org/x/exp/maps" + "golang.org/x/exp/slices" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Invoke(InvokeAddRoutes, InvokeSetHooks), + appconfig.Provide(ProvideModule)) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + Cdc codec.Codec + StoreService store.KVStoreService + ModuleKey depinject.OwnModuleKey + MsgServiceRouter baseapp.MessageRouter + + AccountKeeper govtypes.AccountKeeper + BankKeeper govtypes.BankKeeper + StakingKeeper govtypes.StakingKeeper + PoolKeeper govtypes.PoolKeeper +} + +type ModuleOutputs struct { + depinject.Out + + Module appmodule.AppModule + Keeper *keeper.Keeper + HandlerRoute v1beta1.HandlerRoute +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + defaultConfig := govtypes.DefaultConfig() + if in.Config.MaxTitleLen != 0 { + defaultConfig.MaxTitleLen = in.Config.MaxTitleLen + } + if in.Config.MaxMetadataLen != 0 { + defaultConfig.MaxMetadataLen = in.Config.MaxMetadataLen + } + if in.Config.MaxSummaryLen != 0 { + defaultConfig.MaxSummaryLen = in.Config.MaxSummaryLen + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(govtypes.ModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + k := keeper.NewKeeper( + in.Cdc, + in.StoreService, + in.AccountKeeper, + in.BankKeeper, + in.StakingKeeper, + in.PoolKeeper, + in.MsgServiceRouter, + defaultConfig, + authority.String(), + ) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.PoolKeeper) + hr := v1beta1.HandlerRoute{Handler: v1beta1.ProposalHandler, RouteKey: govtypes.RouterKey} + + return ModuleOutputs{Module: m, Keeper: k, HandlerRoute: hr} +} + +func InvokeAddRoutes(keeper *keeper.Keeper, routes []v1beta1.HandlerRoute) { + if keeper == nil || routes == nil { + return + } + + // Default route order is a lexical sort by RouteKey. + // Explicit ordering can be added to the module config if required. + slices.SortFunc(routes, func(x, y v1beta1.HandlerRoute) int { + return strings.Compare(x.RouteKey, y.RouteKey) + }) + + router := v1beta1.NewRouter() + for _, r := range routes { + router.AddRoute(r.RouteKey, r.Handler) + } + keeper.SetLegacyRouter(router) +} + +func InvokeSetHooks(keeper *keeper.Keeper, govHooks map[string]govtypes.GovHooksWrapper) error { + if keeper == nil || govHooks == nil { + return nil + } + + // Default ordering is lexical by module name. + // Explicit ordering can be added to the module config if required. + modNames := maps.Keys(govHooks) + order := modNames + sort.Strings(order) + + var multiHooks govtypes.MultiGovHooks + for _, modName := range order { + hook, ok := govHooks[modName] + if !ok { + return fmt.Errorf("can't find staking hooks for module %s", modName) + } + multiHooks = append(multiHooks, hook) + } + + keeper.SetHooks(multiHooks) + return nil +} diff --git a/x/gov/module.go b/x/gov/module.go index f6b1750a7b55..52fb641283bd 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -4,21 +4,12 @@ import ( "context" "encoding/json" "fmt" - "sort" - "strings" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - "golang.org/x/exp/maps" - "golang.org/x/exp/slices" - modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - store "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" govclient "cosmossdk.io/x/gov/client" "cosmossdk.io/x/gov/client/cli" "cosmossdk.io/x/gov/keeper" @@ -27,7 +18,6 @@ import ( v1 "cosmossdk.io/x/gov/types/v1" "cosmossdk.io/x/gov/types/v1beta1" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -145,119 +135,9 @@ func NewAppModule( } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} -func init() { - am.Register( - &modulev1.Module{}, - am.Invoke(InvokeAddRoutes, InvokeSetHooks), - am.Provide(ProvideModule)) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - Cdc codec.Codec - StoreService store.KVStoreService - ModuleKey depinject.OwnModuleKey - MsgServiceRouter baseapp.MessageRouter - - AccountKeeper govtypes.AccountKeeper - BankKeeper govtypes.BankKeeper - StakingKeeper govtypes.StakingKeeper - PoolKeeper govtypes.PoolKeeper -} - -type ModuleOutputs struct { - depinject.Out - - Module appmodule.AppModule - Keeper *keeper.Keeper - HandlerRoute v1beta1.HandlerRoute -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - defaultConfig := govtypes.DefaultConfig() - if in.Config.MaxTitleLen != 0 { - defaultConfig.MaxTitleLen = in.Config.MaxTitleLen - } - if in.Config.MaxMetadataLen != 0 { - defaultConfig.MaxMetadataLen = in.Config.MaxMetadataLen - } - if in.Config.MaxSummaryLen != 0 { - defaultConfig.MaxSummaryLen = in.Config.MaxSummaryLen - } - - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(govtypes.ModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper( - in.Cdc, - in.StoreService, - in.AccountKeeper, - in.BankKeeper, - in.StakingKeeper, - in.PoolKeeper, - in.MsgServiceRouter, - defaultConfig, - authority.String(), - ) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.PoolKeeper) - hr := v1beta1.HandlerRoute{Handler: v1beta1.ProposalHandler, RouteKey: govtypes.RouterKey} - - return ModuleOutputs{Module: m, Keeper: k, HandlerRoute: hr} -} - -func InvokeAddRoutes(keeper *keeper.Keeper, routes []v1beta1.HandlerRoute) { - if keeper == nil || routes == nil { - return - } - - // Default route order is a lexical sort by RouteKey. - // Explicit ordering can be added to the module config if required. - slices.SortFunc(routes, func(x, y v1beta1.HandlerRoute) int { - return strings.Compare(x.RouteKey, y.RouteKey) - }) - - router := v1beta1.NewRouter() - for _, r := range routes { - router.AddRoute(r.RouteKey, r.Handler) - } - keeper.SetLegacyRouter(router) -} - -func InvokeSetHooks(keeper *keeper.Keeper, govHooks map[string]govtypes.GovHooksWrapper) error { - if keeper == nil || govHooks == nil { - return nil - } - - // Default ordering is lexical by module name. - // Explicit ordering can be added to the module config if required. - modNames := maps.Keys(govHooks) - order := modNames - sort.Strings(order) - - var multiHooks govtypes.MultiGovHooks - for _, modName := range order { - hook, ok := govHooks[modName] - if !ok { - return fmt.Errorf("can't find staking hooks for module %s", modName) - } - multiHooks = append(multiHooks, hook) - } - - keeper.SetHooks(multiHooks) - return nil -} - // RegisterInvariants registers module invariants func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper, am.bankKeeper) diff --git a/x/group/module/depinject.go b/x/group/module/depinject.go new file mode 100644 index 000000000000..46fa776029cc --- /dev/null +++ b/x/group/module/depinject.go @@ -0,0 +1,61 @@ +package module + +import ( + modulev1 "cosmossdk.io/api/cosmos/group/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + store "cosmossdk.io/store/types" + "cosmossdk.io/x/group" + "cosmossdk.io/x/group/keeper" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type GroupInputs struct { + depinject.In + + Config *modulev1.Module + Key *store.KVStoreKey + Cdc codec.Codec + AccountKeeper group.AccountKeeper + BankKeeper group.BankKeeper + Registry cdctypes.InterfaceRegistry + MsgServiceRouter baseapp.MessageRouter +} + +type GroupOutputs struct { + depinject.Out + + GroupKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in GroupInputs) GroupOutputs { + k := keeper.NewKeeper(in.Key, + in.Cdc, + in.MsgServiceRouter, + in.AccountKeeper, + group.Config{ + MaxExecutionPeriod: in.Config.MaxExecutionPeriod.AsDuration(), + MaxMetadataLen: in.Config.MaxMetadataLen, + MaxProposalTitleLen: in.Config.MaxProposalTitleLen, + MaxProposalSummaryLen: in.Config.MaxProposalSummaryLen, + }, + ) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) + return GroupOutputs{GroupKeeper: k, Module: m} +} diff --git a/x/group/module/module.go b/x/group/module/module.go index 7ce3c2ed217f..a91c618f58bc 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -8,18 +8,13 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/group/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - store "cosmossdk.io/store/types" "cosmossdk.io/x/group" "cosmossdk.io/x/group/client/cli" "cosmossdk.io/x/group/keeper" "cosmossdk.io/x/group/simulation" - "github.com/cosmos/cosmos-sdk/baseapp" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -37,7 +32,6 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} _ module.HasInvariants = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -62,9 +56,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak group.AccountKeeper, } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -176,49 +167,3 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp am.accKeeper, am.bankKeeper, am.keeper, am.cdc, ) } - -// -// App Wiring Setup -// - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type GroupInputs struct { - depinject.In - - Config *modulev1.Module - Key *store.KVStoreKey - Cdc codec.Codec - AccountKeeper group.AccountKeeper - BankKeeper group.BankKeeper - Registry cdctypes.InterfaceRegistry - MsgServiceRouter baseapp.MessageRouter -} - -type GroupOutputs struct { - depinject.Out - - GroupKeeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in GroupInputs) GroupOutputs { - k := keeper.NewKeeper(in.Key, - in.Cdc, - in.MsgServiceRouter, - in.AccountKeeper, - group.Config{ - MaxExecutionPeriod: in.Config.MaxExecutionPeriod.AsDuration(), - MaxMetadataLen: in.Config.MaxMetadataLen, - MaxProposalTitleLen: in.Config.MaxProposalTitleLen, - MaxProposalSummaryLen: in.Config.MaxProposalSummaryLen, - }, - ) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) - return GroupOutputs{GroupKeeper: k, Module: m} -} diff --git a/x/mint/depinject.go b/x/mint/depinject.go new file mode 100644 index 000000000000..178003079158 --- /dev/null +++ b/x/mint/depinject.go @@ -0,0 +1,78 @@ +package mint + +import ( + modulev1 "cosmossdk.io/api/cosmos/mint/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/mint/keeper" + "cosmossdk.io/x/mint/types" + "github.com/cosmos/cosmos-sdk/codec" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + ModuleKey depinject.OwnModuleKey + Config *modulev1.Module + StoreService store.KVStoreService + Cdc codec.Codec + InflationCalculationFn types.InflationCalculationFn `optional:"true"` + + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + StakingKeeper types.StakingKeeper +} + +type ModuleOutputs struct { + depinject.Out + + MintKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + feeCollectorName := in.Config.FeeCollectorName + if feeCollectorName == "" { + feeCollectorName = authtypes.FeeCollectorName + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + as, err := in.AccountKeeper.AddressCodec().BytesToString(authority) + if err != nil { + panic(err) + } + + k := keeper.NewKeeper( + in.Cdc, + in.StoreService, + in.StakingKeeper, + in.AccountKeeper, + in.BankKeeper, + feeCollectorName, + as, + ) + + // when no inflation calculation function is provided it will use the default types.DefaultInflationCalculationFn + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.InflationCalculationFn) + + return ModuleOutputs{MintKeeper: k, Module: m} +} diff --git a/x/mint/module.go b/x/mint/module.go index 4af6eeaa349f..0f1e3492cac1 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -7,12 +7,7 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/mint/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/simulation" "cosmossdk.io/x/mint/types" @@ -32,7 +27,6 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -113,9 +107,6 @@ func NewAppModule( } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -177,67 +168,3 @@ func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - ModuleKey depinject.OwnModuleKey - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec - InflationCalculationFn types.InflationCalculationFn `optional:"true"` - - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - StakingKeeper types.StakingKeeper -} - -type ModuleOutputs struct { - depinject.Out - - MintKeeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - feeCollectorName := in.Config.FeeCollectorName - if feeCollectorName == "" { - feeCollectorName = authtypes.FeeCollectorName - } - - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - as, err := in.AccountKeeper.AddressCodec().BytesToString(authority) - if err != nil { - panic(err) - } - - k := keeper.NewKeeper( - in.Cdc, - in.StoreService, - in.StakingKeeper, - in.AccountKeeper, - in.BankKeeper, - feeCollectorName, - as, - ) - - // when no inflation calculation function is provided it will use the default types.DefaultInflationCalculationFn - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.InflationCalculationFn) - - return ModuleOutputs{MintKeeper: k, Module: m} -} diff --git a/x/nft/module/depinject.go b/x/nft/module/depinject.go new file mode 100644 index 000000000000..c9cc4bc58950 --- /dev/null +++ b/x/nft/module/depinject.go @@ -0,0 +1,49 @@ +package module + +import ( + modulev1 "cosmossdk.io/api/cosmos/nft/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/x/nft" + "cosmossdk.io/x/nft/keeper" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + StoreService store.KVStoreService + Cdc codec.Codec + Registry cdctypes.InterfaceRegistry + + AccountKeeper nft.AccountKeeper + BankKeeper nft.BankKeeper +} + +type ModuleOutputs struct { + depinject.Out + + NFTKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + k := keeper.NewKeeper(in.StoreService, in.Cdc, in.AccountKeeper, in.BankKeeper) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) + + return ModuleOutputs{NFTKeeper: k, Module: m} +} diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 79cc78dff3aa..3173ede06b56 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -7,12 +7,8 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" - modulev1 "cosmossdk.io/api/cosmos/nft/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/errors" "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" @@ -104,9 +100,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak nft.AccountKeeper, b } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -150,38 +143,3 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp am.accountKeeper, am.bankKeeper, am.keeper, ) } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type NftInputs struct { - depinject.In - - StoreService store.KVStoreService - Cdc codec.Codec - Registry cdctypes.InterfaceRegistry - - AccountKeeper nft.AccountKeeper - BankKeeper nft.BankKeeper -} - -type NftOutputs struct { - depinject.Out - - NFTKeeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in NftInputs) NftOutputs { - k := keeper.NewKeeper(in.StoreService, in.Cdc, in.AccountKeeper, in.BankKeeper) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) - - return NftOutputs{NFTKeeper: k, Module: m} -} diff --git a/x/params/depinject.go b/x/params/depinject.go new file mode 100644 index 000000000000..1f62038a3d22 --- /dev/null +++ b/x/params/depinject.go @@ -0,0 +1,70 @@ +package params + +import ( + modulev1 "cosmossdk.io/api/cosmos/params/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + store "cosmossdk.io/store/types" + govv1beta1 "cosmossdk.io/x/gov/types/v1beta1" + "cosmossdk.io/x/params/keeper" + "cosmossdk.io/x/params/types" + "cosmossdk.io/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/codec" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide( + ProvideModule, + ProvideSubspace, + )) +} + +type ModuleInputs struct { + depinject.In + + KvStoreKey *store.KVStoreKey + TransientStoreKey *store.TransientStoreKey + Cdc codec.Codec + LegacyAmino *codec.LegacyAmino +} + +type ModuleOutputs struct { + depinject.Out + + ParamsKeeper keeper.Keeper + Module appmodule.AppModule + GovHandler govv1beta1.HandlerRoute +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.KvStoreKey, in.TransientStoreKey) + + m := NewAppModule(k) + govHandler := govv1beta1.HandlerRoute{RouteKey: proposal.RouterKey, Handler: NewParamChangeProposalHandler(k)} + + return ModuleOutputs{ParamsKeeper: k, Module: m, GovHandler: govHandler} +} + +type SubspaceInputs struct { + depinject.In + + Key depinject.ModuleKey + Keeper keeper.Keeper + KeyTables map[string]types.KeyTable +} + +func ProvideSubspace(in SubspaceInputs) types.Subspace { + moduleName := in.Key.Name() + kt, exists := in.KeyTables[moduleName] + if !exists { + return in.Keeper.Subspace(moduleName) + } + return in.Keeper.Subspace(moduleName).WithKeyTable(kt) +} diff --git a/x/params/module.go b/x/params/module.go index 13ee912d94f8..e2b2ac61f539 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -5,14 +5,8 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/params/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - store "cosmossdk.io/store/types" - govv1beta1 "cosmossdk.io/x/gov/types/v1beta1" "cosmossdk.io/x/params/keeper" - "cosmossdk.io/x/params/types" "cosmossdk.io/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/client" @@ -26,7 +20,6 @@ var ( _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} _ module.HasServices = AppModule{} - _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -73,9 +66,6 @@ func NewAppModule(k keeper.Keeper) AppModule { } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -98,58 +88,3 @@ func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weig // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide( - ProvideModule, - ProvideSubspace, - )) -} - -type ModuleInputs struct { - depinject.In - - KvStoreKey *store.KVStoreKey - TransientStoreKey *store.TransientStoreKey - Cdc codec.Codec - LegacyAmino *codec.LegacyAmino -} - -type ModuleOutputs struct { - depinject.Out - - ParamsKeeper keeper.Keeper - Module appmodule.AppModule - GovHandler govv1beta1.HandlerRoute -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.KvStoreKey, in.TransientStoreKey) - - m := NewAppModule(k) - govHandler := govv1beta1.HandlerRoute{RouteKey: proposal.RouterKey, Handler: NewParamChangeProposalHandler(k)} - - return ModuleOutputs{ParamsKeeper: k, Module: m, GovHandler: govHandler} -} - -type SubspaceInputs struct { - depinject.In - - Key depinject.ModuleKey - Keeper keeper.Keeper - KeyTables map[string]types.KeyTable -} - -func ProvideSubspace(in SubspaceInputs) types.Subspace { - moduleName := in.Key.Name() - kt, exists := in.KeyTables[moduleName] - if !exists { - return in.Keeper.Subspace(moduleName) - } - return in.Keeper.Subspace(moduleName).WithKeyTable(kt) -} diff --git a/x/protocolpool/depinject.go b/x/protocolpool/depinject.go new file mode 100644 index 000000000000..da182061ee90 --- /dev/null +++ b/x/protocolpool/depinject.go @@ -0,0 +1,88 @@ +package protocolpool + +import ( + modulev1 "cosmossdk.io/api/cosmos/protocolpool/module/v1" + "cosmossdk.io/core/appmodule" + storetypes "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/protocolpool/keeper" + "cosmossdk.io/x/protocolpool/simulation" + "cosmossdk.io/x/protocolpool/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + Codec codec.Codec + StoreService storetypes.KVStoreService + + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + StakingKeeper types.StakingKeeper +} + +type ModuleOutputs struct { + depinject.Out + + Keeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress("gov") + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + k := keeper.NewKeeper(in.Codec, in.StoreService, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, authority.String()) + m := NewAppModule(in.Codec, k, in.AccountKeeper, in.BankKeeper) + + return ModuleOutputs{ + Keeper: k, + Module: m, + } +} + +// ____________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the protocolpool module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +} + +// RegisterStoreDecoder registers a decoder for protocolpool module's types +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { +} + +// ProposalMsgs returns all the protocolpool msgs used to simulate governance proposals. +func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return simulation.ProposalMsgs() +} + +// WeightedOperations returns the all the protocolpool module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, + ) +} diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 94dc10334f7b..ae4efdc4e9a4 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -7,21 +7,14 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/protocolpool/module/v1" "cosmossdk.io/core/appmodule" - storetypes "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/protocolpool/keeper" - "cosmossdk.io/x/protocolpool/simulation" "cosmossdk.io/x/protocolpool/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) // ConsensusVersion defines the current x/protocolpool module consensus version. @@ -85,9 +78,6 @@ type AppModule struct { var _ appmodule.AppModule = AppModule{} -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -130,74 +120,3 @@ func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } - -// -// App Wiring Setup -// - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - Codec codec.Codec - StoreService storetypes.KVStoreService - - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - StakingKeeper types.StakingKeeper -} - -type ModuleOutputs struct { - depinject.Out - - Keeper keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - // default to governance authority if not provided - authority := authtypes.NewModuleAddress("gov") - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - k := keeper.NewKeeper(in.Codec, in.StoreService, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, authority.String()) - m := NewAppModule(in.Codec, k, in.AccountKeeper, in.BankKeeper) - - return ModuleOutputs{ - Keeper: k, - Module: m, - } -} - -// ____________________________________________________________________________ - -// AppModuleSimulation functions - -// GenerateGenesisState creates a randomized GenState of the protocolpool module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { -} - -// RegisterStoreDecoder registers a decoder for protocolpool module's types -func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { -} - -// ProposalMsgs returns all the protocolpool msgs used to simulate governance proposals. -func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { - return simulation.ProposalMsgs() -} - -// WeightedOperations returns the all the protocolpool module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, simState.TxConfig, - am.accountKeeper, am.bankKeeper, am.keeper, - ) -} diff --git a/x/slashing/depinject.go b/x/slashing/depinject.go new file mode 100644 index 000000000000..ff8e35f56529 --- /dev/null +++ b/x/slashing/depinject.go @@ -0,0 +1,72 @@ +package slashing + +import ( + "fmt" + + modulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" + "cosmossdk.io/core/appmodule" + store "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/slashing/keeper" + "cosmossdk.io/x/slashing/types" + staking "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService store.KVStoreService + Cdc codec.Codec + LegacyAmino *codec.LegacyAmino + Registry cdctypes.InterfaceRegistry + + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + StakingKeeper types.StakingKeeper +} + +type ModuleOutputs struct { + depinject.Out + + Keeper keeper.Keeper + Module appmodule.AppModule + Hooks staking.StakingHooksWrapper +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + authStr, err := in.AccountKeeper.AddressCodec().BytesToString(authority) + if err != nil { + panic(fmt.Errorf("unable to decode authority in slashing: %w", err)) + } + + k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.StoreService, in.StakingKeeper, authStr) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.Registry) + return ModuleOutputs{ + Keeper: k, + Module: m, + Hooks: staking.StakingHooksWrapper{StakingHooks: k.Hooks()}, + } +} diff --git a/x/slashing/module.go b/x/slashing/module.go index 6a984253745d..ea2b4c9ad947 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -7,16 +7,10 @@ import ( gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - modulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" "cosmossdk.io/core/appmodule" - store "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/simulation" "cosmossdk.io/x/slashing/types" - staking "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -111,9 +105,6 @@ func NewAppModule( } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -182,57 +173,3 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp am.accountKeeper, am.bankKeeper, am.keeper, am.stakingKeeper, ) } - -// -// App Wiring Setup -// - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec - LegacyAmino *codec.LegacyAmino - Registry cdctypes.InterfaceRegistry - - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - StakingKeeper types.StakingKeeper -} - -type ModuleOutputs struct { - depinject.Out - - Keeper keeper.Keeper - Module appmodule.AppModule - Hooks staking.StakingHooksWrapper -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - authStr, err := in.AccountKeeper.AddressCodec().BytesToString(authority) - if err != nil { - panic(fmt.Errorf("unable to decode authority in slashing: %w", err)) - } - - k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.StoreService, in.StakingKeeper, authStr) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.Registry) - return ModuleOutputs{ - Keeper: k, - Module: m, - Hooks: staking.StakingHooksWrapper{StakingHooks: k.Hooks()}, - } -} diff --git a/x/staking/depinject.go b/x/staking/depinject.go new file mode 100644 index 000000000000..5e102208911e --- /dev/null +++ b/x/staking/depinject.go @@ -0,0 +1,143 @@ +package staking + +import ( + "fmt" + "sort" + + modulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/staking/keeper" + "cosmossdk.io/x/staking/simulation" + "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "golang.org/x/exp/maps" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule( + &modulev1.Module{}, + appconfig.Provide(ProvideModule), + appconfig.Invoke(InvokeSetStakingHooks), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + ValidatorAddressCodec runtime.ValidatorAddressCodec + ConsensusAddressCodec runtime.ConsensusAddressCodec + AccountKeeper types.AccountKeeper + BankKeeper types.BankKeeper + Cdc codec.Codec + StoreService store.KVStoreService +} + +// Dependency Injection Outputs +type ModuleOutputs struct { + depinject.Out + + StakingKeeper *keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + as, err := in.AccountKeeper.AddressCodec().BytesToString(authority) + if err != nil { + panic(err) + } + + k := keeper.NewKeeper( + in.Cdc, + in.StoreService, + in.AccountKeeper, + in.BankKeeper, + as, + in.ValidatorAddressCodec, + in.ConsensusAddressCodec, + ) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper) + return ModuleOutputs{StakingKeeper: k, Module: m} +} + +func InvokeSetStakingHooks( + config *modulev1.Module, + keeper *keeper.Keeper, + stakingHooks map[string]types.StakingHooksWrapper, +) error { + // all arguments to invokers are optional + if keeper == nil || config == nil { + return nil + } + + modNames := maps.Keys(stakingHooks) + order := config.HooksOrder + if len(order) == 0 { + order = modNames + sort.Strings(order) + } + + if len(order) != len(modNames) { + return fmt.Errorf("len(hooks_order: %v) != len(hooks modules: %v)", order, modNames) + } + + if len(modNames) == 0 { + return nil + } + + var multiHooks types.MultiStakingHooks + for _, modName := range order { + hook, ok := stakingHooks[modName] + if !ok { + return fmt.Errorf("can't find staking hooks for module %s", modName) + } + + multiHooks = append(multiHooks, hook) + } + + keeper.SetHooks(multiHooks) + return nil +} + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the staking module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return simulation.ProposalMsgs() +} + +// RegisterStoreDecoder registers a decoder for staking module's types +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations returns the all the staking module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return simulation.WeightedOperations( + simState.AppParams, simState.Cdc, simState.TxConfig, + am.accountKeeper, am.bankKeeper, am.keeper, + ) +} diff --git a/x/staking/module.go b/x/staking/module.go index 333d89d53b05..bc2841106ef1 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -4,31 +4,22 @@ import ( "context" "encoding/json" "fmt" - "sort" abci "github.com/cometbft/cometbft/abci/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - "golang.org/x/exp/maps" - modulev1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/staking/client/cli" "cosmossdk.io/x/staking/keeper" - "cosmossdk.io/x/staking/simulation" "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) const ( @@ -120,9 +111,6 @@ func NewAppModule( } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -180,120 +168,3 @@ func (am AppModule) BeginBlock(ctx context.Context) error { func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error) { return am.keeper.EndBlocker(ctx) } - -func init() { - am.Register( - &modulev1.Module{}, - am.Provide(ProvideModule), - am.Invoke(InvokeSetStakingHooks), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - ValidatorAddressCodec runtime.ValidatorAddressCodec - ConsensusAddressCodec runtime.ConsensusAddressCodec - AccountKeeper types.AccountKeeper - BankKeeper types.BankKeeper - Cdc codec.Codec - StoreService store.KVStoreService -} - -// Dependency Injection Outputs -type ModuleOutputs struct { - depinject.Out - - StakingKeeper *keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - as, err := in.AccountKeeper.AddressCodec().BytesToString(authority) - if err != nil { - panic(err) - } - - k := keeper.NewKeeper( - in.Cdc, - in.StoreService, - in.AccountKeeper, - in.BankKeeper, - as, - in.ValidatorAddressCodec, - in.ConsensusAddressCodec, - ) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper) - return ModuleOutputs{StakingKeeper: k, Module: m} -} - -func InvokeSetStakingHooks( - config *modulev1.Module, - keeper *keeper.Keeper, - stakingHooks map[string]types.StakingHooksWrapper, -) error { - // all arguments to invokers are optional - if keeper == nil || config == nil { - return nil - } - - modNames := maps.Keys(stakingHooks) - order := config.HooksOrder - if len(order) == 0 { - order = modNames - sort.Strings(order) - } - - if len(order) != len(modNames) { - return fmt.Errorf("len(hooks_order: %v) != len(hooks modules: %v)", order, modNames) - } - - if len(modNames) == 0 { - return nil - } - - var multiHooks types.MultiStakingHooks - for _, modName := range order { - hook, ok := stakingHooks[modName] - if !ok { - return fmt.Errorf("can't find staking hooks for module %s", modName) - } - - multiHooks = append(multiHooks, hook) - } - - keeper.SetHooks(multiHooks) - return nil -} - -// AppModuleSimulation functions - -// GenerateGenesisState creates a randomized GenState of the staking module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) -} - -// ProposalMsgs returns msgs used for governance proposals for simulations. -func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { - return simulation.ProposalMsgs() -} - -// RegisterStoreDecoder registers a decoder for staking module's types -func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { - sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) -} - -// WeightedOperations returns the all the staking module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, simState.TxConfig, - am.accountKeeper, am.bankKeeper, am.keeper, - ) -} diff --git a/x/upgrade/depinject.go b/x/upgrade/depinject.go new file mode 100644 index 000000000000..9a33a96a30d0 --- /dev/null +++ b/x/upgrade/depinject.go @@ -0,0 +1,91 @@ +package upgrade + +import ( + modulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1" + "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/store" + "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + authtypes "cosmossdk.io/x/auth/types" + "cosmossdk.io/x/upgrade/keeper" + "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/server" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/spf13/cast" +) + +var _ depinject.OnePerModuleType = AppModule{} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +func init() { + appconfig.RegisterModule(&modulev1.Module{}, + appconfig.Provide(ProvideModule), + appconfig.Invoke(PopulateVersionMap), + ) +} + +type ModuleInputs struct { + depinject.In + + Config *modulev1.Module + StoreService store.KVStoreService + Cdc codec.Codec + AddressCodec address.Codec + AppVersionModifier baseapp.AppVersionModifier + + AppOpts servertypes.AppOptions `optional:"true"` +} + +type ModuleOutputs struct { + depinject.Out + + UpgradeKeeper *keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in ModuleInputs) ModuleOutputs { + var ( + homePath string + skipUpgradeHeights = make(map[int64]bool) + ) + + if in.AppOpts != nil { + for _, h := range cast.ToIntSlice(in.AppOpts.Get(server.FlagUnsafeSkipUpgrades)) { + skipUpgradeHeights[int64(h)] = true + } + + homePath = cast.ToString(in.AppOpts.Get(flags.FlagHome)) + } + + // default to governance authority if not provided + authority := authtypes.NewModuleAddress(types.GovModuleName) + if in.Config.Authority != "" { + authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) + } + + auth, err := in.AddressCodec.BytesToString(authority) + if err != nil { + panic(err) + } + + // set the governance module account as the authority for conducting upgrades + k := keeper.NewKeeper(skipUpgradeHeights, in.StoreService, in.Cdc, homePath, in.AppVersionModifier, auth) + m := NewAppModule(k, in.AddressCodec) + + return ModuleOutputs{UpgradeKeeper: k, Module: m} +} + +func PopulateVersionMap(upgradeKeeper *keeper.Keeper, modules map[string]appmodule.AppModule) { + if upgradeKeeper == nil { + return + } + + upgradeKeeper.SetInitVersionMap(module.NewManagerFromMap(modules).GetVersionMap()) +} diff --git a/x/upgrade/module.go b/x/upgrade/module.go index e821a4d8faa5..ea647b5e1d94 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -6,27 +6,17 @@ import ( "fmt" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cast" "github.com/spf13/cobra" - modulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/store" - "cosmossdk.io/depinject" - am "cosmossdk.io/depinject/appmodule" - authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/upgrade/client/cli" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/server" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -90,9 +80,6 @@ func NewAppModule(keeper *keeper.Keeper, ac address.Codec) AppModule { } } -// IsOnePerModuleType implements the depinject.OnePerModuleType interface. -func (am AppModule) IsOnePerModuleType() {} - // IsAppModule implements the appmodule.AppModule interface. func (am AppModule) IsAppModule() {} @@ -160,73 +147,3 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } func (am AppModule) PreBlock(ctx context.Context) (appmodule.ResponsePreBlock, error) { return PreBlocker(ctx, am.keeper) } - -// -// App Wiring Setup -// - -func init() { - am.Register(&modulev1.Module{}, - am.Provide(ProvideModule), - am.Invoke(PopulateVersionMap), - ) -} - -type ModuleInputs struct { - depinject.In - - Config *modulev1.Module - StoreService store.KVStoreService - Cdc codec.Codec - AddressCodec address.Codec - AppVersionModifier baseapp.AppVersionModifier - - AppOpts servertypes.AppOptions `optional:"true"` -} - -type ModuleOutputs struct { - depinject.Out - - UpgradeKeeper *keeper.Keeper - Module appmodule.AppModule -} - -func ProvideModule(in ModuleInputs) ModuleOutputs { - var ( - homePath string - skipUpgradeHeights = make(map[int64]bool) - ) - - if in.AppOpts != nil { - for _, h := range cast.ToIntSlice(in.AppOpts.Get(server.FlagUnsafeSkipUpgrades)) { - skipUpgradeHeights[int64(h)] = true - } - - homePath = cast.ToString(in.AppOpts.Get(flags.FlagHome)) - } - - // default to governance authority if not provided - authority := authtypes.NewModuleAddress(types.GovModuleName) - if in.Config.Authority != "" { - authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) - } - - auth, err := in.AddressCodec.BytesToString(authority) - if err != nil { - panic(err) - } - - // set the governance module account as the authority for conducting upgrades - k := keeper.NewKeeper(skipUpgradeHeights, in.StoreService, in.Cdc, homePath, in.AppVersionModifier, auth) - m := NewAppModule(k, in.AddressCodec) - - return ModuleOutputs{UpgradeKeeper: k, Module: m} -} - -func PopulateVersionMap(upgradeKeeper *keeper.Keeper, modules map[string]appmodule.AppModule) { - if upgradeKeeper == nil { - return - } - - upgradeKeeper.SetInitVersionMap(module.NewManagerFromMap(modules).GetVersionMap()) -} From cdef1181e37d81de36c90da3bd42c4bee407482c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 12 Jan 2024 12:52:41 +0100 Subject: [PATCH 3/8] updates --- UPGRADING.md | 6 +++- docs/architecture/adr-057-app-wiring.md | 39 ++++++++++++------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 3441625bf276..6207265bc3e0 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -82,7 +82,7 @@ for more details. ### Params -* Params Migrations were removed. It is required to migrate to 0.50 prior to upgrading to .51. +* Params migrations were removed. It is required to migrate to 0.50 prior to upgrading to v0.51. ### SimApp @@ -112,6 +112,10 @@ clientCtx = clientCtx. Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a legacy app. +#### Dependency Injection + + + ### Modules #### `**all**` diff --git a/docs/architecture/adr-057-app-wiring.md b/docs/architecture/adr-057-app-wiring.md index a5524fe6b9bf..44b1e75460c2 100644 --- a/docs/architecture/adr-057-app-wiring.md +++ b/docs/architecture/adr-057-app-wiring.md @@ -4,7 +4,7 @@ * 2022-05-04: Initial Draft * 2022-08-19: Updates -* 2024-01-11: Less protobuf-centric (TODO update) +* 2024-01-12: Updates ## Status @@ -75,25 +75,24 @@ than fully static resolution in terms of error reporting and much better in term ### Declarative App Config -In order to compose modules into an app, a declarative app configuration will be used. This configuration is based off -of protobuf and its basic structure is very simple: +In order to compose modules into an app, a declarative app configuration will be used. This configuration is very simple: -```protobuf -package cosmos.app.v1; - -message Config { - repeated ModuleConfig modules = 1; +```go +type AppConfig struct { + // Modules are the module configurations for the app. + Modules []*ModuleConfig `json:"modules,omitempty"` } -message ModuleConfig { - string name = 1; - google.protobuf.Any config = 2; +// ModuleConfig is a module configuration for an app. +type ModuleConfig struct { + // Name is the unique name of the module. + Name string `json:"name,omitempty"` + // Config is the configuration for the module. + Config *any.Any `json:"config,omitempty"` } ``` -(See also https://github.com/cosmos/cosmos-sdk/blob/6e18f582bf69e3926a1e22a6de3c35ea327aadce/proto/cosmos/app/v1alpha1/config.proto) - -The configuration for every module is itself a protobuf message and modules will be identified and loaded based +The configuration for every module is a protobuf message and modules will be identified and loaded based on the protobuf type URL of their config object (ex. `cosmos.bank.module.v1.Module`). Modules are given a unique short `name` to share resources across different versions of the same module which might have a different protobuf package versions (ex. `cosmos.bank.module.v2.Module`). All module config objects should define the `cosmos.app.v1alpha1.module` @@ -182,13 +181,13 @@ Ex: ```go func init() { - appmodule.Register("cosmos.bank.module.v1.Module", - appmodule.Types( + appconfig.Register("cosmos.bank.module.v1.Module", + appconfig.Types( types.Types_tx_proto, types.Types_query_proto, types.Types_types_proto, ), - appmodule.Provide( + appconfig.Provide( provideBankModule, ) ) @@ -251,8 +250,6 @@ defined here are described in [ADR 063: Core Module API](./adr-063-core-module-a ### Registration of Inter-Module Hooks -### Registration of Inter-Module Hooks - Some modules define a hooks interface (ex. `StakingHooks`) which allows one module to call back into another module when certain events happen. @@ -261,9 +258,9 @@ which consumes these hooks can collect these hooks as a map of module name to ho ```go func init() { - appmodule.Register( + appconfig.RegisterModule( &foomodulev1.Module{}, - appmodule.Invoke(InvokeSetFooHooks), + appconfig.Invoke(InvokeSetFooHooks), ... ) } From ac65a4ca1797687fbea8f457187277b842728901 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 12 Jan 2024 13:35:10 +0100 Subject: [PATCH 4/8] partly revert --- api/cosmos/app/v1alpha1/config.pulsar.go | 2090 ++++++++++++++++++++++ baseapp/utils_test.go | 5 +- depinject/appconfig/config.go | 56 +- docs/architecture/adr-057-app-wiring.md | 20 +- orm/model/ormdb/module_test.go | 4 +- orm/orm.go | 3 +- proto/cosmos/app/v1alpha1/config.proto | 55 + runtime/app.go | 4 +- runtime/module.go | 3 +- simapp/app_config.go | 22 +- simapp/app_v2.go | 25 +- simapp/simd/cmd/root_v2.go | 2 +- testutil/configurator/configurator.go | 51 +- x/accounts/go.mod | 2 +- 14 files changed, 2226 insertions(+), 116 deletions(-) create mode 100644 api/cosmos/app/v1alpha1/config.pulsar.go create mode 100644 proto/cosmos/app/v1alpha1/config.proto diff --git a/api/cosmos/app/v1alpha1/config.pulsar.go b/api/cosmos/app/v1alpha1/config.pulsar.go new file mode 100644 index 000000000000..34dfc0d7459c --- /dev/null +++ b/api/cosmos/app/v1alpha1/config.pulsar.go @@ -0,0 +1,2090 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package appv1alpha1 + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + io "io" + reflect "reflect" + sync "sync" +) + +var _ protoreflect.List = (*_Config_1_list)(nil) + +type _Config_1_list struct { + list *[]*ModuleConfig +} + +func (x *_Config_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Config_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Config_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*ModuleConfig) + (*x.list)[i] = concreteValue +} + +func (x *_Config_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*ModuleConfig) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Config_1_list) AppendMutable() protoreflect.Value { + v := new(ModuleConfig) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Config_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Config_1_list) NewElement() protoreflect.Value { + v := new(ModuleConfig) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Config_1_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_Config_2_list)(nil) + +type _Config_2_list struct { + list *[]*GolangBinding +} + +func (x *_Config_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Config_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Config_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*GolangBinding) + (*x.list)[i] = concreteValue +} + +func (x *_Config_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*GolangBinding) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Config_2_list) AppendMutable() protoreflect.Value { + v := new(GolangBinding) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Config_2_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Config_2_list) NewElement() protoreflect.Value { + v := new(GolangBinding) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Config_2_list) IsValid() bool { + return x.list != nil +} + +var ( + md_Config protoreflect.MessageDescriptor + fd_Config_modules protoreflect.FieldDescriptor + fd_Config_golang_bindings protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_app_v1alpha1_config_proto_init() + md_Config = File_cosmos_app_v1alpha1_config_proto.Messages().ByName("Config") + fd_Config_modules = md_Config.Fields().ByName("modules") + fd_Config_golang_bindings = md_Config.Fields().ByName("golang_bindings") +} + +var _ protoreflect.Message = (*fastReflection_Config)(nil) + +type fastReflection_Config Config + +func (x *Config) ProtoReflect() protoreflect.Message { + return (*fastReflection_Config)(x) +} + +func (x *Config) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Config_messageType fastReflection_Config_messageType +var _ protoreflect.MessageType = fastReflection_Config_messageType{} + +type fastReflection_Config_messageType struct{} + +func (x fastReflection_Config_messageType) Zero() protoreflect.Message { + return (*fastReflection_Config)(nil) +} +func (x fastReflection_Config_messageType) New() protoreflect.Message { + return new(fastReflection_Config) +} +func (x fastReflection_Config_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Config +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Config) Descriptor() protoreflect.MessageDescriptor { + return md_Config +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Config) Type() protoreflect.MessageType { + return _fastReflection_Config_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Config) New() protoreflect.Message { + return new(fastReflection_Config) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Config) Interface() protoreflect.ProtoMessage { + return (*Config)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Config) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Modules) != 0 { + value := protoreflect.ValueOfList(&_Config_1_list{list: &x.Modules}) + if !f(fd_Config_modules, value) { + return + } + } + if len(x.GolangBindings) != 0 { + value := protoreflect.ValueOfList(&_Config_2_list{list: &x.GolangBindings}) + if !f(fd_Config_golang_bindings, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Config) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.app.v1alpha1.Config.modules": + return len(x.Modules) != 0 + case "cosmos.app.v1alpha1.Config.golang_bindings": + return len(x.GolangBindings) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Config) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.Config.modules": + x.Modules = nil + case "cosmos.app.v1alpha1.Config.golang_bindings": + x.GolangBindings = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Config) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.app.v1alpha1.Config.modules": + if len(x.Modules) == 0 { + return protoreflect.ValueOfList(&_Config_1_list{}) + } + listValue := &_Config_1_list{list: &x.Modules} + return protoreflect.ValueOfList(listValue) + case "cosmos.app.v1alpha1.Config.golang_bindings": + if len(x.GolangBindings) == 0 { + return protoreflect.ValueOfList(&_Config_2_list{}) + } + listValue := &_Config_2_list{list: &x.GolangBindings} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Config) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.Config.modules": + lv := value.List() + clv := lv.(*_Config_1_list) + x.Modules = *clv.list + case "cosmos.app.v1alpha1.Config.golang_bindings": + lv := value.List() + clv := lv.(*_Config_2_list) + x.GolangBindings = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Config) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.Config.modules": + if x.Modules == nil { + x.Modules = []*ModuleConfig{} + } + value := &_Config_1_list{list: &x.Modules} + return protoreflect.ValueOfList(value) + case "cosmos.app.v1alpha1.Config.golang_bindings": + if x.GolangBindings == nil { + x.GolangBindings = []*GolangBinding{} + } + value := &_Config_2_list{list: &x.GolangBindings} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Config) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.Config.modules": + list := []*ModuleConfig{} + return protoreflect.ValueOfList(&_Config_1_list{list: &list}) + case "cosmos.app.v1alpha1.Config.golang_bindings": + list := []*GolangBinding{} + return protoreflect.ValueOfList(&_Config_2_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.Config")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.Config does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Config) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.Config", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Config) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Config) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Config) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Config) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Config) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if len(x.Modules) > 0 { + for _, e := range x.Modules { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.GolangBindings) > 0 { + for _, e := range x.GolangBindings { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Config) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.GolangBindings) > 0 { + for iNdEx := len(x.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.GolangBindings[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + } + if len(x.Modules) > 0 { + for iNdEx := len(x.Modules) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Modules[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Config) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Config: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Config: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Modules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Modules = append(x.Modules, &ModuleConfig{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Modules[len(x.Modules)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.GolangBindings = append(x.GolangBindings, &GolangBinding{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.GolangBindings[len(x.GolangBindings)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_ModuleConfig_3_list)(nil) + +type _ModuleConfig_3_list struct { + list *[]*GolangBinding +} + +func (x *_ModuleConfig_3_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_ModuleConfig_3_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_ModuleConfig_3_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*GolangBinding) + (*x.list)[i] = concreteValue +} + +func (x *_ModuleConfig_3_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*GolangBinding) + *x.list = append(*x.list, concreteValue) +} + +func (x *_ModuleConfig_3_list) AppendMutable() protoreflect.Value { + v := new(GolangBinding) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_ModuleConfig_3_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_ModuleConfig_3_list) NewElement() protoreflect.Value { + v := new(GolangBinding) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_ModuleConfig_3_list) IsValid() bool { + return x.list != nil +} + +var ( + md_ModuleConfig protoreflect.MessageDescriptor + fd_ModuleConfig_name protoreflect.FieldDescriptor + fd_ModuleConfig_config protoreflect.FieldDescriptor + fd_ModuleConfig_golang_bindings protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_app_v1alpha1_config_proto_init() + md_ModuleConfig = File_cosmos_app_v1alpha1_config_proto.Messages().ByName("ModuleConfig") + fd_ModuleConfig_name = md_ModuleConfig.Fields().ByName("name") + fd_ModuleConfig_config = md_ModuleConfig.Fields().ByName("config") + fd_ModuleConfig_golang_bindings = md_ModuleConfig.Fields().ByName("golang_bindings") +} + +var _ protoreflect.Message = (*fastReflection_ModuleConfig)(nil) + +type fastReflection_ModuleConfig ModuleConfig + +func (x *ModuleConfig) ProtoReflect() protoreflect.Message { + return (*fastReflection_ModuleConfig)(x) +} + +func (x *ModuleConfig) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_ModuleConfig_messageType fastReflection_ModuleConfig_messageType +var _ protoreflect.MessageType = fastReflection_ModuleConfig_messageType{} + +type fastReflection_ModuleConfig_messageType struct{} + +func (x fastReflection_ModuleConfig_messageType) Zero() protoreflect.Message { + return (*fastReflection_ModuleConfig)(nil) +} +func (x fastReflection_ModuleConfig_messageType) New() protoreflect.Message { + return new(fastReflection_ModuleConfig) +} +func (x fastReflection_ModuleConfig_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ModuleConfig +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ModuleConfig) Descriptor() protoreflect.MessageDescriptor { + return md_ModuleConfig +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_ModuleConfig) Type() protoreflect.MessageType { + return _fastReflection_ModuleConfig_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ModuleConfig) New() protoreflect.Message { + return new(fastReflection_ModuleConfig) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ModuleConfig) Interface() protoreflect.ProtoMessage { + return (*ModuleConfig)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_ModuleConfig) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_ModuleConfig_name, value) { + return + } + } + if x.Config != nil { + value := protoreflect.ValueOfMessage(x.Config.ProtoReflect()) + if !f(fd_ModuleConfig_config, value) { + return + } + } + if len(x.GolangBindings) != 0 { + value := protoreflect.ValueOfList(&_ModuleConfig_3_list{list: &x.GolangBindings}) + if !f(fd_ModuleConfig_golang_bindings, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_ModuleConfig) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.app.v1alpha1.ModuleConfig.name": + return x.Name != "" + case "cosmos.app.v1alpha1.ModuleConfig.config": + return x.Config != nil + case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": + return len(x.GolangBindings) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ModuleConfig) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.ModuleConfig.name": + x.Name = "" + case "cosmos.app.v1alpha1.ModuleConfig.config": + x.Config = nil + case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": + x.GolangBindings = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_ModuleConfig) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.app.v1alpha1.ModuleConfig.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "cosmos.app.v1alpha1.ModuleConfig.config": + value := x.Config + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": + if len(x.GolangBindings) == 0 { + return protoreflect.ValueOfList(&_ModuleConfig_3_list{}) + } + listValue := &_ModuleConfig_3_list{list: &x.GolangBindings} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ModuleConfig) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.ModuleConfig.name": + x.Name = value.Interface().(string) + case "cosmos.app.v1alpha1.ModuleConfig.config": + x.Config = value.Message().Interface().(*anypb.Any) + case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": + lv := value.List() + clv := lv.(*_ModuleConfig_3_list) + x.GolangBindings = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ModuleConfig) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.ModuleConfig.config": + if x.Config == nil { + x.Config = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.Config.ProtoReflect()) + case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": + if x.GolangBindings == nil { + x.GolangBindings = []*GolangBinding{} + } + value := &_ModuleConfig_3_list{list: &x.GolangBindings} + return protoreflect.ValueOfList(value) + case "cosmos.app.v1alpha1.ModuleConfig.name": + panic(fmt.Errorf("field name of message cosmos.app.v1alpha1.ModuleConfig is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_ModuleConfig) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.ModuleConfig.name": + return protoreflect.ValueOfString("") + case "cosmos.app.v1alpha1.ModuleConfig.config": + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.app.v1alpha1.ModuleConfig.golang_bindings": + list := []*GolangBinding{} + return protoreflect.ValueOfList(&_ModuleConfig_3_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.ModuleConfig")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.ModuleConfig does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_ModuleConfig) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.ModuleConfig", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_ModuleConfig) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ModuleConfig) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_ModuleConfig) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_ModuleConfig) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ModuleConfig) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Config != nil { + l = options.Size(x.Config) + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.GolangBindings) > 0 { + for _, e := range x.GolangBindings { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*ModuleConfig) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.GolangBindings) > 0 { + for iNdEx := len(x.GolangBindings) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.GolangBindings[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + } + if x.Config != nil { + encoded, err := options.Marshal(x.Config) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ModuleConfig) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ModuleConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ModuleConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Config == nil { + x.Config = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Config); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field GolangBindings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.GolangBindings = append(x.GolangBindings, &GolangBinding{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.GolangBindings[len(x.GolangBindings)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_GolangBinding protoreflect.MessageDescriptor + fd_GolangBinding_interface_type protoreflect.FieldDescriptor + fd_GolangBinding_implementation protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_app_v1alpha1_config_proto_init() + md_GolangBinding = File_cosmos_app_v1alpha1_config_proto.Messages().ByName("GolangBinding") + fd_GolangBinding_interface_type = md_GolangBinding.Fields().ByName("interface_type") + fd_GolangBinding_implementation = md_GolangBinding.Fields().ByName("implementation") +} + +var _ protoreflect.Message = (*fastReflection_GolangBinding)(nil) + +type fastReflection_GolangBinding GolangBinding + +func (x *GolangBinding) ProtoReflect() protoreflect.Message { + return (*fastReflection_GolangBinding)(x) +} + +func (x *GolangBinding) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_GolangBinding_messageType fastReflection_GolangBinding_messageType +var _ protoreflect.MessageType = fastReflection_GolangBinding_messageType{} + +type fastReflection_GolangBinding_messageType struct{} + +func (x fastReflection_GolangBinding_messageType) Zero() protoreflect.Message { + return (*fastReflection_GolangBinding)(nil) +} +func (x fastReflection_GolangBinding_messageType) New() protoreflect.Message { + return new(fastReflection_GolangBinding) +} +func (x fastReflection_GolangBinding_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GolangBinding +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GolangBinding) Descriptor() protoreflect.MessageDescriptor { + return md_GolangBinding +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_GolangBinding) Type() protoreflect.MessageType { + return _fastReflection_GolangBinding_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GolangBinding) New() protoreflect.Message { + return new(fastReflection_GolangBinding) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GolangBinding) Interface() protoreflect.ProtoMessage { + return (*GolangBinding)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_GolangBinding) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.InterfaceType != "" { + value := protoreflect.ValueOfString(x.InterfaceType) + if !f(fd_GolangBinding_interface_type, value) { + return + } + } + if x.Implementation != "" { + value := protoreflect.ValueOfString(x.Implementation) + if !f(fd_GolangBinding_implementation, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_GolangBinding) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.app.v1alpha1.GolangBinding.interface_type": + return x.InterfaceType != "" + case "cosmos.app.v1alpha1.GolangBinding.implementation": + return x.Implementation != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_GolangBinding) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.GolangBinding.interface_type": + x.InterfaceType = "" + case "cosmos.app.v1alpha1.GolangBinding.implementation": + x.Implementation = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_GolangBinding) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.app.v1alpha1.GolangBinding.interface_type": + value := x.InterfaceType + return protoreflect.ValueOfString(value) + case "cosmos.app.v1alpha1.GolangBinding.implementation": + value := x.Implementation + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_GolangBinding) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.GolangBinding.interface_type": + x.InterfaceType = value.Interface().(string) + case "cosmos.app.v1alpha1.GolangBinding.implementation": + x.Implementation = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_GolangBinding) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.GolangBinding.interface_type": + panic(fmt.Errorf("field interface_type of message cosmos.app.v1alpha1.GolangBinding is not mutable")) + case "cosmos.app.v1alpha1.GolangBinding.implementation": + panic(fmt.Errorf("field implementation of message cosmos.app.v1alpha1.GolangBinding is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_GolangBinding) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.GolangBinding.interface_type": + return protoreflect.ValueOfString("") + case "cosmos.app.v1alpha1.GolangBinding.implementation": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.GolangBinding")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.GolangBinding does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_GolangBinding) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.GolangBinding", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_GolangBinding) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_GolangBinding) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_GolangBinding) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_GolangBinding) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GolangBinding) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.InterfaceType) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Implementation) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*GolangBinding) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Implementation) > 0 { + i -= len(x.Implementation) + copy(dAtA[i:], x.Implementation) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Implementation))) + i-- + dAtA[i] = 0x12 + } + if len(x.InterfaceType) > 0 { + i -= len(x.InterfaceType) + copy(dAtA[i:], x.InterfaceType) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.InterfaceType))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*GolangBinding) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GolangBinding: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GolangBinding: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field InterfaceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.InterfaceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Implementation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Implementation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/app/v1alpha1/config.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Config represents the configuration for a Cosmos SDK ABCI app. +// It is intended that all state machine logic including the version of +// baseapp and tx handlers (and possibly even Tendermint) that an app needs +// can be described in a config object. For compatibility, the framework should +// allow a mixture of declarative and imperative app wiring, however, apps +// that strive for the maximum ease of maintainability should be able to describe +// their state machine with a config object alone. +type Config struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // modules are the module configurations for the app. + Modules []*ModuleConfig `protobuf:"bytes,1,rep,name=modules,proto3" json:"modules,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is global (not module specific). + GolangBindings []*GolangBinding `protobuf:"bytes,2,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` +} + +func (x *Config) Reset() { + *x = Config{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Config) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Config) ProtoMessage() {} + +// Deprecated: Use Config.ProtoReflect.Descriptor instead. +func (*Config) Descriptor() ([]byte, []int) { + return file_cosmos_app_v1alpha1_config_proto_rawDescGZIP(), []int{0} +} + +func (x *Config) GetModules() []*ModuleConfig { + if x != nil { + return x.Modules + } + return nil +} + +func (x *Config) GetGolangBindings() []*GolangBinding { + if x != nil { + return x.GolangBindings + } + return nil +} + +// ModuleConfig is a module configuration for an app. +type ModuleConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // name is the unique name of the module within the app. It should be a name + // that persists between different versions of a module so that modules + // can be smoothly upgraded to new versions. + // + // For example, for the module cosmos.bank.module.v1.Module, we may chose + // to simply name the module "bank" in the app. When we upgrade to + // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + // and the framework knows that the v2 module should receive all the same state + // that the v1 module had. Note: modules should provide info on which versions + // they can migrate from in the ModuleDescriptor.can_migration_from field. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // config is the config object for the module. Module config messages should + // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + Config *anypb.Any `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"` + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is module specific. + GolangBindings []*GolangBinding `protobuf:"bytes,3,rep,name=golang_bindings,json=golangBindings,proto3" json:"golang_bindings,omitempty"` +} + +func (x *ModuleConfig) Reset() { + *x = ModuleConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ModuleConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ModuleConfig) ProtoMessage() {} + +// Deprecated: Use ModuleConfig.ProtoReflect.Descriptor instead. +func (*ModuleConfig) Descriptor() ([]byte, []int) { + return file_cosmos_app_v1alpha1_config_proto_rawDescGZIP(), []int{1} +} + +func (x *ModuleConfig) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ModuleConfig) GetConfig() *anypb.Any { + if x != nil { + return x.Config + } + return nil +} + +func (x *ModuleConfig) GetGolangBindings() []*GolangBinding { + if x != nil { + return x.GolangBindings + } + return nil +} + +// GolangBinding is an explicit interface type to implementing type binding for dependency injection. +type GolangBinding struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // interface_type is the interface type which will be bound to a specific implementation type + InterfaceType string `protobuf:"bytes,1,opt,name=interface_type,json=interfaceType,proto3" json:"interface_type,omitempty"` + // implementation is the implementing type which will be supplied when an input of type interface is requested + Implementation string `protobuf:"bytes,2,opt,name=implementation,proto3" json:"implementation,omitempty"` +} + +func (x *GolangBinding) Reset() { + *x = GolangBinding{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_app_v1alpha1_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GolangBinding) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GolangBinding) ProtoMessage() {} + +// Deprecated: Use GolangBinding.ProtoReflect.Descriptor instead. +func (*GolangBinding) Descriptor() ([]byte, []int) { + return file_cosmos_app_v1alpha1_config_proto_rawDescGZIP(), []int{2} +} + +func (x *GolangBinding) GetInterfaceType() string { + if x != nil { + return x.InterfaceType + } + return "" +} + +func (x *GolangBinding) GetImplementation() string { + if x != nil { + return x.Implementation + } + return "" +} + +var File_cosmos_app_v1alpha1_config_proto protoreflect.FileDescriptor + +var file_cosmos_app_v1alpha1_config_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x92, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, + 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x07, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x4b, 0x0a, 0x0f, 0x67, 0x6f, + 0x6c, 0x61, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x6f, 0x6c, 0x61, 0x6e, 0x67, + 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x0e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x42, + 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x9d, 0x01, 0x0a, 0x0c, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x06, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, + 0x6e, 0x79, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4b, 0x0a, 0x0f, 0x67, 0x6f, + 0x6c, 0x61, 0x6e, 0x67, 0x5f, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x47, 0x6f, 0x6c, 0x61, 0x6e, 0x67, + 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x0e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x42, + 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x5e, 0x0a, 0x0d, 0x47, 0x6f, 0x6c, 0x61, 0x6e, + 0x67, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x26, 0x0a, 0x0e, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xc6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, + 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_app_v1alpha1_config_proto_rawDescOnce sync.Once + file_cosmos_app_v1alpha1_config_proto_rawDescData = file_cosmos_app_v1alpha1_config_proto_rawDesc +) + +func file_cosmos_app_v1alpha1_config_proto_rawDescGZIP() []byte { + file_cosmos_app_v1alpha1_config_proto_rawDescOnce.Do(func() { + file_cosmos_app_v1alpha1_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_app_v1alpha1_config_proto_rawDescData) + }) + return file_cosmos_app_v1alpha1_config_proto_rawDescData +} + +var file_cosmos_app_v1alpha1_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_cosmos_app_v1alpha1_config_proto_goTypes = []interface{}{ + (*Config)(nil), // 0: cosmos.app.v1alpha1.Config + (*ModuleConfig)(nil), // 1: cosmos.app.v1alpha1.ModuleConfig + (*GolangBinding)(nil), // 2: cosmos.app.v1alpha1.GolangBinding + (*anypb.Any)(nil), // 3: google.protobuf.Any +} +var file_cosmos_app_v1alpha1_config_proto_depIdxs = []int32{ + 1, // 0: cosmos.app.v1alpha1.Config.modules:type_name -> cosmos.app.v1alpha1.ModuleConfig + 2, // 1: cosmos.app.v1alpha1.Config.golang_bindings:type_name -> cosmos.app.v1alpha1.GolangBinding + 3, // 2: cosmos.app.v1alpha1.ModuleConfig.config:type_name -> google.protobuf.Any + 2, // 3: cosmos.app.v1alpha1.ModuleConfig.golang_bindings:type_name -> cosmos.app.v1alpha1.GolangBinding + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_cosmos_app_v1alpha1_config_proto_init() } +func file_cosmos_app_v1alpha1_config_proto_init() { + if File_cosmos_app_v1alpha1_config_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmos_app_v1alpha1_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_app_v1alpha1_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ModuleConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_app_v1alpha1_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GolangBinding); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cosmos_app_v1alpha1_config_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_cosmos_app_v1alpha1_config_proto_goTypes, + DependencyIndexes: file_cosmos_app_v1alpha1_config_proto_depIdxs, + MessageInfos: file_cosmos_app_v1alpha1_config_proto_msgTypes, + }.Build() + File_cosmos_app_v1alpha1_config_proto = out.File + file_cosmos_app_v1alpha1_config_proto_rawDesc = nil + file_cosmos_app_v1alpha1_config_proto_goTypes = nil + file_cosmos_app_v1alpha1_config_proto_depIdxs = nil +} diff --git a/baseapp/utils_test.go b/baseapp/utils_test.go index afb08bae1cf2..160ecac8a98d 100644 --- a/baseapp/utils_test.go +++ b/baseapp/utils_test.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/require" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/address" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" @@ -93,8 +94,8 @@ func makeMinimalConfig() depinject.Config { return depinject.Configs( depinject.Supply(mempoolOpt, addressCodec, validatorAddressCodec, consensusAddressCodec), - appconfig.Compose(&appconfig.AppConfig{ - Modules: []*appconfig.ModuleConfig{ + appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ { Name: "runtime", Config: appconfig.WrapAny(&runtimev1alpha1.Module{ diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index 6dd5c7d7d99b..4bc44f6ace0b 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -1,11 +1,11 @@ package appconfig import ( - "encoding/json" "fmt" "strings" "github.com/cosmos/cosmos-proto/anyutil" + "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" @@ -17,56 +17,10 @@ import ( internal "cosmossdk.io/depinject/internal/appconfig" ) -// Config represents the configuration for a Cosmos SDK ABCI app. -// It is intended that all state machine logic including the version of -// baseapp and tx handlers (and possibly even Tendermint) that an app needs -// can be described in a config object. For compatibility, the framework should -// allow a mixture of declarative and imperative app wiring, however, apps -// that strive for the maximum ease of maintainability should be able to describe -// their state machine with a config object alone. -type AppConfig struct { - // Modules are the module configurations for the app. - Modules []*ModuleConfig `json:"modules,omitempty"` - // golang_bindings specifies explicit interface to implementation type bindings which - // depinject uses to resolve interface inputs to provider functions. The scope of this - // field's configuration is global (not module specific). - GolangBindings []*GolangBinding `json:"golang_bindings,omitempty"` -} - -// ModuleConfig is a module configuration for an app. -type ModuleConfig struct { - // Name is the unique name of the module within the app. It should be a name - // that persists between different versions of a module so that modules - // can be smoothly upgraded to new versions. - // - // For example, for the module cosmos.bank.module.v1.Module, we may chose - // to simply name the module "bank" in the app. When we upgrade to - // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same - // and the framework knows that the v2 module should receive all the same state - // that the v1 module had. Note: modules should provide info on which versions - // they can migrate from in the ModuleDescriptor.can_migration_from field. - Name string `json:"name,omitempty"` - // Config is the config object for the module. Module config messages should - // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. - Config *anypb.Any `json:"config,omitempty"` - // golang_bindings specifies explicit interface to implementation type bindings which - // depinject uses to resolve interface inputs to provider functions. The scope of this - // field's configuration is module specific. - GolangBindings []*GolangBinding `json:"golang_bindings,omitempty"` -} - -// GolangBinding is an explicit interface type to implementing type binding for dependency injection. -type GolangBinding struct { - // InterfaceType is the interface type which will be bound to a specific implementation type - InterfaceType string `json:"interface_type,omitempty"` - // Implementation is the implementing type which will be supplied when an input of type interface is requested - Implementation string `json:"implementation,omitempty"` -} - // LoadJSON loads an app config in JSON format. func LoadJSON(bz []byte) depinject.Config { - config := &AppConfig{} - err := json.Unmarshal(bz, config) + config := &appv1alpha1.Config{} + err := protojson.Unmarshal(bz, config) if err != nil { return depinject.Error(err) } @@ -94,9 +48,9 @@ func WrapAny(config protoreflect.ProtoMessage) *anypb.Any { return cfg } -// Compose composes an app config into a container option by resolving +// Compose composes a v1alpha1 app config into a container option by resolving // the required modules and composing their options. -func Compose(appConfig *AppConfig) depinject.Config { +func Compose(appConfig *appv1alpha1.Config) depinject.Config { opts := []depinject.Config{ depinject.Supply(appConfig), } diff --git a/docs/architecture/adr-057-app-wiring.md b/docs/architecture/adr-057-app-wiring.md index 44b1e75460c2..239e7d52b352 100644 --- a/docs/architecture/adr-057-app-wiring.md +++ b/docs/architecture/adr-057-app-wiring.md @@ -75,20 +75,18 @@ than fully static resolution in terms of error reporting and much better in term ### Declarative App Config -In order to compose modules into an app, a declarative app configuration will be used. This configuration is very simple: +In order to compose modules into an app, a declarative app configuration will be used. This configuration is based off +of protobuf and its basic structure is very simple: -```go -type AppConfig struct { - // Modules are the module configurations for the app. - Modules []*ModuleConfig `json:"modules,omitempty"` +```protobuf +package cosmos.app.v1; +message Config { + repeated ModuleConfig modules = 1; } -// ModuleConfig is a module configuration for an app. -type ModuleConfig struct { - // Name is the unique name of the module. - Name string `json:"name,omitempty"` - // Config is the configuration for the module. - Config *any.Any `json:"config,omitempty"` +message ModuleConfig { + string name = 1; + google.protobuf.Any config = 2; } ``` diff --git a/orm/model/ormdb/module_test.go b/orm/model/ormdb/module_test.go index b60116ce24b1..18c7f558782e 100644 --- a/orm/model/ormdb/module_test.go +++ b/orm/model/ormdb/module_test.go @@ -398,8 +398,8 @@ func ProvideTestRuntime() store.KVStoreService { } func TestAppConfigModule(t *testing.T) { - appCfg := appconfig.Compose(&appconfig.AppConfig{ - Modules: []*appconfig.ModuleConfig{ + appCfg := appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ {Name: "bank", Config: appconfig.WrapAny(&testpb.Module{})}, {Name: "orm", Config: appconfig.WrapAny(&ormmodulev1alpha1.Module{})}, }, diff --git a/orm/orm.go b/orm/orm.go index 3e81e1f8e7f2..cd292e18da29 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -7,6 +7,7 @@ import ( "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoregistry" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" modulev1alpha1 "cosmossdk.io/api/cosmos/orm/module/v1alpha1" ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1" "cosmossdk.io/core/store" @@ -26,7 +27,7 @@ func init() { type ModuleDBInputs struct { depinject.In - AppConfig *appconfig.AppConfig + AppConfig *appv1alpha1.Config KVStoreService store.KVStoreService MemoryStoreService store.MemoryStoreService `optional:"true"` TransientStoreService store.TransientStoreService `optional:"true"` diff --git a/proto/cosmos/app/v1alpha1/config.proto b/proto/cosmos/app/v1alpha1/config.proto new file mode 100644 index 000000000000..ee3e70659e4b --- /dev/null +++ b/proto/cosmos/app/v1alpha1/config.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; + +package cosmos.app.v1alpha1; + +import "google/protobuf/any.proto"; + +// Config represents the configuration for a Cosmos SDK ABCI app. +// It is intended that all state machine logic including the version of +// baseapp and tx handlers (and possibly even Tendermint) that an app needs +// can be described in a config object. For compatibility, the framework should +// allow a mixture of declarative and imperative app wiring, however, apps +// that strive for the maximum ease of maintainability should be able to describe +// their state machine with a config object alone. +message Config { + // modules are the module configurations for the app. + repeated ModuleConfig modules = 1; + + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is global (not module specific). + repeated GolangBinding golang_bindings = 2; +} + +// ModuleConfig is a module configuration for an app. +message ModuleConfig { + // name is the unique name of the module within the app. It should be a name + // that persists between different versions of a module so that modules + // can be smoothly upgraded to new versions. + // + // For example, for the module cosmos.bank.module.v1.Module, we may chose + // to simply name the module "bank" in the app. When we upgrade to + // cosmos.bank.module.v2.Module, the app-specific name "bank" stays the same + // and the framework knows that the v2 module should receive all the same state + // that the v1 module had. Note: modules should provide info on which versions + // they can migrate from in the ModuleDescriptor.can_migration_from field. + string name = 1; + + // config is the config object for the module. Module config messages should + // define a ModuleDescriptor using the cosmos.app.v1alpha1.is_module extension. + google.protobuf.Any config = 2; + + // golang_bindings specifies explicit interface to implementation type bindings which + // depinject uses to resolve interface inputs to provider functions. The scope of this + // field's configuration is module specific. + repeated GolangBinding golang_bindings = 3; +} + +// GolangBinding is an explicit interface type to implementing type binding for dependency injection. +message GolangBinding { + // interface_type is the interface type which will be bound to a specific implementation type + string interface_type = 1; + + // implementation is the implementing type which will be supplied when an input of type interface is requested + string implementation = 2; +} \ No newline at end of file diff --git a/runtime/app.go b/runtime/app.go index bd8b5684403f..9b07970ff428 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -8,8 +8,8 @@ import ( "golang.org/x/exp/slices" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/appmodule" - "cosmossdk.io/depinject/appconfig" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtx "cosmossdk.io/x/auth/tx" @@ -50,7 +50,7 @@ type App struct { basicManager module.BasicManager baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter - appConfig *appconfig.AppConfig + appConfig *appv1alpha1.Config logger log.Logger // initChainer is the init chainer function defined by the app config. // this is only required if the chain wants to add special InitChainer logic. diff --git a/runtime/module.go b/runtime/module.go index 6029439d7e24..888bdef52c5e 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -9,6 +9,7 @@ import ( "google.golang.org/protobuf/reflect/protoregistry" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/core/address" @@ -121,7 +122,7 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( type AppInputs struct { depinject.In - AppConfig *appconfig.AppConfig + AppConfig *appv1alpha1.Config Config *runtimev1alpha1.Module AppBuilder *AppBuilder Modules map[string]appmodule.AppModule diff --git a/simapp/app_config.go b/simapp/app_config.go index 71061cf1c668..79f73dcf1e73 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -6,6 +6,7 @@ import ( "google.golang.org/protobuf/types/known/durationpb" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" @@ -25,7 +26,6 @@ import ( txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1" vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" - "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" _ "cosmossdk.io/x/auth/tx/config" // import for side-effects authtypes "cosmossdk.io/x/auth/types" @@ -43,8 +43,6 @@ import ( evidencetypes "cosmossdk.io/x/evidence/types" "cosmossdk.io/x/feegrant" _ "cosmossdk.io/x/feegrant/module" // import for side-effects - "cosmossdk.io/x/gov" - govclient "cosmossdk.io/x/gov/client" govtypes "cosmossdk.io/x/gov/types" "cosmossdk.io/x/group" _ "cosmossdk.io/x/group/module" // import for side-effects @@ -62,10 +60,8 @@ import ( upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/runtime" - "github.com/cosmos/cosmos-sdk/types/module" _ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -96,8 +92,8 @@ var ( } // application configuration (used by depinject) - AppConfig = depinject.Configs(appconfig.Compose(&appconfig.AppConfig{ - Modules: []*appconfig.ModuleConfig{ + appConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ { Name: runtime.ModuleName, Config: appconfig.WrapAny(&runtimev1alpha1.Module{ @@ -252,15 +248,5 @@ var ( Name: pooltypes.ModuleName, Config: appconfig.WrapAny(&poolmodulev1.Module{}), }, - }, - }), - depinject.Supply( - // supply custom module basics - map[string]module.AppModuleBasic{ - genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - govtypes.ModuleName: gov.NewAppModuleBasic( - []govclient.ProposalHandler{}, - ), - }, - )) + }}) ) diff --git a/simapp/app_v2.go b/simapp/app_v2.go index 0c4ea6f63ac8..3b42c12c1043 100644 --- a/simapp/app_v2.go +++ b/simapp/app_v2.go @@ -3,6 +3,7 @@ package simapp import ( + _ "embed" "fmt" "io" "os" @@ -25,7 +26,10 @@ import ( distrkeeper "cosmossdk.io/x/distribution/keeper" evidencekeeper "cosmossdk.io/x/evidence/keeper" feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + "cosmossdk.io/x/gov" + govclient "cosmossdk.io/x/gov/client" govkeeper "cosmossdk.io/x/gov/keeper" + govtypes "cosmossdk.io/x/gov/types" groupkeeper "cosmossdk.io/x/group/keeper" mintkeeper "cosmossdk.io/x/mint/keeper" nftkeeper "cosmossdk.io/x/nft/keeper" @@ -48,6 +52,8 @@ import ( testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" "github.com/cosmos/cosmos-sdk/types/module" consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) // DefaultNodeHome default home directories for the application daemon @@ -101,6 +107,23 @@ func init() { DefaultNodeHome = filepath.Join(userHomeDir, ".simapp") } +// AppConfig returns the default app config. +func AppConfig() depinject.Config { + return depinject.Configs( + // appconfig.LoadYAML(AppConfigYAML), + appConfig, + depinject.Supply( + // supply custom module basics + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + []govclient.ProposalHandler{}, + ), + }, + ), + ) +} + // NewSimApp returns a reference to an initialized SimApp. func NewSimApp( logger log.Logger, @@ -116,7 +139,7 @@ func NewSimApp( // merge the AppConfig and other configuration in one config appConfig = depinject.Configs( - AppConfig, + AppConfig(), depinject.Supply( // supply the application options appOpts, diff --git a/simapp/simd/cmd/root_v2.go b/simapp/simd/cmd/root_v2.go index de8bcc17cac2..48f5039ab9bf 100644 --- a/simapp/simd/cmd/root_v2.go +++ b/simapp/simd/cmd/root_v2.go @@ -37,7 +37,7 @@ func NewRootCmd() *cobra.Command { ) if err := depinject.Inject( - depinject.Configs(simapp.AppConfig, + depinject.Configs(simapp.AppConfig(), depinject.Supply( log.NewNopLogger(), simtestutil.NewAppOptionsWithFlagHome(tempDir()), diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index cdfa7d3e57b6..b6e13d8e7da6 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -2,6 +2,7 @@ package configurator import ( runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" @@ -30,7 +31,7 @@ import ( // Config should never need to be instantiated manually and is solely used for ModuleOption. type Config struct { - ModuleConfigs map[string]*appconfig.ModuleConfig + ModuleConfigs map[string]*appv1alpha1.ModuleConfig PreBlockersOrder []string BeginBlockersOrder []string EndBlockersOrder []string @@ -40,7 +41,7 @@ type Config struct { func defaultConfig() *Config { return &Config{ - ModuleConfigs: make(map[string]*appconfig.ModuleConfig), + ModuleConfigs: make(map[string]*appv1alpha1.ModuleConfig), PreBlockersOrder: []string{ testutil.UpgradeModuleName, }, @@ -138,7 +139,7 @@ func WithCustomInitGenesisOrder(initGenesisOrder ...string) ModuleOption { func BankModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.BankModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.BankModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.BankModuleName, Config: appconfig.WrapAny(&bankmodulev1.Module{}), } @@ -147,7 +148,7 @@ func BankModule() ModuleOption { func AuthModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.AuthModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.AuthModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.AuthModuleName, Config: appconfig.WrapAny(&authmodulev1.Module{ Bech32Prefix: "cosmos", @@ -168,7 +169,7 @@ func AuthModule() ModuleOption { func ParamsModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.ParamsModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.ParamsModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.ParamsModuleName, Config: appconfig.WrapAny(¶msmodulev1.Module{}), } @@ -177,7 +178,7 @@ func ParamsModule() ModuleOption { func TxModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.TxModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.TxModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.TxModuleName, Config: appconfig.WrapAny(&txconfigv1.Config{}), } @@ -186,7 +187,7 @@ func TxModule() ModuleOption { func StakingModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.StakingModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.StakingModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.StakingModuleName, Config: appconfig.WrapAny(&stakingmodulev1.Module{}), } @@ -195,7 +196,7 @@ func StakingModule() ModuleOption { func SlashingModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.SlashingModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.SlashingModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.SlashingModuleName, Config: appconfig.WrapAny(&slashingmodulev1.Module{}), } @@ -204,7 +205,7 @@ func SlashingModule() ModuleOption { func GenutilModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["genutil"] = &appconfig.ModuleConfig{ + config.ModuleConfigs["genutil"] = &appv1alpha1.ModuleConfig{ Name: "genutil", Config: appconfig.WrapAny(&genutilmodulev1.Module{}), } @@ -213,7 +214,7 @@ func GenutilModule() ModuleOption { func DistributionModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.DistributionModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.DistributionModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.DistributionModuleName, Config: appconfig.WrapAny(&distrmodulev1.Module{}), } @@ -222,7 +223,7 @@ func DistributionModule() ModuleOption { func FeegrantModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.FeegrantModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.FeegrantModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.FeegrantModuleName, Config: appconfig.WrapAny(&feegrantmodulev1.Module{}), } @@ -231,7 +232,7 @@ func FeegrantModule() ModuleOption { func VestingModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["vesting"] = &appconfig.ModuleConfig{ + config.ModuleConfigs["vesting"] = &appv1alpha1.ModuleConfig{ Name: "vesting", Config: appconfig.WrapAny(&vestingmodulev1.Module{}), } @@ -240,7 +241,7 @@ func VestingModule() ModuleOption { func GovModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.GovModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.GovModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.GovModuleName, Config: appconfig.WrapAny(&govmodulev1.Module{}), } @@ -249,7 +250,7 @@ func GovModule() ModuleOption { func ConsensusModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["consensus"] = &appconfig.ModuleConfig{ + config.ModuleConfigs["consensus"] = &appv1alpha1.ModuleConfig{ Name: "consensus", Config: appconfig.WrapAny(&consensusmodulev1.Module{}), } @@ -258,10 +259,10 @@ func ConsensusModule() ModuleOption { func MintModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.MintModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.MintModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.MintModuleName, Config: appconfig.WrapAny(&mintmodulev1.Module{}), - GolangBindings: []*appconfig.GolangBinding{ + GolangBindings: []*appv1alpha1.GolangBinding{ { InterfaceType: "cosmossdk.io/x/mint/types/types.StakingKeeper", Implementation: "cosmossdk.io/x/staking/keeper/*keeper.Keeper", @@ -273,7 +274,7 @@ func MintModule() ModuleOption { func EvidenceModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.EvidenceModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.EvidenceModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.EvidenceModuleName, Config: appconfig.WrapAny(&evidencemodulev1.Module{}), } @@ -282,7 +283,7 @@ func EvidenceModule() ModuleOption { func AuthzModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.AuthzModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.AuthzModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.AuthzModuleName, Config: appconfig.WrapAny(&authzmodulev1.Module{}), } @@ -291,7 +292,7 @@ func AuthzModule() ModuleOption { func GroupModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.GroupModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.GroupModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.GroupModuleName, Config: appconfig.WrapAny(&groupmodulev1.Module{}), } @@ -300,7 +301,7 @@ func GroupModule() ModuleOption { func NFTModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.NFTModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.NFTModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.NFTModuleName, Config: appconfig.WrapAny(&nftmodulev1.Module{}), } @@ -309,7 +310,7 @@ func NFTModule() ModuleOption { func CircuitModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.CircuitModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.CircuitModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.CircuitModuleName, Config: appconfig.WrapAny(&circuitmodulev1.Module{}), } @@ -318,7 +319,7 @@ func CircuitModule() ModuleOption { func ProtocolPoolModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs[testutil.ProtocolPoolModuleName] = &appconfig.ModuleConfig{ + config.ModuleConfigs[testutil.ProtocolPoolModuleName] = &appv1alpha1.ModuleConfig{ Name: testutil.ProtocolPoolModuleName, Config: appconfig.WrapAny(&poolmodulev1.Module{}), } @@ -327,7 +328,7 @@ func ProtocolPoolModule() ModuleOption { func CounterModule() ModuleOption { return func(config *Config) { - config.ModuleConfigs["counter"] = &appconfig.ModuleConfig{ + config.ModuleConfigs["counter"] = &appv1alpha1.ModuleConfig{ Name: "counter", Config: appconfig.WrapAny(&countermodulev1.Module{}), } @@ -391,7 +392,7 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config { runtimeConfig.InitGenesis = initGenesis } - modules := []*appconfig.ModuleConfig{{ + modules := []*appv1alpha1.ModuleConfig{{ Name: "runtime", Config: appconfig.WrapAny(runtimeConfig), }} @@ -400,5 +401,5 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config { modules = append(modules, m) } - return appconfig.Compose(&appconfig.AppConfig{Modules: modules}) + return appconfig.Compose(&appv1alpha1.Config{Modules: modules}) } diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 44bd0f975256..35c8611b30f8 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -6,6 +6,7 @@ require ( cosmossdk.io/api v0.7.3-0.20231113122742-912390d5fc4a cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 + cosmossdk.io/depinject v1.0.0-alpha.4 github.com/cosmos/cosmos-sdk v0.51.0 github.com/cosmos/gogoproto v1.4.11 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -17,7 +18,6 @@ require ( ) require ( - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.0 // indirect cosmossdk.io/math v1.2.0 // indirect From 054752ef47c6a9f2d1150653463309e4eb8054fd Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Sat, 13 Jan 2024 21:19:49 +0100 Subject: [PATCH 5/8] updates --- api/cosmos/app/v1alpha1/query.pulsar.go | 999 ++++++++++++++++++++++ api/cosmos/app/v1alpha1/query_grpc.pb.go | 114 +++ depinject/internal/appconfig/buf.gen.yaml | 2 +- proto/cosmos/app/v1alpha1/query.proto | 24 + 4 files changed, 1138 insertions(+), 1 deletion(-) create mode 100644 api/cosmos/app/v1alpha1/query.pulsar.go create mode 100644 api/cosmos/app/v1alpha1/query_grpc.pb.go create mode 100644 proto/cosmos/app/v1alpha1/query.proto diff --git a/api/cosmos/app/v1alpha1/query.pulsar.go b/api/cosmos/app/v1alpha1/query.pulsar.go new file mode 100644 index 000000000000..978824645c58 --- /dev/null +++ b/api/cosmos/app/v1alpha1/query.pulsar.go @@ -0,0 +1,999 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package appv1alpha1 + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_QueryConfigRequest protoreflect.MessageDescriptor +) + +func init() { + file_cosmos_app_v1alpha1_query_proto_init() + md_QueryConfigRequest = File_cosmos_app_v1alpha1_query_proto.Messages().ByName("QueryConfigRequest") +} + +var _ protoreflect.Message = (*fastReflection_QueryConfigRequest)(nil) + +type fastReflection_QueryConfigRequest QueryConfigRequest + +func (x *QueryConfigRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryConfigRequest)(x) +} + +func (x *QueryConfigRequest) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryConfigRequest_messageType fastReflection_QueryConfigRequest_messageType +var _ protoreflect.MessageType = fastReflection_QueryConfigRequest_messageType{} + +type fastReflection_QueryConfigRequest_messageType struct{} + +func (x fastReflection_QueryConfigRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryConfigRequest)(nil) +} +func (x fastReflection_QueryConfigRequest_messageType) New() protoreflect.Message { + return new(fastReflection_QueryConfigRequest) +} +func (x fastReflection_QueryConfigRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryConfigRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryConfigRequest) Descriptor() protoreflect.MessageDescriptor { + return md_QueryConfigRequest +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_QueryConfigRequest) Type() protoreflect.MessageType { + return _fastReflection_QueryConfigRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryConfigRequest) New() protoreflect.Message { + return new(fastReflection_QueryConfigRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryConfigRequest) Interface() protoreflect.ProtoMessage { + return (*QueryConfigRequest)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryConfigRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryConfigRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryConfigRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_QueryConfigRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigRequest")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigRequest does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_QueryConfigRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.QueryConfigRequest", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryConfigRequest) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigRequest) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryConfigRequest) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryConfigRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryConfigRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryConfigRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryConfigRequest) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_QueryConfigResponse protoreflect.MessageDescriptor + fd_QueryConfigResponse_config protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_app_v1alpha1_query_proto_init() + md_QueryConfigResponse = File_cosmos_app_v1alpha1_query_proto.Messages().ByName("QueryConfigResponse") + fd_QueryConfigResponse_config = md_QueryConfigResponse.Fields().ByName("config") +} + +var _ protoreflect.Message = (*fastReflection_QueryConfigResponse)(nil) + +type fastReflection_QueryConfigResponse QueryConfigResponse + +func (x *QueryConfigResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_QueryConfigResponse)(x) +} + +func (x *QueryConfigResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_QueryConfigResponse_messageType fastReflection_QueryConfigResponse_messageType +var _ protoreflect.MessageType = fastReflection_QueryConfigResponse_messageType{} + +type fastReflection_QueryConfigResponse_messageType struct{} + +func (x fastReflection_QueryConfigResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_QueryConfigResponse)(nil) +} +func (x fastReflection_QueryConfigResponse_messageType) New() protoreflect.Message { + return new(fastReflection_QueryConfigResponse) +} +func (x fastReflection_QueryConfigResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_QueryConfigResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_QueryConfigResponse) Descriptor() protoreflect.MessageDescriptor { + return md_QueryConfigResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_QueryConfigResponse) Type() protoreflect.MessageType { + return _fastReflection_QueryConfigResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_QueryConfigResponse) New() protoreflect.Message { + return new(fastReflection_QueryConfigResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_QueryConfigResponse) Interface() protoreflect.ProtoMessage { + return (*QueryConfigResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_QueryConfigResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Config != nil { + value := protoreflect.ValueOfMessage(x.Config.ProtoReflect()) + if !f(fd_QueryConfigResponse_config, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_QueryConfigResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.app.v1alpha1.QueryConfigResponse.config": + return x.Config != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.QueryConfigResponse.config": + x.Config = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_QueryConfigResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.app.v1alpha1.QueryConfigResponse.config": + value := x.Config + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.app.v1alpha1.QueryConfigResponse.config": + x.Config = value.Message().Interface().(*Config) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.QueryConfigResponse.config": + if x.Config == nil { + x.Config = new(Config) + } + return protoreflect.ValueOfMessage(x.Config.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_QueryConfigResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.app.v1alpha1.QueryConfigResponse.config": + m := new(Config) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.app.v1alpha1.QueryConfigResponse")) + } + panic(fmt.Errorf("message cosmos.app.v1alpha1.QueryConfigResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_QueryConfigResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.app.v1alpha1.QueryConfigResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_QueryConfigResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_QueryConfigResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_QueryConfigResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_QueryConfigResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*QueryConfigResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Config != nil { + l = options.Size(x.Config) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*QueryConfigResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Config != nil { + encoded, err := options.Marshal(x.Config) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*QueryConfigResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryConfigResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Config == nil { + x.Config = &Config{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Config); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/app/v1alpha1/query.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// QueryConfigRequest is the Query/Config request type. +type QueryConfigRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QueryConfigRequest) Reset() { + *x = QueryConfigRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryConfigRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryConfigRequest) ProtoMessage() {} + +// Deprecated: Use QueryConfigRequest.ProtoReflect.Descriptor instead. +func (*QueryConfigRequest) Descriptor() ([]byte, []int) { + return file_cosmos_app_v1alpha1_query_proto_rawDescGZIP(), []int{0} +} + +// QueryConfigRequest is the Query/Config response type. +type QueryConfigResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // config is the current app config. + Config *Config `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` +} + +func (x *QueryConfigResponse) Reset() { + *x = QueryConfigResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_app_v1alpha1_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryConfigResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryConfigResponse) ProtoMessage() {} + +// Deprecated: Use QueryConfigResponse.ProtoReflect.Descriptor instead. +func (*QueryConfigResponse) Descriptor() ([]byte, []int) { + return file_cosmos_app_v1alpha1_query_proto_rawDescGZIP(), []int{1} +} + +func (x *QueryConfigResponse) GetConfig() *Config { + if x != nil { + return x.Config + } + return nil +} + +var File_cosmos_app_v1alpha1_query_proto protoreflect.FileDescriptor + +var file_cosmos_app_v1alpha1_query_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, + 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4a, + 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0x69, 0x0a, 0x05, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x12, 0x60, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x27, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x03, 0x88, 0x02, 0x01, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, + 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, + 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02, 0x13, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, + 0x68, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x70, + 0x5c, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, + 0x41, 0x70, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_app_v1alpha1_query_proto_rawDescOnce sync.Once + file_cosmos_app_v1alpha1_query_proto_rawDescData = file_cosmos_app_v1alpha1_query_proto_rawDesc +) + +func file_cosmos_app_v1alpha1_query_proto_rawDescGZIP() []byte { + file_cosmos_app_v1alpha1_query_proto_rawDescOnce.Do(func() { + file_cosmos_app_v1alpha1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_app_v1alpha1_query_proto_rawDescData) + }) + return file_cosmos_app_v1alpha1_query_proto_rawDescData +} + +var file_cosmos_app_v1alpha1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_app_v1alpha1_query_proto_goTypes = []interface{}{ + (*QueryConfigRequest)(nil), // 0: cosmos.app.v1alpha1.QueryConfigRequest + (*QueryConfigResponse)(nil), // 1: cosmos.app.v1alpha1.QueryConfigResponse + (*Config)(nil), // 2: cosmos.app.v1alpha1.Config +} +var file_cosmos_app_v1alpha1_query_proto_depIdxs = []int32{ + 2, // 0: cosmos.app.v1alpha1.QueryConfigResponse.config:type_name -> cosmos.app.v1alpha1.Config + 0, // 1: cosmos.app.v1alpha1.Query.Config:input_type -> cosmos.app.v1alpha1.QueryConfigRequest + 1, // 2: cosmos.app.v1alpha1.Query.Config:output_type -> cosmos.app.v1alpha1.QueryConfigResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_cosmos_app_v1alpha1_query_proto_init() } +func file_cosmos_app_v1alpha1_query_proto_init() { + if File_cosmos_app_v1alpha1_query_proto != nil { + return + } + file_cosmos_app_v1alpha1_config_proto_init() + if !protoimpl.UnsafeEnabled { + file_cosmos_app_v1alpha1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryConfigRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_app_v1alpha1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryConfigResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cosmos_app_v1alpha1_query_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_cosmos_app_v1alpha1_query_proto_goTypes, + DependencyIndexes: file_cosmos_app_v1alpha1_query_proto_depIdxs, + MessageInfos: file_cosmos_app_v1alpha1_query_proto_msgTypes, + }.Build() + File_cosmos_app_v1alpha1_query_proto = out.File + file_cosmos_app_v1alpha1_query_proto_rawDesc = nil + file_cosmos_app_v1alpha1_query_proto_goTypes = nil + file_cosmos_app_v1alpha1_query_proto_depIdxs = nil +} diff --git a/api/cosmos/app/v1alpha1/query_grpc.pb.go b/api/cosmos/app/v1alpha1/query_grpc.pb.go new file mode 100644 index 000000000000..b2151b37a09b --- /dev/null +++ b/api/cosmos/app/v1alpha1/query_grpc.pb.go @@ -0,0 +1,114 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: cosmos/app/v1alpha1/query.proto + +package appv1alpha1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Query_Config_FullMethodName = "/cosmos.app.v1alpha1.Query/Config" +) + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type QueryClient interface { + // Deprecated: Do not use. + // Config returns the current app config. + Config(ctx context.Context, in *QueryConfigRequest, opts ...grpc.CallOption) (*QueryConfigResponse, error) +} + +type queryClient struct { + cc grpc.ClientConnInterface +} + +func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { + return &queryClient{cc} +} + +// Deprecated: Do not use. +func (c *queryClient) Config(ctx context.Context, in *QueryConfigRequest, opts ...grpc.CallOption) (*QueryConfigResponse, error) { + out := new(QueryConfigResponse) + err := c.cc.Invoke(ctx, Query_Config_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +// All implementations must embed UnimplementedQueryServer +// for forward compatibility +type QueryServer interface { + // Deprecated: Do not use. + // Config returns the current app config. + Config(context.Context, *QueryConfigRequest) (*QueryConfigResponse, error) + mustEmbedUnimplementedQueryServer() +} + +// UnimplementedQueryServer must be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (UnimplementedQueryServer) Config(context.Context, *QueryConfigRequest) (*QueryConfigResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Config not implemented") +} +func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} + +// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to QueryServer will +// result in compilation errors. +type UnsafeQueryServer interface { + mustEmbedUnimplementedQueryServer() +} + +func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + s.RegisterService(&Query_ServiceDesc, srv) +} + +func _Query_Config_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConfigRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Config(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_Config_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Config(ctx, req.(*QueryConfigRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Query_ServiceDesc is the grpc.ServiceDesc for Query service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Query_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.app.v1alpha1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Config", + Handler: _Query_Config_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/app/v1alpha1/query.proto", +} diff --git a/depinject/internal/appconfig/buf.gen.yaml b/depinject/internal/appconfig/buf.gen.yaml index f4e31b03e8ae..760df9e925fa 100644 --- a/depinject/internal/appconfig/buf.gen.yaml +++ b/depinject/internal/appconfig/buf.gen.yaml @@ -2,7 +2,7 @@ version: v1 managed: enabled: true go_package_prefix: - default: cosmossdk.io/core/internal + default: cosmossdk.io/depinject/internal override: buf.build/cosmos/cosmos-sdk: cosmossdk.io/api plugins: diff --git a/proto/cosmos/app/v1alpha1/query.proto b/proto/cosmos/app/v1alpha1/query.proto new file mode 100644 index 000000000000..2c222d870647 --- /dev/null +++ b/proto/cosmos/app/v1alpha1/query.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package cosmos.app.v1alpha1; + +import "cosmos/app/v1alpha1/config.proto"; + +// Query is the app module query service. +service Query { + + // Config returns the current app config. + rpc Config(QueryConfigRequest) returns (QueryConfigResponse) { + option deprecated = true; + } +} + +// QueryConfigRequest is the Query/Config request type. +message QueryConfigRequest {} + +// QueryConfigRequest is the Query/Config response type. +message QueryConfigResponse { + + // config is the current app config. + Config config = 1; +} From 24dc4fd0b0196f400b2d7d759240a565d5bd798c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Sat, 13 Jan 2024 21:30:31 +0100 Subject: [PATCH 6/8] `make lint-fix` --- simapp/app_config.go | 3 ++- x/auth/depinject.go | 1 + x/circuit/depinject.go | 1 + x/consensus/depinject.go | 1 + x/counter/depinject.go | 1 + x/crisis/depinject.go | 4 +++- x/distribution/depinject.go | 1 + x/evidence/depinject.go | 1 + x/feegrant/module/depinject.go | 1 + x/genutil/depinject.go | 1 + x/gov/depinject.go | 6 ++++-- x/group/module/depinject.go | 1 + x/mint/depinject.go | 1 + x/nft/module/depinject.go | 1 + x/params/depinject.go | 1 + x/protocolpool/depinject.go | 1 + x/slashing/depinject.go | 1 + x/staking/depinject.go | 4 +++- x/upgrade/depinject.go | 4 +++- 19 files changed, 29 insertions(+), 6 deletions(-) diff --git a/simapp/app_config.go b/simapp/app_config.go index 79f73dcf1e73..d0ac7d7fbc16 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -248,5 +248,6 @@ var ( Name: pooltypes.ModuleName, Config: appconfig.WrapAny(&poolmodulev1.Module{}), }, - }}) + }, + }) ) diff --git a/x/auth/depinject.go b/x/auth/depinject.go index 0f1837281888..dcd624f99d10 100644 --- a/x/auth/depinject.go +++ b/x/auth/depinject.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/simulation" "cosmossdk.io/x/auth/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/circuit/depinject.go b/x/circuit/depinject.go index 6bb20c27457b..fdca2207413c 100644 --- a/x/circuit/depinject.go +++ b/x/circuit/depinject.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/depinject/appconfig" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/circuit/keeper" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" diff --git a/x/consensus/depinject.go b/x/consensus/depinject.go index f53ce425fdce..9f613acf3649 100644 --- a/x/consensus/depinject.go +++ b/x/consensus/depinject.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" authtypes "cosmossdk.io/x/auth/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" diff --git a/x/counter/depinject.go b/x/counter/depinject.go index 51d6ecff17dc..a1297170602b 100644 --- a/x/counter/depinject.go +++ b/x/counter/depinject.go @@ -7,6 +7,7 @@ import ( storetypes "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/x/counter/keeper" ) diff --git a/x/crisis/depinject.go b/x/crisis/depinject.go index e81a89418807..4bbbd3417daa 100644 --- a/x/crisis/depinject.go +++ b/x/crisis/depinject.go @@ -1,6 +1,8 @@ package crisis import ( + "github.com/spf13/cast" + modulev1 "cosmossdk.io/api/cosmos/crisis/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" @@ -8,12 +10,12 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" authtypes "cosmossdk.io/x/auth/types" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/x/crisis/keeper" "github.com/cosmos/cosmos-sdk/x/crisis/types" - "github.com/spf13/cast" ) var _ depinject.OnePerModuleType = AppModule{} diff --git a/x/distribution/depinject.go b/x/distribution/depinject.go index 07383b2cb59a..78b0fea3a2e4 100644 --- a/x/distribution/depinject.go +++ b/x/distribution/depinject.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/types" staking "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/evidence/depinject.go b/x/evidence/depinject.go index e1de03c10924..2fba5fa7a13f 100644 --- a/x/evidence/depinject.go +++ b/x/evidence/depinject.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/depinject/appconfig" "cosmossdk.io/x/evidence/keeper" "cosmossdk.io/x/evidence/types" + "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/feegrant/module/depinject.go b/x/feegrant/module/depinject.go index f611ef8d3805..af86f6d7e491 100644 --- a/x/feegrant/module/depinject.go +++ b/x/feegrant/module/depinject.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/keeper" "cosmossdk.io/x/feegrant/simulation" + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" diff --git a/x/genutil/depinject.go b/x/genutil/depinject.go index 4cbe7f64c7fe..77320ca6b0c4 100644 --- a/x/genutil/depinject.go +++ b/x/genutil/depinject.go @@ -6,6 +6,7 @@ import ( "cosmossdk.io/core/genesis" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/x/genutil/types" ) diff --git a/x/gov/depinject.go b/x/gov/depinject.go index 3fb8bd4883c1..40f2c9f30be5 100644 --- a/x/gov/depinject.go +++ b/x/gov/depinject.go @@ -5,6 +5,9 @@ import ( "sort" "strings" + "golang.org/x/exp/maps" + "golang.org/x/exp/slices" + modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" "cosmossdk.io/core/appmodule" store "cosmossdk.io/core/store" @@ -14,10 +17,9 @@ import ( "cosmossdk.io/x/gov/keeper" govtypes "cosmossdk.io/x/gov/types" "cosmossdk.io/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - "golang.org/x/exp/maps" - "golang.org/x/exp/slices" ) var _ depinject.OnePerModuleType = AppModule{} diff --git a/x/group/module/depinject.go b/x/group/module/depinject.go index 46fa776029cc..f006df24f345 100644 --- a/x/group/module/depinject.go +++ b/x/group/module/depinject.go @@ -8,6 +8,7 @@ import ( store "cosmossdk.io/store/types" "cosmossdk.io/x/group" "cosmossdk.io/x/group/keeper" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/mint/depinject.go b/x/mint/depinject.go index 178003079158..d2c5112a4242 100644 --- a/x/mint/depinject.go +++ b/x/mint/depinject.go @@ -9,6 +9,7 @@ import ( authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/types" + "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/nft/module/depinject.go b/x/nft/module/depinject.go index c9cc4bc58950..468a64beb726 100644 --- a/x/nft/module/depinject.go +++ b/x/nft/module/depinject.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/depinject/appconfig" "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" ) diff --git a/x/params/depinject.go b/x/params/depinject.go index 1f62038a3d22..ad94b5c1d410 100644 --- a/x/params/depinject.go +++ b/x/params/depinject.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/x/params/keeper" "cosmossdk.io/x/params/types" "cosmossdk.io/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/protocolpool/depinject.go b/x/protocolpool/depinject.go index da182061ee90..a49ebc0f5952 100644 --- a/x/protocolpool/depinject.go +++ b/x/protocolpool/depinject.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/simulation" "cosmossdk.io/x/protocolpool/types" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" diff --git a/x/slashing/depinject.go b/x/slashing/depinject.go index ff8e35f56529..3da03a787b26 100644 --- a/x/slashing/depinject.go +++ b/x/slashing/depinject.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/types" staking "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" ) diff --git a/x/staking/depinject.go b/x/staking/depinject.go index 5e102208911e..cce30c34783f 100644 --- a/x/staking/depinject.go +++ b/x/staking/depinject.go @@ -4,6 +4,8 @@ import ( "fmt" "sort" + "golang.org/x/exp/maps" + modulev1 "cosmossdk.io/api/cosmos/staking/module/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" @@ -13,11 +15,11 @@ import ( "cosmossdk.io/x/staking/keeper" "cosmossdk.io/x/staking/simulation" "cosmossdk.io/x/staking/types" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "golang.org/x/exp/maps" ) var _ depinject.OnePerModuleType = AppModule{} diff --git a/x/upgrade/depinject.go b/x/upgrade/depinject.go index 9a33a96a30d0..07ed051ceaaf 100644 --- a/x/upgrade/depinject.go +++ b/x/upgrade/depinject.go @@ -1,6 +1,8 @@ package upgrade import ( + "github.com/spf13/cast" + modulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1" "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" @@ -10,13 +12,13 @@ import ( authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/spf13/cast" ) var _ depinject.OnePerModuleType = AppModule{} From 8facd8f83f381ced93b6180f12c929b743ec4541 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Sat, 13 Jan 2024 21:31:40 +0100 Subject: [PATCH 7/8] updates --- tests/integration/runtime/query_test.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tests/integration/runtime/query_test.go b/tests/integration/runtime/query_test.go index f018c6ac1999..4ad7a7553aed 100644 --- a/tests/integration/runtime/query_test.go +++ b/tests/integration/runtime/query_test.go @@ -66,28 +66,6 @@ func initFixture(t assert.TestingT) *fixture { return f } -func TestQueryAppConfig(t *testing.T) { - t.Parallel() - f := initFixture(t) - - res, err := f.appQueryClient.Config(f.ctx, &appv1alpha1.QueryConfigRequest{}) - assert.NilError(t, err) - // app config is not nil - assert.Assert(t, res != nil && res.Config != nil) - - moduleConfigs := map[string]*appv1alpha1.ModuleConfig{} - for _, module := range res.Config.Modules { - moduleConfigs[module.Name] = module - } - - // has all expected modules - for _, modName := range []string{"auth", "bank", "tx", "consensus", "runtime", "staking"} { - modConfig := moduleConfigs[modName] - assert.Assert(t, modConfig != nil) - assert.Assert(t, modConfig.Config != nil) - } -} - func TestReflectionService(t *testing.T) { t.Parallel() f := initFixture(t) From 05976ac8016fbd4005733665a0a53e4f033f95ee Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Sat, 13 Jan 2024 21:34:28 +0100 Subject: [PATCH 8/8] updates --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9013c5c64ac..ab0ecaecb438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,10 @@ Every Module contains its own CHANGELOG.md. Please refer to the module you are i * (types) [#18695](https://github.com/cosmos/cosmos-sdk/pull/18695) Removed global configuration for txEncoder. * (server) [#18909](https://github.com/cosmos/cosmos-sdk/pull/18909) Remove configuration endpoint on grpc reflection endpoint in favour of auth module bech32prefix endpoint already exposed. +### Client Breaking Changes + +* (runtime) [#19040](https://github.com/cosmos/cosmos-sdk/pull/19040) Simplify app config implementation and deprecate `/cosmos/app/v1alpha1/config` query. + ### CLI Breaking Changes * (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `appd export` has moved with other genesis commands, use `appd genesis export` instead.