Skip to content

Commit

Permalink
fixes queries
Browse files Browse the repository at this point in the history
  • Loading branch information
P-U-D-G-E committed Nov 9, 2023
1 parent 9148d69 commit f4af8f4
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 112 deletions.
6 changes: 3 additions & 3 deletions proto/sge/reward/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ message QueryRewardsByAddressRequest {
// QueryRewardsByAddressResponse is response body of the query all rewards by
// address endpoint.
message QueryRewardsByAddressResponse {
repeated Reward rewards = 1 [ (gogoproto.nullable) = false ];
repeated RewardByCategory rewards = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

Expand All @@ -134,7 +134,7 @@ message QueryRewardsByAddressAndCategoryRequest {
// QueryRewardsByAddressAndTypeResponse is response body of the query all
// rewards by address and type endpoint.
message QueryRewardsByAddressAndCategoryResponse {
repeated Reward rewards = 1 [ (gogoproto.nullable) = false ];
repeated RewardByCategory rewards = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

Expand All @@ -148,6 +148,6 @@ message QueryRewardsByCampaignRequest {
// QueryRewardsByCampaignResponse is response body of the query all rewards by
// campaign endpoint.
message QueryRewardsByCampaignResponse {
repeated Reward rewards = 1 [ (gogoproto.nullable) = false ];
repeated RewardByCampaign rewards = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
2 changes: 1 addition & 1 deletion x/reward/client/cli/query_reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func CmdGetRewardByUserAndCategory() *cobra.Command {
cmd := &cobra.Command{
Use: "rewards-by-user-category [address] [category]",
Short: "shows a list of rewards by user and category",
Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx := client.GetClientContextFromCmd(cmd)

Expand Down
12 changes: 6 additions & 6 deletions x/reward/keeper/query_reward.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ func (k Keeper) RewardsByAddress(goCtx context.Context, req *types.QueryRewardsB
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

var rewards []types.Reward
var rewards []types.RewardByCategory
ctx := sdk.UnwrapSDKContext(goCtx)

store := k.getRewardByReceiverAndCategoryStore(ctx)
rewardStore := prefix.NewStore(store, types.GetRewardsByAccPrefix(req.Address))

pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error {
var reward types.Reward
var reward types.RewardByCategory
if err := k.cdc.Unmarshal(value, &reward); err != nil {
return err
}
Expand All @@ -87,14 +87,14 @@ func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.Qu
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

var rewards []types.Reward
var rewards []types.RewardByCategory
ctx := sdk.UnwrapSDKContext(goCtx)

store := k.getRewardByReceiverAndCategoryStore(ctx)
rewardStore := prefix.NewStore(store, types.GetRewardsByCategoryPrefix(req.Address, req.Category))

pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error {
var reward types.Reward
var reward types.RewardByCategory
if err := k.cdc.Unmarshal(value, &reward); err != nil {
return err
}
Expand All @@ -114,14 +114,14 @@ func (k Keeper) RewardsByCampaign(goCtx context.Context, req *types.QueryRewards
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

var rewards []types.Reward
var rewards []types.RewardByCampaign
ctx := sdk.UnwrapSDKContext(goCtx)

store := k.getRewardsByCampaignStore(ctx)
rewardStore := prefix.NewStore(store, types.GetRewardsByCampaignPrefix(req.CampaignUid))

pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error {
var reward types.Reward
var reward types.RewardByCampaign
if err := k.cdc.Unmarshal(value, &reward); err != nil {
return err
}
Expand Down
126 changes: 63 additions & 63 deletions x/reward/types/query.pb.go

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

3 changes: 3 additions & 0 deletions x/reward/types/reward.pb.go

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

Loading

0 comments on commit f4af8f4

Please sign in to comment.