From a0718163b55cb952959d96646fb72140d15e5ecd Mon Sep 17 00:00:00 2001 From: pharr117 Date: Tue, 13 Jun 2023 19:10:43 -0400 Subject: [PATCH] Add the following: * New base cosmos proto for pagination * Osmosis specific protos for Epoch and Protorev specific query endpoints * Codegen and wrappers for RPC querying of Epoch and Protorev: * EpochInfos endpoint * GetProtoRevDeveloperAccount endpoint --- .../osmosis/v15/x/epochs/types/query.pb.go | 1032 +++++++++++++++++ .../osmosis/v15/x/protorev/types/query.pb.go | 543 +++++++++ main.go | 35 + proto/osmosis/epochs/v1beta1/query.proto | 78 ++ proto/osmosis/protorev/v1beta1/query.proto | 29 + query/osmosis/epochs.go | 40 + query/osmosis/protorev.go | 18 + .../base/query/v1beta1/pagination.proto | 50 + 8 files changed, 1825 insertions(+) create mode 100644 client/codec/osmosis/v15/x/epochs/types/query.pb.go create mode 100644 client/codec/osmosis/v15/x/protorev/types/query.pb.go create mode 100644 proto/osmosis/epochs/v1beta1/query.proto create mode 100644 proto/osmosis/protorev/v1beta1/query.proto create mode 100644 query/osmosis/epochs.go create mode 100644 query/osmosis/protorev.go create mode 100644 third_party/proto/cosmos/base/query/v1beta1/pagination.proto diff --git a/client/codec/osmosis/v15/x/epochs/types/query.pb.go b/client/codec/osmosis/v15/x/epochs/types/query.pb.go new file mode 100644 index 0000000..2d6d188 --- /dev/null +++ b/client/codec/osmosis/v15/x/epochs/types/query.pb.go @@ -0,0 +1,1032 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/epochs/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryEpochsInfoRequest struct { +} + +func (m *QueryEpochsInfoRequest) Reset() { *m = QueryEpochsInfoRequest{} } +func (m *QueryEpochsInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEpochsInfoRequest) ProtoMessage() {} +func (*QueryEpochsInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_82bf2f47d6aaa9fa, []int{0} +} +func (m *QueryEpochsInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochsInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochsInfoRequest.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 *QueryEpochsInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochsInfoRequest.Merge(m, src) +} +func (m *QueryEpochsInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochsInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochsInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochsInfoRequest proto.InternalMessageInfo + +type QueryEpochsInfoResponse struct { + Epochs []EpochInfo `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"` +} + +func (m *QueryEpochsInfoResponse) Reset() { *m = QueryEpochsInfoResponse{} } +func (m *QueryEpochsInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEpochsInfoResponse) ProtoMessage() {} +func (*QueryEpochsInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_82bf2f47d6aaa9fa, []int{1} +} +func (m *QueryEpochsInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryEpochsInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEpochsInfoResponse.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 *QueryEpochsInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEpochsInfoResponse.Merge(m, src) +} +func (m *QueryEpochsInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEpochsInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryEpochsInfoResponse proto.InternalMessageInfo + +func (m *QueryEpochsInfoResponse) GetEpochs() []EpochInfo { + if m != nil { + return m.Epochs + } + return nil +} + +type EpochInfo struct { + // identifier is a unique reference to this particular timer. + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` + // start_time is the time at which the timer first ever ticks. + // If start_time is in the future, the epoch will not begin until the start + // time. + StartTime time.Time `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + // duration is the time in between epoch ticks. + // In order for intended behavior to be met, duration should + // be greater than the chains expected block time. + // Duration must be non-zero. + Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"` + // current_epoch is the current epoch number, or in other words, + // how many times has the timer 'ticked'. + // The first tick (current_epoch=1) is defined as + // the first block whose blocktime is greater than the EpochInfo start_time. + CurrentEpoch int64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"` + // current_epoch_start_time describes the start time of the current timer + // interval. The interval is (current_epoch_start_time, + // current_epoch_start_time + duration] When the timer ticks, this is set to + // current_epoch_start_time = last_epoch_start_time + duration only one timer + // tick for a given identifier can occur per block. + // + // NOTE! The current_epoch_start_time may diverge significantly from the + // wall-clock time the epoch began at. Wall-clock time of epoch start may be + // >> current_epoch_start_time. Suppose current_epoch_start_time = 10, + // duration = 5. Suppose the chain goes offline at t=14, and comes back online + // at t=30, and produces blocks at every successive time. (t=31, 32, etc.) + // * The t=30 block will start the epoch for (10, 15] + // * The t=31 block will start the epoch for (15, 20] + // * The t=32 block will start the epoch for (20, 25] + // * The t=33 block will start the epoch for (25, 30] + // * The t=34 block will start the epoch for (30, 35] + // * The **t=36** block will start the epoch for (35, 40] + CurrentEpochStartTime time.Time `protobuf:"bytes,5,opt,name=current_epoch_start_time,json=currentEpochStartTime,proto3,stdtime" json:"current_epoch_start_time" yaml:"current_epoch_start_time"` + // epoch_counting_started is a boolean, that indicates whether this + // epoch timer has began yet. + EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"` + // current_epoch_start_height is the block height at which the current epoch + // started. (The block height at which the timer last ticked) + CurrentEpochStartHeight int64 `protobuf:"varint,8,opt,name=current_epoch_start_height,json=currentEpochStartHeight,proto3" json:"current_epoch_start_height,omitempty"` +} + +func (m *EpochInfo) Reset() { *m = EpochInfo{} } +func (m *EpochInfo) String() string { return proto.CompactTextString(m) } +func (*EpochInfo) ProtoMessage() {} +func (*EpochInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_82bf2f47d6aaa9fa, []int{2} +} +func (m *EpochInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EpochInfo.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 *EpochInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochInfo.Merge(m, src) +} +func (m *EpochInfo) XXX_Size() int { + return m.Size() +} +func (m *EpochInfo) XXX_DiscardUnknown() { + xxx_messageInfo_EpochInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochInfo proto.InternalMessageInfo + +func (m *EpochInfo) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +func (m *EpochInfo) GetStartTime() time.Time { + if m != nil { + return m.StartTime + } + return time.Time{} +} + +func (m *EpochInfo) GetDuration() time.Duration { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *EpochInfo) GetCurrentEpoch() int64 { + if m != nil { + return m.CurrentEpoch + } + return 0 +} + +func (m *EpochInfo) GetCurrentEpochStartTime() time.Time { + if m != nil { + return m.CurrentEpochStartTime + } + return time.Time{} +} + +func (m *EpochInfo) GetEpochCountingStarted() bool { + if m != nil { + return m.EpochCountingStarted + } + return false +} + +func (m *EpochInfo) GetCurrentEpochStartHeight() int64 { + if m != nil { + return m.CurrentEpochStartHeight + } + return 0 +} + +func init() { + proto.RegisterType((*QueryEpochsInfoRequest)(nil), "osmosis.epochs.v1beta1.QueryEpochsInfoRequest") + proto.RegisterType((*QueryEpochsInfoResponse)(nil), "osmosis.epochs.v1beta1.QueryEpochsInfoResponse") + proto.RegisterType((*EpochInfo)(nil), "osmosis.epochs.v1beta1.EpochInfo") +} + +func init() { + proto.RegisterFile("osmosis/epochs/v1beta1/query.proto", fileDescriptor_82bf2f47d6aaa9fa) +} + +var fileDescriptor_82bf2f47d6aaa9fa = []byte{ + // 555 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xb1, 0x8f, 0xd3, 0x3e, + 0x18, 0xad, 0x7f, 0xed, 0xf5, 0xd7, 0xfa, 0x40, 0x80, 0x75, 0xf4, 0x42, 0x25, 0x92, 0x12, 0x96, + 0x0a, 0x50, 0xac, 0x16, 0x58, 0x60, 0x40, 0x2a, 0x45, 0x02, 0xc4, 0x42, 0x8e, 0x01, 0xdd, 0x40, + 0x95, 0xa4, 0x6e, 0x6a, 0xa9, 0xb1, 0x73, 0xb1, 0x73, 0xba, 0x6e, 0xfc, 0x09, 0x1d, 0xf9, 0x93, + 0x6e, 0xbc, 0x91, 0xa9, 0xa0, 0x76, 0x63, 0xbc, 0xbf, 0x00, 0xc5, 0x4e, 0x42, 0xa1, 0x3d, 0xc1, + 0x96, 0xf8, 0xbd, 0xef, 0xbd, 0xef, 0x7d, 0xf9, 0x62, 0x68, 0x73, 0x11, 0x71, 0x41, 0x05, 0x26, + 0x31, 0x0f, 0xa6, 0x02, 0x9f, 0xf6, 0x7c, 0x22, 0xbd, 0x1e, 0x3e, 0x49, 0x49, 0x32, 0x77, 0xe2, + 0x84, 0x4b, 0x8e, 0x5a, 0x39, 0xc7, 0xd1, 0x1c, 0x27, 0xe7, 0xb4, 0x0f, 0x42, 0x1e, 0x72, 0x45, + 0xc1, 0xd9, 0x93, 0x66, 0xb7, 0x1f, 0x04, 0x8a, 0x8e, 0x7d, 0x4f, 0x10, 0x2d, 0x53, 0x8a, 0xc6, + 0x5e, 0x48, 0x99, 0x27, 0x29, 0x67, 0x39, 0xd7, 0x0c, 0x39, 0x0f, 0x67, 0x04, 0xab, 0x37, 0x3f, + 0x9d, 0xe0, 0x71, 0x9a, 0x6c, 0xe2, 0xd6, 0x9f, 0xb8, 0xa4, 0x11, 0x11, 0xd2, 0x8b, 0x62, 0x4d, + 0xb0, 0x0d, 0xd8, 0x7a, 0x9f, 0x59, 0xbc, 0x52, 0x9d, 0xbd, 0x61, 0x13, 0xee, 0x92, 0x93, 0x94, + 0x08, 0x69, 0x1f, 0xc3, 0xc3, 0x2d, 0x44, 0xc4, 0x9c, 0x09, 0x82, 0x5e, 0xc0, 0xba, 0x4e, 0x62, + 0x80, 0x4e, 0xb5, 0xbb, 0xdf, 0xbf, 0xe7, 0xec, 0x0e, 0xe8, 0xa8, 0xda, 0xac, 0x74, 0x50, 0x3b, + 0x5f, 0x5a, 0x15, 0x37, 0x2f, 0xb3, 0x17, 0x35, 0xd8, 0x2c, 0x31, 0x64, 0x42, 0x48, 0xc7, 0x84, + 0x49, 0x3a, 0xa1, 0x24, 0x31, 0x40, 0x07, 0x74, 0x9b, 0xee, 0xc6, 0x09, 0xfa, 0x08, 0xa1, 0x90, + 0x5e, 0x22, 0x47, 0x59, 0xf3, 0xc6, 0x7f, 0x1d, 0xd0, 0xdd, 0xef, 0xb7, 0x1d, 0x9d, 0xcc, 0x29, + 0x92, 0x39, 0x1f, 0x8a, 0x64, 0x83, 0xbb, 0x99, 0xd7, 0xe5, 0xd2, 0xba, 0x35, 0xf7, 0xa2, 0xd9, + 0x33, 0xfb, 0x57, 0xad, 0xbd, 0xf8, 0x66, 0x01, 0xb7, 0xa9, 0x0e, 0x32, 0x3a, 0x9a, 0xc2, 0x46, + 0x31, 0x30, 0xa3, 0xaa, 0x74, 0xef, 0x6c, 0xe9, 0x0e, 0x73, 0xc2, 0xa0, 0x97, 0xc9, 0xfe, 0x58, + 0x5a, 0xa8, 0x28, 0x79, 0xc4, 0x23, 0x2a, 0x49, 0x14, 0xcb, 0xf9, 0xe5, 0xd2, 0xba, 0xa1, 0xcd, + 0x0a, 0xcc, 0xfe, 0x92, 0x59, 0x95, 0xea, 0xe8, 0x3e, 0xbc, 0x1e, 0xa4, 0x49, 0x42, 0x98, 0x1c, + 0xa9, 0x19, 0x18, 0xb5, 0x0e, 0xe8, 0x56, 0xdd, 0x6b, 0xf9, 0xa1, 0x1a, 0x06, 0xfa, 0x0c, 0xa0, + 0xf1, 0x1b, 0x6b, 0xb4, 0x91, 0x7b, 0xef, 0xaf, 0xb9, 0x1f, 0xe6, 0xb9, 0x2d, 0xdd, 0xca, 0x55, + 0x4a, 0x7a, 0x0a, 0xb7, 0x37, 0x9d, 0x8f, 0xca, 0x89, 0x3c, 0x81, 0x2d, 0xcd, 0x0f, 0x78, 0xca, + 0x24, 0x65, 0xa1, 0x2e, 0x24, 0x63, 0xa3, 0xde, 0x01, 0xdd, 0x86, 0x7b, 0xa0, 0xd0, 0x97, 0x39, + 0x78, 0xa4, 0x31, 0xf4, 0x1c, 0xb6, 0x77, 0xb9, 0x4d, 0x09, 0x0d, 0xa7, 0xd2, 0x68, 0xa8, 0xa8, + 0x87, 0x5b, 0x86, 0xaf, 0x15, 0xfc, 0xb6, 0xd6, 0xf8, 0xff, 0x66, 0xa3, 0x7f, 0x06, 0xf7, 0xd4, + 0xba, 0x21, 0x0e, 0x61, 0xb9, 0x1a, 0x02, 0x39, 0x57, 0xad, 0xd6, 0xee, 0xad, 0x6d, 0xe3, 0x7f, + 0xe6, 0xeb, 0x5d, 0xb6, 0x2b, 0x83, 0x4f, 0xe7, 0x2b, 0x13, 0x5c, 0xac, 0x4c, 0xf0, 0x7d, 0x65, + 0x82, 0xc5, 0xda, 0xac, 0x5c, 0xac, 0xcd, 0xca, 0xd7, 0xb5, 0x59, 0x39, 0x1e, 0x86, 0x54, 0x4e, + 0x53, 0xdf, 0x09, 0x78, 0x84, 0x87, 0x64, 0x42, 0x3d, 0x26, 0xdf, 0x79, 0xbe, 0xc8, 0xfe, 0x26, + 0x9f, 0xe0, 0x60, 0x46, 0x09, 0x93, 0x38, 0xe0, 0x63, 0x12, 0xe0, 0xe2, 0x16, 0x38, 0xed, 0x3d, + 0xc5, 0x67, 0xc5, 0x5d, 0x20, 0xe7, 0x31, 0x11, 0x7e, 0x5d, 0x7d, 0xaa, 0xc7, 0x3f, 0x03, 0x00, + 0x00, 0xff, 0xff, 0xac, 0x9f, 0x8d, 0x02, 0x2a, 0x04, 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 { + // EpochInfos provide running epochInfos + EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error) { + out := new(QueryEpochsInfoResponse) + err := c.cc.Invoke(ctx, "/osmosis.epochs.v1beta1.Query/EpochInfos", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // EpochInfos provide running epochInfos + EpochInfos(context.Context, *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) EpochInfos(ctx context.Context, req *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EpochInfos not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_EpochInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEpochsInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).EpochInfos(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.epochs.v1beta1.Query/EpochInfos", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).EpochInfos(ctx, req.(*QueryEpochsInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.epochs.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "EpochInfos", + Handler: _Query_EpochInfos_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/epochs/v1beta1/query.proto", +} + +func (m *QueryEpochsInfoRequest) 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 *QueryEpochsInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochsInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryEpochsInfoResponse) 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 *QueryEpochsInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEpochsInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Epochs) > 0 { + for iNdEx := len(m.Epochs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Epochs[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 (m *EpochInfo) 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 *EpochInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CurrentEpochStartHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpochStartHeight)) + i-- + dAtA[i] = 0x40 + } + if m.EpochCountingStarted { + i-- + if m.EpochCountingStarted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentEpochStartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintQuery(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x2a + if m.CurrentEpoch != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpoch)) + i-- + dAtA[i] = 0x20 + } + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintQuery(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x1a + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintQuery(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x12 + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Identifier))) + 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 *QueryEpochsInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryEpochsInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Epochs) > 0 { + for _, e := range m.Epochs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *EpochInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StartTime) + n += 1 + l + sovQuery(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.Duration) + n += 1 + l + sovQuery(uint64(l)) + if m.CurrentEpoch != 0 { + n += 1 + sovQuery(uint64(m.CurrentEpoch)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentEpochStartTime) + n += 1 + l + sovQuery(uint64(l)) + if m.EpochCountingStarted { + n += 2 + } + if m.CurrentEpochStartHeight != 0 { + n += 1 + sovQuery(uint64(m.CurrentEpochStartHeight)) + } + 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 *QueryEpochsInfoRequest) 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: QueryEpochsInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochsInfoRequest: 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 *QueryEpochsInfoResponse) 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: QueryEpochsInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryEpochsInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Epochs", 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.Epochs = append(m.Epochs, EpochInfo{}) + if err := m.Epochs[len(m.Epochs)-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 (m *EpochInfo) 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: EpochInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", 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.Identifier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", 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 + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpoch", wireType) + } + m.CurrentEpoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpoch |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartTime", 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 + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentEpochStartTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochCountingStarted", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EpochCountingStarted = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochStartHeight", wireType) + } + m.CurrentEpochStartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpochStartHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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/client/codec/osmosis/v15/x/protorev/types/query.pb.go b/client/codec/osmosis/v15/x/protorev/types/query.pb.go new file mode 100644 index 0000000..75eabfe --- /dev/null +++ b/client/codec/osmosis/v15/x/protorev/types/query.pb.go @@ -0,0 +1,543 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/protorev/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// QueryGetProtoRevDeveloperAccountRequest is request type for the +// Query/GetProtoRevDeveloperAccount RPC method. +type QueryGetProtoRevDeveloperAccountRequest struct { +} + +func (m *QueryGetProtoRevDeveloperAccountRequest) Reset() { + *m = QueryGetProtoRevDeveloperAccountRequest{} +} +func (m *QueryGetProtoRevDeveloperAccountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevDeveloperAccountRequest) ProtoMessage() {} +func (*QueryGetProtoRevDeveloperAccountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{0} +} +func (m *QueryGetProtoRevDeveloperAccountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevDeveloperAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevDeveloperAccountRequest.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 *QueryGetProtoRevDeveloperAccountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevDeveloperAccountRequest.Merge(m, src) +} +func (m *QueryGetProtoRevDeveloperAccountRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevDeveloperAccountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevDeveloperAccountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevDeveloperAccountRequest proto.InternalMessageInfo + +// QueryGetProtoRevDeveloperAccountResponse is response type for the +// Query/GetProtoRevDeveloperAccount RPC method. +type QueryGetProtoRevDeveloperAccountResponse struct { + // developer_account is the developer account of the module + DeveloperAccount string `protobuf:"bytes,1,opt,name=developer_account,json=developerAccount,proto3" json:"developer_account,omitempty" yaml:"developer_account"` +} + +func (m *QueryGetProtoRevDeveloperAccountResponse) Reset() { + *m = QueryGetProtoRevDeveloperAccountResponse{} +} +func (m *QueryGetProtoRevDeveloperAccountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetProtoRevDeveloperAccountResponse) ProtoMessage() {} +func (*QueryGetProtoRevDeveloperAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f5e7ac9973cce389, []int{1} +} +func (m *QueryGetProtoRevDeveloperAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetProtoRevDeveloperAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetProtoRevDeveloperAccountResponse.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 *QueryGetProtoRevDeveloperAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetProtoRevDeveloperAccountResponse.Merge(m, src) +} +func (m *QueryGetProtoRevDeveloperAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetProtoRevDeveloperAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetProtoRevDeveloperAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetProtoRevDeveloperAccountResponse proto.InternalMessageInfo + +func (m *QueryGetProtoRevDeveloperAccountResponse) GetDeveloperAccount() string { + if m != nil { + return m.DeveloperAccount + } + return "" +} + +func init() { + proto.RegisterType((*QueryGetProtoRevDeveloperAccountRequest)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevDeveloperAccountRequest") + proto.RegisterType((*QueryGetProtoRevDeveloperAccountResponse)(nil), "osmosis.protorev.v1beta1.QueryGetProtoRevDeveloperAccountResponse") +} + +func init() { + proto.RegisterFile("osmosis/protorev/v1beta1/query.proto", fileDescriptor_f5e7ac9973cce389) +} + +var fileDescriptor_f5e7ac9973cce389 = []byte{ + // 318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0x4a, 0x2d, 0xd3, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x03, 0x0b, 0x0b, 0x49, 0x40, + 0x55, 0xe9, 0xc1, 0x54, 0xe9, 0x41, 0x55, 0x49, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x45, 0xf5, + 0x41, 0x2c, 0x88, 0x02, 0x29, 0xad, 0x64, 0xb0, 0x06, 0xfd, 0xa4, 0xc4, 0xe2, 0x54, 0x88, 0x41, + 0x70, 0x63, 0x0b, 0x12, 0xd3, 0x33, 0xf3, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x20, 0x6a, 0x95, 0x34, + 0xb9, 0xd4, 0x03, 0x41, 0x2a, 0xdc, 0x53, 0x4b, 0x02, 0x40, 0x02, 0x41, 0xa9, 0x65, 0x2e, 0xa9, + 0x65, 0xa9, 0x39, 0xf9, 0x05, 0xa9, 0x45, 0x8e, 0xc9, 0xc9, 0xf9, 0xa5, 0x79, 0x25, 0x41, 0xa9, + 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x4a, 0xa5, 0x5c, 0x1a, 0x84, 0x95, 0x16, 0x17, 0xe4, 0xe7, 0x15, + 0xa7, 0x0a, 0x79, 0x72, 0x09, 0xa6, 0xc0, 0xe4, 0xe2, 0x13, 0x21, 0x92, 0x12, 0x8c, 0x0a, 0x8c, + 0x1a, 0x9c, 0x4e, 0x32, 0x9f, 0xee, 0xc9, 0x4b, 0x54, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0x61, 0x28, + 0x51, 0x0a, 0x12, 0x48, 0x41, 0x33, 0xd2, 0x68, 0x03, 0x23, 0x17, 0x2b, 0xd8, 0x5e, 0xa1, 0x65, + 0x8c, 0x5c, 0xd2, 0x78, 0x2c, 0x17, 0x72, 0xd4, 0xc3, 0x15, 0x50, 0x7a, 0x44, 0xfa, 0x51, 0xca, + 0x89, 0x12, 0x23, 0x20, 0x7e, 0x57, 0x62, 0x70, 0x4a, 0x38, 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, 0xb7, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, + 0x97, 0xd4, 0xb4, 0xcc, 0xc4, 0xbc, 0x12, 0x9f, 0xc4, 0x24, 0x70, 0xfc, 0x27, 0xa5, 0xea, 0x27, + 0xe7, 0x64, 0xa6, 0xe6, 0x95, 0xe8, 0x27, 0xe7, 0xa7, 0xa4, 0x26, 0xeb, 0xc3, 0x92, 0x46, 0x99, + 0xa1, 0xa9, 0x7e, 0x05, 0x22, 0x81, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xf9, 0xc6, + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xaf, 0x3f, 0x8b, 0x41, 0x02, 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 { + // GetProtoRevDeveloperAccount queries the developer account of the module + GetProtoRevDeveloperAccount(ctx context.Context, in *QueryGetProtoRevDeveloperAccountRequest, opts ...grpc.CallOption) (*QueryGetProtoRevDeveloperAccountResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) GetProtoRevDeveloperAccount(ctx context.Context, in *QueryGetProtoRevDeveloperAccountRequest, opts ...grpc.CallOption) (*QueryGetProtoRevDeveloperAccountResponse, error) { + out := new(QueryGetProtoRevDeveloperAccountResponse) + err := c.cc.Invoke(ctx, "/osmosis.protorev.v1beta1.Query/GetProtoRevDeveloperAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // GetProtoRevDeveloperAccount queries the developer account of the module + GetProtoRevDeveloperAccount(context.Context, *QueryGetProtoRevDeveloperAccountRequest) (*QueryGetProtoRevDeveloperAccountResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) GetProtoRevDeveloperAccount(ctx context.Context, req *QueryGetProtoRevDeveloperAccountRequest) (*QueryGetProtoRevDeveloperAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProtoRevDeveloperAccount not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_GetProtoRevDeveloperAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetProtoRevDeveloperAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetProtoRevDeveloperAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.protorev.v1beta1.Query/GetProtoRevDeveloperAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetProtoRevDeveloperAccount(ctx, req.(*QueryGetProtoRevDeveloperAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.protorev.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetProtoRevDeveloperAccount", + Handler: _Query_GetProtoRevDeveloperAccount_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/protorev/v1beta1/query.proto", +} + +func (m *QueryGetProtoRevDeveloperAccountRequest) 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 *QueryGetProtoRevDeveloperAccountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevDeveloperAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGetProtoRevDeveloperAccountResponse) 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 *QueryGetProtoRevDeveloperAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetProtoRevDeveloperAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DeveloperAccount) > 0 { + i -= len(m.DeveloperAccount) + copy(dAtA[i:], m.DeveloperAccount) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DeveloperAccount))) + 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 *QueryGetProtoRevDeveloperAccountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGetProtoRevDeveloperAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DeveloperAccount) + if l > 0 { + 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 *QueryGetProtoRevDeveloperAccountRequest) 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: QueryGetProtoRevDeveloperAccountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevDeveloperAccountRequest: 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 *QueryGetProtoRevDeveloperAccountResponse) 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: QueryGetProtoRevDeveloperAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetProtoRevDeveloperAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeveloperAccount", 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.DeveloperAccount = 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 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/main.go b/main.go index 5eaca15..7c98d64 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( gammTypes "github.com/DefiantLabs/probe/client/codec/osmosis/v15/x/gamm/types" poolmanagerTypes "github.com/DefiantLabs/probe/client/codec/osmosis/v15/x/poolmanager/types" querier "github.com/DefiantLabs/probe/query" + osmosisQueryTypes "github.com/DefiantLabs/probe/query/osmosis" cosmosTypes "github.com/cosmos/cosmos-sdk/types" cquery "github.com/cosmos/cosmos-sdk/types/query" ibcChanTypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -110,6 +111,40 @@ func main() { } } } + + // Osmosis specific querying proof of concepts + + // Get the latest Epoch data + + if cconfig.ChainID == "osmosis-1" { + epochData, err := osmosisQueryTypes.EpochsAtHeightRPC(&query, checkHeight) + + if err != nil { + fmt.Println("Error getting epoch results") + fmt.Println(err) + os.Exit(1) + } + + fmt.Println("Got epoch results, some data follows:") + for _, epoch := range epochData.Epochs { + fmt.Printf("Epoch Identifier: %+v\n", epoch.Identifier) + fmt.Printf("Epoch Current Start Height: %+v\n", epoch.CurrentEpochStartHeight) + fmt.Printf("Epoch Duration: %+v\n", epoch.Duration) + } + + protorevDevAccountData, err := osmosisQueryTypes.ProtorevDeveloperAccountRPC(&query) + + if err != nil { + fmt.Println("Error getting protorev results") + fmt.Println(err) + os.Exit(1) + } + + fmt.Println("Got protorev results, some data follows:") + fmt.Println("Protorev Developer Account Address: ", protorevDevAccountData.DeveloperAccount) + + } + } var handlers = map[string]func(cosmosTypes.Msg){ diff --git a/proto/osmosis/epochs/v1beta1/query.proto b/proto/osmosis/epochs/v1beta1/query.proto new file mode 100644 index 0000000..7287fc6 --- /dev/null +++ b/proto/osmosis/epochs/v1beta1/query.proto @@ -0,0 +1,78 @@ +syntax = "proto3"; +package osmosis.epochs.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/DefiantLabs/probe/client/codec/osmosis/v15/x/epochs/types"; + +// Query defines the gRPC querier service. +service Query { + // EpochInfos provide running epochInfos + rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) { + } +} + +message QueryEpochsInfoRequest {} +message QueryEpochsInfoResponse { + repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ]; +} + +message EpochInfo { + // identifier is a unique reference to this particular timer. + string identifier = 1; + // start_time is the time at which the timer first ever ticks. + // If start_time is in the future, the epoch will not begin until the start + // time. + google.protobuf.Timestamp start_time = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + // duration is the time in between epoch ticks. + // In order for intended behavior to be met, duration should + // be greater than the chains expected block time. + // Duration must be non-zero. + google.protobuf.Duration duration = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "duration,omitempty", + (gogoproto.moretags) = "yaml:\"duration\"" + ]; + // current_epoch is the current epoch number, or in other words, + // how many times has the timer 'ticked'. + // The first tick (current_epoch=1) is defined as + // the first block whose blocktime is greater than the EpochInfo start_time. + int64 current_epoch = 4; + // current_epoch_start_time describes the start time of the current timer + // interval. The interval is (current_epoch_start_time, + // current_epoch_start_time + duration] When the timer ticks, this is set to + // current_epoch_start_time = last_epoch_start_time + duration only one timer + // tick for a given identifier can occur per block. + // + // NOTE! The current_epoch_start_time may diverge significantly from the + // wall-clock time the epoch began at. Wall-clock time of epoch start may be + // >> current_epoch_start_time. Suppose current_epoch_start_time = 10, + // duration = 5. Suppose the chain goes offline at t=14, and comes back online + // at t=30, and produces blocks at every successive time. (t=31, 32, etc.) + // * The t=30 block will start the epoch for (10, 15] + // * The t=31 block will start the epoch for (15, 20] + // * The t=32 block will start the epoch for (20, 25] + // * The t=33 block will start the epoch for (25, 30] + // * The t=34 block will start the epoch for (30, 35] + // * The **t=36** block will start the epoch for (35, 40] + google.protobuf.Timestamp current_epoch_start_time = 5 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"current_epoch_start_time\"" + ]; + // epoch_counting_started is a boolean, that indicates whether this + // epoch timer has began yet. + bool epoch_counting_started = 6; + reserved 7; + // current_epoch_start_height is the block height at which the current epoch + // started. (The block height at which the timer last ticked) + int64 current_epoch_start_height = 8; + } \ No newline at end of file diff --git a/proto/osmosis/protorev/v1beta1/query.proto b/proto/osmosis/protorev/v1beta1/query.proto new file mode 100644 index 0000000..89cf7d2 --- /dev/null +++ b/proto/osmosis/protorev/v1beta1/query.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package osmosis.protorev.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/DefiantLabs/probe/client/codec/osmosis/v15/x/protorev/types"; + +// Query defines the gRPC querier service. +service Query { + + // GetProtoRevDeveloperAccount queries the developer account of the module + rpc GetProtoRevDeveloperAccount(QueryGetProtoRevDeveloperAccountRequest) + returns (QueryGetProtoRevDeveloperAccountResponse) { + } + +} + +// QueryGetProtoRevDeveloperAccountRequest is request type for the +// Query/GetProtoRevDeveloperAccount RPC method. +message QueryGetProtoRevDeveloperAccountRequest {} + +// QueryGetProtoRevDeveloperAccountResponse is response type for the +// Query/GetProtoRevDeveloperAccount RPC method. +message QueryGetProtoRevDeveloperAccountResponse { + // developer_account is the developer account of the module + string developer_account = 1 + [ (gogoproto.moretags) = "yaml:\"developer_account\"" ]; +} diff --git a/query/osmosis/epochs.go b/query/osmosis/epochs.go new file mode 100644 index 0000000..b4cc8e3 --- /dev/null +++ b/query/osmosis/epochs.go @@ -0,0 +1,40 @@ +package query + +import ( + "fmt" + + epochsTypes "github.com/DefiantLabs/probe/client/codec/osmosis/v15/x/epochs/types" + queryTypes "github.com/DefiantLabs/probe/query" + coretypes "github.com/cometbft/cometbft/rpc/core/types" +) + +func EpochsAtHeightRPC(q *queryTypes.Query, height int64) (*epochsTypes.QueryEpochsInfoResponse, error) { + req := epochsTypes.QueryEpochsInfoRequest{} + queryClient := epochsTypes.NewQueryClient(q.Client) + + if height > 0 { + q.Options.Height = height + } + + ctx, cancel := q.GetQueryContext() + defer cancel() + res, err := queryClient.EpochInfos(ctx, &req) + if err != nil { + return nil, err + } + return res, nil +} + +// BlockSearchEpochStartsLessThanHeightRPC searches for blocks with the epoch_start.epoch_number event with height less than the given height. This query only makes sense for Osmosis, which has the Epoch module emitting this event +// in the BeginBlock events. +func BlockSearchEpochStartsLessThanHeightRPC(q *queryTypes.Query, height int64, page int, perPage int) (*coretypes.ResultBlockSearch, error) { + ctx, cancel := q.GetQueryContext() + defer cancel() + + resp, err := q.Client.RPCClient.BlockSearch(ctx, fmt.Sprintf("block.height<%d AND epoch_start.epoch_number EXISTS", height), &page, &perPage, "") + if err != nil { + return nil, err + } + + return resp, nil +} diff --git a/query/osmosis/protorev.go b/query/osmosis/protorev.go new file mode 100644 index 0000000..3ff4af2 --- /dev/null +++ b/query/osmosis/protorev.go @@ -0,0 +1,18 @@ +package query + +import ( + protorevTypes "github.com/DefiantLabs/probe/client/codec/osmosis/v15/x/protorev/types" + queryTypes "github.com/DefiantLabs/probe/query" +) + +func ProtorevDeveloperAccountRPC(q *queryTypes.Query) (*protorevTypes.QueryGetProtoRevDeveloperAccountResponse, error) { + req := protorevTypes.QueryGetProtoRevDeveloperAccountRequest{} + queryClient := protorevTypes.NewQueryClient(q.Client) + ctx, cancel := q.GetQueryContext() + defer cancel() + res, err := queryClient.GetProtoRevDeveloperAccount(ctx, &req) + if err != nil { + return nil, err + } + return res, nil +} diff --git a/third_party/proto/cosmos/base/query/v1beta1/pagination.proto b/third_party/proto/cosmos/base/query/v1beta1/pagination.proto new file mode 100644 index 0000000..2a8cbcc --- /dev/null +++ b/third_party/proto/cosmos/base/query/v1beta1/pagination.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package cosmos.base.query.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/types/query"; + +// PageRequest is to be embedded in gRPC request messages for efficient +// pagination. Ex: +// +// message SomeRequest { +// Foo some_parameter = 1; +// PageRequest pagination = 2; +// } +message PageRequest { + // key is a value returned in PageResponse.next_key to begin + // querying the next page most efficiently. Only one of offset or key + // should be set. + bytes key = 1; + + // offset is a numeric offset that can be used when key is unavailable. + // It is less efficient than using key. Only one of offset or key should + // be set. + uint64 offset = 2; + + // limit is the total number of results to be returned in the result page. + // If left empty it will default to a value to be set by each app. + uint64 limit = 3; + + // count_total is set to true to indicate that the result set should include + // a count of the total number of items available for pagination in UIs. + // count_total is only respected when offset is used. It is ignored when key + // is set. + bool count_total = 4; +} + +// PageResponse is to be embedded in gRPC response messages where the +// corresponding request message has used PageRequest. +// +// message SomeResponse { +// repeated Bar results = 1; +// PageResponse page = 2; +// } +message PageResponse { + // next_key is the key to be passed to PageRequest.key to + // query the next page most efficiently + bytes next_key = 1; + + // total is total number of results available if PageRequest.count_total + // was set, its value is undefined otherwise + uint64 total = 2; +}