From 3670ca18caa4ebe8626a54ad0d17617c432048f0 Mon Sep 17 00:00:00 2001 From: David Terpay <35130517+davidterpay@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:55:54 -0400 Subject: [PATCH] feat(incentives): Adding Proto for Incentives Module (#125) --- .markdownlint.json | 23 +- api/slinky/abci/v1/vote_extensions.pulsar.go | 14 +- .../incentives/module/v1/module.pulsar.go | 505 ++++ api/slinky/incentives/v1/badprice.pulsar.go | 659 ++++++ api/slinky/incentives/v1/genesis.pulsar.go | 1263 ++++++++++ api/slinky/incentives/v1/goodprice.pulsar.go | 659 ++++++ api/slinky/incentives/v1/query.pulsar.go | 2095 +++++++++++++++++ api/slinky/incentives/v1/query_grpc.pb.go | 152 ++ api/slinky/oracle/module/v1/module.pulsar.go | 11 +- api/slinky/oracle/v1/genesis.pulsar.go | 91 +- api/slinky/oracle/v1/query.pulsar.go | 129 +- api/slinky/service/v1/service.pulsar.go | 182 +- api/slinky/service/v1/service_grpc.pb.go | 6 +- proto/buf.lock | 4 +- .../slinky/incentives/module/v1/module.proto | 12 + proto/slinky/incentives/v1/badprice.proto | 21 + proto/slinky/incentives/v1/genesis.proto | 23 + proto/slinky/incentives/v1/goodprice.proto | 21 + proto/slinky/incentives/v1/query.proto | 46 + proto/slinky/oracle/module/v1/module.proto | 2 +- tests/simapp/app.go | 5 + tests/simapp/config.go | 11 + x/incentives/client/cli/query.go | 92 + x/incentives/keeper/genesis.go | 87 + x/incentives/keeper/genesis_test.go | 282 +++ x/incentives/keeper/grpc_query.go | 97 + x/incentives/keeper/grpc_query_test.go | 184 ++ x/incentives/keeper/incentives.go | 128 + x/incentives/keeper/incentives_test.go | 160 ++ x/incentives/keeper/keeper.go | 32 + x/incentives/keeper/keeper_test.go | 70 + x/incentives/keeper/strategy.go | 80 + x/incentives/keeper/strategy_test.go | 485 ++++ x/incentives/module.go | 184 ++ .../types/examples/badprice/badprice.pb.go | 381 +++ .../types/examples/badprice/incentive.go | 61 + .../types/examples/badprice/strategy.go | 75 + .../types/examples/goodprice/goodprice.pb.go | 382 +++ .../types/examples/goodprice/incentive.go | 61 + .../types/examples/goodprice/strategy.go | 83 + .../types/examples/mocks/bank_keeper.go | 60 + .../types/examples/mocks/staking_keeper.go | 66 + x/incentives/types/genesis.go | 79 + x/incentives/types/genesis.pb.go | 567 +++++ x/incentives/types/genesis_test.go | 55 + x/incentives/types/incentive.go | 31 + x/incentives/types/keys.go | 41 + x/incentives/types/query.pb.go | 944 ++++++++ x/incentives/types/query.pb.gw.go | 236 ++ x/incentives/types/strategy.go | 19 + x/incentives/types/utils.go | 42 + 51 files changed, 10800 insertions(+), 198 deletions(-) create mode 100644 api/slinky/incentives/module/v1/module.pulsar.go create mode 100644 api/slinky/incentives/v1/badprice.pulsar.go create mode 100644 api/slinky/incentives/v1/genesis.pulsar.go create mode 100644 api/slinky/incentives/v1/goodprice.pulsar.go create mode 100644 api/slinky/incentives/v1/query.pulsar.go create mode 100644 api/slinky/incentives/v1/query_grpc.pb.go create mode 100644 proto/slinky/incentives/module/v1/module.proto create mode 100644 proto/slinky/incentives/v1/badprice.proto create mode 100644 proto/slinky/incentives/v1/genesis.proto create mode 100644 proto/slinky/incentives/v1/goodprice.proto create mode 100644 proto/slinky/incentives/v1/query.proto create mode 100644 x/incentives/client/cli/query.go create mode 100644 x/incentives/keeper/genesis.go create mode 100644 x/incentives/keeper/genesis_test.go create mode 100644 x/incentives/keeper/grpc_query.go create mode 100644 x/incentives/keeper/grpc_query_test.go create mode 100644 x/incentives/keeper/incentives.go create mode 100644 x/incentives/keeper/incentives_test.go create mode 100644 x/incentives/keeper/keeper.go create mode 100644 x/incentives/keeper/keeper_test.go create mode 100644 x/incentives/keeper/strategy.go create mode 100644 x/incentives/keeper/strategy_test.go create mode 100644 x/incentives/module.go create mode 100644 x/incentives/types/examples/badprice/badprice.pb.go create mode 100644 x/incentives/types/examples/badprice/incentive.go create mode 100644 x/incentives/types/examples/badprice/strategy.go create mode 100644 x/incentives/types/examples/goodprice/goodprice.pb.go create mode 100644 x/incentives/types/examples/goodprice/incentive.go create mode 100644 x/incentives/types/examples/goodprice/strategy.go create mode 100644 x/incentives/types/examples/mocks/bank_keeper.go create mode 100644 x/incentives/types/examples/mocks/staking_keeper.go create mode 100644 x/incentives/types/genesis.go create mode 100644 x/incentives/types/genesis.pb.go create mode 100644 x/incentives/types/genesis_test.go create mode 100644 x/incentives/types/incentive.go create mode 100644 x/incentives/types/keys.go create mode 100644 x/incentives/types/query.pb.go create mode 100644 x/incentives/types/query.pb.gw.go create mode 100644 x/incentives/types/strategy.go create mode 100644 x/incentives/types/utils.go diff --git a/.markdownlint.json b/.markdownlint.json index 1e828de7d..c80b04475 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,12 +1,13 @@ { - "default": true, - "MD004": { "style": "asterisk" }, - "MD007": { "indent": 4 }, - "MD024": { "siblings_only": true }, - "MD025": false, - "MD033": false, - "MD034": false, - "MD014": false, - "no-hard-tabs": false, - "whitespace": false - } \ No newline at end of file + "default": true, + "MD004": { "style": "asterisk" }, + "MD007": { "indent": 4 }, + "MD024": { "siblings_only": true }, + "MD025": false, + "MD033": false, + "MD034": false, + "MD014": false, + "MD013": false, + "no-hard-tabs": false, + "whitespace": false +} \ No newline at end of file diff --git a/api/slinky/abci/v1/vote_extensions.pulsar.go b/api/slinky/abci/v1/vote_extensions.pulsar.go index 7b1fddd3d..d69c188d7 100644 --- a/api/slinky/abci/v1/vote_extensions.pulsar.go +++ b/api/slinky/abci/v1/vote_extensions.pulsar.go @@ -1676,7 +1676,8 @@ type OracleVoteExtension struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Prices defines a map of CurrencyPair -> hexPrice. i.e. "BTC/USD/8" -> "0x1234". + // Prices defines a map of CurrencyPair -> hexPrice. i.e. "BTC/USD/8" -> + // "0x1234". Prices map[string]string `protobuf:"bytes,1,rep,name=prices,proto3" json:"prices,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Timestamp defines the block timestamp when the oracle data was validated. Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` @@ -1725,20 +1726,23 @@ func (x *OracleVoteExtension) GetHeight() int64 { return 0 } -// OracleData defines the deterministic final oracle prices and data that will be inserted (PrepareProposal) -// and verified (ProcessProposal) in every block proposal. +// OracleData defines the deterministic final oracle prices and data that will +// be inserted (PrepareProposal) and verified (ProcessProposal) in every block +// proposal. type OracleData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Prices defines a map of CurrencyPair -> hexPrice. i.e. "BTC/USD/8" -> "0x1234". + // Prices defines a map of CurrencyPair -> hexPrice. i.e. "BTC/USD/8" -> + // "0x1234". Prices map[string]string `protobuf:"bytes,1,rep,name=prices,proto3" json:"prices,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Timestamp defines the block timestamp when the oracle data was validated. Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Height defines the block height when the oracle data was validated. Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - // ExtendedCommitInfo defines the last commit info which contains all vote extension data. + // ExtendedCommitInfo defines the last commit info which contains all vote + // extension data. ExtendedCommitInfo []byte `protobuf:"bytes,5,opt,name=extended_commit_info,json=extendedCommitInfo,proto3" json:"extended_commit_info,omitempty"` } diff --git a/api/slinky/incentives/module/v1/module.pulsar.go b/api/slinky/incentives/module/v1/module.pulsar.go new file mode 100644 index 000000000..029ce8da5 --- /dev/null +++ b/api/slinky/incentives/module/v1/module.pulsar.go @@ -0,0 +1,505 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package modulev1 + +import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" + 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_Module protoreflect.MessageDescriptor +) + +func init() { + file_slinky_incentives_module_v1_module_proto_init() + md_Module = File_slinky_incentives_module_v1_module_proto.Messages().ByName("Module") +} + +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_slinky_incentives_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 +var _ 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) { +} + +// 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() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.module.v1.Module")) + } + panic(fmt.Errorf("message slinky.incentives.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() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.module.v1.Module")) + } + panic(fmt.Errorf("message slinky.incentives.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() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.module.v1.Module")) + } + panic(fmt.Errorf("message slinky.incentives.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() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.module.v1.Module")) + } + panic(fmt.Errorf("message slinky.incentives.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() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.module.v1.Module")) + } + panic(fmt.Errorf("message slinky.incentives.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() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.module.v1.Module")) + } + panic(fmt.Errorf("message slinky.incentives.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 slinky.incentives.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 + 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 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 { + 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: slinky/incentives/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 incentives module. +type Module struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Module) Reset() { + *x = Module{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_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_slinky_incentives_module_v1_module_proto_rawDescGZIP(), []int{0} +} + +var File_slinky_incentives_module_v1_module_proto protoreflect.FileDescriptor + +var file_slinky_incentives_module_v1_module_proto_rawDesc = []byte{ + 0x0a, 0x28, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x6f, + 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x73, 0x6c, 0x69, 0x6e, + 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 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, 0x39, 0x0a, 0x06, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x3a, 0x2f, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x29, 0x0a, 0x27, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6b, 0x69, 0x70, 0x2d, 0x6d, 0x65, 0x76, + 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x78, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x42, 0xf4, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, + 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 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, 0x35, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, + 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x53, 0x49, 0x4d, 0xaa, 0x02, 0x1b, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x49, 0x6e, + 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, + 0x56, 0x31, 0xca, 0x02, 0x1b, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, 0x65, + 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, + 0xe2, 0x02, 0x27, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x53, 0x6c, 0x69, + 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x3a, + 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_slinky_incentives_module_v1_module_proto_rawDescOnce sync.Once + file_slinky_incentives_module_v1_module_proto_rawDescData = file_slinky_incentives_module_v1_module_proto_rawDesc +) + +func file_slinky_incentives_module_v1_module_proto_rawDescGZIP() []byte { + file_slinky_incentives_module_v1_module_proto_rawDescOnce.Do(func() { + file_slinky_incentives_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_slinky_incentives_module_v1_module_proto_rawDescData) + }) + return file_slinky_incentives_module_v1_module_proto_rawDescData +} + +var file_slinky_incentives_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_slinky_incentives_module_v1_module_proto_goTypes = []interface{}{ + (*Module)(nil), // 0: slinky.incentives.module.v1.Module +} +var file_slinky_incentives_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_slinky_incentives_module_v1_module_proto_init() } +func file_slinky_incentives_module_v1_module_proto_init() { + if File_slinky_incentives_module_v1_module_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_slinky_incentives_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_slinky_incentives_module_v1_module_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_slinky_incentives_module_v1_module_proto_goTypes, + DependencyIndexes: file_slinky_incentives_module_v1_module_proto_depIdxs, + MessageInfos: file_slinky_incentives_module_v1_module_proto_msgTypes, + }.Build() + File_slinky_incentives_module_v1_module_proto = out.File + file_slinky_incentives_module_v1_module_proto_rawDesc = nil + file_slinky_incentives_module_v1_module_proto_goTypes = nil + file_slinky_incentives_module_v1_module_proto_depIdxs = nil +} diff --git a/api/slinky/incentives/v1/badprice.pulsar.go b/api/slinky/incentives/v1/badprice.pulsar.go new file mode 100644 index 000000000..2371aa7e2 --- /dev/null +++ b/api/slinky/incentives/v1/badprice.pulsar.go @@ -0,0 +1,659 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package incentivesv1 + +import ( + _ "cosmossdk.io/api/amino" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + 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_BadPriceIncentive protoreflect.MessageDescriptor + fd_BadPriceIncentive_validator protoreflect.FieldDescriptor + fd_BadPriceIncentive_amount protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_badprice_proto_init() + md_BadPriceIncentive = File_slinky_incentives_v1_badprice_proto.Messages().ByName("BadPriceIncentive") + fd_BadPriceIncentive_validator = md_BadPriceIncentive.Fields().ByName("validator") + fd_BadPriceIncentive_amount = md_BadPriceIncentive.Fields().ByName("amount") +} + +var _ protoreflect.Message = (*fastReflection_BadPriceIncentive)(nil) + +type fastReflection_BadPriceIncentive BadPriceIncentive + +func (x *BadPriceIncentive) ProtoReflect() protoreflect.Message { + return (*fastReflection_BadPriceIncentive)(x) +} + +func (x *BadPriceIncentive) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_badprice_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_BadPriceIncentive_messageType fastReflection_BadPriceIncentive_messageType +var _ protoreflect.MessageType = fastReflection_BadPriceIncentive_messageType{} + +type fastReflection_BadPriceIncentive_messageType struct{} + +func (x fastReflection_BadPriceIncentive_messageType) Zero() protoreflect.Message { + return (*fastReflection_BadPriceIncentive)(nil) +} +func (x fastReflection_BadPriceIncentive_messageType) New() protoreflect.Message { + return new(fastReflection_BadPriceIncentive) +} +func (x fastReflection_BadPriceIncentive_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_BadPriceIncentive +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_BadPriceIncentive) Descriptor() protoreflect.MessageDescriptor { + return md_BadPriceIncentive +} + +// 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_BadPriceIncentive) Type() protoreflect.MessageType { + return _fastReflection_BadPriceIncentive_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_BadPriceIncentive) New() protoreflect.Message { + return new(fastReflection_BadPriceIncentive) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_BadPriceIncentive) Interface() protoreflect.ProtoMessage { + return (*BadPriceIncentive)(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_BadPriceIncentive) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Validator != "" { + value := protoreflect.ValueOfString(x.Validator) + if !f(fd_BadPriceIncentive_validator, value) { + return + } + } + if x.Amount != "" { + value := protoreflect.ValueOfString(x.Amount) + if !f(fd_BadPriceIncentive_amount, 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_BadPriceIncentive) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.BadPriceIncentive.validator": + return x.Validator != "" + case "slinky.incentives.v1.BadPriceIncentive.amount": + return x.Amount != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.BadPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.BadPriceIncentive 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_BadPriceIncentive) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.BadPriceIncentive.validator": + x.Validator = "" + case "slinky.incentives.v1.BadPriceIncentive.amount": + x.Amount = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.BadPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.BadPriceIncentive 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_BadPriceIncentive) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.BadPriceIncentive.validator": + value := x.Validator + return protoreflect.ValueOfString(value) + case "slinky.incentives.v1.BadPriceIncentive.amount": + value := x.Amount + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.BadPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.BadPriceIncentive 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_BadPriceIncentive) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.BadPriceIncentive.validator": + x.Validator = value.Interface().(string) + case "slinky.incentives.v1.BadPriceIncentive.amount": + x.Amount = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.BadPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.BadPriceIncentive 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_BadPriceIncentive) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.BadPriceIncentive.validator": + panic(fmt.Errorf("field validator of message slinky.incentives.v1.BadPriceIncentive is not mutable")) + case "slinky.incentives.v1.BadPriceIncentive.amount": + panic(fmt.Errorf("field amount of message slinky.incentives.v1.BadPriceIncentive is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.BadPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.BadPriceIncentive 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_BadPriceIncentive) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.BadPriceIncentive.validator": + return protoreflect.ValueOfString("") + case "slinky.incentives.v1.BadPriceIncentive.amount": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.BadPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.BadPriceIncentive 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_BadPriceIncentive) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.BadPriceIncentive", 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_BadPriceIncentive) 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_BadPriceIncentive) 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_BadPriceIncentive) 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_BadPriceIncentive) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*BadPriceIncentive) + 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.Validator) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Amount) + 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().(*BadPriceIncentive) + 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.Amount) > 0 { + i -= len(x.Amount) + copy(dAtA[i:], x.Amount) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(x.Validator) > 0 { + i -= len(x.Validator) + copy(dAtA[i:], x.Validator) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Validator))) + 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().(*BadPriceIncentive) + 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: BadPriceIncentive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: BadPriceIncentive: 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 Validator", 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.Validator = 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 Amount", 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.Amount = 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: slinky/incentives/v1/badprice.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) +) + +// BadPriceIncentive is a message that contains the information about a bad price +// that was submitted by a validator. +// +// NOTE: This is an example of a bad price incentive. It is not used in production. +type BadPriceIncentive struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Validator is the address of the validator that submitted the bad price. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Amount is the amount to slash. + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *BadPriceIncentive) Reset() { + *x = BadPriceIncentive{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_badprice_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BadPriceIncentive) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BadPriceIncentive) ProtoMessage() {} + +// Deprecated: Use BadPriceIncentive.ProtoReflect.Descriptor instead. +func (*BadPriceIncentive) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_badprice_proto_rawDescGZIP(), []int{0} +} + +func (x *BadPriceIncentive) GetValidator() string { + if x != nil { + return x.Validator + } + return "" +} + +func (x *BadPriceIncentive) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +var File_slinky_incentives_v1_badprice_proto protoreflect.FileDescriptor + +var file_slinky_incentives_v1_badprice_proto_rawDesc = []byte{ + 0x0a, 0x23, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x62, 0x61, 0x64, 0x70, 0x72, 0x69, 0x63, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, + 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x11, 0x61, 0x6d, 0x69, + 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x91, 0x01, 0x0a, 0x11, 0x42, 0x61, + 0x64, 0x50, 0x72, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x16, 0x0a, + 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x46, 0xca, 0xb4, 0x2d, 0x1e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x8a, 0xe7, 0xb0, 0x2a, 0x1f, 0x73, 0x6c, + 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x42, 0x61, 0x64, 0x50, + 0x72, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x42, 0xcf, 0x01, + 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, + 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x42, 0x61, 0x64, 0x70, + 0x72, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, + 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2f, + 0x76, 0x31, 0x3b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x76, 0x31, 0xa2, + 0x02, 0x03, 0x53, 0x49, 0x58, 0xaa, 0x02, 0x14, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x49, + 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x14, 0x53, + 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, + 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x20, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, + 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, + 0x3a, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_slinky_incentives_v1_badprice_proto_rawDescOnce sync.Once + file_slinky_incentives_v1_badprice_proto_rawDescData = file_slinky_incentives_v1_badprice_proto_rawDesc +) + +func file_slinky_incentives_v1_badprice_proto_rawDescGZIP() []byte { + file_slinky_incentives_v1_badprice_proto_rawDescOnce.Do(func() { + file_slinky_incentives_v1_badprice_proto_rawDescData = protoimpl.X.CompressGZIP(file_slinky_incentives_v1_badprice_proto_rawDescData) + }) + return file_slinky_incentives_v1_badprice_proto_rawDescData +} + +var file_slinky_incentives_v1_badprice_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_slinky_incentives_v1_badprice_proto_goTypes = []interface{}{ + (*BadPriceIncentive)(nil), // 0: slinky.incentives.v1.BadPriceIncentive +} +var file_slinky_incentives_v1_badprice_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_slinky_incentives_v1_badprice_proto_init() } +func file_slinky_incentives_v1_badprice_proto_init() { + if File_slinky_incentives_v1_badprice_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_slinky_incentives_v1_badprice_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BadPriceIncentive); 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_slinky_incentives_v1_badprice_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_slinky_incentives_v1_badprice_proto_goTypes, + DependencyIndexes: file_slinky_incentives_v1_badprice_proto_depIdxs, + MessageInfos: file_slinky_incentives_v1_badprice_proto_msgTypes, + }.Build() + File_slinky_incentives_v1_badprice_proto = out.File + file_slinky_incentives_v1_badprice_proto_rawDesc = nil + file_slinky_incentives_v1_badprice_proto_goTypes = nil + file_slinky_incentives_v1_badprice_proto_depIdxs = nil +} diff --git a/api/slinky/incentives/v1/genesis.pulsar.go b/api/slinky/incentives/v1/genesis.pulsar.go new file mode 100644 index 000000000..bb776809a --- /dev/null +++ b/api/slinky/incentives/v1/genesis.pulsar.go @@ -0,0 +1,1263 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package incentivesv1 + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + 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 _ protoreflect.List = (*_GenesisState_1_list)(nil) + +type _GenesisState_1_list struct { + list *[]*IncentivesByType +} + +func (x *_GenesisState_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GenesisState_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_GenesisState_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*IncentivesByType) + (*x.list)[i] = concreteValue +} + +func (x *_GenesisState_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*IncentivesByType) + *x.list = append(*x.list, concreteValue) +} + +func (x *_GenesisState_1_list) AppendMutable() protoreflect.Value { + v := new(IncentivesByType) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_GenesisState_1_list) NewElement() protoreflect.Value { + v := new(IncentivesByType) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_GenesisState protoreflect.MessageDescriptor + fd_GenesisState_registry protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_genesis_proto_init() + md_GenesisState = File_slinky_incentives_v1_genesis_proto.Messages().ByName("GenesisState") + fd_GenesisState_registry = md_GenesisState.Fields().ByName("registry") +} + +var _ protoreflect.Message = (*fastReflection_GenesisState)(nil) + +type fastReflection_GenesisState GenesisState + +func (x *GenesisState) ProtoReflect() protoreflect.Message { + return (*fastReflection_GenesisState)(x) +} + +func (x *GenesisState) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_genesis_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_GenesisState_messageType fastReflection_GenesisState_messageType +var _ protoreflect.MessageType = fastReflection_GenesisState_messageType{} + +type fastReflection_GenesisState_messageType struct{} + +func (x fastReflection_GenesisState_messageType) Zero() protoreflect.Message { + return (*fastReflection_GenesisState)(nil) +} +func (x fastReflection_GenesisState_messageType) New() protoreflect.Message { + return new(fastReflection_GenesisState) +} +func (x fastReflection_GenesisState_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GenesisState +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GenesisState) Descriptor() protoreflect.MessageDescriptor { + return md_GenesisState +} + +// 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_GenesisState) Type() protoreflect.MessageType { + return _fastReflection_GenesisState_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GenesisState) New() protoreflect.Message { + return new(fastReflection_GenesisState) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GenesisState) Interface() protoreflect.ProtoMessage { + return (*GenesisState)(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_GenesisState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Registry) != 0 { + value := protoreflect.ValueOfList(&_GenesisState_1_list{list: &x.Registry}) + if !f(fd_GenesisState_registry, 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_GenesisState) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.GenesisState.registry": + return len(x.Registry) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GenesisState")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GenesisState 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_GenesisState) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.GenesisState.registry": + x.Registry = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GenesisState")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GenesisState 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_GenesisState) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.GenesisState.registry": + if len(x.Registry) == 0 { + return protoreflect.ValueOfList(&_GenesisState_1_list{}) + } + listValue := &_GenesisState_1_list{list: &x.Registry} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GenesisState")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GenesisState 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_GenesisState) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.GenesisState.registry": + lv := value.List() + clv := lv.(*_GenesisState_1_list) + x.Registry = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GenesisState")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GenesisState 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_GenesisState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GenesisState.registry": + if x.Registry == nil { + x.Registry = []*IncentivesByType{} + } + value := &_GenesisState_1_list{list: &x.Registry} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GenesisState")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GenesisState 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_GenesisState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GenesisState.registry": + list := []*IncentivesByType{} + return protoreflect.ValueOfList(&_GenesisState_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GenesisState")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GenesisState 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_GenesisState) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.GenesisState", 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_GenesisState) 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_GenesisState) 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_GenesisState) 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_GenesisState) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GenesisState) + 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.Registry) > 0 { + for _, e := range x.Registry { + 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().(*GenesisState) + 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.Registry) > 0 { + for iNdEx := len(x.Registry) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Registry[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().(*GenesisState) + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GenesisState: 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 Registry", 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.Registry = append(x.Registry, &IncentivesByType{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Registry[len(x.Registry)-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 = (*_IncentivesByType_2_list)(nil) + +type _IncentivesByType_2_list struct { + list *[][]byte +} + +func (x *_IncentivesByType_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_IncentivesByType_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfBytes((*x.list)[i]) +} + +func (x *_IncentivesByType_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Bytes() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_IncentivesByType_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Bytes() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_IncentivesByType_2_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message IncentivesByType at list field Entries as it is not of Message kind")) +} + +func (x *_IncentivesByType_2_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_IncentivesByType_2_list) NewElement() protoreflect.Value { + var v []byte + return protoreflect.ValueOfBytes(v) +} + +func (x *_IncentivesByType_2_list) IsValid() bool { + return x.list != nil +} + +var ( + md_IncentivesByType protoreflect.MessageDescriptor + fd_IncentivesByType_incentive_type protoreflect.FieldDescriptor + fd_IncentivesByType_entries protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_genesis_proto_init() + md_IncentivesByType = File_slinky_incentives_v1_genesis_proto.Messages().ByName("IncentivesByType") + fd_IncentivesByType_incentive_type = md_IncentivesByType.Fields().ByName("incentive_type") + fd_IncentivesByType_entries = md_IncentivesByType.Fields().ByName("entries") +} + +var _ protoreflect.Message = (*fastReflection_IncentivesByType)(nil) + +type fastReflection_IncentivesByType IncentivesByType + +func (x *IncentivesByType) ProtoReflect() protoreflect.Message { + return (*fastReflection_IncentivesByType)(x) +} + +func (x *IncentivesByType) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_genesis_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_IncentivesByType_messageType fastReflection_IncentivesByType_messageType +var _ protoreflect.MessageType = fastReflection_IncentivesByType_messageType{} + +type fastReflection_IncentivesByType_messageType struct{} + +func (x fastReflection_IncentivesByType_messageType) Zero() protoreflect.Message { + return (*fastReflection_IncentivesByType)(nil) +} +func (x fastReflection_IncentivesByType_messageType) New() protoreflect.Message { + return new(fastReflection_IncentivesByType) +} +func (x fastReflection_IncentivesByType_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_IncentivesByType +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_IncentivesByType) Descriptor() protoreflect.MessageDescriptor { + return md_IncentivesByType +} + +// 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_IncentivesByType) Type() protoreflect.MessageType { + return _fastReflection_IncentivesByType_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_IncentivesByType) New() protoreflect.Message { + return new(fastReflection_IncentivesByType) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_IncentivesByType) Interface() protoreflect.ProtoMessage { + return (*IncentivesByType)(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_IncentivesByType) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.IncentiveType != "" { + value := protoreflect.ValueOfString(x.IncentiveType) + if !f(fd_IncentivesByType_incentive_type, value) { + return + } + } + if len(x.Entries) != 0 { + value := protoreflect.ValueOfList(&_IncentivesByType_2_list{list: &x.Entries}) + if !f(fd_IncentivesByType_entries, 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_IncentivesByType) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.IncentivesByType.incentive_type": + return x.IncentiveType != "" + case "slinky.incentives.v1.IncentivesByType.entries": + return len(x.Entries) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.IncentivesByType")) + } + panic(fmt.Errorf("message slinky.incentives.v1.IncentivesByType 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_IncentivesByType) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.IncentivesByType.incentive_type": + x.IncentiveType = "" + case "slinky.incentives.v1.IncentivesByType.entries": + x.Entries = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.IncentivesByType")) + } + panic(fmt.Errorf("message slinky.incentives.v1.IncentivesByType 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_IncentivesByType) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.IncentivesByType.incentive_type": + value := x.IncentiveType + return protoreflect.ValueOfString(value) + case "slinky.incentives.v1.IncentivesByType.entries": + if len(x.Entries) == 0 { + return protoreflect.ValueOfList(&_IncentivesByType_2_list{}) + } + listValue := &_IncentivesByType_2_list{list: &x.Entries} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.IncentivesByType")) + } + panic(fmt.Errorf("message slinky.incentives.v1.IncentivesByType 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_IncentivesByType) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.IncentivesByType.incentive_type": + x.IncentiveType = value.Interface().(string) + case "slinky.incentives.v1.IncentivesByType.entries": + lv := value.List() + clv := lv.(*_IncentivesByType_2_list) + x.Entries = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.IncentivesByType")) + } + panic(fmt.Errorf("message slinky.incentives.v1.IncentivesByType 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_IncentivesByType) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.IncentivesByType.entries": + if x.Entries == nil { + x.Entries = [][]byte{} + } + value := &_IncentivesByType_2_list{list: &x.Entries} + return protoreflect.ValueOfList(value) + case "slinky.incentives.v1.IncentivesByType.incentive_type": + panic(fmt.Errorf("field incentive_type of message slinky.incentives.v1.IncentivesByType is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.IncentivesByType")) + } + panic(fmt.Errorf("message slinky.incentives.v1.IncentivesByType 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_IncentivesByType) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.IncentivesByType.incentive_type": + return protoreflect.ValueOfString("") + case "slinky.incentives.v1.IncentivesByType.entries": + list := [][]byte{} + return protoreflect.ValueOfList(&_IncentivesByType_2_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.IncentivesByType")) + } + panic(fmt.Errorf("message slinky.incentives.v1.IncentivesByType 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_IncentivesByType) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.IncentivesByType", 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_IncentivesByType) 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_IncentivesByType) 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_IncentivesByType) 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_IncentivesByType) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*IncentivesByType) + 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.IncentiveType) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.Entries) > 0 { + for _, b := range x.Entries { + l = len(b) + 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().(*IncentivesByType) + 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.Entries) > 0 { + for iNdEx := len(x.Entries) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.Entries[iNdEx]) + copy(dAtA[i:], x.Entries[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Entries[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(x.IncentiveType) > 0 { + i -= len(x.IncentiveType) + copy(dAtA[i:], x.IncentiveType) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.IncentiveType))) + 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().(*IncentivesByType) + 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: IncentivesByType: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: IncentivesByType: 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 IncentiveType", 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.IncentiveType = 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 Entries", wireType) + } + var byteLen 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++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + 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.Entries = append(x.Entries, make([]byte, postIndex-iNdEx)) + copy(x.Entries[len(x.Entries)-1], 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: slinky/incentives/v1/genesis.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) +) + +// GenesisState is the genesis-state for the x/incentives module. +type GenesisState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Registry is a list of incentives by type. The registry defined here + // should be a subset of the incentive types defined in the incentive + // module (keeper). + Registry []*IncentivesByType `protobuf:"bytes,1,rep,name=registry,proto3" json:"registry,omitempty"` +} + +func (x *GenesisState) Reset() { + *x = GenesisState{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_genesis_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenesisState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenesisState) ProtoMessage() {} + +// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. +func (*GenesisState) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_genesis_proto_rawDescGZIP(), []int{0} +} + +func (x *GenesisState) GetRegistry() []*IncentivesByType { + if x != nil { + return x.Registry + } + return nil +} + +// IncentivesByType encapsulates a list of incentives by type. Each of the +// entries here must correspond to the same incentive type defined here. +type IncentivesByType struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // IncentiveType is the incentive type i.e. (BadPriceIncentiveType, GoodPriceIncentiveType). + IncentiveType string `protobuf:"bytes,1,opt,name=incentive_type,json=incentiveType,proto3" json:"incentive_type,omitempty"` + // Entries is a list of incentive bytes. + Entries [][]byte `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries,omitempty"` +} + +func (x *IncentivesByType) Reset() { + *x = IncentivesByType{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_genesis_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IncentivesByType) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IncentivesByType) ProtoMessage() {} + +// Deprecated: Use IncentivesByType.ProtoReflect.Descriptor instead. +func (*IncentivesByType) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_genesis_proto_rawDescGZIP(), []int{1} +} + +func (x *IncentivesByType) GetIncentiveType() string { + if x != nil { + return x.IncentiveType + } + return "" +} + +func (x *IncentivesByType) GetEntries() [][]byte { + if x != nil { + return x.Entries + } + return nil +} + +var File_slinky_incentives_v1_genesis_proto protoreflect.FileDescriptor + +var file_slinky_incentives_v1_genesis_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, + 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x58, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x48, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, + 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, + 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x22, 0x59, 0x0a, 0x10, 0x49, 0x6e, + 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x65, 0x6e, + 0x74, 0x72, 0x69, 0x65, 0x73, 0x42, 0xce, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, + 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, + 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, + 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x49, 0x58, 0xaa, 0x02, 0x14, 0x53, + 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, + 0x2e, 0x56, 0x31, 0xca, 0x02, 0x14, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, + 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x20, 0x53, 0x6c, 0x69, + 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x5c, 0x56, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, + 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_slinky_incentives_v1_genesis_proto_rawDescOnce sync.Once + file_slinky_incentives_v1_genesis_proto_rawDescData = file_slinky_incentives_v1_genesis_proto_rawDesc +) + +func file_slinky_incentives_v1_genesis_proto_rawDescGZIP() []byte { + file_slinky_incentives_v1_genesis_proto_rawDescOnce.Do(func() { + file_slinky_incentives_v1_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_slinky_incentives_v1_genesis_proto_rawDescData) + }) + return file_slinky_incentives_v1_genesis_proto_rawDescData +} + +var file_slinky_incentives_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_slinky_incentives_v1_genesis_proto_goTypes = []interface{}{ + (*GenesisState)(nil), // 0: slinky.incentives.v1.GenesisState + (*IncentivesByType)(nil), // 1: slinky.incentives.v1.IncentivesByType +} +var file_slinky_incentives_v1_genesis_proto_depIdxs = []int32{ + 1, // 0: slinky.incentives.v1.GenesisState.registry:type_name -> slinky.incentives.v1.IncentivesByType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] 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_slinky_incentives_v1_genesis_proto_init() } +func file_slinky_incentives_v1_genesis_proto_init() { + if File_slinky_incentives_v1_genesis_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_slinky_incentives_v1_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenesisState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_slinky_incentives_v1_genesis_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IncentivesByType); 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_slinky_incentives_v1_genesis_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_slinky_incentives_v1_genesis_proto_goTypes, + DependencyIndexes: file_slinky_incentives_v1_genesis_proto_depIdxs, + MessageInfos: file_slinky_incentives_v1_genesis_proto_msgTypes, + }.Build() + File_slinky_incentives_v1_genesis_proto = out.File + file_slinky_incentives_v1_genesis_proto_rawDesc = nil + file_slinky_incentives_v1_genesis_proto_goTypes = nil + file_slinky_incentives_v1_genesis_proto_depIdxs = nil +} diff --git a/api/slinky/incentives/v1/goodprice.pulsar.go b/api/slinky/incentives/v1/goodprice.pulsar.go new file mode 100644 index 000000000..e772b217e --- /dev/null +++ b/api/slinky/incentives/v1/goodprice.pulsar.go @@ -0,0 +1,659 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package incentivesv1 + +import ( + _ "cosmossdk.io/api/amino" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + 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_GoodPriceIncentive protoreflect.MessageDescriptor + fd_GoodPriceIncentive_validator protoreflect.FieldDescriptor + fd_GoodPriceIncentive_amount protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_goodprice_proto_init() + md_GoodPriceIncentive = File_slinky_incentives_v1_goodprice_proto.Messages().ByName("GoodPriceIncentive") + fd_GoodPriceIncentive_validator = md_GoodPriceIncentive.Fields().ByName("validator") + fd_GoodPriceIncentive_amount = md_GoodPriceIncentive.Fields().ByName("amount") +} + +var _ protoreflect.Message = (*fastReflection_GoodPriceIncentive)(nil) + +type fastReflection_GoodPriceIncentive GoodPriceIncentive + +func (x *GoodPriceIncentive) ProtoReflect() protoreflect.Message { + return (*fastReflection_GoodPriceIncentive)(x) +} + +func (x *GoodPriceIncentive) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_goodprice_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_GoodPriceIncentive_messageType fastReflection_GoodPriceIncentive_messageType +var _ protoreflect.MessageType = fastReflection_GoodPriceIncentive_messageType{} + +type fastReflection_GoodPriceIncentive_messageType struct{} + +func (x fastReflection_GoodPriceIncentive_messageType) Zero() protoreflect.Message { + return (*fastReflection_GoodPriceIncentive)(nil) +} +func (x fastReflection_GoodPriceIncentive_messageType) New() protoreflect.Message { + return new(fastReflection_GoodPriceIncentive) +} +func (x fastReflection_GoodPriceIncentive_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GoodPriceIncentive +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GoodPriceIncentive) Descriptor() protoreflect.MessageDescriptor { + return md_GoodPriceIncentive +} + +// 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_GoodPriceIncentive) Type() protoreflect.MessageType { + return _fastReflection_GoodPriceIncentive_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GoodPriceIncentive) New() protoreflect.Message { + return new(fastReflection_GoodPriceIncentive) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GoodPriceIncentive) Interface() protoreflect.ProtoMessage { + return (*GoodPriceIncentive)(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_GoodPriceIncentive) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Validator != "" { + value := protoreflect.ValueOfString(x.Validator) + if !f(fd_GoodPriceIncentive_validator, value) { + return + } + } + if x.Amount != "" { + value := protoreflect.ValueOfString(x.Amount) + if !f(fd_GoodPriceIncentive_amount, 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_GoodPriceIncentive) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.GoodPriceIncentive.validator": + return x.Validator != "" + case "slinky.incentives.v1.GoodPriceIncentive.amount": + return x.Amount != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GoodPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GoodPriceIncentive 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_GoodPriceIncentive) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.GoodPriceIncentive.validator": + x.Validator = "" + case "slinky.incentives.v1.GoodPriceIncentive.amount": + x.Amount = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GoodPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GoodPriceIncentive 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_GoodPriceIncentive) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.GoodPriceIncentive.validator": + value := x.Validator + return protoreflect.ValueOfString(value) + case "slinky.incentives.v1.GoodPriceIncentive.amount": + value := x.Amount + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GoodPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GoodPriceIncentive 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_GoodPriceIncentive) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.GoodPriceIncentive.validator": + x.Validator = value.Interface().(string) + case "slinky.incentives.v1.GoodPriceIncentive.amount": + x.Amount = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GoodPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GoodPriceIncentive 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_GoodPriceIncentive) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GoodPriceIncentive.validator": + panic(fmt.Errorf("field validator of message slinky.incentives.v1.GoodPriceIncentive is not mutable")) + case "slinky.incentives.v1.GoodPriceIncentive.amount": + panic(fmt.Errorf("field amount of message slinky.incentives.v1.GoodPriceIncentive is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GoodPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GoodPriceIncentive 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_GoodPriceIncentive) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GoodPriceIncentive.validator": + return protoreflect.ValueOfString("") + case "slinky.incentives.v1.GoodPriceIncentive.amount": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GoodPriceIncentive")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GoodPriceIncentive 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_GoodPriceIncentive) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.GoodPriceIncentive", 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_GoodPriceIncentive) 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_GoodPriceIncentive) 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_GoodPriceIncentive) 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_GoodPriceIncentive) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GoodPriceIncentive) + 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.Validator) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Amount) + 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().(*GoodPriceIncentive) + 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.Amount) > 0 { + i -= len(x.Amount) + copy(dAtA[i:], x.Amount) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(x.Validator) > 0 { + i -= len(x.Validator) + copy(dAtA[i:], x.Validator) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Validator))) + 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().(*GoodPriceIncentive) + 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: GoodPriceIncentive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GoodPriceIncentive: 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 Validator", 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.Validator = 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 Amount", 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.Amount = 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: slinky/incentives/v1/goodprice.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) +) + +// GoodPriceIncentive is a message that contains the information about a good price +// that was submitted by a validator. +// +// NOTE: This is an example of a good price incentive. It is not used in production. +type GoodPriceIncentive struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Validator is the address of the validator that submitted the good price. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Amount is the amount to reward. + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *GoodPriceIncentive) Reset() { + *x = GoodPriceIncentive{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_goodprice_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GoodPriceIncentive) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GoodPriceIncentive) ProtoMessage() {} + +// Deprecated: Use GoodPriceIncentive.ProtoReflect.Descriptor instead. +func (*GoodPriceIncentive) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_goodprice_proto_rawDescGZIP(), []int{0} +} + +func (x *GoodPriceIncentive) GetValidator() string { + if x != nil { + return x.Validator + } + return "" +} + +func (x *GoodPriceIncentive) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +var File_slinky_incentives_v1_goodprice_proto protoreflect.FileDescriptor + +var file_slinky_incentives_v1_goodprice_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x6f, 0x6f, 0x64, 0x70, 0x72, 0x69, 0x63, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, + 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x11, 0x61, 0x6d, + 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x01, 0x0a, 0x12, 0x47, + 0x6f, 0x6f, 0x64, 0x50, 0x72, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, + 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x46, 0xca, 0xb4, 0x2d, 0x1e, 0x73, 0x6c, 0x69, + 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x8a, 0xe7, 0xb0, 0x2a, 0x1f, + 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x42, 0x61, + 0x64, 0x50, 0x72, 0x69, 0x63, 0x65, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x42, + 0xd0, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, + 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0e, 0x47, 0x6f, + 0x6f, 0x64, 0x70, 0x72, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, + 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x49, 0x58, 0xaa, 0x02, 0x14, 0x53, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x31, 0xca, + 0x02, 0x14, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x20, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, + 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x53, 0x6c, 0x69, 0x6e, + 0x6b, 0x79, 0x3a, 0x3a, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_slinky_incentives_v1_goodprice_proto_rawDescOnce sync.Once + file_slinky_incentives_v1_goodprice_proto_rawDescData = file_slinky_incentives_v1_goodprice_proto_rawDesc +) + +func file_slinky_incentives_v1_goodprice_proto_rawDescGZIP() []byte { + file_slinky_incentives_v1_goodprice_proto_rawDescOnce.Do(func() { + file_slinky_incentives_v1_goodprice_proto_rawDescData = protoimpl.X.CompressGZIP(file_slinky_incentives_v1_goodprice_proto_rawDescData) + }) + return file_slinky_incentives_v1_goodprice_proto_rawDescData +} + +var file_slinky_incentives_v1_goodprice_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_slinky_incentives_v1_goodprice_proto_goTypes = []interface{}{ + (*GoodPriceIncentive)(nil), // 0: slinky.incentives.v1.GoodPriceIncentive +} +var file_slinky_incentives_v1_goodprice_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_slinky_incentives_v1_goodprice_proto_init() } +func file_slinky_incentives_v1_goodprice_proto_init() { + if File_slinky_incentives_v1_goodprice_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_slinky_incentives_v1_goodprice_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GoodPriceIncentive); 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_slinky_incentives_v1_goodprice_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_slinky_incentives_v1_goodprice_proto_goTypes, + DependencyIndexes: file_slinky_incentives_v1_goodprice_proto_depIdxs, + MessageInfos: file_slinky_incentives_v1_goodprice_proto_msgTypes, + }.Build() + File_slinky_incentives_v1_goodprice_proto = out.File + file_slinky_incentives_v1_goodprice_proto_rawDesc = nil + file_slinky_incentives_v1_goodprice_proto_goTypes = nil + file_slinky_incentives_v1_goodprice_proto_depIdxs = nil +} diff --git a/api/slinky/incentives/v1/query.pulsar.go b/api/slinky/incentives/v1/query.pulsar.go new file mode 100644 index 000000000..f6df67756 --- /dev/null +++ b/api/slinky/incentives/v1/query.pulsar.go @@ -0,0 +1,2095 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package incentivesv1 + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + _ "google.golang.org/genproto/googleapis/api/annotations" + 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_GetIncentivesByTypeRequest protoreflect.MessageDescriptor + fd_GetIncentivesByTypeRequest_incentive_type protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_query_proto_init() + md_GetIncentivesByTypeRequest = File_slinky_incentives_v1_query_proto.Messages().ByName("GetIncentivesByTypeRequest") + fd_GetIncentivesByTypeRequest_incentive_type = md_GetIncentivesByTypeRequest.Fields().ByName("incentive_type") +} + +var _ protoreflect.Message = (*fastReflection_GetIncentivesByTypeRequest)(nil) + +type fastReflection_GetIncentivesByTypeRequest GetIncentivesByTypeRequest + +func (x *GetIncentivesByTypeRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_GetIncentivesByTypeRequest)(x) +} + +func (x *GetIncentivesByTypeRequest) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_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_GetIncentivesByTypeRequest_messageType fastReflection_GetIncentivesByTypeRequest_messageType +var _ protoreflect.MessageType = fastReflection_GetIncentivesByTypeRequest_messageType{} + +type fastReflection_GetIncentivesByTypeRequest_messageType struct{} + +func (x fastReflection_GetIncentivesByTypeRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_GetIncentivesByTypeRequest)(nil) +} +func (x fastReflection_GetIncentivesByTypeRequest_messageType) New() protoreflect.Message { + return new(fastReflection_GetIncentivesByTypeRequest) +} +func (x fastReflection_GetIncentivesByTypeRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GetIncentivesByTypeRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GetIncentivesByTypeRequest) Descriptor() protoreflect.MessageDescriptor { + return md_GetIncentivesByTypeRequest +} + +// 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_GetIncentivesByTypeRequest) Type() protoreflect.MessageType { + return _fastReflection_GetIncentivesByTypeRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GetIncentivesByTypeRequest) New() protoreflect.Message { + return new(fastReflection_GetIncentivesByTypeRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GetIncentivesByTypeRequest) Interface() protoreflect.ProtoMessage { + return (*GetIncentivesByTypeRequest)(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_GetIncentivesByTypeRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.IncentiveType != "" { + value := protoreflect.ValueOfString(x.IncentiveType) + if !f(fd_GetIncentivesByTypeRequest_incentive_type, 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_GetIncentivesByTypeRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeRequest.incentive_type": + return x.IncentiveType != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeRequest 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_GetIncentivesByTypeRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeRequest.incentive_type": + x.IncentiveType = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeRequest 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_GetIncentivesByTypeRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeRequest.incentive_type": + value := x.IncentiveType + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeRequest 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_GetIncentivesByTypeRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeRequest.incentive_type": + x.IncentiveType = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeRequest 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_GetIncentivesByTypeRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeRequest.incentive_type": + panic(fmt.Errorf("field incentive_type of message slinky.incentives.v1.GetIncentivesByTypeRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeRequest 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_GetIncentivesByTypeRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeRequest.incentive_type": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeRequest 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_GetIncentivesByTypeRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.GetIncentivesByTypeRequest", 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_GetIncentivesByTypeRequest) 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_GetIncentivesByTypeRequest) 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_GetIncentivesByTypeRequest) 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_GetIncentivesByTypeRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GetIncentivesByTypeRequest) + 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.IncentiveType) + 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().(*GetIncentivesByTypeRequest) + 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.IncentiveType) > 0 { + i -= len(x.IncentiveType) + copy(dAtA[i:], x.IncentiveType) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.IncentiveType))) + 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().(*GetIncentivesByTypeRequest) + 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: GetIncentivesByTypeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GetIncentivesByTypeRequest: 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 IncentiveType", 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.IncentiveType = 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, + } +} + +var _ protoreflect.List = (*_GetIncentivesByTypeResponse_1_list)(nil) + +type _GetIncentivesByTypeResponse_1_list struct { + list *[][]byte +} + +func (x *_GetIncentivesByTypeResponse_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GetIncentivesByTypeResponse_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfBytes((*x.list)[i]) +} + +func (x *_GetIncentivesByTypeResponse_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Bytes() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_GetIncentivesByTypeResponse_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Bytes() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_GetIncentivesByTypeResponse_1_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message GetIncentivesByTypeResponse at list field Entries as it is not of Message kind")) +} + +func (x *_GetIncentivesByTypeResponse_1_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_GetIncentivesByTypeResponse_1_list) NewElement() protoreflect.Value { + var v []byte + return protoreflect.ValueOfBytes(v) +} + +func (x *_GetIncentivesByTypeResponse_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_GetIncentivesByTypeResponse protoreflect.MessageDescriptor + fd_GetIncentivesByTypeResponse_entries protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_query_proto_init() + md_GetIncentivesByTypeResponse = File_slinky_incentives_v1_query_proto.Messages().ByName("GetIncentivesByTypeResponse") + fd_GetIncentivesByTypeResponse_entries = md_GetIncentivesByTypeResponse.Fields().ByName("entries") +} + +var _ protoreflect.Message = (*fastReflection_GetIncentivesByTypeResponse)(nil) + +type fastReflection_GetIncentivesByTypeResponse GetIncentivesByTypeResponse + +func (x *GetIncentivesByTypeResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_GetIncentivesByTypeResponse)(x) +} + +func (x *GetIncentivesByTypeResponse) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_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_GetIncentivesByTypeResponse_messageType fastReflection_GetIncentivesByTypeResponse_messageType +var _ protoreflect.MessageType = fastReflection_GetIncentivesByTypeResponse_messageType{} + +type fastReflection_GetIncentivesByTypeResponse_messageType struct{} + +func (x fastReflection_GetIncentivesByTypeResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_GetIncentivesByTypeResponse)(nil) +} +func (x fastReflection_GetIncentivesByTypeResponse_messageType) New() protoreflect.Message { + return new(fastReflection_GetIncentivesByTypeResponse) +} +func (x fastReflection_GetIncentivesByTypeResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GetIncentivesByTypeResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GetIncentivesByTypeResponse) Descriptor() protoreflect.MessageDescriptor { + return md_GetIncentivesByTypeResponse +} + +// 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_GetIncentivesByTypeResponse) Type() protoreflect.MessageType { + return _fastReflection_GetIncentivesByTypeResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GetIncentivesByTypeResponse) New() protoreflect.Message { + return new(fastReflection_GetIncentivesByTypeResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GetIncentivesByTypeResponse) Interface() protoreflect.ProtoMessage { + return (*GetIncentivesByTypeResponse)(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_GetIncentivesByTypeResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Entries) != 0 { + value := protoreflect.ValueOfList(&_GetIncentivesByTypeResponse_1_list{list: &x.Entries}) + if !f(fd_GetIncentivesByTypeResponse_entries, 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_GetIncentivesByTypeResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeResponse.entries": + return len(x.Entries) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeResponse 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_GetIncentivesByTypeResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeResponse.entries": + x.Entries = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeResponse 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_GetIncentivesByTypeResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeResponse.entries": + if len(x.Entries) == 0 { + return protoreflect.ValueOfList(&_GetIncentivesByTypeResponse_1_list{}) + } + listValue := &_GetIncentivesByTypeResponse_1_list{list: &x.Entries} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeResponse 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_GetIncentivesByTypeResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeResponse.entries": + lv := value.List() + clv := lv.(*_GetIncentivesByTypeResponse_1_list) + x.Entries = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeResponse 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_GetIncentivesByTypeResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeResponse.entries": + if x.Entries == nil { + x.Entries = [][]byte{} + } + value := &_GetIncentivesByTypeResponse_1_list{list: &x.Entries} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeResponse 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_GetIncentivesByTypeResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GetIncentivesByTypeResponse.entries": + list := [][]byte{} + return protoreflect.ValueOfList(&_GetIncentivesByTypeResponse_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetIncentivesByTypeResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetIncentivesByTypeResponse 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_GetIncentivesByTypeResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.GetIncentivesByTypeResponse", 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_GetIncentivesByTypeResponse) 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_GetIncentivesByTypeResponse) 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_GetIncentivesByTypeResponse) 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_GetIncentivesByTypeResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GetIncentivesByTypeResponse) + 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.Entries) > 0 { + for _, b := range x.Entries { + l = len(b) + 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().(*GetIncentivesByTypeResponse) + 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.Entries) > 0 { + for iNdEx := len(x.Entries) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.Entries[iNdEx]) + copy(dAtA[i:], x.Entries[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Entries[iNdEx]))) + 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().(*GetIncentivesByTypeResponse) + 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: GetIncentivesByTypeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GetIncentivesByTypeResponse: 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 Entries", wireType) + } + var byteLen 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++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + 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.Entries = append(x.Entries, make([]byte, postIndex-iNdEx)) + copy(x.Entries[len(x.Entries)-1], 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, + } +} + +var ( + md_GetAllIncentivesRequest protoreflect.MessageDescriptor +) + +func init() { + file_slinky_incentives_v1_query_proto_init() + md_GetAllIncentivesRequest = File_slinky_incentives_v1_query_proto.Messages().ByName("GetAllIncentivesRequest") +} + +var _ protoreflect.Message = (*fastReflection_GetAllIncentivesRequest)(nil) + +type fastReflection_GetAllIncentivesRequest GetAllIncentivesRequest + +func (x *GetAllIncentivesRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_GetAllIncentivesRequest)(x) +} + +func (x *GetAllIncentivesRequest) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_query_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_GetAllIncentivesRequest_messageType fastReflection_GetAllIncentivesRequest_messageType +var _ protoreflect.MessageType = fastReflection_GetAllIncentivesRequest_messageType{} + +type fastReflection_GetAllIncentivesRequest_messageType struct{} + +func (x fastReflection_GetAllIncentivesRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_GetAllIncentivesRequest)(nil) +} +func (x fastReflection_GetAllIncentivesRequest_messageType) New() protoreflect.Message { + return new(fastReflection_GetAllIncentivesRequest) +} +func (x fastReflection_GetAllIncentivesRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GetAllIncentivesRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GetAllIncentivesRequest) Descriptor() protoreflect.MessageDescriptor { + return md_GetAllIncentivesRequest +} + +// 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_GetAllIncentivesRequest) Type() protoreflect.MessageType { + return _fastReflection_GetAllIncentivesRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GetAllIncentivesRequest) New() protoreflect.Message { + return new(fastReflection_GetAllIncentivesRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GetAllIncentivesRequest) Interface() protoreflect.ProtoMessage { + return (*GetAllIncentivesRequest)(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_GetAllIncentivesRequest) 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_GetAllIncentivesRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesRequest 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_GetAllIncentivesRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesRequest 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_GetAllIncentivesRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesRequest 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_GetAllIncentivesRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesRequest 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_GetAllIncentivesRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesRequest 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_GetAllIncentivesRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesRequest")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesRequest 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_GetAllIncentivesRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.GetAllIncentivesRequest", 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_GetAllIncentivesRequest) 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_GetAllIncentivesRequest) 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_GetAllIncentivesRequest) 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_GetAllIncentivesRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GetAllIncentivesRequest) + 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().(*GetAllIncentivesRequest) + 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().(*GetAllIncentivesRequest) + 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: GetAllIncentivesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GetAllIncentivesRequest: 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 _ protoreflect.List = (*_GetAllIncentivesResponse_1_list)(nil) + +type _GetAllIncentivesResponse_1_list struct { + list *[]*IncentivesByType +} + +func (x *_GetAllIncentivesResponse_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GetAllIncentivesResponse_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_GetAllIncentivesResponse_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*IncentivesByType) + (*x.list)[i] = concreteValue +} + +func (x *_GetAllIncentivesResponse_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*IncentivesByType) + *x.list = append(*x.list, concreteValue) +} + +func (x *_GetAllIncentivesResponse_1_list) AppendMutable() protoreflect.Value { + v := new(IncentivesByType) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GetAllIncentivesResponse_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_GetAllIncentivesResponse_1_list) NewElement() protoreflect.Value { + v := new(IncentivesByType) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GetAllIncentivesResponse_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_GetAllIncentivesResponse protoreflect.MessageDescriptor + fd_GetAllIncentivesResponse_registry protoreflect.FieldDescriptor +) + +func init() { + file_slinky_incentives_v1_query_proto_init() + md_GetAllIncentivesResponse = File_slinky_incentives_v1_query_proto.Messages().ByName("GetAllIncentivesResponse") + fd_GetAllIncentivesResponse_registry = md_GetAllIncentivesResponse.Fields().ByName("registry") +} + +var _ protoreflect.Message = (*fastReflection_GetAllIncentivesResponse)(nil) + +type fastReflection_GetAllIncentivesResponse GetAllIncentivesResponse + +func (x *GetAllIncentivesResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_GetAllIncentivesResponse)(x) +} + +func (x *GetAllIncentivesResponse) slowProtoReflect() protoreflect.Message { + mi := &file_slinky_incentives_v1_query_proto_msgTypes[3] + 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_GetAllIncentivesResponse_messageType fastReflection_GetAllIncentivesResponse_messageType +var _ protoreflect.MessageType = fastReflection_GetAllIncentivesResponse_messageType{} + +type fastReflection_GetAllIncentivesResponse_messageType struct{} + +func (x fastReflection_GetAllIncentivesResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_GetAllIncentivesResponse)(nil) +} +func (x fastReflection_GetAllIncentivesResponse_messageType) New() protoreflect.Message { + return new(fastReflection_GetAllIncentivesResponse) +} +func (x fastReflection_GetAllIncentivesResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_GetAllIncentivesResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_GetAllIncentivesResponse) Descriptor() protoreflect.MessageDescriptor { + return md_GetAllIncentivesResponse +} + +// 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_GetAllIncentivesResponse) Type() protoreflect.MessageType { + return _fastReflection_GetAllIncentivesResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_GetAllIncentivesResponse) New() protoreflect.Message { + return new(fastReflection_GetAllIncentivesResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_GetAllIncentivesResponse) Interface() protoreflect.ProtoMessage { + return (*GetAllIncentivesResponse)(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_GetAllIncentivesResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Registry) != 0 { + value := protoreflect.ValueOfList(&_GetAllIncentivesResponse_1_list{list: &x.Registry}) + if !f(fd_GetAllIncentivesResponse_registry, 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_GetAllIncentivesResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "slinky.incentives.v1.GetAllIncentivesResponse.registry": + return len(x.Registry) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesResponse 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_GetAllIncentivesResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "slinky.incentives.v1.GetAllIncentivesResponse.registry": + x.Registry = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesResponse 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_GetAllIncentivesResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "slinky.incentives.v1.GetAllIncentivesResponse.registry": + if len(x.Registry) == 0 { + return protoreflect.ValueOfList(&_GetAllIncentivesResponse_1_list{}) + } + listValue := &_GetAllIncentivesResponse_1_list{list: &x.Registry} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesResponse 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_GetAllIncentivesResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "slinky.incentives.v1.GetAllIncentivesResponse.registry": + lv := value.List() + clv := lv.(*_GetAllIncentivesResponse_1_list) + x.Registry = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesResponse 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_GetAllIncentivesResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GetAllIncentivesResponse.registry": + if x.Registry == nil { + x.Registry = []*IncentivesByType{} + } + value := &_GetAllIncentivesResponse_1_list{list: &x.Registry} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesResponse 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_GetAllIncentivesResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "slinky.incentives.v1.GetAllIncentivesResponse.registry": + list := []*IncentivesByType{} + return protoreflect.ValueOfList(&_GetAllIncentivesResponse_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.incentives.v1.GetAllIncentivesResponse")) + } + panic(fmt.Errorf("message slinky.incentives.v1.GetAllIncentivesResponse 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_GetAllIncentivesResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in slinky.incentives.v1.GetAllIncentivesResponse", 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_GetAllIncentivesResponse) 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_GetAllIncentivesResponse) 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_GetAllIncentivesResponse) 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_GetAllIncentivesResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*GetAllIncentivesResponse) + 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.Registry) > 0 { + for _, e := range x.Registry { + 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().(*GetAllIncentivesResponse) + 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.Registry) > 0 { + for iNdEx := len(x.Registry) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Registry[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().(*GetAllIncentivesResponse) + 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: GetAllIncentivesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: GetAllIncentivesResponse: 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 Registry", 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.Registry = append(x.Registry, &IncentivesByType{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Registry[len(x.Registry)-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, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: slinky/incentives/v1/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) +) + +// GetIncentivesByTypeRequest is the request type for the Query/GetIncentivesByType +// RPC method. +type GetIncentivesByTypeRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // IncentiveType is the incentive type i.e. (BadPriceIncentiveType, GoodPriceIncentiveType). + IncentiveType string `protobuf:"bytes,1,opt,name=incentive_type,json=incentiveType,proto3" json:"incentive_type,omitempty"` +} + +func (x *GetIncentivesByTypeRequest) Reset() { + *x = GetIncentivesByTypeRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetIncentivesByTypeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetIncentivesByTypeRequest) ProtoMessage() {} + +// Deprecated: Use GetIncentivesByTypeRequest.ProtoReflect.Descriptor instead. +func (*GetIncentivesByTypeRequest) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_query_proto_rawDescGZIP(), []int{0} +} + +func (x *GetIncentivesByTypeRequest) GetIncentiveType() string { + if x != nil { + return x.IncentiveType + } + return "" +} + +// GetIncentivesByTypeResponse is the response type for the Query/GetIncentivesByType +// RPC method. +type GetIncentivesByTypeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Incentives is the list of incentives of the given type. + Entries [][]byte `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` +} + +func (x *GetIncentivesByTypeResponse) Reset() { + *x = GetIncentivesByTypeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetIncentivesByTypeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetIncentivesByTypeResponse) ProtoMessage() {} + +// Deprecated: Use GetIncentivesByTypeResponse.ProtoReflect.Descriptor instead. +func (*GetIncentivesByTypeResponse) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_query_proto_rawDescGZIP(), []int{1} +} + +func (x *GetIncentivesByTypeResponse) GetEntries() [][]byte { + if x != nil { + return x.Entries + } + return nil +} + +// GetAllIncentivesRequest is the request type for the Query/GetAllIncentives +// RPC method. +type GetAllIncentivesRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetAllIncentivesRequest) Reset() { + *x = GetAllIncentivesRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_query_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAllIncentivesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAllIncentivesRequest) ProtoMessage() {} + +// Deprecated: Use GetAllIncentivesRequest.ProtoReflect.Descriptor instead. +func (*GetAllIncentivesRequest) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_query_proto_rawDescGZIP(), []int{2} +} + +// GetAllIncentivesResponse is the response type for the Query/GetAllIncentives +// RPC method. +type GetAllIncentivesResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Incentives is the list of all incentives. + Registry []*IncentivesByType `protobuf:"bytes,1,rep,name=registry,proto3" json:"registry,omitempty"` +} + +func (x *GetAllIncentivesResponse) Reset() { + *x = GetAllIncentivesResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_slinky_incentives_v1_query_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetAllIncentivesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetAllIncentivesResponse) ProtoMessage() {} + +// Deprecated: Use GetAllIncentivesResponse.ProtoReflect.Descriptor instead. +func (*GetAllIncentivesResponse) Descriptor() ([]byte, []int) { + return file_slinky_incentives_v1_query_proto_rawDescGZIP(), []int{3} +} + +func (x *GetAllIncentivesResponse) GetRegistry() []*IncentivesByType { + if x != nil { + return x.Registry + } + return nil +} + +var File_slinky_incentives_v1_query_proto protoreflect.FileDescriptor + +var file_slinky_incentives_v1_query_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, + 0x76, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x14, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, + 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x22, 0x73, 0x6c, + 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2f, + 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x43, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, + 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, + 0x0a, 0x0e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x37, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x63, 0x65, + 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x22, 0x19, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x64, 0x0a, 0x18, 0x47, 0x65, 0x74, + 0x41, 0x6c, 0x6c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, + 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, + 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x42, + 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x32, + 0xe0, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0xb0, 0x01, 0x0a, 0x13, 0x47, 0x65, + 0x74, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x30, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, + 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x63, 0x65, + 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, + 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, + 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x42, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x12, 0x2c, + 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0xa3, 0x01, 0x0a, + 0x10, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, + 0x73, 0x12, 0x2d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, + 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x49, + 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x2e, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, + 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x49, 0x6e, + 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x30, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, + 0x67, 0x65, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x42, 0xcc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2e, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x42, + 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, + 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x69, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x76, + 0x31, 0xa2, 0x02, 0x03, 0x53, 0x49, 0x58, 0xaa, 0x02, 0x14, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, + 0x2e, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, + 0x14, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, + 0x65, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x20, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x49, + 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x53, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x3a, 0x3a, 0x49, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x69, 0x76, 0x65, 0x73, 0x3a, 0x3a, 0x56, + 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_slinky_incentives_v1_query_proto_rawDescOnce sync.Once + file_slinky_incentives_v1_query_proto_rawDescData = file_slinky_incentives_v1_query_proto_rawDesc +) + +func file_slinky_incentives_v1_query_proto_rawDescGZIP() []byte { + file_slinky_incentives_v1_query_proto_rawDescOnce.Do(func() { + file_slinky_incentives_v1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_slinky_incentives_v1_query_proto_rawDescData) + }) + return file_slinky_incentives_v1_query_proto_rawDescData +} + +var file_slinky_incentives_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_slinky_incentives_v1_query_proto_goTypes = []interface{}{ + (*GetIncentivesByTypeRequest)(nil), // 0: slinky.incentives.v1.GetIncentivesByTypeRequest + (*GetIncentivesByTypeResponse)(nil), // 1: slinky.incentives.v1.GetIncentivesByTypeResponse + (*GetAllIncentivesRequest)(nil), // 2: slinky.incentives.v1.GetAllIncentivesRequest + (*GetAllIncentivesResponse)(nil), // 3: slinky.incentives.v1.GetAllIncentivesResponse + (*IncentivesByType)(nil), // 4: slinky.incentives.v1.IncentivesByType +} +var file_slinky_incentives_v1_query_proto_depIdxs = []int32{ + 4, // 0: slinky.incentives.v1.GetAllIncentivesResponse.registry:type_name -> slinky.incentives.v1.IncentivesByType + 0, // 1: slinky.incentives.v1.Query.GetIncentivesByType:input_type -> slinky.incentives.v1.GetIncentivesByTypeRequest + 2, // 2: slinky.incentives.v1.Query.GetAllIncentives:input_type -> slinky.incentives.v1.GetAllIncentivesRequest + 1, // 3: slinky.incentives.v1.Query.GetIncentivesByType:output_type -> slinky.incentives.v1.GetIncentivesByTypeResponse + 3, // 4: slinky.incentives.v1.Query.GetAllIncentives:output_type -> slinky.incentives.v1.GetAllIncentivesResponse + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] 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_slinky_incentives_v1_query_proto_init() } +func file_slinky_incentives_v1_query_proto_init() { + if File_slinky_incentives_v1_query_proto != nil { + return + } + file_slinky_incentives_v1_genesis_proto_init() + if !protoimpl.UnsafeEnabled { + file_slinky_incentives_v1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetIncentivesByTypeRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_slinky_incentives_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetIncentivesByTypeResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_slinky_incentives_v1_query_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetAllIncentivesRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_slinky_incentives_v1_query_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetAllIncentivesResponse); 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_slinky_incentives_v1_query_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_slinky_incentives_v1_query_proto_goTypes, + DependencyIndexes: file_slinky_incentives_v1_query_proto_depIdxs, + MessageInfos: file_slinky_incentives_v1_query_proto_msgTypes, + }.Build() + File_slinky_incentives_v1_query_proto = out.File + file_slinky_incentives_v1_query_proto_rawDesc = nil + file_slinky_incentives_v1_query_proto_goTypes = nil + file_slinky_incentives_v1_query_proto_depIdxs = nil +} diff --git a/api/slinky/incentives/v1/query_grpc.pb.go b/api/slinky/incentives/v1/query_grpc.pb.go new file mode 100644 index 000000000..a794bcc35 --- /dev/null +++ b/api/slinky/incentives/v1/query_grpc.pb.go @@ -0,0 +1,152 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: slinky/incentives/v1/query.proto + +package incentivesv1 + +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_GetIncentivesByType_FullMethodName = "/slinky.incentives.v1.Query/GetIncentivesByType" + Query_GetAllIncentives_FullMethodName = "/slinky.incentives.v1.Query/GetAllIncentives" +) + +// 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 { + // GetIncentivesByType returns all incentives of a given type. If the type is + // not registered with the module, an error is returned. + GetIncentivesByType(ctx context.Context, in *GetIncentivesByTypeRequest, opts ...grpc.CallOption) (*GetIncentivesByTypeResponse, error) + // GetAllIncentives returns all incentives. + GetAllIncentives(ctx context.Context, in *GetAllIncentivesRequest, opts ...grpc.CallOption) (*GetAllIncentivesResponse, error) +} + +type queryClient struct { + cc grpc.ClientConnInterface +} + +func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) GetIncentivesByType(ctx context.Context, in *GetIncentivesByTypeRequest, opts ...grpc.CallOption) (*GetIncentivesByTypeResponse, error) { + out := new(GetIncentivesByTypeResponse) + err := c.cc.Invoke(ctx, Query_GetIncentivesByType_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetAllIncentives(ctx context.Context, in *GetAllIncentivesRequest, opts ...grpc.CallOption) (*GetAllIncentivesResponse, error) { + out := new(GetAllIncentivesResponse) + err := c.cc.Invoke(ctx, Query_GetAllIncentives_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 { + // GetIncentivesByType returns all incentives of a given type. If the type is + // not registered with the module, an error is returned. + GetIncentivesByType(context.Context, *GetIncentivesByTypeRequest) (*GetIncentivesByTypeResponse, error) + // GetAllIncentives returns all incentives. + GetAllIncentives(context.Context, *GetAllIncentivesRequest) (*GetAllIncentivesResponse, error) + mustEmbedUnimplementedQueryServer() +} + +// UnimplementedQueryServer must be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (UnimplementedQueryServer) GetIncentivesByType(context.Context, *GetIncentivesByTypeRequest) (*GetIncentivesByTypeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetIncentivesByType not implemented") +} +func (UnimplementedQueryServer) GetAllIncentives(context.Context, *GetAllIncentivesRequest) (*GetAllIncentivesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAllIncentives 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_GetIncentivesByType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetIncentivesByTypeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetIncentivesByType(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_GetIncentivesByType_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetIncentivesByType(ctx, req.(*GetIncentivesByTypeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetAllIncentives_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAllIncentivesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetAllIncentives(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Query_GetAllIncentives_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetAllIncentives(ctx, req.(*GetAllIncentivesRequest)) + } + 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: "slinky.incentives.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetIncentivesByType", + Handler: _Query_GetIncentivesByType_Handler, + }, + { + MethodName: "GetAllIncentives", + Handler: _Query_GetAllIncentives_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "slinky/incentives/v1/query.proto", +} diff --git a/api/slinky/oracle/module/v1/module.pulsar.go b/api/slinky/oracle/module/v1/module.pulsar.go index 249776593..91a02b492 100644 --- a/api/slinky/oracle/module/v1/module.pulsar.go +++ b/api/slinky/oracle/module/v1/module.pulsar.go @@ -315,7 +315,7 @@ 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 + dAtA[i] = 0xa } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) @@ -366,7 +366,7 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 2: + case 1: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } @@ -452,8 +452,9 @@ type Module struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Authority defines the custom module authority. If not set, defaults to the governance module. - Authority string `protobuf:"bytes,2,opt,name=authority,proto3" json:"authority,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"` } func (x *Module) Reset() { @@ -493,7 +494,7 @@ var file_slinky_oracle_module_v1_module_proto_rawDesc = []byte{ 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, 0x53, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 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, 0x2b, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x25, 0x0a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6b, 0x69, 0x70, 0x2d, 0x6d, 0x65, 0x76, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x78, 0x2f, diff --git a/api/slinky/oracle/v1/genesis.pulsar.go b/api/slinky/oracle/v1/genesis.pulsar.go index 0438558a6..f8abc1e34 100644 --- a/api/slinky/oracle/v1/genesis.pulsar.go +++ b/api/slinky/oracle/v1/genesis.pulsar.go @@ -2326,52 +2326,51 @@ var file_slinky_oracle_v1_genesis_proto_rawDesc = []byte{ 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x38, 0x0a, 0x0c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x42, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x42, 0x61, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x51, 0x75, 0x6f, 0x74, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x22, 0xd2, - 0x01, 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, - 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, 0xc8, 0xde, - 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, - 0x65, 0x12, 0x4d, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, - 0x52, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x22, 0xca, 0x01, 0x0a, 0x13, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, - 0x50, 0x61, 0x69, 0x72, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x49, 0x0a, 0x0d, 0x63, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, - 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, - 0x69, 0x72, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x12, 0x52, 0x0a, 0x13, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, - 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x01, 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, - 0x79, 0x50, 0x61, 0x69, 0x72, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, - 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, - 0x22, 0x6f, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x5f, 0x0a, 0x15, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, - 0x72, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x25, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x47, - 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x13, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, - 0x73, 0x42, 0xb2, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, - 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, - 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, 0x69, - 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x72, - 0x61, 0x63, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x4f, 0x58, 0xaa, 0x02, 0x10, 0x53, - 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, - 0x02, 0x10, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, - 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, - 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x12, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, - 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x22, 0xc1, + 0x01, 0x0a, 0x0a, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, + 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, + 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, + 0x12, 0x4d, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, + 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x22, 0xca, 0x01, 0x0a, 0x13, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, + 0x61, 0x69, 0x72, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x12, 0x49, 0x0a, 0x0d, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1e, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, + 0x72, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, + 0x79, 0x50, 0x61, 0x69, 0x72, 0x12, 0x52, 0x0a, 0x13, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, + 0x79, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, + 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, + 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x01, 0x52, 0x11, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x50, 0x61, 0x69, 0x72, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, + 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x22, + 0x6f, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x5f, 0x0a, 0x15, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, 0x72, + 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, + 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x47, 0x65, + 0x6e, 0x65, 0x73, 0x69, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x13, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x42, 0xb2, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, + 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, + 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, 0x69, 0x6e, + 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x72, 0x61, + 0x63, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x4f, 0x58, 0xaa, 0x02, 0x10, 0x53, 0x6c, + 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, + 0x10, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x56, + 0x31, 0xe2, 0x02, 0x1c, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, + 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x12, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, + 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/slinky/oracle/v1/query.pulsar.go b/api/slinky/oracle/v1/query.pulsar.go index bd49b8d2f..4a85517a7 100644 --- a/api/slinky/oracle/v1/query.pulsar.go +++ b/api/slinky/oracle/v1/query.pulsar.go @@ -1418,9 +1418,10 @@ func (x *fastReflection_GetPriceRequest) ProtoMethods() *protoiface.Methods { } var ( - md_GetPriceResponse protoreflect.MessageDescriptor - fd_GetPriceResponse_price protoreflect.FieldDescriptor - fd_GetPriceResponse_nonce protoreflect.FieldDescriptor + md_GetPriceResponse protoreflect.MessageDescriptor + fd_GetPriceResponse_price protoreflect.FieldDescriptor + fd_GetPriceResponse_nonce protoreflect.FieldDescriptor + fd_GetPriceResponse_decimals protoreflect.FieldDescriptor ) func init() { @@ -1428,6 +1429,7 @@ func init() { md_GetPriceResponse = File_slinky_oracle_v1_query_proto.Messages().ByName("GetPriceResponse") fd_GetPriceResponse_price = md_GetPriceResponse.Fields().ByName("price") fd_GetPriceResponse_nonce = md_GetPriceResponse.Fields().ByName("nonce") + fd_GetPriceResponse_decimals = md_GetPriceResponse.Fields().ByName("decimals") } var _ protoreflect.Message = (*fastReflection_GetPriceResponse)(nil) @@ -1507,6 +1509,12 @@ func (x *fastReflection_GetPriceResponse) Range(f func(protoreflect.FieldDescrip return } } + if x.Decimals != uint64(0) { + value := protoreflect.ValueOfUint64(x.Decimals) + if !f(fd_GetPriceResponse_decimals, value) { + return + } + } } // Has reports whether a field is populated. @@ -1526,6 +1534,8 @@ func (x *fastReflection_GetPriceResponse) Has(fd protoreflect.FieldDescriptor) b return x.Price != nil case "slinky.oracle.v1.GetPriceResponse.nonce": return x.Nonce != uint64(0) + case "slinky.oracle.v1.GetPriceResponse.decimals": + return x.Decimals != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.GetPriceResponse")) @@ -1546,6 +1556,8 @@ func (x *fastReflection_GetPriceResponse) Clear(fd protoreflect.FieldDescriptor) x.Price = nil case "slinky.oracle.v1.GetPriceResponse.nonce": x.Nonce = uint64(0) + case "slinky.oracle.v1.GetPriceResponse.decimals": + x.Decimals = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.GetPriceResponse")) @@ -1568,6 +1580,9 @@ func (x *fastReflection_GetPriceResponse) Get(descriptor protoreflect.FieldDescr case "slinky.oracle.v1.GetPriceResponse.nonce": value := x.Nonce return protoreflect.ValueOfUint64(value) + case "slinky.oracle.v1.GetPriceResponse.decimals": + value := x.Decimals + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.GetPriceResponse")) @@ -1592,6 +1607,8 @@ func (x *fastReflection_GetPriceResponse) Set(fd protoreflect.FieldDescriptor, v x.Price = value.Message().Interface().(*QuotePrice) case "slinky.oracle.v1.GetPriceResponse.nonce": x.Nonce = value.Uint() + case "slinky.oracle.v1.GetPriceResponse.decimals": + x.Decimals = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.GetPriceResponse")) @@ -1619,6 +1636,8 @@ func (x *fastReflection_GetPriceResponse) Mutable(fd protoreflect.FieldDescripto return protoreflect.ValueOfMessage(x.Price.ProtoReflect()) case "slinky.oracle.v1.GetPriceResponse.nonce": panic(fmt.Errorf("field nonce of message slinky.oracle.v1.GetPriceResponse is not mutable")) + case "slinky.oracle.v1.GetPriceResponse.decimals": + panic(fmt.Errorf("field decimals of message slinky.oracle.v1.GetPriceResponse is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.GetPriceResponse")) @@ -1637,6 +1656,8 @@ func (x *fastReflection_GetPriceResponse) NewField(fd protoreflect.FieldDescript return protoreflect.ValueOfMessage(m.ProtoReflect()) case "slinky.oracle.v1.GetPriceResponse.nonce": return protoreflect.ValueOfUint64(uint64(0)) + case "slinky.oracle.v1.GetPriceResponse.decimals": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.GetPriceResponse")) @@ -1713,6 +1734,9 @@ func (x *fastReflection_GetPriceResponse) ProtoMethods() *protoiface.Methods { if x.Nonce != 0 { n += 1 + runtime.Sov(uint64(x.Nonce)) } + if x.Decimals != 0 { + n += 1 + runtime.Sov(uint64(x.Decimals)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1742,6 +1766,11 @@ func (x *fastReflection_GetPriceResponse) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.Decimals != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Decimals)) + i-- + dAtA[i] = 0x18 + } if x.Nonce != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.Nonce)) i-- @@ -1865,6 +1894,25 @@ func (x *fastReflection_GetPriceResponse) ProtoMethods() *protoiface.Methods { break } } + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) + } + x.Decimals = 0 + 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++ + x.Decimals |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2065,6 +2113,10 @@ type GetPriceResponse struct { Price *QuotePrice `protobuf:"bytes,1,opt,name=price,proto3" json:"price,omitempty"` // nonce represents the nonce for the CurrencyPair if it exists in state Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` + // decimals represents the number of decimals that the quote-price is + // represented in. For Pairs where ETHEREUM is the quote this will be 18, + // otherwise it will be 8. + Decimals uint64 `protobuf:"varint,3,opt,name=decimals,proto3" json:"decimals,omitempty"` } func (x *GetPriceResponse) Reset() { @@ -2101,6 +2153,13 @@ func (x *GetPriceResponse) GetNonce() uint64 { return 0 } +func (x *GetPriceResponse) GetDecimals() uint64 { + if x != nil { + return x.Decimals + } + return 0 +} + var File_slinky_oracle_v1_query_proto protoreflect.FileDescriptor var file_slinky_oracle_v1_query_proto_rawDesc = []byte{ @@ -2131,42 +2190,44 @@ var file_slinky_oracle_v1_query_proto_rawDesc = []byte{ 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x49, 0x64, 0x42, 0x18, 0x0a, 0x16, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x70, 0x61, 0x69, 0x72, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x22, - 0x62, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x7e, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x01, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6e, 0x6f, - 0x6e, 0x63, 0x65, 0x32, 0x9f, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x9d, 0x01, - 0x0a, 0x13, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, - 0x50, 0x61, 0x69, 0x72, 0x73, 0x12, 0x2c, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, - 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, - 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x12, 0x21, 0x2f, 0x73, 0x6c, 0x69, - 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, - 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x12, 0x76, 0x0a, - 0x08, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x21, 0x2e, 0x73, 0x6c, 0x69, 0x6e, - 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, - 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x73, - 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, - 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, - 0x70, 0x72, 0x69, 0x63, 0x65, 0x42, 0xb0, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, - 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, - 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, - 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x4f, 0x58, 0xaa, 0x02, - 0x10, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x56, - 0x31, 0xca, 0x02, 0x10, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, - 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, - 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x4f, 0x72, - 0x61, 0x63, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x73, 0x32, + 0x9f, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x9d, 0x01, 0x0a, 0x13, 0x47, 0x65, + 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, + 0x73, 0x12, 0x2c, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x63, 0x79, 0x50, 0x61, 0x69, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6c, 0x6c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, + 0x79, 0x50, 0x61, 0x69, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x12, 0x21, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, + 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x61, 0x6c, + 0x6c, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x72, 0x73, 0x12, 0x76, 0x0a, 0x08, 0x47, 0x65, 0x74, + 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x21, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, + 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, + 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, + 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x74, 0x5f, 0x70, 0x72, 0x69, 0x63, + 0x65, 0x42, 0xb0, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, + 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x72, 0x61, 0x63, + 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x4f, 0x58, 0xaa, 0x02, 0x10, 0x53, 0x6c, 0x69, + 0x6e, 0x6b, 0x79, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, + 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x56, 0x31, + 0xe2, 0x02, 0x1c, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, + 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x12, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, + 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/slinky/service/v1/service.pulsar.go b/api/slinky/service/v1/service.pulsar.go index 32f9e2763..e4a785205 100644 --- a/api/slinky/service/v1/service.pulsar.go +++ b/api/slinky/service/v1/service.pulsar.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go-pulsar. DO NOT EDIT. -package oraclev1 +package servicev1 import ( fmt "fmt" @@ -108,9 +108,9 @@ func (x *fastReflection_QueryPricesRequest) Has(fd protoreflect.FieldDescriptor) switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesRequest")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesRequest does not contain field %s", fd.FullName())) } } @@ -124,9 +124,9 @@ func (x *fastReflection_QueryPricesRequest) Clear(fd protoreflect.FieldDescripto switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesRequest")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesRequest does not contain field %s", fd.FullName())) } } @@ -140,9 +140,9 @@ func (x *fastReflection_QueryPricesRequest) Get(descriptor protoreflect.FieldDes switch descriptor.FullName() { default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesRequest")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesRequest does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesRequest does not contain field %s", descriptor.FullName())) } } @@ -160,9 +160,9 @@ func (x *fastReflection_QueryPricesRequest) Set(fd protoreflect.FieldDescriptor, switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesRequest")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesRequest does not contain field %s", fd.FullName())) } } @@ -180,9 +180,9 @@ func (x *fastReflection_QueryPricesRequest) Mutable(fd protoreflect.FieldDescrip switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesRequest")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesRequest does not contain field %s", fd.FullName())) } } @@ -193,9 +193,9 @@ func (x *fastReflection_QueryPricesRequest) NewField(fd protoreflect.FieldDescri switch fd.FullName() { default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesRequest")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesRequest")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesRequest does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesRequest does not contain field %s", fd.FullName())) } } @@ -205,7 +205,7 @@ func (x *fastReflection_QueryPricesRequest) NewField(fd protoreflect.FieldDescri func (x *fastReflection_QueryPricesRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in slinky.oracle.v1.QueryPricesRequest", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in slinky.service.v1.QueryPricesRequest", d.FullName())) } panic("unreachable") } @@ -560,15 +560,15 @@ func (x *fastReflection_QueryPricesResponse) Range(f func(protoreflect.FieldDesc // a repeated field is populated if it is non-empty. func (x *fastReflection_QueryPricesResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "slinky.oracle.v1.QueryPricesResponse.prices": + case "slinky.service.v1.QueryPricesResponse.prices": return len(x.Prices) != 0 - case "slinky.oracle.v1.QueryPricesResponse.timestamp": + case "slinky.service.v1.QueryPricesResponse.timestamp": return x.Timestamp != nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesResponse")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesResponse does not contain field %s", fd.FullName())) } } @@ -580,15 +580,15 @@ func (x *fastReflection_QueryPricesResponse) Has(fd protoreflect.FieldDescriptor // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryPricesResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "slinky.oracle.v1.QueryPricesResponse.prices": + case "slinky.service.v1.QueryPricesResponse.prices": x.Prices = nil - case "slinky.oracle.v1.QueryPricesResponse.timestamp": + case "slinky.service.v1.QueryPricesResponse.timestamp": x.Timestamp = nil default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesResponse")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesResponse does not contain field %s", fd.FullName())) } } @@ -600,20 +600,20 @@ func (x *fastReflection_QueryPricesResponse) Clear(fd protoreflect.FieldDescript // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_QueryPricesResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "slinky.oracle.v1.QueryPricesResponse.prices": + case "slinky.service.v1.QueryPricesResponse.prices": if len(x.Prices) == 0 { return protoreflect.ValueOfMap(&_QueryPricesResponse_1_map{}) } mapValue := &_QueryPricesResponse_1_map{m: &x.Prices} return protoreflect.ValueOfMap(mapValue) - case "slinky.oracle.v1.QueryPricesResponse.timestamp": + case "slinky.service.v1.QueryPricesResponse.timestamp": value := x.Timestamp return protoreflect.ValueOfMessage(value.ProtoReflect()) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesResponse")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesResponse does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesResponse does not contain field %s", descriptor.FullName())) } } @@ -629,17 +629,17 @@ func (x *fastReflection_QueryPricesResponse) Get(descriptor protoreflect.FieldDe // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryPricesResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "slinky.oracle.v1.QueryPricesResponse.prices": + case "slinky.service.v1.QueryPricesResponse.prices": mv := value.Map() cmv := mv.(*_QueryPricesResponse_1_map) x.Prices = *cmv.m - case "slinky.oracle.v1.QueryPricesResponse.timestamp": + case "slinky.service.v1.QueryPricesResponse.timestamp": x.Timestamp = value.Message().Interface().(*timestamppb.Timestamp) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesResponse")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesResponse does not contain field %s", fd.FullName())) } } @@ -655,22 +655,22 @@ func (x *fastReflection_QueryPricesResponse) Set(fd protoreflect.FieldDescriptor // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_QueryPricesResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "slinky.oracle.v1.QueryPricesResponse.prices": + case "slinky.service.v1.QueryPricesResponse.prices": if x.Prices == nil { x.Prices = make(map[string]string) } value := &_QueryPricesResponse_1_map{m: &x.Prices} return protoreflect.ValueOfMap(value) - case "slinky.oracle.v1.QueryPricesResponse.timestamp": + case "slinky.service.v1.QueryPricesResponse.timestamp": if x.Timestamp == nil { x.Timestamp = new(timestamppb.Timestamp) } return protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesResponse")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesResponse does not contain field %s", fd.FullName())) } } @@ -679,17 +679,17 @@ func (x *fastReflection_QueryPricesResponse) Mutable(fd protoreflect.FieldDescri // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_QueryPricesResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "slinky.oracle.v1.QueryPricesResponse.prices": + case "slinky.service.v1.QueryPricesResponse.prices": m := make(map[string]string) return protoreflect.ValueOfMap(&_QueryPricesResponse_1_map{m: &m}) - case "slinky.oracle.v1.QueryPricesResponse.timestamp": + case "slinky.service.v1.QueryPricesResponse.timestamp": m := new(timestamppb.Timestamp) return protoreflect.ValueOfMessage(m.ProtoReflect()) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.oracle.v1.QueryPricesResponse")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: slinky.service.v1.QueryPricesResponse")) } - panic(fmt.Errorf("message slinky.oracle.v1.QueryPricesResponse does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message slinky.service.v1.QueryPricesResponse does not contain field %s", fd.FullName())) } } @@ -699,7 +699,7 @@ func (x *fastReflection_QueryPricesResponse) NewField(fd protoreflect.FieldDescr func (x *fastReflection_QueryPricesResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in slinky.oracle.v1.QueryPricesResponse", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in slinky.service.v1.QueryPricesResponse", d.FullName())) } panic("unreachable") } @@ -1202,51 +1202,51 @@ var File_slinky_service_v1_service_proto protoreflect.FileDescriptor var file_slinky_service_v1_service_proto_rawDesc = []byte{ 0x0a, 0x1f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x10, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, - 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, - 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xe5, 0x01, 0x0a, 0x13, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x4f, 0x0a, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x31, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x72, 0x69, 0x63, - 0x65, 0x73, 0x12, 0x42, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x39, 0x0a, 0x0b, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x32, 0x81, 0x01, 0x0a, 0x06, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x12, 0x77, 0x0a, 0x06, - 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x24, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, - 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, - 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, - 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x73, 0x6c, - 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x70, - 0x72, 0x69, 0x63, 0x65, 0x73, 0x42, 0xb3, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, - 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0c, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2b, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, - 0x76, 0x31, 0x3b, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x4f, - 0x58, 0xaa, 0x02, 0x10, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x4f, 0x72, 0x61, 0x63, 0x6c, - 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x4f, 0x72, - 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, - 0x5c, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, - 0x3a, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x6f, 0x12, 0x11, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xe6, 0x01, 0x0a, 0x13, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x50, 0x0a, 0x06, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, + 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x72, 0x69, 0x63, 0x65, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x72, + 0x69, 0x63, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x39, 0x0a, 0x0b, 0x50, 0x72, 0x69, 0x63, + 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x32, 0x83, 0x01, 0x0a, 0x06, 0x4f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x12, 0x79, + 0x0a, 0x06, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x25, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, + 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x26, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, + 0x18, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x6f, 0x72, 0x61, 0x63, 0x6c, 0x65, 0x2f, + 0x76, 0x31, 0x2f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x42, 0xb9, 0x01, 0x0a, 0x15, 0x63, 0x6f, + 0x6d, 0x2e, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x2f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x76, + 0x31, 0xa2, 0x02, 0x03, 0x53, 0x53, 0x58, 0xaa, 0x02, 0x11, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x11, 0x53, 0x6c, + 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5c, 0x56, 0x31, 0xe2, + 0x02, 0x1d, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x13, 0x53, 0x6c, 0x69, 0x6e, 0x6b, 0x79, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1263,16 +1263,16 @@ func file_slinky_service_v1_service_proto_rawDescGZIP() []byte { var file_slinky_service_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_slinky_service_v1_service_proto_goTypes = []interface{}{ - (*QueryPricesRequest)(nil), // 0: slinky.oracle.v1.QueryPricesRequest - (*QueryPricesResponse)(nil), // 1: slinky.oracle.v1.QueryPricesResponse - nil, // 2: slinky.oracle.v1.QueryPricesResponse.PricesEntry + (*QueryPricesRequest)(nil), // 0: slinky.service.v1.QueryPricesRequest + (*QueryPricesResponse)(nil), // 1: slinky.service.v1.QueryPricesResponse + nil, // 2: slinky.service.v1.QueryPricesResponse.PricesEntry (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp } var file_slinky_service_v1_service_proto_depIdxs = []int32{ - 2, // 0: slinky.oracle.v1.QueryPricesResponse.prices:type_name -> slinky.oracle.v1.QueryPricesResponse.PricesEntry - 3, // 1: slinky.oracle.v1.QueryPricesResponse.timestamp:type_name -> google.protobuf.Timestamp - 0, // 2: slinky.oracle.v1.Oracle.Prices:input_type -> slinky.oracle.v1.QueryPricesRequest - 1, // 3: slinky.oracle.v1.Oracle.Prices:output_type -> slinky.oracle.v1.QueryPricesResponse + 2, // 0: slinky.service.v1.QueryPricesResponse.prices:type_name -> slinky.service.v1.QueryPricesResponse.PricesEntry + 3, // 1: slinky.service.v1.QueryPricesResponse.timestamp:type_name -> google.protobuf.Timestamp + 0, // 2: slinky.service.v1.Oracle.Prices:input_type -> slinky.service.v1.QueryPricesRequest + 1, // 3: slinky.service.v1.Oracle.Prices:output_type -> slinky.service.v1.QueryPricesResponse 3, // [3:4] is the sub-list for method output_type 2, // [2:3] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name diff --git a/api/slinky/service/v1/service_grpc.pb.go b/api/slinky/service/v1/service_grpc.pb.go index 30e1c2c6c..3713f0ccf 100644 --- a/api/slinky/service/v1/service_grpc.pb.go +++ b/api/slinky/service/v1/service_grpc.pb.go @@ -4,7 +4,7 @@ // - protoc (unknown) // source: slinky/service/v1/service.proto -package oraclev1 +package servicev1 import ( context "context" @@ -19,7 +19,7 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Oracle_Prices_FullMethodName = "/slinky.oracle.v1.Oracle/Prices" + Oracle_Prices_FullMethodName = "/slinky.service.v1.Oracle/Prices" ) // OracleClient is the client API for Oracle service. @@ -98,7 +98,7 @@ func _Oracle_Prices_Handler(srv interface{}, ctx context.Context, dec func(inter // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Oracle_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "slinky.oracle.v1.Oracle", + ServiceName: "slinky.service.v1.Oracle", HandlerType: (*OracleServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/proto/buf.lock b/proto/buf.lock index 9b57607f2..f802501e0 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -19,5 +19,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: cc916c31859748a68fd229a3c8d7a2e8 - digest: shake256:469b049d0eb04203d5272062636c078decefc96fec69739159c25d85349c50c34c7706918a8b216c5c27f76939df48452148cff8c5c3ae77fa6ba5c25c1b8bf8 + commit: 28151c0d0a1641bf938a7672c500e01d + digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de diff --git a/proto/slinky/incentives/module/v1/module.proto b/proto/slinky/incentives/module/v1/module.proto new file mode 100644 index 000000000..4d61dc2f9 --- /dev/null +++ b/proto/slinky/incentives/module/v1/module.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package slinky.incentives.module.v1; + +import "cosmos/app/v1alpha1/module.proto"; + +// Module is the config object of the incentives module. +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import : "github.com/skip-mev/slinky/x/incentives" + }; +} \ No newline at end of file diff --git a/proto/slinky/incentives/v1/badprice.proto b/proto/slinky/incentives/v1/badprice.proto new file mode 100644 index 000000000..22a4c1177 --- /dev/null +++ b/proto/slinky/incentives/v1/badprice.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package slinky.incentives.v1; + +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/skip-mev/slinky/x/incentives/types/examples/badprice"; + +// BadPriceIncentive is a message that contains the information about a bad price +// that was submitted by a validator. +// +// NOTE: This is an example of a bad price incentive. It is not used in production. +message BadPriceIncentive { + option (cosmos_proto.implements_interface) = "slinky.incentives.v1.Incentive"; + option (amino.name) = "slinky/oracle/BadPriceIncentive"; + + // Validator is the address of the validator that submitted the bad price. + string validator = 1; + // Amount is the amount to slash. + string amount = 2; +} \ No newline at end of file diff --git a/proto/slinky/incentives/v1/genesis.proto b/proto/slinky/incentives/v1/genesis.proto new file mode 100644 index 000000000..e7b11c910 --- /dev/null +++ b/proto/slinky/incentives/v1/genesis.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package slinky.incentives.v1; + +option go_package = "github.com/skip-mev/slinky/x/incentives/types"; + +import "gogoproto/gogo.proto"; + +// GenesisState is the genesis-state for the x/incentives module. +message GenesisState { + // Registry is a list of incentives by type. The registry defined here + // should be a subset of the incentive types defined in the incentive + // module (keeper). + repeated IncentivesByType registry = 1 [(gogoproto.nullable) = false]; +} + +// IncentivesByType encapsulates a list of incentives by type. Each of the +// entries here must correspond to the same incentive type defined here. +message IncentivesByType { + // IncentiveType is the incentive type i.e. (BadPriceIncentiveType, GoodPriceIncentiveType). + string incentive_type = 1; + // Entries is a list of incentive bytes. + repeated bytes entries = 2 [(gogoproto.nullable) = false]; +} diff --git a/proto/slinky/incentives/v1/goodprice.proto b/proto/slinky/incentives/v1/goodprice.proto new file mode 100644 index 000000000..6153613e5 --- /dev/null +++ b/proto/slinky/incentives/v1/goodprice.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package slinky.incentives.v1; + +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/skip-mev/slinky/x/incentives/types/examples/goodprice"; + +// GoodPriceIncentive is a message that contains the information about a good price +// that was submitted by a validator. +// +// NOTE: This is an example of a good price incentive. It is not used in production. +message GoodPriceIncentive { + option (cosmos_proto.implements_interface) = "slinky.incentives.v1.Incentive"; + option (amino.name) = "slinky/oracle/BadPriceIncentive"; + + // Validator is the address of the validator that submitted the good price. + string validator = 1; + // Amount is the amount to reward. + string amount = 2; +} \ No newline at end of file diff --git a/proto/slinky/incentives/v1/query.proto b/proto/slinky/incentives/v1/query.proto new file mode 100644 index 000000000..ba03839a8 --- /dev/null +++ b/proto/slinky/incentives/v1/query.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; +package slinky.incentives.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "slinky/incentives/v1/genesis.proto"; + +option go_package = "github.com/skip-mev/slinky/x/incentives/types"; + +service Query { + // GetIncentivesByType returns all incentives of a given type. If the type is + // not registered with the module, an error is returned. + rpc GetIncentivesByType(GetIncentivesByTypeRequest) returns (GetIncentivesByTypeResponse) { + option (google.api.http).get = "/slinky/incentives/v1/get_incentives_by_type"; + } + + // GetAllIncentives returns all incentives. + rpc GetAllIncentives(GetAllIncentivesRequest) returns (GetAllIncentivesResponse) { + option (google.api.http).get = "/slinky/incentives/v1/get_all_incentives"; + } +} + +// GetIncentivesByTypeRequest is the request type for the Query/GetIncentivesByType +// RPC method. +message GetIncentivesByTypeRequest { + // IncentiveType is the incentive type i.e. (BadPriceIncentiveType, GoodPriceIncentiveType). + string incentive_type = 1; +} + +// GetIncentivesByTypeResponse is the response type for the Query/GetIncentivesByType +// RPC method. +message GetIncentivesByTypeResponse { + // Entries is the list of incentives of the given type. + repeated bytes entries = 1; +} + +// GetAllIncentivesRequest is the request type for the Query/GetAllIncentives +// RPC method. +message GetAllIncentivesRequest {} + +// GetAllIncentivesResponse is the response type for the Query/GetAllIncentives +// RPC method. +message GetAllIncentivesResponse { + // Registry is the list of all incentives, grouped by type. + repeated IncentivesByType registry = 1 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/slinky/oracle/module/v1/module.proto b/proto/slinky/oracle/module/v1/module.proto index 225c0a400..429e720ed 100644 --- a/proto/slinky/oracle/module/v1/module.proto +++ b/proto/slinky/oracle/module/v1/module.proto @@ -12,5 +12,5 @@ message Module { // Authority defines the custom module authority. If not set, defaults to the // governance module. - string authority = 2; + string authority = 1; } \ No newline at end of file diff --git a/tests/simapp/app.go b/tests/simapp/app.go index 07b960ba2..4eb4c4dcf 100644 --- a/tests/simapp/app.go +++ b/tests/simapp/app.go @@ -64,6 +64,8 @@ import ( "github.com/skip-mev/slinky/abci" oracleconfig "github.com/skip-mev/slinky/oracle/config" oracleservice "github.com/skip-mev/slinky/service/client" + "github.com/skip-mev/slinky/x/incentives" + incentiveskeeper "github.com/skip-mev/slinky/x/incentives/keeper" "github.com/skip-mev/slinky/x/oracle" oraclekeeper "github.com/skip-mev/slinky/x/oracle/keeper" ) @@ -102,6 +104,7 @@ var ( vesting.AppModuleBasic{}, consensus.AppModuleBasic{}, oracle.AppModuleBasic{}, + incentives.AppModuleBasic{}, ) ) @@ -136,6 +139,7 @@ type SimApp struct { ConsensusParamsKeeper consensuskeeper.Keeper CircuitBreakerKeeper circuitkeeper.Keeper OracleKeeper oraclekeeper.Keeper + IncentivesKeeper incentiveskeeper.Keeper // simulation manager sm *module.SimulationManager @@ -219,6 +223,7 @@ func NewSimApp( &app.ConsensusParamsKeeper, &app.CircuitBreakerKeeper, &app.OracleKeeper, + &app.IncentivesKeeper, ); err != nil { panic(err) } diff --git a/tests/simapp/config.go b/tests/simapp/config.go index 15721586b..f0d2dd9ed 100644 --- a/tests/simapp/config.go +++ b/tests/simapp/config.go @@ -25,6 +25,7 @@ import ( upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1" vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" "cosmossdk.io/depinject" + incentivesmodulev1 "github.com/skip-mev/slinky/api/slinky/incentives/module/v1" oraclemodulev1 "github.com/skip-mev/slinky/api/slinky/oracle/module/v1" _ "cosmossdk.io/x/circuit" // import for side-effects @@ -43,6 +44,7 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/params" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/slashing" // import for side-effects _ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects + _ "github.com/skip-mev/slinky/x/incentives" // import for side-effects _ "github.com/skip-mev/slinky/x/oracle" // import for side-effects "cosmossdk.io/core/appconfig" @@ -66,6 +68,7 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + incentivetypes "github.com/skip-mev/slinky/x/incentives/types" oracletypes "github.com/skip-mev/slinky/x/oracle/types" ) @@ -79,6 +82,7 @@ var ( {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}}, {Account: oracletypes.ModuleName, Permissions: []string{}}, + {Account: incentivetypes.ModuleName, Permissions: []string{}}, } // blocked account addresses @@ -112,6 +116,7 @@ var ( genutiltypes.ModuleName, authz.ModuleName, oracletypes.ModuleName, + incentivetypes.ModuleName, }, EndBlockers: []string{ crisistypes.ModuleName, @@ -120,6 +125,7 @@ var ( genutiltypes.ModuleName, group.ModuleName, oracletypes.ModuleName, + incentivetypes.ModuleName, }, OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{ { @@ -148,6 +154,7 @@ var ( consensustypes.ModuleName, circuittypes.ModuleName, oracletypes.ModuleName, + incentivetypes.ModuleName, }, // When ExportGenesis is not specified, the export genesis module order // is equal to the init genesis order @@ -196,6 +203,10 @@ var ( Name: oracletypes.ModuleName, Config: appconfig.WrapAny(&oraclemodulev1.Module{}), }, + { + Name: incentivetypes.ModuleName, + Config: appconfig.WrapAny(&incentivesmodulev1.Module{}), + }, { Name: genutiltypes.ModuleName, Config: appconfig.WrapAny(&genutilmodulev1.Module{}), diff --git a/x/incentives/client/cli/query.go b/x/incentives/client/cli/query.go new file mode 100644 index 000000000..45c4f4c90 --- /dev/null +++ b/x/incentives/client/cli/query.go @@ -0,0 +1,92 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/spf13/cobra" +) + +// GetQueryCmd returns the parent command for all x/incentives cli query commands. The +// provided clientCtx should have, at a minimum, a verifier, CometBFT RPC client, +// and marshaler set. +func GetQueryCmd() *cobra.Command { + // create base-command + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + RunE: client.ValidateCmd, + } + + // add sub-commands + cmd.AddCommand( + GetIncentivesByTypeCmd(), + GetAllIncentivesCmd(), + ) + + return cmd +} + +// GetIncentivesByTypeCmd returns the cli-command that queries the incentives of a given type. +// This is essentially a wrapper around the module's QueryClient, as under-the-hood it constructs +// a request to a query-client served over a grpc-conn embedded in the clientCtx. +func GetIncentivesByTypeCmd() *cobra.Command { + return &cobra.Command{ + Use: "type [type]", + Short: "Query for all incentives of a specified type", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + // get context + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + // retrieve incentive type from arguments + incentiveType := args[0] + + // create client + qc := types.NewQueryClient(clientCtx) + + // query for incentives + res, err := qc.GetIncentivesByType(clientCtx.CmdContext, &types.GetIncentivesByTypeRequest{ + IncentiveType: incentiveType, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } +} + +// GetAllIncentivesCmd returns the cli-command that queries all incentives currently stored in the +// incentives module. This is essentially a wrapper around the module's QueryClient, as under-the-hood +// it constructs a request to a query-client served over a grpc-conn embedded in the clientCtx. +func GetAllIncentivesCmd() *cobra.Command { + return &cobra.Command{ + Use: "all-incentives", + Short: "Query for all incentives currently stored in the module", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, _ []string) error { + // get context + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + // create client + qc := types.NewQueryClient(clientCtx) + + // query for incentives + res, err := qc.GetAllIncentives(clientCtx.CmdContext, &types.GetAllIncentivesRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } +} diff --git a/x/incentives/keeper/genesis.go b/x/incentives/keeper/genesis.go new file mode 100644 index 000000000..694b89dd9 --- /dev/null +++ b/x/incentives/keeper/genesis.go @@ -0,0 +1,87 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +// InitGenesis initializes the store state from a genesis state. Note, that +// all of the incentive types (e.g. badprice, goodprice) must be registered +// with the keeper in order for this to execute successfully. +func (k Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) { + // Validate the genesis state. + if err := gs.ValidateBasic(); err != nil { + panic(err) + } + + // Create a reverse map of the incentives. + reverseMap := make(map[string]types.Incentive) + for incentive := range k.incentiveStrategies { + reverseMap[incentive.Type()] = incentive + } + + // Add each incentive to the store. + for _, entry := range gs.Registry { + name, incentives := entry.IncentiveType, entry.Entries + + // Get the incentive type. + incentiveType, ok := reverseMap[name] + if !ok { + panic("unknown incentive type: " + name) + } + + // Unmarshal each incentive with the correspond type. + unmarshalledIncentives := make([]types.Incentive, len(incentives)) + for i, bz := range incentives { + // Attempt to unmarshal the incentive. + if err := incentiveType.Unmarshal(bz); err != nil { + panic(err) + } + + unmarshalledIncentives[i] = incentiveType.Copy() + } + + // Add the incentives to the store. + if err := k.AddIncentives(ctx, unmarshalledIncentives); err != nil { + panic(err) + } + + // Remove the incentive type from the reverse map since we've already + // processed it. + delete(reverseMap, name) + } +} + +// ExportGenesis returns the current store state as a genesis state. Note, that +// if any of the incentive types have no entries in the store, they will not +// be included in the genesis state. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + incentiveGenesis := make([]types.IncentivesByType, 0) + + // Get all of the incentive types and sort them by name. + sortedIncentives := types.SortIncentivesStrategiesMap(k.incentiveStrategies) + + // Iterate over each incentive type. + for _, incentiveType := range sortedIncentives { + // Get the incentives for the current type. + incentives, err := k.GetIncentivesByType(ctx, incentiveType) + if err != nil { + panic(err) + } + + if len(incentives) == 0 { + continue + } + + // Marshal each incentive. + marshalledIncentives, err := types.IncentivesToBytes(incentives...) + if err != nil { + panic(err) + } + + // Add the incentives to the genesis state. + incentiveGenesis = append(incentiveGenesis, types.NewIncentives(incentiveType.Type(), marshalledIncentives)) + } + + return types.NewGenesisState(incentiveGenesis) +} diff --git a/x/incentives/keeper/genesis_test.go b/x/incentives/keeper/genesis_test.go new file mode 100644 index 000000000..394ea40b0 --- /dev/null +++ b/x/incentives/keeper/genesis_test.go @@ -0,0 +1,282 @@ +package keeper_test + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/skip-mev/slinky/x/incentives/types/examples/badprice" + "github.com/skip-mev/slinky/x/incentives/types/examples/goodprice" +) + +func (s *KeeperTestSuite) TestInitGenesis() { + s.Run("can initialize genesis with no incentives", func() { + genesis := types.NewDefaultGenesisState() + s.incentivesKeeper.InitGenesis(s.ctx, *genesis) + }) + + s.Run("can initialize genesis with a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + // Create the genesis state. + bz, err := badPrice.Marshal() + s.Require().NoError(err) + + badPriceIncentives := types.NewIncentives(badprice.BadPriceIncentiveType, [][]byte{bz}) + genesis := types.NewGenesisState([]types.IncentivesByType{badPriceIncentives}) + + // Initialize the genesis state. + s.incentivesKeeper.InitGenesis(s.ctx, *genesis) + + // Check that the incentive was added to the store. + incentives, err := s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + // Check that the incentive is the same as the one we added. + i, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator.String(), i.Validator) + s.Require().Equal(amount.String(), i.Amount) + }) + + s.Run("can initialize genesis with multiple incentives", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + + // Create the genesis state. + bz1, err := badPrice1.Marshal() + s.Require().NoError(err) + + bz2, err := badPrice2.Marshal() + s.Require().NoError(err) + + badPriceIncentives := types.NewIncentives(badprice.BadPriceIncentiveType, [][]byte{bz1, bz2}) + genesis := types.NewGenesisState([]types.IncentivesByType{badPriceIncentives}) + + // Initialize the genesis state. + s.incentivesKeeper.InitGenesis(s.ctx, *genesis) + + // Check that the incentives were added to the store. + incentives, err := s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + // Check that the incentives are the same as the ones we added. + i1, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(amount1.String(), i1.Amount) + + i2, ok := incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(amount2.String(), i2.Amount) + }) + + s.Run("can initialize genesis with multiple incentive types", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice := badprice.NewBadPriceIncentive(validator1, amount1) + goodPrice := goodprice.NewGoodPriceIncentive(validator2, amount2) + + // Create the genesis state. + bz1, err := badPrice.Marshal() + s.Require().NoError(err) + + bz2, err := goodPrice.Marshal() + s.Require().NoError(err) + + badPriceIncentives := types.NewIncentives(badprice.BadPriceIncentiveType, [][]byte{bz1}) + goodPriceIncentives := types.NewIncentives(goodprice.GoodPriceIncentiveType, [][]byte{bz2}) + genesis := types.NewGenesisState([]types.IncentivesByType{badPriceIncentives, goodPriceIncentives}) + + // Initialize the genesis state. + s.incentivesKeeper.InitGenesis(s.ctx, *genesis) + + // Check that the incentives were added to the store. + incentives, err := s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i1, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(amount1.String(), i1.Amount) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i2, ok := incentives[0].(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(amount2.String(), i2.Amount) + }) + + s.Run("errors when initializing genesis with unsupported incentive type", func() { + unsupportedIncentive := types.NewIncentives("unsupported", [][]byte{[]byte("unsupported")}) + genesis := types.NewGenesisState([]types.IncentivesByType{unsupportedIncentive}) + + // catch and check that initgenesis panics + defer func() { + r := recover() + s.Require().NotNil(r) + }() + + s.incentivesKeeper.InitGenesis(s.ctx, *genesis) + }) + + s.Run("errors when initializing genesis with invalid incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + // marshal the incentive to a byte slice + bz, err := badPrice.Marshal() + s.Require().NoError(err) + + // modify the byte slice to make it invalid + bz[0] = 0x00 + + // create the genesis state + badPriceIncentives := types.NewIncentives(badprice.BadPriceIncentiveType, [][]byte{bz}) + genesis := types.NewGenesisState([]types.IncentivesByType{badPriceIncentives}) + + // catch and check that initgenesis panics + defer func() { + r := recover() + s.Require().NotNil(r) + }() + + s.incentivesKeeper.InitGenesis(s.ctx, *genesis) + }) +} + +func (s *KeeperTestSuite) TestExportGenesis() { + s.Run("can export genesis with no incentives", func() { + genesis := s.incentivesKeeper.ExportGenesis(s.ctx) + s.Require().NotNil(genesis) + + // Check that the genesis state is valid. + err := genesis.ValidateBasic() + s.Require().NoError(err) + + // Check that the genesis state is empty. + s.Require().Len(genesis.Registry, 0) + }) + + s.Run("can export genesis with a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + // Add the incentive to the store. + err := s.incentivesKeeper.AddIncentives(s.ctx, []types.Incentive{badPrice}) + s.Require().NoError(err) + + // Export the genesis state. + genesis := s.incentivesKeeper.ExportGenesis(s.ctx) + s.Require().NotNil(genesis) + + // Check that the genesis state is valid. + err = genesis.ValidateBasic() + s.Require().NoError(err) + + // Check that the genesis state contains the incentive. + s.Require().Len(genesis.Registry, 1) + s.Require().Equal(badprice.BadPriceIncentiveType, genesis.Registry[0].IncentiveType) + s.Require().Len(genesis.Registry[0].Entries, 1) + + bz, err := badPrice.Marshal() + s.Require().NoError(err) + s.Require().Equal(bz, genesis.Registry[0].Entries[0]) + }) + + s.Run("can export genesis with multiple incentives", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + + // Add the incentives to the store. + err := s.incentivesKeeper.AddIncentives(s.ctx, []types.Incentive{badPrice1, badPrice2}) + s.Require().NoError(err) + + // Export the genesis state. + genesis := s.incentivesKeeper.ExportGenesis(s.ctx) + s.Require().NotNil(genesis) + + // Check that the genesis state is valid. + err = genesis.ValidateBasic() + s.Require().NoError(err) + + // Check that the genesis state contains the incentives. + s.Require().Len(genesis.Registry, 1) + s.Require().Equal(badprice.BadPriceIncentiveType, genesis.Registry[0].IncentiveType) + s.Require().Len(genesis.Registry[0].Entries, 2) + + bz1, err := badPrice1.Marshal() + s.Require().NoError(err) + + bz2, err := badPrice2.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz1, genesis.Registry[0].Entries[0]) + s.Require().Equal(bz2, genesis.Registry[0].Entries[1]) + }) + + s.Run("can export genesis with multiple incentive types", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice := badprice.NewBadPriceIncentive(validator1, amount1) + goodPrice := goodprice.NewGoodPriceIncentive(validator2, amount2) + + // Add the incentives to the store. + err := s.incentivesKeeper.AddIncentives(s.ctx, []types.Incentive{badPrice, goodPrice}) + s.Require().NoError(err) + + // Export the genesis state. + genesis := s.incentivesKeeper.ExportGenesis(s.ctx) + s.Require().NotNil(genesis) + + // Check that the genesis state is valid. + err = genesis.ValidateBasic() + s.Require().NoError(err) + + // Check that the genesis state contains the incentives. + s.Require().Len(genesis.Registry, 2) + s.Require().Equal(badprice.BadPriceIncentiveType, genesis.Registry[0].IncentiveType) + s.Require().Len(genesis.Registry[0].Entries, 1) + s.Require().Equal(goodprice.GoodPriceIncentiveType, genesis.Registry[1].IncentiveType) + s.Require().Len(genesis.Registry[1].Entries, 1) + + bz1, err := badPrice.Marshal() + s.Require().NoError(err) + + bz2, err := goodPrice.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz1, genesis.Registry[0].Entries[0]) + s.Require().Equal(bz2, genesis.Registry[1].Entries[0]) + }) +} diff --git a/x/incentives/keeper/grpc_query.go b/x/incentives/keeper/grpc_query.go new file mode 100644 index 000000000..0e424a1fe --- /dev/null +++ b/x/incentives/keeper/grpc_query.go @@ -0,0 +1,97 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +var _ types.QueryServer = QueryServer{} + +// QueryServer is the default implementation of the x/incentives QueryServer. +type QueryServer struct { + k Keeper +} + +// NewQueryServer returns an implementation of the x/incentives QueryServer. +func NewQueryServer(k Keeper) QueryServer { + return QueryServer{ + k, + } +} + +// GetIncentivesByType returns all incentives of a given type currently stored in the +// incentives module. If the type is not registered with the module, an error is returned. +func (q QueryServer) GetIncentivesByType( + ctx context.Context, + req *types.GetIncentivesByTypeRequest, +) (*types.GetIncentivesByTypeResponse, error) { + if req == nil { + return nil, fmt.Errorf("request cannot be nil") + } + + var incentive types.Incentive + for i := range q.k.incentiveStrategies { + if i.Type() == req.IncentiveType { + incentive = i + break + } + } + + if incentive == nil { + return nil, fmt.Errorf("unknown incentive type: %s", req.IncentiveType) + } + + incentives, err := q.k.GetIncentivesByType(sdk.UnwrapSDKContext(ctx), incentive) + if err != nil { + return nil, err + } + + incentiveBytes, err := types.IncentivesToBytes(incentives...) + if err != nil { + return nil, err + } + + resp := types.GetIncentivesByTypeResponse{ + Entries: incentiveBytes, + } + + return &resp, nil +} + +// GetAllIncentives returns all incentives currently stored in the module. +func (q QueryServer) GetAllIncentives( + ctx context.Context, + _ *types.GetAllIncentivesRequest, +) (*types.GetAllIncentivesResponse, error) { + incentives := make([]types.IncentivesByType, 0) + + // Get all of the incentive types and sort them by name. + sortedIncentives := types.SortIncentivesStrategiesMap(q.k.incentiveStrategies) + + for _, incentive := range sortedIncentives { + incentivesByType, err := q.k.GetIncentivesByType(sdk.UnwrapSDKContext(ctx), incentive) + if err != nil { + return nil, err + } + + if len(incentivesByType) == 0 { + continue + } + + incentiveBytes, err := types.IncentivesToBytes(incentivesByType...) + if err != nil { + return nil, err + } + + incentives = append(incentives, types.NewIncentives(incentive.Type(), incentiveBytes)) + } + + resp := types.GetAllIncentivesResponse{ + Registry: incentives, + } + + return &resp, nil +} diff --git a/x/incentives/keeper/grpc_query_test.go b/x/incentives/keeper/grpc_query_test.go new file mode 100644 index 000000000..21c114059 --- /dev/null +++ b/x/incentives/keeper/grpc_query_test.go @@ -0,0 +1,184 @@ +package keeper_test + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/skip-mev/slinky/x/incentives/types/examples/badprice" + "github.com/skip-mev/slinky/x/incentives/types/examples/goodprice" +) + +func (s *KeeperTestSuite) TestGetIncentivesByType() { + s.Run("returns an error with empty type", func() { + _, err := s.queryServer.GetIncentivesByType(s.ctx, nil) + s.Require().Error(err) + }) + + s.Run("returns an error with unsupported type", func() { + req := &types.GetIncentivesByTypeRequest{IncentiveType: "unsupported"} + _, err := s.queryServer.GetIncentivesByType(s.ctx, req) + s.Require().Error(err) + }) + + s.Run("returns an empty list with no incentives", func() { + req := &types.GetIncentivesByTypeRequest{IncentiveType: badprice.BadPriceIncentiveType} + resp, err := s.queryServer.GetIncentivesByType(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Entries, 0) + }) + + s.Run("returns a single incentive stored in the module", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + incentives := []types.Incentive{badPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + req := &types.GetIncentivesByTypeRequest{IncentiveType: badprice.BadPriceIncentiveType} + resp, err := s.queryServer.GetIncentivesByType(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Entries, 1) + + // check that the incentive is the same as the one we added + bz, err := badPrice.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz, resp.Entries[0]) + }) + + s.Run("returns multiple incentives stored in the module", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + + incentives := []types.Incentive{badPrice1, badPrice2} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + req := &types.GetIncentivesByTypeRequest{IncentiveType: badprice.BadPriceIncentiveType} + resp, err := s.queryServer.GetIncentivesByType(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Entries, 2) + + // check that the incentives are the same as the ones we added + bz1, err := badPrice1.Marshal() + s.Require().NoError(err) + + bz2, err := badPrice2.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz1, resp.Entries[0]) + s.Require().Equal(bz2, resp.Entries[1]) + }) +} + +func (s *KeeperTestSuite) TestGetAllIncentives() { + s.Run("returns an empty list with no incentives", func() { + req := &types.GetAllIncentivesRequest{} + resp, err := s.queryServer.GetAllIncentives(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Registry, 0) + }) + + s.Run("returns a single incentive stored in the module", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + incentives := []types.Incentive{badPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + req := &types.GetAllIncentivesRequest{} + resp, err := s.queryServer.GetAllIncentives(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Registry, 1) + + s.Require().Equal(badprice.BadPriceIncentiveType, resp.Registry[0].IncentiveType) + s.Require().Len(resp.Registry[0].Entries, 1) + + // check that the incentive is the same as the one we added + bz, err := badPrice.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz, resp.Registry[0].Entries[0]) + }) + + s.Run("returns multiple incentives stored in the module", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + + incentives := []types.Incentive{badPrice1, badPrice2} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + req := &types.GetAllIncentivesRequest{} + resp, err := s.queryServer.GetAllIncentives(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Registry, 1) + + s.Require().Equal(badprice.BadPriceIncentiveType, resp.Registry[0].IncentiveType) + s.Require().Len(resp.Registry[0].Entries, 2) + + // check that the incentives are the same as the ones we added + bz1, err := badPrice1.Marshal() + s.Require().NoError(err) + + bz2, err := badPrice2.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz1, resp.Registry[0].Entries[0]) + s.Require().Equal(bz2, resp.Registry[0].Entries[1]) + }) + + s.Run("returns a single incentive for each type", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice := badprice.NewBadPriceIncentive(validator1, amount1) + goodPrice := goodprice.NewGoodPriceIncentive(validator2, amount2) + + incentives := []types.Incentive{badPrice, goodPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + req := &types.GetAllIncentivesRequest{} + resp, err := s.queryServer.GetAllIncentives(s.ctx, req) + s.Require().NoError(err) + s.Require().Len(resp.Registry, 2) + + s.Require().Equal(badprice.BadPriceIncentiveType, resp.Registry[0].IncentiveType) + s.Require().Len(resp.Registry[0].Entries, 1) + + s.Require().Equal(goodprice.GoodPriceIncentiveType, resp.Registry[1].IncentiveType) + s.Require().Len(resp.Registry[1].Entries, 1) + + // check that the incentives are the same as the ones we added + bz1, err := badPrice.Marshal() + s.Require().NoError(err) + + bz2, err := goodPrice.Marshal() + s.Require().NoError(err) + + s.Require().Equal(bz1, resp.Registry[0].Entries[0]) + s.Require().Equal(bz2, resp.Registry[1].Entries[0]) + }) +} diff --git a/x/incentives/keeper/incentives.go b/x/incentives/keeper/incentives.go new file mode 100644 index 000000000..67a565752 --- /dev/null +++ b/x/incentives/keeper/incentives.go @@ -0,0 +1,128 @@ +package keeper + +import ( + storetypes "cosmossdk.io/store/types" + db "github.com/cosmos/cosmos-db" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +// GetIncentivesByType returns all incentives of a given type. +func (k Keeper) GetIncentivesByType(ctx sdk.Context, incentive types.Incentive) ([]types.Incentive, error) { + key := types.GetIncentiveKey(incentive) + + // Create a callback to unmarshal the incentives. + incentives := []types.Incentive{} + cb := func(it db.Iterator) error { + if err := incentive.Unmarshal(it.Value()); err != nil { + return err + } + + // Copy the incentive, and append it to the list of incentives. + incentives = append(incentives, incentive.Copy()) + return nil + } + + // Iterate through all incentives of the given type, unmashalling them, + // and appending them to the list of incentives. + if err := k.iteratorFunc(ctx, key, cb); err != nil { + return nil, err + } + + return incentives, nil +} + +// AddIncentives adds a set of incentives to the module's state. +func (k Keeper) AddIncentives(ctx sdk.Context, incentives []types.Incentive) error { + for _, incentive := range incentives { + if err := k.addIncentive(ctx, incentive); err != nil { + return err + } + } + + return nil +} + +// addIncentive adds a single incentive to the module's state. +func (k Keeper) addIncentive(ctx sdk.Context, incentive types.Incentive) error { + // Get the next incentive index. + index, err := k.getIncentiveCount(ctx, incentive) + if err != nil { + return err + } + + // Marshal the incentive into + bz, err := incentive.Marshal() + if err != nil { + return err + } + + // set the incentive in the store + store := ctx.KVStore(k.storeKey) + key := types.GetIncentiveKeyWithIndex(incentive, index+1) + store.Set(key, bz) + + // increment the incentive count + k.setIncentiveCount(ctx, incentive, index+1) + + return nil +} + +// RemoveIncentivesByType removes all incentives of a given type from the module's state. +func (k Keeper) RemoveIncentivesByType(ctx sdk.Context, incentive types.Incentive) error { + key := types.GetIncentiveKey(incentive) + + // Create a callback to delete the incentives. + cb := func(it db.Iterator) error { + store := ctx.KVStore(k.storeKey) + store.Delete(it.Key()) + return nil + } + + // Iterate through all incentives of the given type, deleting them. + return k.iteratorFunc(ctx, key, cb) +} + +// getIncentiveCount returns the number of incentives of a given type. Note that this +// is the number of incentives that have been added to the module's state, not the +// number of incentives that are currently active. +func (k Keeper) getIncentiveCount(ctx sdk.Context, incentive types.Incentive) (uint64, error) { + key := types.GetIncentiveCountKey(incentive) + + store := ctx.KVStore(k.storeKey) + bz := store.Get(key) + if bz == nil { + return 0, nil + } + + return sdk.BigEndianToUint64(bz), nil +} + +// setIncentiveCount updates the number of incentives of a given type. Note that this +// is the number of incentives that have been added to the module's state, not the +// number of incentives that are currently active. +func (k Keeper) setIncentiveCount(ctx sdk.Context, incentive types.Incentive, count uint64) { + key := types.GetIncentiveCountKey(incentive) + + store := ctx.KVStore(k.storeKey) + bz := sdk.Uint64ToBigEndian(count) + store.Set(key, bz) +} + +// iteratorFunc is a helper function that will create an iterator for a given +// store, and execute a call-back for each key/value pair. +func (k Keeper) iteratorFunc(ctx sdk.Context, prefix []byte, f func(db.Iterator) error) error { + // get iterator for store w/ prefix + store := ctx.KVStore(k.storeKey) + it := storetypes.KVStorePrefixIterator(store, prefix) + + // close the iterator + defer it.Close() + for ; it.Valid(); it.Next() { + // execute call-back, and return error if necessary + if err := f(it); err != nil { + return err + } + } + return nil +} diff --git a/x/incentives/keeper/incentives_test.go b/x/incentives/keeper/incentives_test.go new file mode 100644 index 000000000..fa32c25b7 --- /dev/null +++ b/x/incentives/keeper/incentives_test.go @@ -0,0 +1,160 @@ +package keeper_test + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/skip-mev/slinky/x/incentives/types/examples/badprice" + "github.com/skip-mev/slinky/x/incentives/types/examples/goodprice" +) + +func (s *KeeperTestSuite) TestAddIncentives() { + s.Run("can add an empty list of incentives", func() { + err := s.incentivesKeeper.AddIncentives(s.ctx, nil) + s.Require().NoError(err) + + // Check the count of incentives for each type. + incentives, err := s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + }) + + s.Run("can add a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + incentives := []types.Incentive{badPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // retrieve the incentive from the store + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + // check that the incentive is the same as the one we added + i, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator.String(), i.Validator) + s.Require().Equal(amount.String(), i.Amount) + }) + + s.Run("can add multiple incentives", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + + incentives := []types.Incentive{badPrice1, badPrice2} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // retrieve the incentives from the store + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + // check that the incentives are the same as the ones we added + i1, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(amount1.String(), i1.Amount) + + i2, ok := incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(amount2.String(), i2.Amount) + }) + + s.Run("can add single incentive of different types", func() { + goodValidator := sdk.ValAddress([]byte("good_validator")) + goodAmount := math.NewInt(100) + goodPrice := goodprice.NewGoodPriceIncentive(goodValidator, goodAmount) + + badValidator := sdk.ValAddress([]byte("bad_validator")) + badAmount := math.NewInt(200) + badPrice := badprice.NewBadPriceIncentive(badValidator, badAmount) + + incentives := []types.Incentive{goodPrice, badPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // retrieve the incentives from the store + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i1, ok := incentives[0].(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + s.Require().Equal(goodValidator.String(), i1.Validator) + s.Require().Equal(goodAmount.String(), i1.Amount) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i2, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(badValidator.String(), i2.Validator) + s.Require().Equal(badAmount.String(), i2.Amount) + }) + + s.Run("can add multiple incentives of different types", func() { + goodValidator1 := sdk.ValAddress([]byte("good_validator1")) + goodAmount1 := math.NewInt(100) + goodPrice1 := goodprice.NewGoodPriceIncentive(goodValidator1, goodAmount1) + + goodValidator2 := sdk.ValAddress([]byte("good_validator2")) + goodAmount2 := math.NewInt(200) + goodPrice2 := goodprice.NewGoodPriceIncentive(goodValidator2, goodAmount2) + + badValidator1 := sdk.ValAddress([]byte("bad_validator1")) + badAmount1 := math.NewInt(300) + badPrice1 := badprice.NewBadPriceIncentive(badValidator1, badAmount1) + + badValidator2 := sdk.ValAddress([]byte("bad_validator2")) + badAmount2 := math.NewInt(400) + badPrice2 := badprice.NewBadPriceIncentive(badValidator2, badAmount2) + + incentives := []types.Incentive{goodPrice1, goodPrice2, badPrice1, badPrice2} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // retrieve the incentives from the store + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + i1, ok := incentives[0].(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + s.Require().Equal(goodValidator1.String(), i1.Validator) + s.Require().Equal(goodAmount1.String(), i1.Amount) + + i2, ok := incentives[1].(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + s.Require().Equal(goodValidator2.String(), i2.Validator) + s.Require().Equal(goodAmount2.String(), i2.Amount) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + i3, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(badValidator1.String(), i3.Validator) + s.Require().Equal(badAmount1.String(), i3.Amount) + + i4, ok := incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(badValidator2.String(), i4.Validator) + s.Require().Equal(badAmount2.String(), i4.Amount) + }) +} diff --git a/x/incentives/keeper/keeper.go b/x/incentives/keeper/keeper.go new file mode 100644 index 000000000..91808a8f9 --- /dev/null +++ b/x/incentives/keeper/keeper.go @@ -0,0 +1,32 @@ +package keeper + +import ( + storetypes "cosmossdk.io/store/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +type ( + // Keeper is the base keeper for the x/incentives module. + Keeper struct { + storeKey storetypes.StoreKey + + // incentiveStrategies is a map of incentive types to their corresponding strategy + // functions. + incentiveStrategies map[types.Incentive]types.Strategy + } +) + +// NewKeeper constructs a new keeper from a store-key and a given set of +// (incentive, strategies) pairings. Note, if the strategies map is empty, +// then the keeper will not be able to process any incentives. This must be +// set by the application developer. Each incentive type must have a +// corresponding strategy function. +func NewKeeper( + sk storetypes.StoreKey, + incentiveStrategies map[types.Incentive]types.Strategy, +) Keeper { + return Keeper{ + storeKey: sk, + incentiveStrategies: incentiveStrategies, + } +} diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go new file mode 100644 index 000000000..78740341c --- /dev/null +++ b/x/incentives/keeper/keeper_test.go @@ -0,0 +1,70 @@ +package keeper_test + +import ( + "testing" + + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/keeper" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/skip-mev/slinky/x/incentives/types/examples/badprice" + "github.com/skip-mev/slinky/x/incentives/types/examples/goodprice" + "github.com/skip-mev/slinky/x/incentives/types/examples/mocks" + "github.com/stretchr/testify/suite" +) + +type KeeperTestSuite struct { + suite.Suite + + incentivesKeeper keeper.Keeper + queryServer keeper.QueryServer + key storetypes.StoreKey + ctx sdk.Context + + // mock strategies + stakingKeeper mocks.StakingKeeper + bankKeeper mocks.BankKeeper +} + +func (s *KeeperTestSuite) SetupTest() { + s.key = storetypes.NewKVStoreKey(types.StoreKey) + s.ctx = testutil.DefaultContext(s.key, storetypes.NewTransientStoreKey("transient_key")) + s.incentivesKeeper = keeper.NewKeeper(s.key, nil) + s.queryServer = keeper.NewQueryServer(s.incentivesKeeper) +} + +func (s *KeeperTestSuite) SetupSubTest() { + err := s.incentivesKeeper.RemoveIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + + incentives, err := s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + + err = s.incentivesKeeper.RemoveIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + + // Reset the mock strategies. + s.bankKeeper = *mocks.NewBankKeeper(s.T()) + s.stakingKeeper = *mocks.NewStakingKeeper(s.T()) + + badPriceStrategy := badprice.NewBadPriceIncentiveStrategy(&s.stakingKeeper).GetStrategy() + goodPriceStrategy := goodprice.NewGoodPriceIncentiveStrategy(&s.bankKeeper).GetStrategy() + strategies := map[types.Incentive]types.Strategy{ + &badprice.BadPriceIncentive{}: badPriceStrategy, + &goodprice.GoodPriceIncentive{}: goodPriceStrategy, + } + + // Reset the keeper with the new strategies. + s.incentivesKeeper = keeper.NewKeeper(s.key, strategies) + s.queryServer = keeper.NewQueryServer(s.incentivesKeeper) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/incentives/keeper/strategy.go b/x/incentives/keeper/strategy.go new file mode 100644 index 000000000..c4fea138b --- /dev/null +++ b/x/incentives/keeper/strategy.go @@ -0,0 +1,80 @@ +package keeper + +import ( + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +// ExecuteByIncentiveTypeCB is a callback function that can utilized to update all +// incentives of a given type. This is useful for having incentive/strategy pairs +// that are meant to last several blocks. This function should return the updated +// incentive, or nil if the incentive should be deleted. +type ExecuteByIncentiveTypeCB func(incentive types.Incentive) (types.Incentive, error) + +// ExecuteStrategies executes all of the strategies with the stored incentives. +func (k Keeper) ExecuteStrategies(ctx sdk.Context) error { + for incentive, strategy := range k.incentiveStrategies { + if err := k.ExecuteIncentiveStrategy(ctx, incentive, strategy); err != nil { + return err + } + } + + return nil +} + +// ExecuteIncentiveStrategy executes a given strategy for all incentives of a given type. +// Note that the strategy may mutate the incentive, and return a new incentive to be +// stored. Stategies must return nil if the incentive should be deleted. Otherwise, the +// incentive will be updated. +func (k Keeper) ExecuteIncentiveStrategy( + ctx sdk.Context, + incentive types.Incentive, + strategy types.Strategy, +) error { + cb := func(incentive types.Incentive) (types.Incentive, error) { + return strategy(ctx, incentive) + } + + return k.ExecuteByIncentiveType(ctx, incentive, cb) +} + +// ExecuteByIncentiveType updates all incentives of a given type. +func (k Keeper) ExecuteByIncentiveType( + ctx sdk.Context, + incentive types.Incentive, + cb ExecuteByIncentiveTypeCB, +) error { + // get iterator for store w/ prefix + store := ctx.KVStore(k.storeKey) + key := types.GetIncentiveKey(incentive) + it := storetypes.KVStorePrefixIterator(store, key) + + // close the iterator + defer it.Close() + for ; it.Valid(); it.Next() { + // Unmarshal the incentive. + if err := incentive.Unmarshal(it.Value()); err != nil { + return err + } + + update, err := cb(incentive) + if err != nil { + return err + } + + // If the callback returns nil, then delete the incentive. + if update == nil { + store.Delete(it.Key()) + } else { + updateBz, err := update.Marshal() + if err != nil { + return err + } + + store.Set(it.Key(), updateBz) + } + } + + return nil +} diff --git a/x/incentives/keeper/strategy_test.go b/x/incentives/keeper/strategy_test.go new file mode 100644 index 000000000..d00e742f6 --- /dev/null +++ b/x/incentives/keeper/strategy_test.go @@ -0,0 +1,485 @@ +package keeper_test + +import ( + "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/keeper" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/skip-mev/slinky/x/incentives/types/examples/badprice" + "github.com/skip-mev/slinky/x/incentives/types/examples/goodprice" + "github.com/stretchr/testify/mock" +) + +func (s *KeeperTestSuite) TestExecuteByIncentiveType() { + deleteCB := func(incentive types.Incentive) (types.Incentive, error) { + return nil, nil + } + + updatePriceCB := func(incentive types.Incentive) (types.Incentive, error) { + badPrice, ok := incentive.(*badprice.BadPriceIncentive) + s.Require().True(ok) + + badPrice.Amount = math.NewInt(200000).String() + return badPrice, nil + } + + s.Run("can update an empty list of incentives", func() { + err := s.incentivesKeeper.ExecuteByIncentiveType(s.ctx, &badprice.BadPriceIncentive{}, deleteCB) + s.Require().NoError(err) + + // Check the count of incentives for each type. + incentives, err := s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + }) + + s.Run("can run a no-op on a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + incentives := []types.Incentive{badPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Update the incentives with the no-op callback. + err = s.incentivesKeeper.ExecuteByIncentiveType(s.ctx, &badprice.BadPriceIncentive{}, deleteCB) + s.Require().NoError(err) + + // Check that the incentive was removed from the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + }) + + s.Run("can run a valid update on a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + incentives := []types.Incentive{badPrice} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Check the incentive in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator.String(), i.Validator) + s.Require().Equal(amount.String(), i.Amount) + + // Update the incentives with the update callback. + err = s.incentivesKeeper.ExecuteByIncentiveType(s.ctx, &badprice.BadPriceIncentive{}, updatePriceCB) + s.Require().NoError(err) + + // Check that the incentive was updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i, ok = incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator.String(), i.Validator) + s.Require().Equal(math.NewInt(200000).String(), i.Amount) + }) + + s.Run("can update multiple incentives", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + + incentives := []types.Incentive{badPrice1, badPrice2} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Check the incentives in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + i1, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(amount1.String(), i1.Amount) + + i2, ok := incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(amount2.String(), i2.Amount) + + // Update the incentives with the update callback. + err = s.incentivesKeeper.ExecuteByIncentiveType(s.ctx, &badprice.BadPriceIncentive{}, updatePriceCB) + s.Require().NoError(err) + + // Check that the incentives were updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + i1, ok = incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(math.NewInt(200000).String(), i1.Amount) + + i2, ok = incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(math.NewInt(200000).String(), i2.Amount) + }) + + s.Run("can update some incentives and remove others", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + validator3 := sdk.ValAddress([]byte("validator3")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + amount3 := math.NewInt(300) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + badPrice3 := badprice.NewBadPriceIncentive(validator3, amount3) + + incentives := []types.Incentive{badPrice1, badPrice2, badPrice3} + + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Check the incentives in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 3) + + i1, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(amount1.String(), i1.Amount) + + i2, ok := incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(amount2.String(), i2.Amount) + + i3, ok := incentives[2].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator3.String(), i3.Validator) + s.Require().Equal(amount3.String(), i3.Amount) + + cb := func(incentive types.Incentive) (types.Incentive, error) { + badPrice, ok := incentive.(*badprice.BadPriceIncentive) + s.Require().True(ok) + + // If this is validator 2 we remove + if badPrice.Validator == validator2.String() { + return nil, nil + } + + // Otherwise we update the price + badPrice.Amount = math.NewInt(200000).String() + return badPrice, nil + } + + // Update the incentives with the update callback. + err = s.incentivesKeeper.ExecuteByIncentiveType(s.ctx, &badprice.BadPriceIncentive{}, cb) + s.Require().NoError(err) + + // Check that the incentives were updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 2) + + i1, ok = incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i1.Validator) + s.Require().Equal(math.NewInt(200000).String(), i1.Amount) + + i2, ok = incentives[1].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator3.String(), i2.Validator) + s.Require().Equal(math.NewInt(200000).String(), i2.Amount) + }) +} + +func (s *KeeperTestSuite) TestExecuteStrategies() { + s.Run("can execute a strategy on an empty list of incentives", func() { + err := s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + }) + + s.Run("can execute a strategy on a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + // Add the incentive to the store. + incentives := []types.Incentive{badPrice} + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Mock the results of the staking keeper. + s.stakingKeeper.On("GetValidatorStake", mock.Anything, validator).Return(amount, true).Once() + s.stakingKeeper.On("Slash", mock.Anything, validator, amount).Return(nil).Once() + + // Execute the strategy. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentive was removed from the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + }) + + s.Run("stores the incentive if the strategy returns an error", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + // Add the incentive to the store. + incentives := []types.Incentive{badPrice} + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Mock the results of the staking keeper. + s.stakingKeeper.On("GetValidatorStake", mock.Anything, validator).Return(amount, true).Once() + s.stakingKeeper.On("Slash", mock.Anything, validator, amount).Return(fmt.Errorf("slash error")).Once() + + // Execute the strategy. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().Error(err) + + // Check that the incentive was not removed from the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + }) + + s.Run("can execute a strategy on multiple of the same incentive types", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice1 := badprice.NewBadPriceIncentive(validator1, amount1) + badPrice2 := badprice.NewBadPriceIncentive(validator2, amount2) + incentives := []types.Incentive{badPrice1, badPrice2} + + // Add the incentives to the store. + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Mock the results of the staking keeper. + s.stakingKeeper.On("GetValidatorStake", mock.Anything, validator1).Return(amount1, true).Once() + s.stakingKeeper.On("Slash", mock.Anything, validator1, amount1).Return(nil).Once() + + s.stakingKeeper.On("GetValidatorStake", mock.Anything, validator2).Return(amount2, true).Once() + s.stakingKeeper.On("Slash", mock.Anything, validator2, amount2).Return(nil).Once() + + // Execute the strategy. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentives were removed from the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + }) + + s.Run("can execute a strategy on multiple different incentive types", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice := badprice.NewBadPriceIncentive(validator1, amount1) + goodPrice := goodprice.NewGoodPriceIncentive(validator2, amount2) + incentives := []types.Incentive{badPrice, goodPrice} + + // Add the incentives to the store. + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Mock the results of the staking keeper. + s.stakingKeeper.On("GetValidatorStake", mock.Anything, validator1).Return(amount1, true).Once() + s.stakingKeeper.On("Slash", mock.Anything, validator1, amount1).Return(nil).Once() + + // Mock the results of the bank keeper. + s.bankKeeper.On( + "MintCoins", + mock.Anything, mock.Anything, amount2, + ).Return(nil).Once() + + s.bankKeeper.On( + "SendCoinsFromModuleToAccount", + mock.Anything, mock.Anything, validator2, amount2, + ).Return(nil).Once() + + // Execute the strategy. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentives were removed from the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 0) + }) + + updateBadPriceStrategy := func(ctx sdk.Context, incentive types.Incentive) (types.Incentive, error) { + badPrice, ok := incentive.(*badprice.BadPriceIncentive) + s.Require().True(ok) + + amount, ok := math.NewIntFromString(badPrice.Amount) + s.Require().True(ok) + + amount = amount.Add(math.NewInt(100)) + badPrice.Amount = amount.String() + + return badPrice, nil + } + + s.Run("can run an update strategy on a single incentive", func() { + validator := sdk.ValAddress([]byte("validator")) + amount := math.NewInt(100) + badPrice := badprice.NewBadPriceIncentive(validator, amount) + + // create a new keeper with the updated strategy + strategies := map[types.Incentive]types.Strategy{ + &badprice.BadPriceIncentive{}: updateBadPriceStrategy, + } + s.incentivesKeeper = keeper.NewKeeper(s.key, strategies) + + // Add the incentive to the store. + incentives := []types.Incentive{badPrice} + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Execute the strategy. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentive was updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator.String(), i.Validator) + s.Require().Equal(math.NewInt(200).String(), i.Amount) + + // Execute the strategy again. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentive was updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i, ok = incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator.String(), i.Validator) + s.Require().Equal(math.NewInt(300).String(), i.Amount) + }) + + updateGoodPriceStrategy := func(ctx sdk.Context, incentive types.Incentive) (types.Incentive, error) { + goodPrice, ok := incentive.(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + + amount, ok := math.NewIntFromString(goodPrice.Amount) + s.Require().True(ok) + + amount = amount.Add(math.NewInt(100)) + goodPrice.Amount = amount.String() + + return goodPrice, nil + } + + s.Run("can run an update strategy on multiple different incentive types", func() { + validator1 := sdk.ValAddress([]byte("validator1")) + validator2 := sdk.ValAddress([]byte("validator2")) + + amount1 := math.NewInt(100) + amount2 := math.NewInt(200) + + badPrice := badprice.NewBadPriceIncentive(validator1, amount1) + goodPrice := goodprice.NewGoodPriceIncentive(validator2, amount2) + + // create a new keeper with the updated strategy + strategies := map[types.Incentive]types.Strategy{ + &badprice.BadPriceIncentive{}: updateBadPriceStrategy, + &goodprice.GoodPriceIncentive{}: updateGoodPriceStrategy, + } + s.incentivesKeeper = keeper.NewKeeper(s.key, strategies) + + // Add the incentives to the store. + incentives := []types.Incentive{badPrice, goodPrice} + err := s.incentivesKeeper.AddIncentives(s.ctx, incentives) + s.Require().NoError(err) + + // Execute the strategy. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentives were updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i, ok := incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i.Validator) + s.Require().Equal(math.NewInt(200).String(), i.Amount) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i2, ok := incentives[0].(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(math.NewInt(300).String(), i2.Amount) + + // Execute the strategy again. + err = s.incentivesKeeper.ExecuteStrategies(s.ctx) + s.Require().NoError(err) + + // Check that the incentives were updated in the store. + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &badprice.BadPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i, ok = incentives[0].(*badprice.BadPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator1.String(), i.Validator) + s.Require().Equal(math.NewInt(300).String(), i.Amount) + + incentives, err = s.incentivesKeeper.GetIncentivesByType(s.ctx, &goodprice.GoodPriceIncentive{}) + s.Require().NoError(err) + s.Require().Len(incentives, 1) + + i2, ok = incentives[0].(*goodprice.GoodPriceIncentive) + s.Require().True(ok) + s.Require().Equal(validator2.String(), i2.Validator) + s.Require().Equal(math.NewInt(400).String(), i2.Amount) + }) +} diff --git a/x/incentives/module.go b/x/incentives/module.go new file mode 100644 index 000000000..74d2bc692 --- /dev/null +++ b/x/incentives/module.go @@ -0,0 +1,184 @@ +package incentives + +import ( + "context" + "encoding/json" + + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" + + storetypes "cosmossdk.io/store/types" + cometabci "github.com/cometbft/cometbft/abci/types" + "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" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + incentivesmodulev1 "github.com/skip-mev/slinky/api/slinky/incentives/module/v1" + "github.com/skip-mev/slinky/x/incentives/client/cli" + "github.com/skip-mev/slinky/x/incentives/keeper" + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/spf13/cobra" +) + +// ConsensusVersion is the x/incentives module's current version, as modules integrate and +// updates are made, this value determines what version of the module is being run by the chain. +const ConsensusVersion = 1 + +var ( + _ module.AppModule = AppModule{} + _ appmodule.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the base interface that the x/incentives module exposes to the +// application. +type AppModuleBasic struct { + cdc codec.Codec +} + +// Name returns the name of this module. +func (AppModuleBasic) Name() string { return types.ModuleName } + +// RegisterLegacyAminoCodec registers the necessary types from the x/incentives module +// for amino serialization. +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} + +// RegisterInterfaces registers the necessary implementations / interfaces in the +// x/incentives module w/ the interface-registry. +func (AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {} + +// RegisterGRPCGatewayRoutes registers the necessary REST routes for the GRPC-gateway to +// the x/incentives module QueryService on mux. This method panics on failure. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(cliCtx client.Context, mux *runtime.ServeMux) { + // Register the gate-way routes w/ the provided mux. + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(cliCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd is a no-op, as no txs are registered for submission. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the x/incentives module base query cli-command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// DefaultGenesis returns default genesis state as raw bytes for the incentives +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.NewDefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the incentives module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return err + } + + return gs.ValidateBasic() +} + +// No RESTful routes exist for the incentives module (outside of those served via the grpc-gateway). +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// AppModule represents an application module for the x/incentives module. +type AppModule struct { + AppModuleBasic + + k keeper.Keeper +} + +// NewAppModule returns an application module for the x/incentives module. +func NewAppModule(cdc codec.Codec, k keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{ + cdc: cdc, + }, + k: k, + } +} + +// BeginBlock returns the begin blocker for the incentives module. +func (am AppModule) BeginBlock(ctx context.Context) error { + return am.k.ExecuteStrategies(sdk.UnwrapSDKContext(ctx)) +} + +// IsAppModule implements the appmodule.AppModule interface. +func (AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (AppModule) IsOnePerModuleType() {} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } + +// RegisterServices registers the module's services with the app's module configurator +func (am AppModule) RegisterServices(cfc module.Configurator) { + // Register the query service. + types.RegisterQueryServer(cfc.QueryServer(), keeper.NewQueryServer(am.k)) +} + +// RegisterInvariants registers the invariants of the incentives module. If an invariant +// deviates from its predicted value, the InvariantRegistry triggers appropriate +// logic (most often the chain will be halted). No invariants exist for the incentives module. +func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the genesis initialization for the x/incentives module. It determines the +// genesis state to initialize from via a json-encoded genesis-state. This method returns no validator set updates. +// This method panics on any errors. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []cometabci.ValidatorUpdate { + var gs types.GenesisState + cdc.MustUnmarshalJSON(bz, &gs) + + am.k.InitGenesis(ctx, gs) + + // return no validator-set updates + return []cometabci.ValidatorUpdate{} +} + +// ExportGenesis returns the incentives module's exported genesis state as raw +// JSON bytes. This method panics on any error. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.k.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +func init() { + appmodule.Register( + &incentivesmodulev1.Module{}, + appmodule.Provide(ProvideModule), + ) +} + +type Inputs struct { + depinject.In + + Config *incentivesmodulev1.Module + Cdc codec.Codec + Key *storetypes.KVStoreKey +} + +type Outputs struct { + depinject.Out + + IncentivesKeeper keeper.Keeper + Module appmodule.AppModule +} + +func ProvideModule(in Inputs) Outputs { + incentivesKeeper := keeper.NewKeeper( + in.Key, + nil, + ) + + m := NewAppModule(in.Cdc, incentivesKeeper) + + return Outputs{IncentivesKeeper: incentivesKeeper, Module: m} +} diff --git a/x/incentives/types/examples/badprice/badprice.pb.go b/x/incentives/types/examples/badprice/badprice.pb.go new file mode 100644 index 000000000..a1aa7f06a --- /dev/null +++ b/x/incentives/types/examples/badprice/badprice.pb.go @@ -0,0 +1,381 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: slinky/incentives/v1/badprice.proto + +package badprice + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// BadPriceIncentive is a message that contains the information about a bad price +// that was submitted by a validator. +// +// NOTE: This is an example of a bad price incentive. It is not used in production. +type BadPriceIncentive struct { + // Validator is the address of the validator that submitted the bad price. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Amount is the amount to slash. + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *BadPriceIncentive) Reset() { *m = BadPriceIncentive{} } +func (m *BadPriceIncentive) String() string { return proto.CompactTextString(m) } +func (*BadPriceIncentive) ProtoMessage() {} +func (*BadPriceIncentive) Descriptor() ([]byte, []int) { + return fileDescriptor_90b575131cd0f9c4, []int{0} +} +func (m *BadPriceIncentive) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BadPriceIncentive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BadPriceIncentive.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *BadPriceIncentive) XXX_Merge(src proto.Message) { + xxx_messageInfo_BadPriceIncentive.Merge(m, src) +} +func (m *BadPriceIncentive) XXX_Size() int { + return m.Size() +} +func (m *BadPriceIncentive) XXX_DiscardUnknown() { + xxx_messageInfo_BadPriceIncentive.DiscardUnknown(m) +} + +var xxx_messageInfo_BadPriceIncentive proto.InternalMessageInfo + +func (m *BadPriceIncentive) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *BadPriceIncentive) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func init() { + proto.RegisterType((*BadPriceIncentive)(nil), "slinky.incentives.v1.BadPriceIncentive") +} + +func init() { + proto.RegisterFile("slinky/incentives/v1/badprice.proto", fileDescriptor_90b575131cd0f9c4) +} + +var fileDescriptor_90b575131cd0f9c4 = []byte{ + // 255 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2e, 0xce, 0xc9, 0xcc, + 0xcb, 0xae, 0xd4, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x2d, 0xd6, 0x2f, 0x33, + 0xd4, 0x4f, 0x4a, 0x4c, 0x29, 0x28, 0xca, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x81, 0x28, 0xd2, 0x43, 0x28, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, 0xcb, + 0xd7, 0x07, 0x93, 0x10, 0x85, 0x52, 0x92, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0x60, 0x9e, + 0x3e, 0x84, 0x03, 0x91, 0x52, 0x9a, 0xc8, 0xc8, 0x25, 0xe8, 0x94, 0x98, 0x12, 0x00, 0x32, 0xd6, + 0x13, 0x66, 0x8e, 0x90, 0x0c, 0x17, 0x67, 0x59, 0x62, 0x4e, 0x66, 0x4a, 0x62, 0x49, 0x7e, 0x91, + 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x42, 0x40, 0x48, 0x8c, 0x8b, 0x2d, 0x31, 0x37, 0xbf, + 0x34, 0xaf, 0x44, 0x82, 0x09, 0x2c, 0x05, 0xe5, 0x59, 0xb9, 0x9d, 0xda, 0xa2, 0x2b, 0x87, 0xcd, + 0x4d, 0x7a, 0x70, 0x93, 0xbb, 0x9e, 0x6f, 0xd0, 0x92, 0x87, 0xfa, 0x2d, 0xbf, 0x28, 0x31, 0x39, + 0x27, 0x55, 0x1f, 0xc3, 0x76, 0xa7, 0xc8, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, + 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, + 0x88, 0xb2, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x2f, 0xce, 0xce, + 0x2c, 0xd0, 0xcd, 0x4d, 0x2d, 0xd3, 0x87, 0x1a, 0x57, 0x81, 0x1c, 0x58, 0x25, 0x95, 0x05, 0xa9, + 0xc5, 0xfa, 0xa9, 0x15, 0x89, 0xb9, 0x05, 0x39, 0xa9, 0xc5, 0xf0, 0x80, 0x4b, 0x62, 0x03, 0xfb, + 0xda, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x72, 0xb7, 0x35, 0xcf, 0x60, 0x01, 0x00, 0x00, +} + +func (m *BadPriceIncentive) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BadPriceIncentive) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BadPriceIncentive) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintBadprice(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintBadprice(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintBadprice(dAtA []byte, offset int, v uint64) int { + offset -= sovBadprice(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BadPriceIncentive) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovBadprice(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovBadprice(uint64(l)) + } + return n +} + +func sovBadprice(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozBadprice(x uint64) (n int) { + return sovBadprice(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *BadPriceIncentive) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBadprice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BadPriceIncentive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BadPriceIncentive: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBadprice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBadprice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBadprice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBadprice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBadprice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBadprice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBadprice(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBadprice + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipBadprice(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBadprice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBadprice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBadprice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthBadprice + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupBadprice + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthBadprice + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthBadprice = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowBadprice = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupBadprice = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentives/types/examples/badprice/incentive.go b/x/incentives/types/examples/badprice/incentive.go new file mode 100644 index 000000000..d40f0ccf4 --- /dev/null +++ b/x/incentives/types/examples/badprice/incentive.go @@ -0,0 +1,61 @@ +package badprice + +import ( + fmt "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +const ( + // BadPriceIncentiveType is the type for the BadPriceIncentive. + BadPriceIncentiveType = "bad_price_update" +) + +// Each Incentive type must implement the types.Incentive interface. +var _ types.Incentive = (*BadPriceIncentive)(nil) + +// NewBadPriceIncentive creates a new BadPriceIncentive. +// +// NOTE: THIS SHOULD NOT BE USED IN PRODUCTION. THIS IS ONLY FOR TESTING. +func NewBadPriceIncentive(validator sdk.ValAddress, amount math.Int) *BadPriceIncentive { + return &BadPriceIncentive{ + Validator: validator.String(), + Amount: amount.String(), + } +} + +// ValidateBasic does a basic stateless validation check that +// doesn't require access to any other information. +func (b *BadPriceIncentive) ValidateBasic() error { + // You can add your custom validation logic here if needed. + _, err := sdk.ValAddressFromBech32(b.Validator) + if err != nil { + return fmt.Errorf("invalid validator address %s: %w", b.Validator, err) + } + + amount, ok := math.NewIntFromString(b.Amount) + if !ok { + return fmt.Errorf("invalid amount %s", b.Amount) + } + + if amount.IsNegative() { + return fmt.Errorf("amount %s cannot be negative", b.Amount) + } + + return nil +} + +// Type returns the type of the incentive. +func (b *BadPriceIncentive) Type() string { + return BadPriceIncentiveType +} + +// Copy returns a copy of the incentive. +func (b *BadPriceIncentive) Copy() types.Incentive { + return &BadPriceIncentive{ + Validator: b.Validator, + Amount: b.Amount, + } +} diff --git a/x/incentives/types/examples/badprice/strategy.go b/x/incentives/types/examples/badprice/strategy.go new file mode 100644 index 000000000..a241736c3 --- /dev/null +++ b/x/incentives/types/examples/badprice/strategy.go @@ -0,0 +1,75 @@ +package badprice + +import ( + fmt "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +// StakingKeeper defines the expected staking keeper interface required by +// the BadPriceIncentive strategy. +// +//go:generate mockery --name StakingKeeper --output ./../mocks --outpkg mocks --case underscore +type StakingKeeper interface { + // GetValidatorStake returns the total amount of stake that a validator + // currently has delegated to it. + GetValidatorStake(ctx sdk.Context, val sdk.ValAddress) (stake math.Int, found bool) + + // Slash attempts to slash the validator at the given address by the + // given amount. If the validator does not have sufficient stake to + // slash, the slash will fail. + Slash(ctx sdk.Context, val sdk.ValAddress, amount math.Int) error +} + +// BadPriceIncentiveStrategy is the strategy function for the BadPriceIncentive +// type. +type BadPriceIncentiveStrategy struct { + keeper StakingKeeper +} + +// NewBadPriceIncentiveStrategy returns a new BadPriceIncentiveStrategy. +func NewBadPriceIncentiveStrategy(keeper StakingKeeper) *BadPriceIncentiveStrategy { + return &BadPriceIncentiveStrategy{ + keeper: keeper, + } +} + +// GetStrategy returns the BadPriceIncentiveStrategy. +func (s *BadPriceIncentiveStrategy) GetStrategy() types.Strategy { + return func(ctx sdk.Context, incentive types.Incentive) (types.Incentive, error) { + // Cast the incentive to the concrete type. + badPriceIncentive, ok := incentive.(*BadPriceIncentive) + if !ok { + return incentive, fmt.Errorf("invalid incentive type: %T", incentive) + } + + validator, err := sdk.ValAddressFromBech32(badPriceIncentive.Validator) + if err != nil { + return incentive, nil + } + + // Get the validator's current stake. + stake, found := s.keeper.GetValidatorStake(ctx, validator) + if !found { + return incentive, nil + } + + // Check the upper bound on what we can slash + slashAmount, ok := math.NewIntFromString(badPriceIncentive.Amount) + if !ok { + return incentive, nil + } + + if slashAmount.GT(stake) { + slashAmount = stake + } + + if err := s.keeper.Slash(ctx, validator, slashAmount); err != nil { + return incentive, err + } + + return nil, nil + } +} diff --git a/x/incentives/types/examples/goodprice/goodprice.pb.go b/x/incentives/types/examples/goodprice/goodprice.pb.go new file mode 100644 index 000000000..43f48adc0 --- /dev/null +++ b/x/incentives/types/examples/goodprice/goodprice.pb.go @@ -0,0 +1,382 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: slinky/incentives/v1/goodprice.proto + +package goodprice + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GoodPriceIncentive is a message that contains the information about a good price +// that was submitted by a validator. +// +// NOTE: This is an example of a good price incentive. It is not used in production. +type GoodPriceIncentive struct { + // Validator is the address of the validator that submitted the good price. + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + // Amount is the amount to reward. + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *GoodPriceIncentive) Reset() { *m = GoodPriceIncentive{} } +func (m *GoodPriceIncentive) String() string { return proto.CompactTextString(m) } +func (*GoodPriceIncentive) ProtoMessage() {} +func (*GoodPriceIncentive) Descriptor() ([]byte, []int) { + return fileDescriptor_c8813c6c1723a5ae, []int{0} +} +func (m *GoodPriceIncentive) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GoodPriceIncentive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GoodPriceIncentive.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GoodPriceIncentive) XXX_Merge(src proto.Message) { + xxx_messageInfo_GoodPriceIncentive.Merge(m, src) +} +func (m *GoodPriceIncentive) XXX_Size() int { + return m.Size() +} +func (m *GoodPriceIncentive) XXX_DiscardUnknown() { + xxx_messageInfo_GoodPriceIncentive.DiscardUnknown(m) +} + +var xxx_messageInfo_GoodPriceIncentive proto.InternalMessageInfo + +func (m *GoodPriceIncentive) GetValidator() string { + if m != nil { + return m.Validator + } + return "" +} + +func (m *GoodPriceIncentive) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func init() { + proto.RegisterType((*GoodPriceIncentive)(nil), "slinky.incentives.v1.GoodPriceIncentive") +} + +func init() { + proto.RegisterFile("slinky/incentives/v1/goodprice.proto", fileDescriptor_c8813c6c1723a5ae) +} + +var fileDescriptor_c8813c6c1723a5ae = []byte{ + // 259 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x29, 0xce, 0xc9, 0xcc, + 0xcb, 0xae, 0xd4, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x2d, 0xd6, 0x2f, 0x33, + 0xd4, 0x4f, 0xcf, 0xcf, 0x4f, 0x29, 0x28, 0xca, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x81, 0xa8, 0xd2, 0x43, 0xa8, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x4c, 0xcc, 0xcd, 0xcc, + 0xcb, 0xd7, 0x07, 0x93, 0x10, 0x85, 0x52, 0x92, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0x60, + 0x9e, 0x3e, 0x84, 0x03, 0x91, 0x52, 0x9a, 0xc4, 0xc8, 0x25, 0xe4, 0x9e, 0x9f, 0x9f, 0x12, 0x00, + 0x32, 0xd7, 0x13, 0x66, 0x90, 0x90, 0x0c, 0x17, 0x67, 0x59, 0x62, 0x4e, 0x66, 0x4a, 0x62, 0x49, + 0x7e, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x42, 0x40, 0x48, 0x8c, 0x8b, 0x2d, 0x31, + 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x09, 0x2c, 0x05, 0xe5, 0x59, 0xb9, 0x9d, 0xda, 0xa2, 0x2b, + 0x87, 0xcd, 0x51, 0x7a, 0x70, 0x93, 0xbb, 0x9e, 0x6f, 0xd0, 0x92, 0x87, 0xfa, 0x2e, 0xbf, 0x28, + 0x31, 0x39, 0x27, 0x55, 0xdf, 0x29, 0x11, 0xcd, 0x76, 0xa7, 0xa8, 0x13, 0x8f, 0xe4, 0x18, 0x2f, + 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, + 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x72, 0x48, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, + 0xd5, 0x2f, 0xce, 0xce, 0x2c, 0xd0, 0xcd, 0x4d, 0x2d, 0xd3, 0x87, 0x1a, 0x57, 0x81, 0x1c, 0x5c, + 0x25, 0x95, 0x05, 0xa9, 0xc5, 0xfa, 0xa9, 0x15, 0x89, 0xb9, 0x05, 0x39, 0xa9, 0xc5, 0x88, 0xa0, + 0x4b, 0x62, 0x03, 0xfb, 0xdb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xff, 0x3a, 0xfc, 0x63, + 0x01, 0x00, 0x00, +} + +func (m *GoodPriceIncentive) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GoodPriceIncentive) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GoodPriceIncentive) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintGoodprice(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintGoodprice(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGoodprice(dAtA []byte, offset int, v uint64) int { + offset -= sovGoodprice(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GoodPriceIncentive) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovGoodprice(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovGoodprice(uint64(l)) + } + return n +} + +func sovGoodprice(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGoodprice(x uint64) (n int) { + return sovGoodprice(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GoodPriceIncentive) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGoodprice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GoodPriceIncentive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GoodPriceIncentive: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGoodprice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGoodprice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGoodprice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGoodprice + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGoodprice + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGoodprice + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGoodprice(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGoodprice + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGoodprice(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGoodprice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGoodprice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGoodprice + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGoodprice + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGoodprice + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGoodprice + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGoodprice = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGoodprice = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGoodprice = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentives/types/examples/goodprice/incentive.go b/x/incentives/types/examples/goodprice/incentive.go new file mode 100644 index 000000000..54606b24a --- /dev/null +++ b/x/incentives/types/examples/goodprice/incentive.go @@ -0,0 +1,61 @@ +package goodprice + +import ( + fmt "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +const ( + // GoodPriceIncentiveType is the type for the GoodPriceIncentive. + GoodPriceIncentiveType = "good_price_update" +) + +// Ensure that GoodPriceIncentive implements the Incentive interface +var _ types.Incentive = (*GoodPriceIncentive)(nil) + +// NewGoodPriceIncentive returns a new GoodPriceIncentive. +// +// NOTE: THIS SHOULD NOT BE USED IN PRODUCTION. THIS IS ONLY FOR TESTING. +func NewGoodPriceIncentive(validator sdk.ValAddress, amount math.Int) *GoodPriceIncentive { + return &GoodPriceIncentive{ + Validator: validator.String(), + Amount: amount.String(), + } +} + +// ValidateBasic does a basic stateless validation check that +// doesn't require access to any other information. +func (b *GoodPriceIncentive) ValidateBasic() error { + // You can add your custom validation logic here if needed. + _, err := sdk.ValAddressFromBech32(b.Validator) + if err != nil { + return fmt.Errorf("invalid validator address %s: %w", b.Validator, err) + } + + amount, ok := math.NewIntFromString(b.Amount) + if !ok { + return fmt.Errorf("invalid amount %s", b.Amount) + } + + if amount.IsNegative() { + return fmt.Errorf("amount %s cannot be negative", b.Amount) + } + + return nil +} + +// Type returns the type of the incentive. +func (b *GoodPriceIncentive) Type() string { + return GoodPriceIncentiveType +} + +// Copy returns a copy of the incentive. +func (b *GoodPriceIncentive) Copy() types.Incentive { + return &GoodPriceIncentive{ + Validator: b.Validator, + Amount: b.Amount, + } +} diff --git a/x/incentives/types/examples/goodprice/strategy.go b/x/incentives/types/examples/goodprice/strategy.go new file mode 100644 index 000000000..9c89406c2 --- /dev/null +++ b/x/incentives/types/examples/goodprice/strategy.go @@ -0,0 +1,83 @@ +package goodprice + +import ( + "context" + fmt "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/skip-mev/slinky/x/incentives/types" +) + +// BankKeeper defines the expected bank keeper interface required by +// the GoodPriceIncentive strategy. +// +//go:generate mockery --name BankKeeper --output ./../mocks --outpkg mocks --case underscore +type BankKeeper interface { + // Mint coins and add to the module account before distributing them + // to the recipient. + MintCoins( + ctx context.Context, + moduleName string, + amt math.Int, + ) error + + // Send coins from the module account to the recipient. + SendCoinsFromModuleToAccount( + ctx context.Context, + senderModule string, + recipientAddr sdk.ValAddress, + amt math.Int, + ) error +} + +// GoodPriceIncentiveStrategy is the strategy function for the GoodPriceIncentive +// type. +type GoodPriceIncentiveStrategy struct { + bk BankKeeper +} + +// NewBadPriceIncentiveStrategy returns a new GoodPriceIncentiveStrategy. +func NewGoodPriceIncentiveStrategy(bk BankKeeper) *GoodPriceIncentiveStrategy { + return &GoodPriceIncentiveStrategy{ + bk: bk, + } +} + +// GetStrategy returns the BadPriceIncentiveStrategy. +func (s *GoodPriceIncentiveStrategy) GetStrategy() types.Strategy { + return func(ctx sdk.Context, incentive types.Incentive) (types.Incentive, error) { + // Cast the incentive to the concrete type. + badPriceIncentive, ok := incentive.(*GoodPriceIncentive) + if !ok { + return incentive, fmt.Errorf("invalid incentive type: %T", incentive) + } + + validator, err := sdk.ValAddressFromBech32(badPriceIncentive.Validator) + if err != nil { + return nil, nil + } + + amount, ok := math.NewIntFromString(badPriceIncentive.Amount) + if !ok { + return nil, nil + } + + if amount.IsNegative() { + return nil, nil + } + + // Mint coins and add to the module account before distributing them + // to the recipient. + if err := s.bk.MintCoins(ctx, types.ModuleName, amount); err != nil { + return incentive, err + } + + // Send coins from the module account to the recipient. + if err := s.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, validator, amount); err != nil { + return incentive, err + } + + return nil, nil + } +} diff --git a/x/incentives/types/examples/mocks/bank_keeper.go b/x/incentives/types/examples/mocks/bank_keeper.go new file mode 100644 index 000000000..9dacbdc20 --- /dev/null +++ b/x/incentives/types/examples/mocks/bank_keeper.go @@ -0,0 +1,60 @@ +// Code generated by mockery v2.30.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + math "cosmossdk.io/math" + + mock "github.com/stretchr/testify/mock" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// BankKeeper is an autogenerated mock type for the BankKeeper type +type BankKeeper struct { + mock.Mock +} + +// MintCoins provides a mock function with given fields: ctx, moduleName, amt +func (_m *BankKeeper) MintCoins(ctx context.Context, moduleName string, amt math.Int) error { + ret := _m.Called(ctx, moduleName, amt) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, math.Int) error); ok { + r0 = rf(ctx, moduleName, amt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendCoinsFromModuleToAccount provides a mock function with given fields: ctx, senderModule, recipientAddr, amt +func (_m *BankKeeper) SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr types.ValAddress, amt math.Int) error { + ret := _m.Called(ctx, senderModule, recipientAddr, amt) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.ValAddress, math.Int) error); ok { + r0 = rf(ctx, senderModule, recipientAddr, amt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewBankKeeper creates a new instance of BankKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewBankKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *BankKeeper { + mock := &BankKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/x/incentives/types/examples/mocks/staking_keeper.go b/x/incentives/types/examples/mocks/staking_keeper.go new file mode 100644 index 000000000..30a0b6547 --- /dev/null +++ b/x/incentives/types/examples/mocks/staking_keeper.go @@ -0,0 +1,66 @@ +// Code generated by mockery v2.30.1. DO NOT EDIT. + +package mocks + +import ( + math "cosmossdk.io/math" + types "github.com/cosmos/cosmos-sdk/types" + mock "github.com/stretchr/testify/mock" +) + +// StakingKeeper is an autogenerated mock type for the StakingKeeper type +type StakingKeeper struct { + mock.Mock +} + +// GetValidatorStake provides a mock function with given fields: ctx, val +func (_m *StakingKeeper) GetValidatorStake(ctx types.Context, val types.ValAddress) (math.Int, bool) { + ret := _m.Called(ctx, val) + + var r0 math.Int + var r1 bool + if rf, ok := ret.Get(0).(func(types.Context, types.ValAddress) (math.Int, bool)); ok { + return rf(ctx, val) + } + if rf, ok := ret.Get(0).(func(types.Context, types.ValAddress) math.Int); ok { + r0 = rf(ctx, val) + } else { + r0 = ret.Get(0).(math.Int) + } + + if rf, ok := ret.Get(1).(func(types.Context, types.ValAddress) bool); ok { + r1 = rf(ctx, val) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// Slash provides a mock function with given fields: ctx, val, amount +func (_m *StakingKeeper) Slash(ctx types.Context, val types.ValAddress, amount math.Int) error { + ret := _m.Called(ctx, val, amount) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, types.ValAddress, math.Int) error); ok { + r0 = rf(ctx, val, amount) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NewStakingKeeper creates a new instance of StakingKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewStakingKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *StakingKeeper { + mock := &StakingKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/x/incentives/types/genesis.go b/x/incentives/types/genesis.go new file mode 100644 index 000000000..935129b17 --- /dev/null +++ b/x/incentives/types/genesis.go @@ -0,0 +1,79 @@ +package types + +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" +) + +// NewDefaultGenesisState returns a default genesis state for the module. +func NewDefaultGenesisState() *GenesisState { + return &GenesisState{} +} + +// NewGenesisState returns a new genesis state for the module. +func NewGenesisState(incentives []IncentivesByType) *GenesisState { + return &GenesisState{ + Registry: incentives, + } +} + +// ValidateBasic performs basic validation of the genesis state data returning an +// error for any failed validation criteria. +func (gs GenesisState) ValidateBasic() error { + seen := make(map[string]struct{}) + for _, entry := range gs.Registry { + if _, ok := seen[entry.IncentiveType]; ok { + return fmt.Errorf("duplicate incentive name %s", entry.IncentiveType) + } + + if err := entry.ValidateBasic(); err != nil { + return err + } + + seen[entry.IncentiveType] = struct{}{} + } + + return nil +} + +// NewIncentives returns a new Incentives instance. +func NewIncentives(name string, incentives [][]byte) IncentivesByType { + return IncentivesByType{ + IncentiveType: name, + Entries: incentives, + } +} + +// ValidateBasic performs basic validation of the Incentives data returning an +// error for any failed validation criteria. +func (i IncentivesByType) ValidateBasic() error { + if len(i.IncentiveType) == 0 { + return fmt.Errorf("incentive name cannot be empty") + } + + if len(i.Entries) == 0 { + return fmt.Errorf("incentive %s must have at least one incentive", i.IncentiveType) + } + + for _, incentive := range i.Entries { + if len(incentive) == 0 { + return fmt.Errorf("incentive %s cannot be empty", i.IncentiveType) + } + } + + return nil +} + +// GetGenesisStateFromAppState returns x/incentives GenesisState given raw application +// genesis state. +func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState { + var genesisState GenesisState + + if appState[ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) + } + + return genesisState +} diff --git a/x/incentives/types/genesis.pb.go b/x/incentives/types/genesis.pb.go new file mode 100644 index 000000000..fbef54245 --- /dev/null +++ b/x/incentives/types/genesis.pb.go @@ -0,0 +1,567 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: slinky/incentives/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState is the genesis-state for the x/incentives module. +type GenesisState struct { + // Registry is a list of incentives by type. The registry defined here + // should be a subset of the incentive types defined in the incentive + // module (keeper). + Registry []IncentivesByType `protobuf:"bytes,1,rep,name=registry,proto3" json:"registry"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_1313e98e0d51d196, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetRegistry() []IncentivesByType { + if m != nil { + return m.Registry + } + return nil +} + +// IncentivesByType encapsulates a list of incentives by type. Each of the +// entries here must correspond to the same incentive type defined here. +type IncentivesByType struct { + // IncentiveType is the incentive type i.e. (BadPriceIncentiveType, GoodPriceIncentiveType). + IncentiveType string `protobuf:"bytes,1,opt,name=incentive_type,json=incentiveType,proto3" json:"incentive_type,omitempty"` + // Entries is a list of incentive bytes. + Entries [][]byte `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries,omitempty"` +} + +func (m *IncentivesByType) Reset() { *m = IncentivesByType{} } +func (m *IncentivesByType) String() string { return proto.CompactTextString(m) } +func (*IncentivesByType) ProtoMessage() {} +func (*IncentivesByType) Descriptor() ([]byte, []int) { + return fileDescriptor_1313e98e0d51d196, []int{1} +} +func (m *IncentivesByType) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IncentivesByType) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IncentivesByType.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IncentivesByType) XXX_Merge(src proto.Message) { + xxx_messageInfo_IncentivesByType.Merge(m, src) +} +func (m *IncentivesByType) XXX_Size() int { + return m.Size() +} +func (m *IncentivesByType) XXX_DiscardUnknown() { + xxx_messageInfo_IncentivesByType.DiscardUnknown(m) +} + +var xxx_messageInfo_IncentivesByType proto.InternalMessageInfo + +func (m *IncentivesByType) GetIncentiveType() string { + if m != nil { + return m.IncentiveType + } + return "" +} + +func (m *IncentivesByType) GetEntries() [][]byte { + if m != nil { + return m.Entries + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "slinky.incentives.v1.GenesisState") + proto.RegisterType((*IncentivesByType)(nil), "slinky.incentives.v1.IncentivesByType") +} + +func init() { + proto.RegisterFile("slinky/incentives/v1/genesis.proto", fileDescriptor_1313e98e0d51d196) +} + +var fileDescriptor_1313e98e0d51d196 = []byte{ + // 250 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0xce, 0xc9, 0xcc, + 0xcb, 0xae, 0xd4, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x2d, 0xd6, 0x2f, 0x33, + 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x81, 0xa8, 0xd1, 0x43, 0xa8, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0x95, 0x22, 0xb8, 0x78, 0xdc, 0x21, 0x9a, 0x83, 0x4b, 0x12, 0x4b, + 0x52, 0x85, 0x3c, 0xb8, 0x38, 0x8a, 0x52, 0xd3, 0x33, 0x8b, 0x4b, 0x8a, 0x2a, 0x25, 0x18, 0x15, + 0x98, 0x35, 0xb8, 0x8d, 0xd4, 0xf4, 0xb0, 0x19, 0xa7, 0xe7, 0x09, 0xe7, 0x39, 0x55, 0x86, 0x54, + 0x16, 0xa4, 0x3a, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0xd7, 0xad, 0x14, 0xc9, 0x25, 0x80, + 0xae, 0x46, 0x48, 0x95, 0x8b, 0x0f, 0x6e, 0x4a, 0x7c, 0x49, 0x65, 0x41, 0xaa, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x67, 0x10, 0x2f, 0x5c, 0x14, 0xac, 0x4c, 0x8e, 0x8b, 0x3d, 0x35, 0xaf, 0xa4, 0x28, + 0x33, 0xb5, 0x58, 0x82, 0x49, 0x81, 0x59, 0x83, 0x07, 0x6a, 0x36, 0x4c, 0xd0, 0xc9, 0xfd, 0xc4, + 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, + 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, + 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x8b, 0xb3, 0x33, 0x0b, 0x74, 0x73, 0x53, 0xcb, 0xf4, 0xa1, 0x41, + 0x56, 0x81, 0x1c, 0x68, 0x20, 0xcb, 0x8b, 0x93, 0xd8, 0xc0, 0x81, 0x60, 0x0c, 0x08, 0x00, 0x00, + 0xff, 0xff, 0xe9, 0x39, 0xe6, 0xc5, 0x56, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Registry) > 0 { + for iNdEx := len(m.Registry) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Registry[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *IncentivesByType) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IncentivesByType) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IncentivesByType) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Entries[iNdEx]) + copy(dAtA[i:], m.Entries[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Entries[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.IncentiveType) > 0 { + i -= len(m.IncentiveType) + copy(dAtA[i:], m.IncentiveType) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.IncentiveType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Registry) > 0 { + for _, e := range m.Registry { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *IncentivesByType) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.IncentiveType) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Entries) > 0 { + for _, b := range m.Entries { + l = len(b) + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Registry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Registry = append(m.Registry, IncentivesByType{}) + if err := m.Registry[len(m.Registry)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IncentivesByType) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IncentivesByType: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IncentivesByType: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentiveType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentiveType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, make([]byte, postIndex-iNdEx)) + copy(m.Entries[len(m.Entries)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentives/types/genesis_test.go b/x/incentives/types/genesis_test.go new file mode 100644 index 000000000..d3595f7d2 --- /dev/null +++ b/x/incentives/types/genesis_test.go @@ -0,0 +1,55 @@ +package types_test + +import ( + "testing" + + "github.com/skip-mev/slinky/x/incentives/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + t.Run("can create a new default genesis state", func(t *testing.T) { + gs := types.NewDefaultGenesisState() + require.NoError(t, gs.ValidateBasic()) + }) + + t.Run("can accept a valid genesis state with a single incentive type", func(t *testing.T) { + badPrice := types.NewIncentives("badprice", [][]byte{[]byte("incentive1")}) + gs := types.NewGenesisState([]types.IncentivesByType{badPrice}) + require.NoError(t, gs.ValidateBasic()) + }) + + t.Run("can accept a valid genesis state with multiple incentive types", func(t *testing.T) { + badPrice := types.NewIncentives("badprice", [][]byte{[]byte("incentive1")}) + goodPrice := types.NewIncentives("goodprice", [][]byte{[]byte("incentive1")}) + + gs := types.NewGenesisState([]types.IncentivesByType{badPrice, goodPrice}) + + require.NoError(t, gs.ValidateBasic()) + }) + + t.Run("can reject a genesis state with duplicate incentive types", func(t *testing.T) { + badPrice := types.NewIncentives("badprice", [][]byte{[]byte("incentive1")}) + goodPrice := types.NewIncentives("badprice", [][]byte{[]byte("incentive1")}) + + gs := types.NewGenesisState([]types.IncentivesByType{badPrice, goodPrice}) + + require.Error(t, gs.ValidateBasic()) + }) + + t.Run("can reject a genesis state with an empty incentive type", func(t *testing.T) { + badPrice := types.NewIncentives("", [][]byte{[]byte("incentive1")}) + + gs := types.NewGenesisState([]types.IncentivesByType{badPrice}) + + require.Error(t, gs.ValidateBasic()) + }) + + t.Run("can reject a genesis state with an empty incentive", func(t *testing.T) { + badPrice := types.NewIncentives("badprice", [][]byte{[]byte("")}) + + gs := types.NewGenesisState([]types.IncentivesByType{badPrice}) + + require.Error(t, gs.ValidateBasic()) + }) +} diff --git a/x/incentives/types/incentive.go b/x/incentives/types/incentive.go new file mode 100644 index 000000000..46631aa0b --- /dev/null +++ b/x/incentives/types/incentive.go @@ -0,0 +1,31 @@ +package types + +import ( + "github.com/cosmos/gogoproto/proto" +) + +type ( + // Incentive is the interface contract that must be fulfilled to allow for + // slashing/rewarding arbitrary events. To add a new incentive, implement + // this interface along with the corresponding strategy callback function. + // Each incentive type must be registered with its corresponding strategy + // function in the keeper. + Incentive interface { + proto.Message + + // ValidateBasic does a stateless check on the incentive. + ValidateBasic() error + + // Type returns the incentive type. + Type() string + + // Marshall the incentive into bytes. + Marshal() ([]byte, error) + + // Unmarshal the incentive from bytes. + Unmarshal([]byte) error + + // Copy the incentive. + Copy() Incentive + } +) diff --git a/x/incentives/types/keys.go b/x/incentives/types/keys.go new file mode 100644 index 000000000..7f8299298 --- /dev/null +++ b/x/incentives/types/keys.go @@ -0,0 +1,41 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + // ModuleName is the name of the module. + ModuleName = "incentives" + // StoreKey is the store key string for incentives. + StoreKey = ModuleName +) + +const ( + // keyPrefixIncentive is the root key prefix under which all incentives are stored. + keyPrefixIncentive = iota + // keyPrefixCount is the key prefix used to index incentives. + keyPrefixCount +) + +var ( + // KeyPrefixIncentive is the root key prefix under which all incentives are stored. + KeyPrefixIncentive = []byte{keyPrefixIncentive} + // KeyPrefixCount is the key prefix used to index incentives. + KeyPrefixCount = []byte{keyPrefixCount} +) + +// GetIncentiveKey gets the store key for an incentive. +func GetIncentiveKey(incentive Incentive) []byte { + return append(KeyPrefixIncentive, []byte(incentive.Type())...) +} + +// GetIncentiveKeyWithIndex gets the store key for an incentive with an index. +func GetIncentiveKeyWithIndex(incentive Incentive, index uint64) []byte { + return append(GetIncentiveKey(incentive), sdk.Uint64ToBigEndian(index)...) +} + +// GetIncentiveCountKey gets the store key for the incentive count. +func GetIncentiveCountKey(incentive Incentive) []byte { + return append(KeyPrefixCount, []byte(incentive.Type())...) +} diff --git a/x/incentives/types/query.pb.go b/x/incentives/types/query.pb.go new file mode 100644 index 000000000..8e1591878 --- /dev/null +++ b/x/incentives/types/query.pb.go @@ -0,0 +1,944 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: slinky/incentives/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GetIncentivesByTypeRequest is the request type for the Query/GetIncentivesByType +// RPC method. +type GetIncentivesByTypeRequest struct { + // IncentiveType is the incentive type i.e. (BadPriceIncentiveType, GoodPriceIncentiveType). + IncentiveType string `protobuf:"bytes,1,opt,name=incentive_type,json=incentiveType,proto3" json:"incentive_type,omitempty"` +} + +func (m *GetIncentivesByTypeRequest) Reset() { *m = GetIncentivesByTypeRequest{} } +func (m *GetIncentivesByTypeRequest) String() string { return proto.CompactTextString(m) } +func (*GetIncentivesByTypeRequest) ProtoMessage() {} +func (*GetIncentivesByTypeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8ec938f9117db3eb, []int{0} +} +func (m *GetIncentivesByTypeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetIncentivesByTypeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetIncentivesByTypeRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetIncentivesByTypeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetIncentivesByTypeRequest.Merge(m, src) +} +func (m *GetIncentivesByTypeRequest) XXX_Size() int { + return m.Size() +} +func (m *GetIncentivesByTypeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetIncentivesByTypeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetIncentivesByTypeRequest proto.InternalMessageInfo + +func (m *GetIncentivesByTypeRequest) GetIncentiveType() string { + if m != nil { + return m.IncentiveType + } + return "" +} + +// GetIncentivesByTypeResponse is the response type for the Query/GetIncentivesByType +// RPC method. +type GetIncentivesByTypeResponse struct { + // Entries is the list of incentives of the given type. + Entries [][]byte `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"` +} + +func (m *GetIncentivesByTypeResponse) Reset() { *m = GetIncentivesByTypeResponse{} } +func (m *GetIncentivesByTypeResponse) String() string { return proto.CompactTextString(m) } +func (*GetIncentivesByTypeResponse) ProtoMessage() {} +func (*GetIncentivesByTypeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8ec938f9117db3eb, []int{1} +} +func (m *GetIncentivesByTypeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetIncentivesByTypeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetIncentivesByTypeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetIncentivesByTypeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetIncentivesByTypeResponse.Merge(m, src) +} +func (m *GetIncentivesByTypeResponse) XXX_Size() int { + return m.Size() +} +func (m *GetIncentivesByTypeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetIncentivesByTypeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetIncentivesByTypeResponse proto.InternalMessageInfo + +func (m *GetIncentivesByTypeResponse) GetEntries() [][]byte { + if m != nil { + return m.Entries + } + return nil +} + +// GetAllIncentivesRequest is the request type for the Query/GetAllIncentives +// RPC method. +type GetAllIncentivesRequest struct { +} + +func (m *GetAllIncentivesRequest) Reset() { *m = GetAllIncentivesRequest{} } +func (m *GetAllIncentivesRequest) String() string { return proto.CompactTextString(m) } +func (*GetAllIncentivesRequest) ProtoMessage() {} +func (*GetAllIncentivesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_8ec938f9117db3eb, []int{2} +} +func (m *GetAllIncentivesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAllIncentivesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAllIncentivesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAllIncentivesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAllIncentivesRequest.Merge(m, src) +} +func (m *GetAllIncentivesRequest) XXX_Size() int { + return m.Size() +} +func (m *GetAllIncentivesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetAllIncentivesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAllIncentivesRequest proto.InternalMessageInfo + +// GetAllIncentivesResponse is the response type for the Query/GetAllIncentives +// RPC method. +type GetAllIncentivesResponse struct { + // Registry is the list of all incentives, grouped by type. + Registry []IncentivesByType `protobuf:"bytes,1,rep,name=registry,proto3" json:"registry"` +} + +func (m *GetAllIncentivesResponse) Reset() { *m = GetAllIncentivesResponse{} } +func (m *GetAllIncentivesResponse) String() string { return proto.CompactTextString(m) } +func (*GetAllIncentivesResponse) ProtoMessage() {} +func (*GetAllIncentivesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_8ec938f9117db3eb, []int{3} +} +func (m *GetAllIncentivesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAllIncentivesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAllIncentivesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAllIncentivesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAllIncentivesResponse.Merge(m, src) +} +func (m *GetAllIncentivesResponse) XXX_Size() int { + return m.Size() +} +func (m *GetAllIncentivesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetAllIncentivesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAllIncentivesResponse proto.InternalMessageInfo + +func (m *GetAllIncentivesResponse) GetRegistry() []IncentivesByType { + if m != nil { + return m.Registry + } + return nil +} + +func init() { + proto.RegisterType((*GetIncentivesByTypeRequest)(nil), "slinky.incentives.v1.GetIncentivesByTypeRequest") + proto.RegisterType((*GetIncentivesByTypeResponse)(nil), "slinky.incentives.v1.GetIncentivesByTypeResponse") + proto.RegisterType((*GetAllIncentivesRequest)(nil), "slinky.incentives.v1.GetAllIncentivesRequest") + proto.RegisterType((*GetAllIncentivesResponse)(nil), "slinky.incentives.v1.GetAllIncentivesResponse") +} + +func init() { proto.RegisterFile("slinky/incentives/v1/query.proto", fileDescriptor_8ec938f9117db3eb) } + +var fileDescriptor_8ec938f9117db3eb = []byte{ + // 402 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0xce, 0xc9, 0xcc, + 0xcb, 0xae, 0xd4, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x2d, 0xd6, 0x2f, 0x33, + 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x81, 0xa8, + 0xd0, 0x43, 0xa8, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd0, 0x07, + 0xb1, 0x20, 0x6a, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, + 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0xa1, 0xb2, 0x4a, 0x58, 0xed, + 0x4a, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x84, 0xaa, 0x51, 0x72, 0xe6, 0x92, 0x72, 0x4f, 0x2d, 0xf1, + 0x84, 0xab, 0x70, 0xaa, 0x0c, 0xa9, 0x2c, 0x48, 0x0d, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, + 0x52, 0xe5, 0xe2, 0x83, 0x6b, 0x8e, 0x2f, 0xa9, 0x2c, 0x48, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x0c, 0xe2, 0x85, 0x8b, 0x82, 0x54, 0x2b, 0x99, 0x73, 0x49, 0x63, 0x35, 0xa4, 0xb8, 0x20, 0x3f, + 0xaf, 0x38, 0x55, 0x48, 0x82, 0x8b, 0x3d, 0x35, 0xaf, 0xa4, 0x28, 0x33, 0xb5, 0x58, 0x82, 0x51, + 0x81, 0x59, 0x83, 0x27, 0x08, 0xc6, 0x55, 0x92, 0xe4, 0x12, 0x77, 0x4f, 0x2d, 0x71, 0xcc, 0xc9, + 0x41, 0xe8, 0x85, 0x5a, 0xad, 0x94, 0xc2, 0x25, 0x81, 0x29, 0x05, 0x35, 0xd0, 0x83, 0x8b, 0xa3, + 0x28, 0x35, 0x3d, 0xb3, 0xb8, 0xa4, 0xa8, 0x12, 0x6c, 0x22, 0xb7, 0x91, 0x9a, 0x1e, 0xb6, 0x50, + 0xd3, 0x43, 0x77, 0x92, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x70, 0xdd, 0x46, 0x0f, 0x98, + 0xb8, 0x58, 0x03, 0x41, 0x81, 0x2f, 0xb4, 0x81, 0x91, 0x4b, 0x18, 0x8b, 0x27, 0x84, 0x0c, 0xb0, + 0x9b, 0x8c, 0x3b, 0xd0, 0xa4, 0x0c, 0x49, 0xd0, 0x01, 0xf1, 0x90, 0x92, 0x49, 0xd3, 0xe5, 0x27, + 0x93, 0x99, 0xf4, 0x84, 0x74, 0xf4, 0x71, 0x44, 0x59, 0x49, 0x3c, 0x42, 0x24, 0x3e, 0xa9, 0x12, + 0x1c, 0x17, 0x42, 0x8b, 0x19, 0xb9, 0x04, 0xd0, 0xc3, 0x48, 0x48, 0x17, 0xa7, 0xed, 0xd8, 0x82, + 0x59, 0x4a, 0x8f, 0x58, 0xe5, 0x50, 0x97, 0x1a, 0x80, 0x5d, 0xaa, 0x25, 0xa4, 0x81, 0xdb, 0xa5, + 0x89, 0x39, 0x39, 0x48, 0xae, 0x75, 0x72, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, + 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, + 0x86, 0x28, 0xdd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe2, 0xec, + 0xcc, 0x02, 0xdd, 0xdc, 0xd4, 0x32, 0x98, 0xb1, 0x15, 0xc8, 0x06, 0x83, 0x7c, 0x5b, 0x9c, 0xc4, + 0x06, 0x4e, 0xb1, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xb9, 0xa0, 0x01, 0x43, 0x03, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // GetIncentivesByType returns all incentives of a given type. If the type is + // not registered with the module, an error is returned. + GetIncentivesByType(ctx context.Context, in *GetIncentivesByTypeRequest, opts ...grpc.CallOption) (*GetIncentivesByTypeResponse, error) + // GetAllIncentives returns all incentives. + GetAllIncentives(ctx context.Context, in *GetAllIncentivesRequest, opts ...grpc.CallOption) (*GetAllIncentivesResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) GetIncentivesByType(ctx context.Context, in *GetIncentivesByTypeRequest, opts ...grpc.CallOption) (*GetIncentivesByTypeResponse, error) { + out := new(GetIncentivesByTypeResponse) + err := c.cc.Invoke(ctx, "/slinky.incentives.v1.Query/GetIncentivesByType", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetAllIncentives(ctx context.Context, in *GetAllIncentivesRequest, opts ...grpc.CallOption) (*GetAllIncentivesResponse, error) { + out := new(GetAllIncentivesResponse) + err := c.cc.Invoke(ctx, "/slinky.incentives.v1.Query/GetAllIncentives", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // GetIncentivesByType returns all incentives of a given type. If the type is + // not registered with the module, an error is returned. + GetIncentivesByType(context.Context, *GetIncentivesByTypeRequest) (*GetIncentivesByTypeResponse, error) + // GetAllIncentives returns all incentives. + GetAllIncentives(context.Context, *GetAllIncentivesRequest) (*GetAllIncentivesResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) GetIncentivesByType(ctx context.Context, req *GetIncentivesByTypeRequest) (*GetIncentivesByTypeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetIncentivesByType not implemented") +} +func (*UnimplementedQueryServer) GetAllIncentives(ctx context.Context, req *GetAllIncentivesRequest) (*GetAllIncentivesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAllIncentives not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_GetIncentivesByType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetIncentivesByTypeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetIncentivesByType(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/slinky.incentives.v1.Query/GetIncentivesByType", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetIncentivesByType(ctx, req.(*GetIncentivesByTypeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetAllIncentives_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAllIncentivesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetAllIncentives(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/slinky.incentives.v1.Query/GetAllIncentives", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetAllIncentives(ctx, req.(*GetAllIncentivesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "slinky.incentives.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetIncentivesByType", + Handler: _Query_GetIncentivesByType_Handler, + }, + { + MethodName: "GetAllIncentives", + Handler: _Query_GetAllIncentives_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "slinky/incentives/v1/query.proto", +} + +func (m *GetIncentivesByTypeRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetIncentivesByTypeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetIncentivesByTypeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncentiveType) > 0 { + i -= len(m.IncentiveType) + copy(dAtA[i:], m.IncentiveType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.IncentiveType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetIncentivesByTypeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetIncentivesByTypeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetIncentivesByTypeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Entries[iNdEx]) + copy(dAtA[i:], m.Entries[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Entries[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *GetAllIncentivesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAllIncentivesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetAllIncentivesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GetAllIncentivesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAllIncentivesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetAllIncentivesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Registry) > 0 { + for iNdEx := len(m.Registry) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Registry[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GetIncentivesByTypeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.IncentiveType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *GetIncentivesByTypeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Entries) > 0 { + for _, b := range m.Entries { + l = len(b) + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *GetAllIncentivesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GetAllIncentivesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Registry) > 0 { + for _, e := range m.Registry { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GetIncentivesByTypeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetIncentivesByTypeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetIncentivesByTypeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentiveType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentiveType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetIncentivesByTypeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetIncentivesByTypeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetIncentivesByTypeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, make([]byte, postIndex-iNdEx)) + copy(m.Entries[len(m.Entries)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAllIncentivesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAllIncentivesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAllIncentivesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAllIncentivesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAllIncentivesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAllIncentivesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Registry", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Registry = append(m.Registry, IncentivesByType{}) + if err := m.Registry[len(m.Registry)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/incentives/types/query.pb.gw.go b/x/incentives/types/query.pb.gw.go new file mode 100644 index 000000000..374027b92 --- /dev/null +++ b/x/incentives/types/query.pb.gw.go @@ -0,0 +1,236 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: slinky/incentives/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Query_GetIncentivesByType_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_GetIncentivesByType_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetIncentivesByTypeRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetIncentivesByType_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetIncentivesByType(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetIncentivesByType_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetIncentivesByTypeRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetIncentivesByType_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetIncentivesByType(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetAllIncentives_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAllIncentivesRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetAllIncentives(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetAllIncentives_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAllIncentivesRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetAllIncentives(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_GetIncentivesByType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetIncentivesByType_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetIncentivesByType_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetAllIncentives_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetAllIncentives_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAllIncentives_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_GetIncentivesByType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetIncentivesByType_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetIncentivesByType_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetAllIncentives_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetAllIncentives_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAllIncentives_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_GetIncentivesByType_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"slinky", "incentives", "v1", "get_incentives_by_type"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetAllIncentives_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"slinky", "incentives", "v1", "get_all_incentives"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_GetIncentivesByType_0 = runtime.ForwardResponseMessage + + forward_Query_GetAllIncentives_0 = runtime.ForwardResponseMessage +) diff --git a/x/incentives/types/strategy.go b/x/incentives/types/strategy.go new file mode 100644 index 000000000..ee3042a34 --- /dev/null +++ b/x/incentives/types/strategy.go @@ -0,0 +1,19 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Strategy defines the callback function that will be executed by the +// incentives module with the given context and incentive. The strategy is +// responsible for the following: +// 1. If the strategy desires to update the incentive, it must return the +// updated incentive. +// 2. If the strategy desires to delete the incentive, it must return nil. +// 3. If the strategy desires to leave the incentive unchanged, it must return +// the same incentive. +// 4. Applying any desired state transitions such as minting rewards, or +// slashing. +// +// For an example implementation, please see the examples/ directory. +type Strategy func(ctx sdk.Context, incentive Incentive) (updatedIncentive Incentive, err error) diff --git a/x/incentives/types/utils.go b/x/incentives/types/utils.go new file mode 100644 index 000000000..7b3238a56 --- /dev/null +++ b/x/incentives/types/utils.go @@ -0,0 +1,42 @@ +package types + +import "sort" + +// IncentivesToBytes converts a slice of Incentives to a slice of bytes. +func IncentivesToBytes(incentives ...Incentive) ([][]byte, error) { + incentiveBytes := make([][]byte, len(incentives)) + for i, incentive := range incentives { + bz, err := incentive.Marshal() + if err != nil { + return nil, err + } + + incentiveBytes[i] = bz + } + + return incentiveBytes, nil +} + +// SortIncentivesStrategiesMap sorts a map of IncentivesByType by their type. +func SortIncentivesStrategiesMap(incentiveStrategies map[Incentive]Strategy) []Incentive { + // Get all of the incentive types and sort them by name. + incentiveTypes := make([]Incentive, len(incentiveStrategies)) + i := 0 + for incentive := range incentiveStrategies { + incentiveTypes[i] = incentive + i++ + } + + // Sort the incentive types by name. + return SortIncentivesByType(incentiveTypes) +} + +// SortIncentivesByType sorts a slice of Incentives by their type. +func SortIncentivesByType(incentives []Incentive) []Incentive { + // Sort the incentive types by name. + sort.Slice(incentives, func(i, j int) bool { + return incentives[i].Type() < incentives[j].Type() + }) + + return incentives +}