Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Grpc gateway annotations #6918

Merged
merged 101 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
9a943bb
grpc for bank module
atheeshp Aug 2, 2020
52465d3
edit module.go
atheeshp Aug 2, 2020
84735ee
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 2, 2020
4da61f0
added annotations for x/auth query proto
atheeshp Aug 2, 2020
dd41bf4
generated gw file
atheeshp Aug 2, 2020
3264244
added grpc gateway for x/staking query proto
atheeshp Aug 2, 2020
50a582c
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 3, 2020
304725d
added annotations for evidence
atheeshp Aug 3, 2020
0019542
added annotations for gov query proto
atheeshp Aug 3, 2020
c198157
added annotations
atheeshp Aug 3, 2020
e95f786
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 3, 2020
4e6efef
added annotations for slashing module
atheeshp Aug 3, 2020
fe8861d
updated annotations
atheeshp Aug 3, 2020
8c8e775
added annotations for staking module
atheeshp Aug 3, 2020
1fe80df
added annotations for upgrade query
atheeshp Aug 3, 2020
94d0554
annotations added for x/ibc/channel query proto
atheeshp Aug 3, 2020
ad64f11
added annotations for ibc/connection query proto
atheeshp Aug 3, 2020
6e54f0b
updated annotations
atheeshp Aug 3, 2020
4093561
updated annotations
atheeshp Aug 3, 2020
c312b28
annotation changes
atheeshp Aug 3, 2020
ce21f9f
ommitted ibc module
atheeshp Aug 3, 2020
5fdce6e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 3, 2020
77563b2
updated go.mod
atheeshp Aug 3, 2020
4c1c261
fixed lint issue
atheeshp Aug 3, 2020
2599d09
review changes
atheeshp Aug 3, 2020
8f17e57
review changes
atheeshp Aug 3, 2020
48398ce
review changes
atheeshp Aug 4, 2020
19abdd3
review changes
atheeshp Aug 4, 2020
125f3b8
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 4, 2020
113d3be
go sum changes
atheeshp Aug 4, 2020
03620b4
updated annotations
atheeshp Aug 4, 2020
a52869f
annotation changes
atheeshp Aug 4, 2020
e291450
Merge branch 'master' into atheesh/5921-grpc-gateway
atheeshp Aug 4, 2020
2fc5628
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 4, 2020
bc4cd94
Merge branch 'atheesh/5921-grpc-gateway' of github.com:cosmos/cosmos-…
atheeshp Aug 4, 2020
1513c4b
Merge branch 'master' into atheesh/5921-grpc-gateway
sahith-narahari Aug 4, 2020
e490f26
Merge branch 'master' into atheesh/5921-grpc-gateway
atheeshp Aug 5, 2020
324d1c2
Fix proto lint issues
anilcse Aug 5, 2020
2581419
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 6, 2020
9bac410
review changes
atheeshp Aug 6, 2020
5e9fbc6
Merge branch 'atheesh/5921-grpc-gateway' of github.com:cosmos/cosmos-…
atheeshp Aug 6, 2020
3510d26
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 6, 2020
0834305
review changes
atheeshp Aug 6, 2020
ab817d5
Merge branch 'master' into atheesh/5921-grpc-gateway
atheeshp Aug 7, 2020
2a98fd2
review changes
atheeshp Aug 7, 2020
d3b50bf
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 7, 2020
02939dd
Merge branch 'atheesh/5921-grpc-gateway' of github.com:cosmos/cosmos-…
atheeshp Aug 7, 2020
e0bb1b4
Merge branch 'master' into atheesh/5921-grpc-gateway
atheeshp Aug 9, 2020
f213e41
Merge branch 'atheesh/5921-grpc-gateway' of github.com:cosmos/cosmos-…
atheeshp Aug 10, 2020
b3d0732
discussion changes
atheeshp Aug 10, 2020
059d8c7
review changes
atheeshp Aug 10, 2020
bb499d5
grpc for bank module
atheeshp Aug 2, 2020
3922b15
edit module.go
atheeshp Aug 2, 2020
41c731c
added annotations for x/auth query proto
atheeshp Aug 2, 2020
41a6044
generated gw file
atheeshp Aug 2, 2020
25f0009
added grpc gateway for x/staking query proto
atheeshp Aug 2, 2020
05bf4df
added annotations for evidence
atheeshp Aug 3, 2020
60e367a
added annotations for gov query proto
atheeshp Aug 3, 2020
4ed79e8
added annotations
atheeshp Aug 3, 2020
bcd82c3
added annotations for slashing module
atheeshp Aug 3, 2020
5c8e539
updated annotations
atheeshp Aug 3, 2020
baf8832
added annotations for staking module
atheeshp Aug 3, 2020
c576dbc
added annotations for upgrade query
atheeshp Aug 3, 2020
616df4b
annotations added for x/ibc/channel query proto
atheeshp Aug 3, 2020
51ded63
added annotations for ibc/connection query proto
atheeshp Aug 3, 2020
bfc8e89
updated annotations
atheeshp Aug 3, 2020
10b6495
updated annotations
atheeshp Aug 3, 2020
2ba6755
annotation changes
atheeshp Aug 3, 2020
4a9cec7
ommitted ibc module
atheeshp Aug 3, 2020
4515b54
updated go.mod
atheeshp Aug 3, 2020
5348be2
fixed lint issue
atheeshp Aug 3, 2020
da15459
review changes
atheeshp Aug 3, 2020
4b808eb
review changes
atheeshp Aug 3, 2020
98a0875
review changes
atheeshp Aug 4, 2020
adec92e
review changes
atheeshp Aug 4, 2020
2e2a86c
go sum changes
atheeshp Aug 4, 2020
c1eedf8
updated annotations
atheeshp Aug 4, 2020
324e271
annotation changes
atheeshp Aug 4, 2020
a856b65
Fix proto lint issues
anilcse Aug 5, 2020
df85474
review changes
atheeshp Aug 6, 2020
e32ae7c
review changes
atheeshp Aug 6, 2020
9946434
review changes
atheeshp Aug 7, 2020
031b8a6
discussion changes
atheeshp Aug 10, 2020
7a10390
review changes
atheeshp Aug 10, 2020
eef029c
Merge branch 'atheesh/5921-grpc-gateway' of github.com:cosmos/cosmos-…
atheeshp Aug 10, 2020
f9d68a4
fixed conflicts
atheeshp Aug 10, 2020
cb31884
review changes
atheeshp Aug 10, 2020
2491736
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 11, 2020
8930fb4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 11, 2020
811c6bf
updated gw files
atheeshp Aug 11, 2020
6284436
lint
atheeshp Aug 11, 2020
52a0a2d
lint
atheeshp Aug 11, 2020
c661334
lint
atheeshp Aug 11, 2020
6d8dfaa
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 12, 2020
83e3965
added missing annotations
atheeshp Aug 12, 2020
f9be33c
review changes
atheeshp Aug 12, 2020
879249e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 12, 2020
e4d9d9d
review changes
atheeshp Aug 12, 2020
873848b
review changes
atheeshp Aug 12, 2020
25ac9bd
Merge branch 'master' of github.com:cosmos/cosmos-sdk into atheesh/59…
atheeshp Aug 14, 2020
aa9f6ad
review changes
atheeshp Aug 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions proto/cosmos/auth/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cosmos.auth;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "cosmos/auth/auth.proto";
import "cosmos_proto/cosmos.proto";

Expand All @@ -11,10 +12,14 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
// Query creates service with Account and Parameters as rpc
service Query{
// Account returns account details based on address
rpc Account (QueryAccountRequest) returns (QueryAccountResponse) {}
rpc Account (QueryAccountRequest) returns (QueryAccountResponse) {
option (google.api.http).get = "/cosmos/auth/account/{address}";
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
}

// Params queries all parameters
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {}
rpc Params (QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cosmos/auth/params";
}
}

// QueryAccountRequest is request type for the Query/Account RPC method
Expand Down
17 changes: 13 additions & 4 deletions proto/cosmos/bank/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ package cosmos.bank;
import "cosmos/query/pagination.proto";
import "gogoproto/gogo.proto";
import "cosmos/cosmos.proto";
import "google/api/annotations.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";

// Query provides defines the gRPC querier service
service Query {
// Balance queries the balance of a single coin for a single account
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {}
rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) {
option (google.api.http).get = "/cosmos/bank/balance/{address}/{denom}";
}

// AllBalances queries the balance of all coins for a single account
rpc AllBalances(QueryAllBalancesRequest) returns (QueryAllBalancesResponse) {}
rpc AllBalances(QueryAllBalancesRequest) returns (QueryAllBalancesResponse) {
option (google.api.http).get = "/cosmos/bank/balances/{address}";
}

// TotalSupply queries the total supply of all coins
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {}
rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) {
option (google.api.http).get = "/cosmos/bank/total-supply";
}

// SupplyOf queries the supply of a single coin
rpc SupplyOf(QuerySupplyOfRequest) returns (QuerySupplyOfResponse) {}
rpc SupplyOf(QuerySupplyOfRequest) returns (QuerySupplyOfResponse) {
option (google.api.http).get = "/cosmos/bank/supply/{denom}";
}
}

// QueryBalanceRequest is the request type for the Query/Balance RPC method
Expand Down
37 changes: 28 additions & 9 deletions proto/cosmos/distribution/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,56 @@ import "cosmos/query/pagination.proto";
import "gogoproto/gogo.proto";
import "cosmos/cosmos.proto";
import "cosmos/distribution/distribution.proto";
import "google/api/annotations.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";

// Query defines the gRPC querier service for distribution module
service Query {
// Params queries params of distribution module
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {}
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cosmos/distribution/params";
}

// ValidatorOutstandingRewards queries rewards of a validator address
rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) returns (QueryValidatorOutstandingRewardsResponse) {}
rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) returns (QueryValidatorOutstandingRewardsResponse) {
option (google.api.http).get = "/cosmos/distribution/{validator_address}/outstanding-rewards";
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
}

// ValidatorCommission queries accumulated commission for a validator
rpc ValidatorCommission (QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) {}
rpc ValidatorCommission (QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) {
option (google.api.http).get = "/cosmos/distribution/{validator_address}/validator-commission";
}

// ValidatorSlashes queries slash events of a validator
rpc ValidatorSlashes (QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) {}
rpc ValidatorSlashes (QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) {
option (google.api.http).get = "/cosmos/distribution/{validator_address}/validator-slashes/{starting_height}/{ending_height}/{pagination.key}/{pagination.offset}/{pagination.limit}/{pagination.count_total}";
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
}

// DelegationRewards the total rewards accrued by a delegation
rpc DelegationRewards (QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) {}
rpc DelegationRewards (QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) {
option (google.api.http).get = "/cosmos/distribution/{delegator_address}/{validator_address}/rewards";
}

// DelegationTotalRewards the total rewards accrued by a each validator
rpc DelegationTotalRewards (QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) {}
rpc DelegationTotalRewards (QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) {
option (google.api.http).get = "/cosmos/distribution/{delegator_address}/total-rewards";
}

// DelegatorValidators queries the validators of a delegator
rpc DelegatorValidators (QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {}
rpc DelegatorValidators (QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {
option (google.api.http).get = "/cosmos/distribution/{delegator_address}/validators";
}

// DelegatorWithdrawAddress queries withdraw address of a delegator
rpc DelegatorWithdrawAddress (QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {}
rpc DelegatorWithdrawAddress (QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {
option (google.api.http).get = "/cosmos/distribution/withdraw-address/{delegator_address}";
}

// CommunityPool queries the community pool coins
rpc CommunityPool (QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {}
rpc CommunityPool (QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {
option (google.api.http).get = "/cosmos/distribution/community-pool";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method
Expand Down
17 changes: 17 additions & 0 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,29 @@ for dir in $proto_dirs; do
--gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')

# command to generate gRPC gateway
protoc \
-I "proto" \
-I "third_party/proto" \
--grpc-gateway_out=logtostderr=true:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')

# TODO
# command to generate swagger doc
# protoc \
# -I "proto" \
# -I "third_party/proto" \
# --swagger_out=logtostderr=true:. \
# $(find "${dir}" -maxdepth 1 -name '*.proto')
done

# generate codec/testdata proto code
protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./testutil/testdata/proto.proto

# protoc -I "proto" -I "third_party/proto" -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:. proto/cosmos/bank/query.proto

# move proto files to the right places
cp -r github.com/cosmos/cosmos-sdk/* ./
rm -rf github.com
Expand Down
31 changes: 31 additions & 0 deletions third_party/proto/google/api/annotations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.api;

import "google/api/http.proto";
import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
Loading