Skip to content

Commit 968b78e

Browse files
committed
feat(cosmos): generate GRPC REST gateway implementations
1 parent fc062b8 commit 968b78e

File tree

5 files changed

+765
-10
lines changed

5 files changed

+765
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
syntax = "proto3";
2+
package agoric.vbank;
3+
4+
import "gogoproto/gogo.proto";
5+
import "google/api/annotations.proto";
6+
import "agoric/vbank/vbank.proto";
7+
8+
option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types";
9+
10+
// Query defines the gRPC querier service for vbank module.
11+
service Query {
12+
// Params queries params of the vbank module.
13+
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
14+
option (google.api.http).get = "/agoric/vbank/params";
15+
}
16+
17+
rpc State(QueryStateRequest) returns (QueryStateResponse) {
18+
option (google.api.http).get = "/agoric/vbank/state";
19+
}
20+
}
21+
22+
// QueryParamsRequest is the request type for the Query/Params RPC method.
23+
message QueryParamsRequest {}
24+
25+
// QueryParamsResponse is the response type for the Query/Params RPC method.
26+
message QueryParamsResponse {
27+
// params defines the parameters of the module.
28+
Params params = 1 [(gogoproto.nullable) = false];
29+
}
30+
31+
// QueryStateRequest is the request type for the Query/State RPC method.
32+
message QueryStateRequest {}
33+
34+
// QueryStateResponse is the response type for the Query/State RPC method.
35+
message QueryStateResponse {
36+
// state defines the parameters of the module.
37+
State state = 1 [(gogoproto.nullable) = false];
38+
}

golang/cosmos/proto/agoric/vbank/vbank.proto

+20-10
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types";
88

99
message Params {
1010
option (gogoproto.equal) = true;
11+
option (gogoproto.goproto_stringer) = false;
1112

12-
// feeEpochDurationBlocks is the length of a fee epoch, in blocks.
13+
// fee_epoch_duration_blocks is the length of a fee epoch, in blocks.
1314
// A value of zero has the same meaning as a value of one:
1415
// the full fee buffer should be distributed immediately.
15-
int64 feeEpochDurationBlocks = 1;
16+
int64 fee_epoch_duration_blocks = 1 [
17+
(gogoproto.moretags) = "yaml:\"fee_epoch_duration_blocks\""
18+
];
1619
}
1720

1821
message State {
@@ -21,15 +24,22 @@ message State {
2124
// rewardPool is the current balance of rewards in the module account.
2225
// NOTE: Tracking manually since there is no bank call for getting a
2326
// module account balance by name.
24-
repeated cosmos.base.v1beta1.Coin rewardPool = 1
25-
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
26-
];
27+
repeated cosmos.base.v1beta1.Coin reward_pool = 1 [
28+
(gogoproto.nullable) = false,
29+
(gogoproto.moretags) = "yaml:\"reward_pool\"",
30+
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
31+
];
2732

28-
// rewardRate is the amount of reward, if available, to send to the
33+
// reward_rate is the amount of reward, if available, to send to the
2934
// fee collector module on every block.
30-
repeated cosmos.base.v1beta1.Coin rewardRate = 2
31-
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
35+
repeated cosmos.base.v1beta1.Coin reward_rate = 2 [
36+
(gogoproto.nullable) = false,
37+
(gogoproto.moretags) = "yaml:\"reward_rate\"",
38+
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
39+
];
3240

33-
// lastNonce is a sequence number for communicating with the VM.
34-
uint64 lastNonce = 3;
41+
// last_sequence is a sequence number for communicating with the VM.
42+
uint64 last_sequence = 3 [
43+
(gogoproto.moretags) = "yaml:\"last_sequence\""
44+
];
3545
}

golang/cosmos/scripts/protocgen.sh

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ for dir in $proto_dirs; do
99
-I third_party/proto \
1010
--gocosmos_out=plugins=interfacetype+grpc,\
1111
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
12+
--grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \
1213
$(find "${dir}" -maxdepth 1 -name '*.proto')
1314
done
1415

0 commit comments

Comments
 (0)