Skip to content

Commit 0748a2a

Browse files
authored
feat(cosmos_proto): add annotation to denote version (#133)
1 parent 1e5446b commit 0748a2a

13 files changed

Lines changed: 1332 additions & 200 deletions

File tree

buf.work.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: v1
2+
directories:
3+
- testpb
4+
- proto

cosmos.pb.go

Lines changed: 138 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/cosmos_proto/cosmos.proto

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import "google/protobuf/descriptor.proto";
55

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

8+
extend google.protobuf.MethodOptions {
9+
10+
// method_added_in is used to indicate from which version the method was added.
11+
string method_added_in = 93001;
12+
}
13+
814
extend google.protobuf.MessageOptions {
915

1016
// implements_interface is used to indicate the type name of the interface
@@ -13,6 +19,9 @@ extend google.protobuf.MessageOptions {
1319
// interfaces. Interfaces should be declared using a declare_interface
1420
// file option.
1521
repeated string implements_interface = 93001;
22+
23+
// message_added_in is used to indicate from which version the message was added.
24+
string message_added_in = 93002;
1625
}
1726

1827
extend google.protobuf.FieldOptions {
@@ -27,6 +36,9 @@ extend google.protobuf.FieldOptions {
2736
// generators may choose to use this information to map this field to a
2837
// language-specific type representing the scalar.
2938
string scalar = 93002;
39+
40+
// field_added_in is used to indicate from which version the field was added.
41+
string field_added_in = 93003;
3042
}
3143

3244
extend google.protobuf.FileOptions {
@@ -46,6 +58,9 @@ extend google.protobuf.FileOptions {
4658
// expected that the declaration will be found in a protobuf file named
4759
// a/b/scalars.proto in the file descriptor set.
4860
repeated ScalarDescriptor declare_scalar = 793022;
61+
62+
// file_added_in is used to indicate from which the version the file was added.
63+
string file_added_in = 793023;
4964
}
5065

5166
// InterfaceDescriptor describes an interface type to be used with
@@ -94,4 +109,4 @@ enum ScalarType {
94109
SCALAR_TYPE_UNSPECIFIED = 0;
95110
SCALAR_TYPE_STRING = 1;
96111
SCALAR_TYPE_BYTES = 2;
97-
}
112+
}

testpb/1.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
syntax="proto3";
22

3-
import "testpb/2.proto";
3+
import "2.proto";
44

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

testpb/1.pulsar.go

Lines changed: 100 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testpb/2.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
syntax="proto3";
2+
23
option go_package = "github.com/cosmos/cosmos-proto/testpb";
34

45
message ImportedMessage {

testpb/2.pulsar.go

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testpb/3.proto

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
syntax="proto3";
2+
3+
import "cosmos_proto/cosmos.proto";
4+
5+
option go_package = "github.com/cosmos/cosmos-proto/testpb";
6+
7+
// QueryService defines the gRPC querier service.
8+
service QueryService {
9+
// CounterQuery queries a counter.
10+
rpc CounterQuery(CounterQueryRequest) returns (CounterQueryResponse) {
11+
option (cosmos_proto.method_added_in) = "github.com/cosmos/cosmos-proto v1.0.1";
12+
}
13+
}
14+
15+
// CounterQueryRequest defines the request type used to query the counter.
16+
message CounterQueryRequest {}
17+
18+
// CounterQueryResponse defines the response type for querying the counter.
19+
message CounterQueryResponse {
20+
option (cosmos_proto.message_added_in) = "github.com/cosmos/cosmos-proto v1.0.1";
21+
22+
uint64 counter = 1 [(cosmos_proto.field_added_in) = "github.com/cosmos/cosmos-proto v1.0.1"];
23+
}

0 commit comments

Comments
 (0)