Skip to content

Commit dfb167a

Browse files
committed
improve proto
1 parent ca70cb2 commit dfb167a

10 files changed

Lines changed: 160 additions & 69 deletions

File tree

proto/side/auction/auction.proto

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,43 @@ syntax = "proto3";
22
package side.auction;
33

44
import "gogoproto/gogo.proto";
5-
// import "side/btcbridge/params.proto";
6-
// import "side/btcbridge/btcbridge.proto";
5+
import "google/protobuf/timestamp.proto";
6+
import "cosmos/base/v1beta1/coin.proto";
77

88
option go_package = "github.com/sideprotocol/side/x/auction/types";
99

1010
message Bid {
11-
string auction_id = 1;
12-
string bidder = 2;
13-
int64 bid_price = 3;
14-
Coin bid_amount = 4;
15-
BidStatus status = 5;
11+
uint64 id = 1;
12+
uint64 auction_id = 2;
13+
string bidder = 3;
14+
int64 bid_price = 4;
15+
cosmos.base.v1beta1.Coin bid_amount = 5;
16+
BidStatus status = 6;
1617
}
1718

1819
message Auction {
19-
string id = 1;
20-
Coin deposited_asset = 2;
20+
uint64 id = 1;
21+
cosmos.base.v1beta1.Coin deposited_asset = 2;
2122
string borrower = 3;
2223
int64 liquidated_price = 4;
23-
int64 liquidated_time = 5;
24+
google.protobuf.Timestamp liquidated_time = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
2425
int64 expected_value = 6;
2526
int64 bidded_value = 7;
26-
AuctionStatus status = 8;
27-
string payment_tx_id = 9;
27+
string payment_tx_id = 8;
28+
AuctionStatus status = 9;
2829
}
2930

3031
enum AssetType {
31-
Bitcoin = 1;
32+
Bitcoin = 0;
3233
}
3334

3435
enum AuctionStatus {
35-
AuctionOpen = 1;
36-
AuctionClose = 2;
36+
AuctionOpen = 0;
37+
AuctionClose = 1;
3738
}
3839

3940
enum BidStatus {
40-
Bidding = 1;
41-
Accepted = 2;
42-
Rejected = 3;
43-
}
41+
Bidding = 0;
42+
Accepted = 1;
43+
Rejected = 2;
44+
}

proto/side/auction/genesis.proto

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ syntax = "proto3";
22
package side.auction;
33

44
import "gogoproto/gogo.proto";
5-
// import "side/btcbridge/params.proto";
6-
// import "side/btcbridge/btcbridge.proto";
5+
import "side/auction/auction.proto";
6+
import "side/auction/params.proto";
77

88
option go_package = "github.com/sideprotocol/side/x/auction/types";
99

10+
// GenesisState defines the auctioin module's genesis state.
11+
message GenesisState {
12+
Params params = 1 [(gogoproto.nullable) = false];
1013

14+
repeated Auction auctions = 2;
15+
repeated Bid bids = 3;
16+
}

proto/side/auction/params.proto

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ syntax = "proto3";
22
package side.auction;
33

44
import "gogoproto/gogo.proto";
5-
// import "side/btcbridge/params.proto";
6-
// import "side/btcbridge/btcbridge.proto";
5+
import "google/protobuf/duration.proto";
76

87
option go_package = "github.com/sideprotocol/side/x/auction/types";
98

109
// Params defines the parameters for the module.
1110
message Params {
12-
uint32 price_drop_period = 1;
11+
google.protobuf.Duration price_drop_period = 1 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
1312
uint32 initial_discount = 2;
1413
uint32 fee_rate = 3;
1514
uint64 min_bid_amount = 4;
16-
}
15+
}

proto/side/auction/query.proto

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
syntax = "proto3";
2+
package side.auction;
3+
4+
import "gogoproto/gogo.proto";
5+
import "google/api/annotations.proto";
6+
import "cosmos/base/query/v1beta1/pagination.proto";
7+
import "side/auction/auction.proto";
8+
import "side/auction/params.proto";
9+
10+
option go_package = "github.com/sideprotocol/side/x/auction/types";
11+
12+
// Query defines the gRPC querier service.
13+
service Query {
14+
// Params queries the parameters of the module.
15+
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
16+
option (google.api.http).get = "/side/auction/params";
17+
}
18+
// Auctions queries the auctions by the given status.
19+
rpc Auctions(QueryAuctionsRequest) returns (QueryAuctionsResponse) {
20+
option (google.api.http).get = "/side/auction/auctions";
21+
}
22+
// Bids queries the bids by the given status.
23+
rpc Bids(QueryBidsRequest) returns (QueryBidsResponse) {
24+
option (google.api.http).get = "/side/auction/bids";
25+
}
26+
}
27+
28+
// QueryParamsRequest is request type for the Query/Params RPC method.
29+
message QueryParamsRequest {
30+
}
31+
32+
// QueryParamsResponse is response type for the Query/Params RPC method.
33+
message QueryParamsResponse {
34+
Params params = 1;
35+
}
36+
37+
// QueryAuctionsRequest is request type for the Query/Auctions RPC method.
38+
message QueryAuctionsRequest {
39+
string status = 1;
40+
cosmos.base.query.v1beta1.PageRequest pagination = 2;
41+
}
42+
43+
// QueryAuctionsResponse is response type for the Query/Auctions RPC method.
44+
message QueryAuctionsResponse {
45+
repeated Auction auctions = 1;
46+
cosmos.base.query.v1beta1.PageResponse pagination = 2;
47+
}
48+
49+
// QueryBidsRequest is request type for the Query/Bids RPC method.
50+
message QueryBidsRequest {
51+
string status = 1;
52+
cosmos.base.query.v1beta1.PageRequest pagination = 2;
53+
}
54+
55+
// QueryBidsResponse is response type for the Query/Bids RPC method.
56+
message QueryBidsResponse {
57+
repeated Bid bids = 1;
58+
cosmos.base.query.v1beta1.PageRequest pagination = 2;
59+
}

proto/side/auction/tx.proto

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
syntax = "proto3";
2+
package side.auction;
3+
4+
import "gogoproto/gogo.proto";
5+
import "cosmos/base/v1beta1/coin.proto";
6+
import "cosmos/msg/v1/msg.proto";
7+
8+
option go_package = "github.com/sideprotocol/side/x/auction/types";
9+
10+
// Msg defines the Msg service.
11+
service Msg {
12+
option (cosmos.msg.v1.service) = true;
13+
14+
// Make bid for the specified auction.
15+
rpc Bid(MsgBid) returns (MsgBidResponse);
16+
}
17+
18+
// MsgBid defines the Msg/Bid request type.
19+
message MsgBid {
20+
option (cosmos.msg.v1.signer) = "sender";
21+
22+
string sender = 1;
23+
uint64 auction_id = 2;
24+
int64 price = 3;
25+
cosmos.base.v1beta1.Coin amount = 4;
26+
}
27+
28+
// MsgBidResponse defines the Msg/Bid response type.
29+
message MsgBidResponse {}

proto/side/dlc/dlc.proto

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,33 @@ syntax = "proto3";
22
package side.dlc;
33

44
import "gogoproto/gogo.proto";
5-
// import "side/btcbridge/params.proto";
6-
// import "side/btcbridge/btcbridge.proto";
5+
import "google/protobuf/timestamp.proto";
76

87
option go_package = "github.com/sideprotocol/side/x/dlc/types";
98

109
enum AnnouncementStatus {
11-
Announcement_Unspecified = 1;
12-
Announcement_Pending = 2;
13-
Announcement_Ready = 3;
10+
Announcement_Unspecified = 0;
11+
Announcement_Pending = 1;
12+
Announcement_Ready = 2;
1413
}
1514

1615
message DLCAnnouncement {
17-
string id = 1;
16+
uint64 id = 1;
1817
DLCEvent oracle_event = 2;
1918
string signature = 3;
2019
AnnouncementStatus status = 4;
2120
}
2221

2322
message DLCAttestation {
24-
string announcement_id = 1;
25-
string time = 2;
23+
uint64 announcement_id = 1;
24+
google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
2625
string outcome = 3;
2726
string signature = 4;
2827
}
2928

3029
message DLCEvent {
31-
uint32 maturity_epoch = 2;
32-
string nonce = 3;
33-
string descriptor = 4;
34-
string pubkey = 5;
30+
uint32 maturity_epoch = 1;
31+
string nonce = 2;
32+
string descriptor = 3;
33+
string pubkey = 4;
3534
}
36-
37-
38-

proto/side/dlc/genesis.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ syntax = "proto3";
22
package side.dlc;
33

44
import "gogoproto/gogo.proto";
5-
65
import "side/dlc/params.proto";
76
import "side/dlc/dlc.proto";
87

@@ -11,7 +10,7 @@ option go_package = "github.com/sideprotocol/side/x/dlc/types";
1110
// GenesisState defines the dlc module's genesis state.
1211
message GenesisState {
1312
Params params = 1 [(gogoproto.nullable) = false];
14-
13+
1514
repeated DLCAnnouncement announcements = 2;
1615
repeated DLCAttestation attestations = 3;
17-
}
16+
}

proto/side/dlc/params.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ message PriceInterval {
1313
// Params defines the parameters for the module.
1414
message Params {
1515
repeated PriceInterval price_interval = 1;
16-
}
16+
}

proto/side/dlc/query.proto

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,47 @@ option go_package = "github.com/sideprotocol/side/x/dlc/types";
1111

1212
// Query defines the gRPC querier service.
1313
service Query {
14-
// Parameters queries the parameters of the module.
15-
rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) {
14+
// Params queries the parameters of the module.
15+
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
1616
option (google.api.http).get = "/side/dlc/params";
1717
}
18-
rpc QueryAnnouncements(QueryAnnouncementRequest) returns (QueryAnnouncementResponse) {
19-
option (google.api.http).get = "/side/dlc/announcements";
18+
// Announcements queries the announcements by the given status.
19+
rpc Announcements(QueryAnnouncementsRequest) returns (QueryAnnouncementsResponse) {
20+
option (google.api.http).get = "/side/dlc/announcements";
2021
}
21-
rpc QueryPrices(QueryPriceRequest) returns (QueryPricesResponse) {
22-
option (google.api.http).get = "/side/dlc/announcements";
22+
// Price queries the current price by the given symbol.
23+
rpc Price(QueryPriceRequest) returns (QueryPriceResponse) {
24+
option (google.api.http).get = "/side/dlc/price";
2325
}
24-
2526
}
2627

27-
// QueryParamsRequest is request type for the QueryParams RPC method.
28+
// QueryParamsRequest is request type for the Query/Params RPC method.
2829
message QueryParamsRequest {
2930
}
3031

31-
// QueryParamsResponse is response type for the QueryParams RPC method.
32+
// QueryParamsResponse is response type for the Query/Params RPC method.
3233
message QueryParamsResponse {
3334
Params params = 1;
3435
}
3536

36-
// QueryAnnouncementRequest is request type for the Query/QueryAnnouncements RPC method.
37-
message QueryAnnouncementRequest {
37+
// QueryAnnouncementsRequest is request type for the Query/Announcements RPC method.
38+
message QueryAnnouncementsRequest {
3839
string status = 1;
3940
cosmos.base.query.v1beta1.PageRequest pagination = 2;
4041
}
41-
42-
// QueryAnnouncementResponse is response type for the Query/QueryAnnouncements RPC method.
43-
message QueryAnnouncementResponse {
42+
43+
// QueryAnnouncementsResponse is response type for the Query/Announcements RPC method.
44+
message QueryAnnouncementsResponse {
4445
repeated DLCAnnouncement announcements = 1;
4546
cosmos.base.query.v1beta1.PageResponse pagination = 2;
4647
}
47-
48-
// QueryAnnouncementRequest is request type for the Query/QueryAnnouncements RPC method.
48+
49+
// QueryPriceRequest is request type for the Query/Price RPC method.
4950
message QueryPriceRequest {
5051
string symbol = 1;
5152
}
52-
53-
// QueryAnnouncementResponse is response type for the Query/QueryAnnouncements RPC method.
54-
message QueryPricesResponse {
53+
54+
// QueryPriceResponse is response type for the Query/Price RPC method.
55+
message QueryPriceResponse {
5556
uint32 price = 1;
5657
}
57-

proto/side/dlc/tx.proto

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@ syntax = "proto3";
22
package side.dlc;
33

44
import "gogoproto/gogo.proto";
5+
import "cosmos/msg/v1/msg.proto";
56

67
option go_package = "github.com/sideprotocol/side/x/dlc/types";
78

89
// Msg defines the Msg service.
910
service Msg {
1011
option (cosmos.msg.v1.service) = true;
1112

12-
rpc SubmitAnnounceNonce (MsgSubmitAnnouncementNonce) returns (MsgSubmitAnnouncementNonceResponse);
13+
rpc SubmitAnnouncementNonce (MsgSubmitAnnouncementNonce) returns (MsgSubmitAnnouncementNonceResponse);
1314
rpc SubmitAttestation(MsgSubmitAttestation) returns (MsgSubmitAttestationResponse);
1415
}
1516

1617
message MsgSubmitAnnouncementNonce {
1718
option (cosmos.msg.v1.signer) = "sender";
18-
19+
1920
string sender = 1;
20-
string announcement_id = 2;
21+
uint64 announcement_id = 2;
2122
string nonce = 3;
2223
string signature = 4;
2324
}
@@ -27,9 +28,10 @@ message MsgSubmitAnnouncementNonceResponse {}
2728

2829
message MsgSubmitAttestation {
2930
option (cosmos.msg.v1.signer) = "sender";
31+
3032
string sender = 1;
31-
string announcement_id = 2;
33+
uint64 announcement_id = 2;
3234
string signature = 3;
3335
}
3436

35-
message MsgSubmitAttestationResponse {}
37+
message MsgSubmitAttestationResponse {}

0 commit comments

Comments
 (0)