Skip to content

Commit

Permalink
Add Query/BySigner to x/data (#173)
Browse files Browse the repository at this point in the history
* Add Query/BySigner to x/data

* add file

* lint

* proto lint

Co-authored-by: Cory <[email protected]>
  • Loading branch information
aaronc and clevinson authored Nov 19, 2020
1 parent 83040c1 commit e1ca72f
Show file tree
Hide file tree
Showing 8 changed files with 672 additions and 30 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,18 @@ proto-check-breaking-docker:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master

GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/master/proto/cosmos

GOGO_PROTO_TYPES = third_party/proto/gogoproto
COSMOS_PROTO_TYPES = third_party/proto/cosmos

proto-update-deps:
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

@mkdir -p $(COSMOS_PROTO_TYPES)/base/query/v1beta1/
@curl -sSL $(COSMOS_PROTO_URL)/base/query/v1beta1/pagination.proto > $(COSMOS_PROTO_TYPES)/base/query/v1beta1/pagination.proto


###############################################################################
### Localnet ###
Expand Down
29 changes: 27 additions & 2 deletions proto/regen/data/v1alpha1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package regen.data.v1alpha1;

import "google/protobuf/timestamp.proto";
import "cosmos/base/query/v1beta1/pagination.proto";

option go_package = "github.com/regen-network/regen-ledger/x/data";

Expand All @@ -11,6 +12,9 @@ service Query {

// ByCid queries data based on its CID.
rpc ByCid(QueryByCidRequest) returns (QueryByCidResponse);

// BySigner queries data based on signers.
rpc BySigner(QueryBySignerRequest) returns (QueryBySignerResponse);
}

// QueryByCidRequest is the Query/ByCid request type.
Expand All @@ -21,7 +25,7 @@ message QueryByCidRequest {
bytes cid = 1;
}

// QueryByCidRequest is the Query/ByCid response type.
// QueryByCidResponse is the Query/ByCid response type.
message QueryByCidResponse {

// timestamp is the timestamp of the block at which the data was anchored.
Expand All @@ -32,4 +36,25 @@ message QueryByCidResponse {

// content is the content of the data, if it was stored on-chain.
bytes content = 3;
}
}


// QueryBySignerRequest is the Query/BySigner request type.
message QueryBySignerRequest {

// signer is the address of the signer to query by.
string signer = 1;

// pagination is the PageRequest to use for pagination.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryBySignerResponse is the Query/BySigner response type.
message QueryBySignerResponse {

// cids are in the CIDs returned in this page of the query.
repeated bytes cids = 1;

// pagination is the pagination PageResponse.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
50 changes: 50 additions & 0 deletions third_party/proto/cosmos/base/query/v1beta1/pagination.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
syntax = "proto3";
package cosmos.base.query.v1beta1;

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

// PageRequest is to be embedded in gRPC request messages for efficient
// pagination. Ex:
//
// message SomeRequest {
// Foo some_parameter = 1;
// PageRequest pagination = 2;
// }
message PageRequest {
// key is a value returned in PageResponse.next_key to begin
// querying the next page most efficiently. Only one of offset or key
// should be set.
bytes key = 1;

// offset is a numeric offset that can be used when key is unavailable.
// It is less efficient than using key. Only one of offset or key should
// be set.
uint64 offset = 2;

// limit is the total number of results to be returned in the result page.
// If left empty it will default to a value to be set by each app.
uint64 limit = 3;

// count_total is set to true to indicate that the result set should include
// a count of the total number of items available for pagination in UIs.
// count_total is only respected when offset is used. It is ignored when key
// is set.
bool count_total = 4;
}

// PageResponse is to be embedded in gRPC response messages where the
// corresponding request message has used PageRequest.
//
// message SomeResponse {
// repeated Bar results = 1;
// PageResponse page = 2;
// }
message PageResponse {
// next_key is the key to be passed to PageRequest.key to
// query the next page most efficiently
bytes next_key = 1;

// total is total number of results available if PageRequest.count_total
// was set, its value is undefined otherwise
uint64 total = 2;
}
Loading

0 comments on commit e1ca72f

Please sign in to comment.