Skip to content

Commit

Permalink
feat: add query groups in x/group (backport cosmos#14879) (cosmos…
Browse files Browse the repository at this point in the history
…#15476)

Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
  • Loading branch information
3 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 42257c7 commit ce315ba
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 89 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* (x/groups) [#14879](https://github.com/cosmos/cosmos-sdk/pull/14879) Add `Query/Groups` query to get all the groups.

### Improvements

* (simapp) [#15305](https://github.com/cosmos/cosmos-sdk/pull/15305) Add `AppStateFnWithExtendedCb` with callback function to extend rawState and `AppStateRandomizedFnWithState` with extra genesisState argument which is the genesis state of the app.
Expand Down
6 changes: 4 additions & 2 deletions x/group/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ func (k Keeper) TallyResult(goCtx context.Context, request *group.QueryTallyResu
}

// Groups returns all the groups present in the state.
func (k Keeper) Groups(ctx context.Context, request *group.QueryGroupsRequest) (*group.QueryGroupsResponse, error) {
it, err := k.groupTable.PrefixScan(k.KVStoreService.OpenKVStore(ctx), 1, math.MaxUint64)
func (k Keeper) Groups(goCtx context.Context, request *group.QueryGroupsRequest) (*group.QueryGroupsResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

it, err := k.groupTable.PrefixScan(ctx.KVStore(k.key), 1, math.MaxUint64)
if err != nil {
return nil, err
}
Expand Down
25 changes: 23 additions & 2 deletions x/group/proto/cosmos/group/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ service Query {
};

// Groups queries all groups in state.
//
// Since: cosmos-sdk 0.47.1
rpc Groups(QueryGroupsRequest) returns (QueryGroupsResponse) {
option (cosmos_proto.method_added_in) = "cosmos-sdk 0.47.1";
option (google.api.http).get = "/cosmos/group/v1/groups";
option (google.api.http).get = "/cosmos/group/v1/groups";
};
}

Expand Down Expand Up @@ -314,3 +315,23 @@ message QueryGroupsResponse {
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryGroupsRequest is the Query/Groups request type.
//
// Since: cosmos-sdk 0.47.1
message QueryGroupsRequest {

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryGroupsResponse is the Query/Groups response type.
//
// Since: cosmos-sdk 0.47.1
message QueryGroupsResponse {
// `groups` is all the groups present in state.
repeated GroupInfo groups = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
175 changes: 90 additions & 85 deletions x/group/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ce315ba

Please sign in to comment.