Skip to content

Commit

Permalink
feat(cosmos_proto): add annotation to denote version (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Apr 18, 2024
1 parent 1e5446b commit 0748a2a
Show file tree
Hide file tree
Showing 13 changed files with 1,332 additions and 200 deletions.
4 changes: 4 additions & 0 deletions buf.work.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v1
directories:
- testpb
- proto
201 changes: 138 additions & 63 deletions cosmos.pb.go

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion proto/cosmos_proto/cosmos.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import "google/protobuf/descriptor.proto";

option go_package = "github.com/cosmos/cosmos-proto;cosmos_proto";

extend google.protobuf.MethodOptions {

// method_added_in is used to indicate from which version the method was added.
string method_added_in = 93001;
}

extend google.protobuf.MessageOptions {

// implements_interface is used to indicate the type name of the interface
Expand All @@ -13,6 +19,9 @@ extend google.protobuf.MessageOptions {
// interfaces. Interfaces should be declared using a declare_interface
// file option.
repeated string implements_interface = 93001;

// message_added_in is used to indicate from which version the message was added.
string message_added_in = 93002;
}

extend google.protobuf.FieldOptions {
Expand All @@ -27,6 +36,9 @@ extend google.protobuf.FieldOptions {
// generators may choose to use this information to map this field to a
// language-specific type representing the scalar.
string scalar = 93002;

// field_added_in is used to indicate from which version the field was added.
string field_added_in = 93003;
}

extend google.protobuf.FileOptions {
Expand All @@ -46,6 +58,9 @@ extend google.protobuf.FileOptions {
// expected that the declaration will be found in a protobuf file named
// a/b/scalars.proto in the file descriptor set.
repeated ScalarDescriptor declare_scalar = 793022;

// file_added_in is used to indicate from which the version the file was added.
string file_added_in = 793023;
}

// InterfaceDescriptor describes an interface type to be used with
Expand Down Expand Up @@ -94,4 +109,4 @@ enum ScalarType {
SCALAR_TYPE_UNSPECIFIED = 0;
SCALAR_TYPE_STRING = 1;
SCALAR_TYPE_BYTES = 2;
}
}
2 changes: 1 addition & 1 deletion testpb/1.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax="proto3";

import "testpb/2.proto";
import "2.proto";

option go_package = "github.com/cosmos/cosmos-proto/testpb";

Expand Down
199 changes: 100 additions & 99 deletions testpb/1.pulsar.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions testpb/2.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax="proto3";

option go_package = "github.com/cosmos/cosmos-proto/testpb";

message ImportedMessage {
Expand Down
72 changes: 36 additions & 36 deletions testpb/2.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions testpb/3.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax="proto3";

import "cosmos_proto/cosmos.proto";

option go_package = "github.com/cosmos/cosmos-proto/testpb";

// QueryService defines the gRPC querier service.
service QueryService {
// CounterQuery queries a counter.
rpc CounterQuery(CounterQueryRequest) returns (CounterQueryResponse) {
option (cosmos_proto.method_added_in) = "github.com/cosmos/cosmos-proto v1.0.1";
}
}

// CounterQueryRequest defines the request type used to query the counter.
message CounterQueryRequest {}

// CounterQueryResponse defines the response type for querying the counter.
message CounterQueryResponse {
option (cosmos_proto.message_added_in) = "github.com/cosmos/cosmos-proto v1.0.1";

uint64 counter = 1 [(cosmos_proto.field_added_in) = "github.com/cosmos/cosmos-proto v1.0.1"];
}
Loading

0 comments on commit 0748a2a

Please sign in to comment.