From 1b913130230c5d9c43d9e88af50bad96b07dc71a Mon Sep 17 00:00:00 2001 From: Pino' Surace Date: Tue, 2 May 2023 14:20:51 +0200 Subject: [PATCH 1/2] Update app_v2 --- Makefile | 1 + api/cosmwasm/wasm/module/v1/module.pulsar.go | 587 +++++++++++++++++++ proto/buf.gen.pulsar.yaml | 17 + proto/cosmwasm/wasm/module/v1/module.proto | 16 + scripts/protocgen-pulsar.sh | 16 + scripts/protocgen.sh | 2 +- x/wasm/module.go | 105 +++- 7 files changed, 741 insertions(+), 3 deletions(-) create mode 100644 api/cosmwasm/wasm/module/v1/module.pulsar.go create mode 100644 proto/buf.gen.pulsar.yaml create mode 100644 proto/cosmwasm/wasm/module/v1/module.proto create mode 100644 scripts/protocgen-pulsar.sh diff --git a/Makefile b/Makefile index 8a2f2f261f..4f61b405c2 100644 --- a/Makefile +++ b/Makefile @@ -186,6 +186,7 @@ proto-all: proto-format proto-lint proto-gen format proto-gen: @echo "Generating Protobuf files" @$(protoImage) sh ./scripts/protocgen.sh + @$(protoImage) sh ./scripts/protocgen-pulsar.sh proto-format: @echo "Formatting Protobuf files" diff --git a/api/cosmwasm/wasm/module/v1/module.pulsar.go b/api/cosmwasm/wasm/module/v1/module.pulsar.go new file mode 100644 index 0000000000..3bde2fbea6 --- /dev/null +++ b/api/cosmwasm/wasm/module/v1/module.pulsar.go @@ -0,0 +1,587 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package modulev1 + +import ( + fmt "fmt" + io "io" + reflect "reflect" + sync "sync" + + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + + 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" +) + +var ( + md_Module protoreflect.MessageDescriptor + fd_Module_authority protoreflect.FieldDescriptor +) + +func init() { + file_cosmwasm_wasm_module_v1_module_proto_init() + md_Module = File_cosmwasm_wasm_module_v1_module_proto.Messages().ByName("Module") + fd_Module_authority = md_Module.Fields().ByName("authority") +} + +var _ protoreflect.Message = (*fastReflection_Module)(nil) + +type fastReflection_Module Module + +func (x *Module) ProtoReflect() protoreflect.Message { + return (*fastReflection_Module)(x) +} + +func (x *Module) slowProtoReflect() protoreflect.Message { + mi := &file_cosmwasm_wasm_module_v1_module_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_Module_messageType fastReflection_Module_messageType + _ protoreflect.MessageType = fastReflection_Module_messageType{} +) + +type fastReflection_Module_messageType struct{} + +func (x fastReflection_Module_messageType) Zero() protoreflect.Message { + return (*fastReflection_Module)(nil) +} + +func (x fastReflection_Module_messageType) New() protoreflect.Message { + return new(fastReflection_Module) +} + +func (x fastReflection_Module_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Module) Descriptor() protoreflect.MessageDescriptor { + return md_Module +} + +// 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_Module) Type() protoreflect.MessageType { + return _fastReflection_Module_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Module) New() protoreflect.Message { + return new(fastReflection_Module) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { + return (*Module)(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_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_Module_authority, 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_Module) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.authority": + return x.Authority != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmwasm.wasm.module.v1.Module")) + } + panic(fmt.Errorf("message cosmwasm.wasm.module.v1.Module 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_Module) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.authority": + x.Authority = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmwasm.wasm.module.v1.Module")) + } + panic(fmt.Errorf("message cosmwasm.wasm.module.v1.Module 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_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmwasm.wasm.module.v1.Module.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmwasm.wasm.module.v1.Module")) + } + panic(fmt.Errorf("message cosmwasm.wasm.module.v1.Module 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_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.authority": + x.Authority = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmwasm.wasm.module.v1.Module")) + } + panic(fmt.Errorf("message cosmwasm.wasm.module.v1.Module 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_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.authority": + panic(fmt.Errorf("field authority of message cosmwasm.wasm.module.v1.Module is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmwasm.wasm.module.v1.Module")) + } + panic(fmt.Errorf("message cosmwasm.wasm.module.v1.Module 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_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.authority": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmwasm.wasm.module.v1.Module")) + } + panic(fmt.Errorf("message cosmwasm.wasm.module.v1.Module 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_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmwasm.wasm.module.v1.Module", 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_Module) 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_Module) 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_Module) 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_Module) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Module) + 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.Authority) + 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().(*Module) + 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.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + 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().(*Module) + 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: Module: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: 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 Authority", 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.Authority = 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: cosmwasm/wasm/module/v1/module.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) +) + +// Module is the config object of the wasm module. +type Module struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // authority defines the custom module authority. If not set, defaults to the + // governance module. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (x *Module) Reset() { + *x = Module{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmwasm_wasm_module_v1_module_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Module) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Module) ProtoMessage() {} + +// Deprecated: Use Module.ProtoReflect.Descriptor instead. +func (*Module) Descriptor() ([]byte, []int) { + return file_cosmwasm_wasm_module_v1_module_proto_rawDescGZIP(), []int{0} +} + +func (x *Module) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +var File_cosmwasm_wasm_module_v1_module_proto protoreflect.FileDescriptor + +var file_cosmwasm_wasm_module_v1_module_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, + 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, + 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x50, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3a, 0x28, 0xba, 0xc0, 0x96, 0xda, 0x01, + 0x22, 0x0a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x6f, + 0x73, 0x6d, 0x57, 0x61, 0x73, 0x6d, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x64, 0x2f, 0x78, 0x2f, 0x77, + 0x61, 0x73, 0x6d, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x31, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2f, 0x77, 0x61, + 0x73, 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x57, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, + 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0x2e, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, + 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, + 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, + 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmwasm_wasm_module_v1_module_proto_rawDescOnce sync.Once + file_cosmwasm_wasm_module_v1_module_proto_rawDescData = file_cosmwasm_wasm_module_v1_module_proto_rawDesc +) + +func file_cosmwasm_wasm_module_v1_module_proto_rawDescGZIP() []byte { + file_cosmwasm_wasm_module_v1_module_proto_rawDescOnce.Do(func() { + file_cosmwasm_wasm_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmwasm_wasm_module_v1_module_proto_rawDescData) + }) + return file_cosmwasm_wasm_module_v1_module_proto_rawDescData +} + +var ( + file_cosmwasm_wasm_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1) + file_cosmwasm_wasm_module_v1_module_proto_goTypes = []interface{}{ + (*Module)(nil), // 0: cosmwasm.wasm.module.v1.Module + } +) +var file_cosmwasm_wasm_module_v1_module_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_cosmwasm_wasm_module_v1_module_proto_init() } +func file_cosmwasm_wasm_module_v1_module_proto_init() { + if File_cosmwasm_wasm_module_v1_module_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmwasm_wasm_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Module); 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_cosmwasm_wasm_module_v1_module_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_cosmwasm_wasm_module_v1_module_proto_goTypes, + DependencyIndexes: file_cosmwasm_wasm_module_v1_module_proto_depIdxs, + MessageInfos: file_cosmwasm_wasm_module_v1_module_proto_msgTypes, + }.Build() + File_cosmwasm_wasm_module_v1_module_proto = out.File + file_cosmwasm_wasm_module_v1_module_proto_rawDesc = nil + file_cosmwasm_wasm_module_v1_module_proto_goTypes = nil + file_cosmwasm_wasm_module_v1_module_proto_depIdxs = nil +} diff --git a/proto/buf.gen.pulsar.yaml b/proto/buf.gen.pulsar.yaml new file mode 100644 index 0000000000..fada5e7dd3 --- /dev/null +++ b/proto/buf.gen.pulsar.yaml @@ -0,0 +1,17 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: cosmossdk.io/api + except: + - buf.build/googleapis/googleapis + - buf.build/cosmos/gogo-proto + - buf.build/cosmos/cosmos-proto + override: +plugins: + - name: go-pulsar + out: ../api + opt: paths=source_relative + - name: go-grpc + out: ../api + opt: paths=source_relative diff --git a/proto/cosmwasm/wasm/module/v1/module.proto b/proto/cosmwasm/wasm/module/v1/module.proto new file mode 100644 index 0000000000..6774d907bc --- /dev/null +++ b/proto/cosmwasm/wasm/module/v1/module.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package cosmwasm.wasm.module.v1; + +import "cosmos/app/v1alpha1/module.proto"; + +// Module is the config object of the wasm module. +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import : "github.com/CosmWasm/wasmd/x/wasm" + }; + + // authority defines the custom module authority. If not set, defaults to the + // governance module. + string authority = 1; +} \ No newline at end of file diff --git a/scripts/protocgen-pulsar.sh b/scripts/protocgen-pulsar.sh new file mode 100644 index 0000000000..04f095832b --- /dev/null +++ b/scripts/protocgen-pulsar.sh @@ -0,0 +1,16 @@ +# this script is for generating protobuf files for the new google.golang.org/protobuf API + +set -eo pipefail + +protoc_install_gopulsar() { + go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest +} + +protoc_install_gopulsar + +echo "Cleaning API directory" +(cd api; find ./ -type f \( -iname \*.pulsar.go -o -iname \*.pb.go -o -iname \*.cosmos_orm.go -o -iname \*.pb.gw.go \) -delete; find . -empty -type d -delete; cd ..) + +echo "Generating API" +(cd proto; buf generate --template buf.gen.pulsar.yaml --path cosmwasm/wasm/module) diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 8a630868ca..9f97112a92 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -21,7 +21,7 @@ done protoc_install_proto_gen_doc echo "Generating proto docs" -buf generate --template buf.gen.doc.yml +buf generate --template buf.gen.doc.yml --path cosmwasm/wasm/v1 cd .. diff --git a/x/wasm/module.go b/x/wasm/module.go index 272b32d1a4..fb845f20de 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -4,13 +4,16 @@ import ( "context" "encoding/json" "fmt" + "path/filepath" "runtime/debug" "strings" "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client/flags" + "cosmossdk.io/depinject" wasmvm "github.com/CosmWasm/wasmvm" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" @@ -18,18 +21,31 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/server" servertypes "github.com/cosmos/cosmos-sdk/server/types" + store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/grpc-ecosystem/grpc-gateway/runtime" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cast" "github.com/spf13/cobra" + modulev1 "github.com/CosmWasm/wasmd/api/cosmwasm/wasm/module/v1" + "github.com/CosmWasm/wasmd/x/wasm/client/cli" "github.com/CosmWasm/wasmd/x/wasm/exported" "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/CosmWasm/wasmd/x/wasm/simulation" "github.com/CosmWasm/wasmd/x/wasm/types" + + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" + ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ) var ( @@ -51,7 +67,7 @@ func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { RegisterCodec(amino) } -func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *gwruntime.ServeMux) { err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx)) if err != nil { panic(err) @@ -199,6 +215,91 @@ func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Validato return []abci.ValidatorUpdate{} } +func init() { + appmodule.Register( + &modulev1.Module{}, + appmodule.Provide( + provideModule, + ), + ) +} + +type wasmInputs struct { + depinject.In + + Config *modulev1.Module + Cdc codec.Codec + Key *store.KVStoreKey + AppOpts servertypes.AppOptions `optional:"true"` + WasmOpts []Option `optional:"true"` + AvailableCapabilities string + MsgServiceRouter *baseapp.MsgServiceRouter + GRPCQueryRouter *baseapp.GRPCQueryRouter + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + DistrKeeper distrkeeper.Keeper + + IBCKeeper *ibckeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper + + // LegacySubspace is used solely for migration of x/params managed parameters + LegacySubspace exported.Subspace `optional:"true"` +} + +// Dependency Injection Outputs +type wasmOutputs struct { + depinject.Out + + Module appmodule.AppModule + WasmKeeper *Keeper +} + +func provideModule(in wasmInputs) wasmOutputs { + var homePath string + var wasmConfig types.WasmConfig + var err error + if in.AppOpts != nil { + homePath = cast.ToString(in.AppOpts.Get(flags.FlagHome)) + wasmConfig, err = ReadWasmConfig(in.AppOpts) + if err != nil { + panic(fmt.Sprintf("error while reading wasm config: %s", err)) + } + } + + wasmDir := filepath.Join(homePath, "wasm") + + // 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.Key, + in.AccountKeeper, + in.BankKeeper, + in.StakingKeeper, + distrkeeper.NewQuerier(in.DistrKeeper), + in.IBCKeeper.ChannelKeeper, + &in.IBCKeeper.PortKeeper, + in.ScopedWasmKeeper, + in.TransferKeeper, + in.MsgServiceRouter, + in.GRPCQueryRouter, + wasmDir, + wasmConfig, + in.AvailableCapabilities, + authority.String(), + in.WasmOpts..., + ) + + m := NewAppModule(in.Cdc, &k, in.StakingKeeper, in.AccountKeeper, in.BankKeeper, in.MsgServiceRouter, in.LegacySubspace) + return wasmOutputs{WasmKeeper: &k, Module: m} +} + // ____________________________________________________________________________ // AppModuleSimulation functions From e923a9204f5e0777ec9cffa94671d7b8c413b177 Mon Sep 17 00:00:00 2001 From: Pino' Surace Date: Thu, 4 May 2023 12:17:19 +0200 Subject: [PATCH 2/2] Remove wasmkeeper initialization in app_v2.go --- api/cosmwasm/wasm/module/v1/module.pulsar.go | 122 +++++++++++++++---- app/app_v2.go | 41 +------ app/app_v2_config.go | 9 ++ proto/cosmwasm/wasm/module/v1/module.proto | 4 +- x/wasm/module.go | 54 ++++---- 5 files changed, 139 insertions(+), 91 deletions(-) diff --git a/api/cosmwasm/wasm/module/v1/module.pulsar.go b/api/cosmwasm/wasm/module/v1/module.pulsar.go index 3bde2fbea6..3fe60f290f 100644 --- a/api/cosmwasm/wasm/module/v1/module.pulsar.go +++ b/api/cosmwasm/wasm/module/v1/module.pulsar.go @@ -16,13 +16,15 @@ import ( ) var ( - md_Module protoreflect.MessageDescriptor - fd_Module_authority protoreflect.FieldDescriptor + md_Module protoreflect.MessageDescriptor + fd_Module_available_capabilities protoreflect.FieldDescriptor + fd_Module_authority protoreflect.FieldDescriptor ) func init() { file_cosmwasm_wasm_module_v1_module_proto_init() md_Module = File_cosmwasm_wasm_module_v1_module_proto.Messages().ByName("Module") + fd_Module_available_capabilities = md_Module.Fields().ByName("available_capabilities") fd_Module_authority = md_Module.Fields().ByName("authority") } @@ -95,6 +97,12 @@ func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.AvailableCapabilities != "" { + value := protoreflect.ValueOfString(x.AvailableCapabilities) + if !f(fd_Module_available_capabilities, value) { + return + } + } if x.Authority != "" { value := protoreflect.ValueOfString(x.Authority) if !f(fd_Module_authority, value) { @@ -116,6 +124,8 @@ func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, proto // a repeated field is populated if it is non-empty. func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.available_capabilities": + return x.AvailableCapabilities != "" case "cosmwasm.wasm.module.v1.Module.authority": return x.Authority != "" default: @@ -134,6 +144,8 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool { // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.available_capabilities": + x.AvailableCapabilities = "" case "cosmwasm.wasm.module.v1.Module.authority": x.Authority = "" default: @@ -152,6 +164,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) { // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "cosmwasm.wasm.module.v1.Module.available_capabilities": + value := x.AvailableCapabilities + return protoreflect.ValueOfString(value) case "cosmwasm.wasm.module.v1.Module.authority": value := x.Authority return protoreflect.ValueOfString(value) @@ -175,6 +190,8 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.available_capabilities": + x.AvailableCapabilities = value.Interface().(string) case "cosmwasm.wasm.module.v1.Module.authority": x.Authority = value.Interface().(string) default: @@ -197,6 +214,8 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.available_capabilities": + panic(fmt.Errorf("field available_capabilities of message cosmwasm.wasm.module.v1.Module is not mutable")) case "cosmwasm.wasm.module.v1.Module.authority": panic(fmt.Errorf("field authority of message cosmwasm.wasm.module.v1.Module is not mutable")) default: @@ -212,6 +231,8 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "cosmwasm.wasm.module.v1.Module.available_capabilities": + return protoreflect.ValueOfString("") case "cosmwasm.wasm.module.v1.Module.authority": return protoreflect.ValueOfString("") default: @@ -283,6 +304,10 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + l = len(x.AvailableCapabilities) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } l = len(x.Authority) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) @@ -321,6 +346,13 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { copy(dAtA[i:], x.Authority) i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) i-- + dAtA[i] = 0x12 + } + if len(x.AvailableCapabilities) > 0 { + i -= len(x.AvailableCapabilities) + copy(dAtA[i:], x.AvailableCapabilities) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AvailableCapabilities))) + i-- dAtA[i] = 0xa } if input.Buf != nil { @@ -373,6 +405,38 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { } switch fieldNum { case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AvailableCapabilities", 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.AvailableCapabilities = 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 Authority", wireType) } @@ -458,9 +522,10 @@ type Module struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + AvailableCapabilities string `protobuf:"bytes,1,opt,name=available_capabilities,json=availableCapabilities,proto3" json:"available_capabilities,omitempty"` // authority defines the custom module authority. If not set, defaults to the // governance module. - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,omitempty"` } func (x *Module) Reset() { @@ -483,6 +548,13 @@ func (*Module) Descriptor() ([]byte, []int) { return file_cosmwasm_wasm_module_v1_module_proto_rawDescGZIP(), []int{0} } +func (x *Module) GetAvailableCapabilities() string { + if x != nil { + return x.AvailableCapabilities + } + return "" +} + func (x *Module) GetAuthority() string { if x != nil { return x.Authority @@ -499,26 +571,30 @@ var file_cosmwasm_wasm_module_v1_module_proto_rawDesc = []byte{ 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x50, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3a, 0x28, 0xba, 0xc0, 0x96, 0xda, 0x01, - 0x22, 0x0a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x6f, - 0x73, 0x6d, 0x57, 0x61, 0x73, 0x6d, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x64, 0x2f, 0x78, 0x2f, 0x77, - 0x61, 0x73, 0x6d, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, - 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x31, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2f, 0x77, 0x61, - 0x73, 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, - 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x57, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, - 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x57, 0x61, 0x73, 0x6d, 0x2e, 0x4d, 0x6f, 0x64, 0x75, - 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, - 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, - 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, - 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, - 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x22, 0x87, 0x01, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x35, 0x0a, 0x16, + 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, + 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x61, 0x76, + 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x69, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, + 0x79, 0x3a, 0x28, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x22, 0x0a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x6f, 0x73, 0x6d, 0x57, 0x61, 0x73, 0x6d, 0x2f, 0x77, + 0x61, 0x73, 0x6d, 0x64, 0x2f, 0x78, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x42, 0xdc, 0x01, 0x0a, 0x1b, + 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x77, 0x61, 0x73, + 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2f, 0x77, 0x61, 0x73, 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, + 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x43, 0x57, 0x4d, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x2e, 0x57, + 0x61, 0x73, 0x6d, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x17, + 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x4d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x23, 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, + 0x73, 0x6d, 0x5c, 0x57, 0x61, 0x73, 0x6d, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, + 0x43, 0x6f, 0x73, 0x6d, 0x77, 0x61, 0x73, 0x6d, 0x3a, 0x3a, 0x57, 0x61, 0x73, 0x6d, 0x3a, 0x3a, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/app/app_v2.go b/app/app_v2.go index 00f2200e9e..edc8ff7479 100644 --- a/app/app_v2.go +++ b/app/app_v2.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "os" - "path/filepath" "strings" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" @@ -20,7 +19,6 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/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" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -78,7 +76,6 @@ import ( porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" - "github.com/spf13/cast" "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" @@ -261,6 +258,7 @@ func NewWasmApp( &app.GroupKeeper, &app.NFTKeeper, &app.ConsensusParamsKeeper, + &app.WasmKeeper, ); err != nil { panic(err) } @@ -323,13 +321,12 @@ func NewWasmApp( keys := sdk.NewKVStoreKeys( // non sdk store keys ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, - wasm.StoreKey, icahosttypes.StoreKey, - icacontrollertypes.StoreKey, + icahosttypes.StoreKey, icacontrollertypes.StoreKey, ) app.MountKVStores(keys) app.keys = keys // set params subspaces - for _, m := range []string{ibctransfertypes.ModuleName, ibcexported.ModuleName, icahosttypes.SubModuleName, icacontrollertypes.SubModuleName, wasm.ModuleName} { + for _, m := range []string{ibctransfertypes.ModuleName, ibcexported.ModuleName, icahosttypes.SubModuleName, icacontrollertypes.SubModuleName} { app.ParamsKeeper.Subspace(m) } @@ -405,37 +402,6 @@ func NewWasmApp( app.MsgServiceRouter(), ) - homePath := cast.ToString(appOpts.Get(flags.FlagHome)) - wasmDir := filepath.Join(homePath, "wasm") - wasmConfig, err := wasm.ReadWasmConfig(appOpts) - if err != nil { - panic(fmt.Sprintf("error while reading wasm config: %s", err)) - } - - // The last arguments can contain custom message handlers, and custom query handlers, - // if we want to allow any custom callbacks - // See https://github.com/CosmWasm/cosmwasm/blob/main/docs/CAPABILITIES-BUILT-IN.md - availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2" - app.WasmKeeper = wasm.NewKeeper( - app.appCodec, - keys[wasm.StoreKey], - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - distrkeeper.NewQuerier(app.DistrKeeper), - app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, - scopedWasmKeeper, - app.TransferKeeper, - app.MsgServiceRouter(), - app.GRPCQueryRouter(), - wasmDir, - wasmConfig, - availableCapabilities, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - wasmOpts..., - ) - // The gov proposal types can be individually enabled if len(enabledProposals) != 0 { govRouter.AddRoute(wasm.RouterKey, wasm.NewWasmProposalHandler(app.WasmKeeper, enabledProposals)) @@ -484,7 +450,6 @@ func NewWasmApp( transfer.NewAppModule(app.TransferKeeper), ibcfee.NewAppModule(app.IBCFeeKeeper), ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), - wasm.NewAppModule(app.appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), } app.RegisterModules(legacyModules...) cfg := app.Configurator() diff --git a/app/app_v2_config.go b/app/app_v2_config.go index 7da15c644b..0b94ff2e9e 100644 --- a/app/app_v2_config.go +++ b/app/app_v2_config.go @@ -52,6 +52,9 @@ import ( ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "google.golang.org/protobuf/types/known/durationpb" + wasmmodulev1 "github.com/CosmWasm/wasmd/api/cosmwasm/wasm/module/v1" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/CosmWasm/wasmd/x/wasm" ) @@ -194,6 +197,12 @@ var ( Name: consensustypes.ModuleName, Config: appconfig.WrapAny(&consensusmodulev1.Module{}), }, + { + Name: wasmtypes.ModuleName, + Config: appconfig.WrapAny(&wasmmodulev1.Module{ + AvailableCapabilities: "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2", + }), + }, }, }) ) diff --git a/proto/cosmwasm/wasm/module/v1/module.proto b/proto/cosmwasm/wasm/module/v1/module.proto index 6774d907bc..e6e198ab7e 100644 --- a/proto/cosmwasm/wasm/module/v1/module.proto +++ b/proto/cosmwasm/wasm/module/v1/module.proto @@ -10,7 +10,9 @@ message Module { go_import : "github.com/CosmWasm/wasmd/x/wasm" }; + string available_capabilities = 1; + // authority defines the custom module authority. If not set, defaults to the // governance module. - string authority = 1; + string authority = 2; } \ No newline at end of file diff --git a/x/wasm/module.go b/x/wasm/module.go index fb845f20de..3928667e69 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -41,11 +41,8 @@ import ( authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ) var ( @@ -219,7 +216,7 @@ func init() { appmodule.Register( &modulev1.Module{}, appmodule.Provide( - provideModule, + ProvideModule, ), ) } @@ -227,22 +224,21 @@ func init() { type wasmInputs struct { depinject.In - Config *modulev1.Module - Cdc codec.Codec - Key *store.KVStoreKey - AppOpts servertypes.AppOptions `optional:"true"` - WasmOpts []Option `optional:"true"` - AvailableCapabilities string - MsgServiceRouter *baseapp.MsgServiceRouter - GRPCQueryRouter *baseapp.GRPCQueryRouter - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - StakingKeeper *stakingkeeper.Keeper - DistrKeeper distrkeeper.Keeper - - IBCKeeper *ibckeeper.Keeper - TransferKeeper ibctransferkeeper.Keeper - ScopedWasmKeeper capabilitykeeper.ScopedKeeper + Config *modulev1.Module + Cdc codec.Codec + Key *store.KVStoreKey + AppOpts servertypes.AppOptions `optional:"true"` + WasmOpts []Option `optional:"true"` + MsgServiceRouter *baseapp.MsgServiceRouter + // GRPCQueryRouter *baseapp.GRPCQueryRouter + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + DistrKeeper distrkeeper.Keeper + + // IBCKeeper *ibckeeper.Keeper + // TransferKeeper ibctransferkeeper.Keeper + // ScopedWasmKeeper capabilitykeeper.ScopedKeeper // LegacySubspace is used solely for migration of x/params managed parameters LegacySubspace exported.Subspace `optional:"true"` @@ -253,10 +249,10 @@ type wasmOutputs struct { depinject.Out Module appmodule.AppModule - WasmKeeper *Keeper + WasmKeeper Keeper } -func provideModule(in wasmInputs) wasmOutputs { +func ProvideModule(in wasmInputs) wasmOutputs { var homePath string var wasmConfig types.WasmConfig var err error @@ -283,21 +279,21 @@ func provideModule(in wasmInputs) wasmOutputs { in.BankKeeper, in.StakingKeeper, distrkeeper.NewQuerier(in.DistrKeeper), - in.IBCKeeper.ChannelKeeper, - &in.IBCKeeper.PortKeeper, - in.ScopedWasmKeeper, - in.TransferKeeper, + nil, + nil, + nil, + nil, in.MsgServiceRouter, - in.GRPCQueryRouter, + nil, wasmDir, wasmConfig, - in.AvailableCapabilities, + in.Config.AvailableCapabilities, authority.String(), in.WasmOpts..., ) m := NewAppModule(in.Cdc, &k, in.StakingKeeper, in.AccountKeeper, in.BankKeeper, in.MsgServiceRouter, in.LegacySubspace) - return wasmOutputs{WasmKeeper: &k, Module: m} + return wasmOutputs{WasmKeeper: k, Module: m} } // ____________________________________________________________________________