Skip to content

Commit

Permalink
fix: add funders back to pool query (#160)
Browse files Browse the repository at this point in the history
(cherry picked from commit 979eaf7)

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
troykessler authored and mergify[bot] committed Dec 14, 2023
1 parent 68e5ff7 commit da34b10
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 45 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

An '!' indicates a state machine breaking change.

<<<<<<< HEAD
=======
## [Unreleased]

### Bug Fixes

- (`x/query`) [#159](https://github.com/KYVENetwork/chain/pull/159) Add pool params back to kyve params query.
- (`x/query`) [#160](https://github.com/KYVENetwork/chain/pull/160) Add funders back to pool query.

>>>>>>> 979eaf7 (fix: add funders back to pool query (#160))
## [v1.4.0](https://github.com/KYVENetwork/chain/releases/tag/v1.4.0) - 2023-11-17

### Features
Expand Down
86 changes: 86 additions & 0 deletions docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,49 @@ paths:
type: string
format: uint64
description: account_balance ...
fundings:
type: array
items:
type: object
properties:
funder_address:
type: string
title: funder_id is the id of the funder
pool_id:
type: string
format: uint64
title: pool_id is the id of the pool this funding is for
amount:
type: string
format: uint64
title: >-
amount is the amount of funds in ukyve the funder
has left
amount_per_bundle:
type: string
format: uint64
title: >-
amount_per_bundle is the amount of funds in ukyve
the funder pays per bundle
total_funded:
type: string
format: uint64
title: >-
total_funded is the total amount of funds in ukyve
the funder has funded
description: >-
Funding is the object which holds info about the current
funding
funder_address and pool_id (m2m) are unique together
which means that
a funder can only fund each pool once and a pool can
only be funded
by each funder once. However, a funder can update the
amount of funds.
description: funders ...
description: >-
QueryPoolResponse is the response type for the Query/Pool RPC
method.
Expand Down Expand Up @@ -5563,6 +5606,49 @@ paths:
type: string
format: uint64
description: account_balance ...
fundings:
type: array
items:
type: object
properties:
funder_address:
type: string
title: funder_id is the id of the funder
pool_id:
type: string
format: uint64
title: pool_id is the id of the pool this funding is for
amount:
type: string
format: uint64
title: >-
amount is the amount of funds in ukyve the funder
has left
amount_per_bundle:
type: string
format: uint64
title: >-
amount_per_bundle is the amount of funds in ukyve
the funder pays per bundle
total_funded:
type: string
format: uint64
title: >-
total_funded is the total amount of funds in ukyve
the funder has funded
description: >-
Funding is the object which holds info about the
current funding
funder_address and pool_id (m2m) are unique together
which means that
a funder can only fund each pool once and a pool can
only be funded
by each funder once. However, a funder can update the
amount of funds.
description: funders ...
description: PoolResponse ...
description: pools ...
pagination:
Expand Down
3 changes: 3 additions & 0 deletions proto/kyve/query/v1beta1/pools.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "kyve/bundles/v1beta1/bundles.proto";
import "kyve/funders/v1beta1/funders.proto";
import "kyve/pool/v1beta1/pool.proto";

option go_package = "github.com/KYVENetwork/chain/x/query/types";
Expand Down Expand Up @@ -69,6 +70,8 @@ message PoolResponse {
string account = 8;
// account_balance ...
uint64 account_balance = 9;
// funders ...
repeated kyve.funders.v1beta1.Funding fundings = 10;
}

// =========
Expand Down
10 changes: 10 additions & 0 deletions x/query/keeper/grpc_query_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
poolTypes "github.com/KYVENetwork/chain/x/pool/types"
// Query
"github.com/KYVENetwork/chain/x/query/types"
// Funders
fundersTypes "github.com/KYVENetwork/chain/x/funders/types"
)

func (k Keeper) Pools(c context.Context, req *types.QueryPoolsRequest) (*types.QueryPoolsResponse, error) {
Expand Down Expand Up @@ -63,6 +65,13 @@ func (k Keeper) parsePoolResponse(ctx sdk.Context, pool *poolTypes.Pool) types.P
poolAccount := pool.GetPoolAccount()
poolBalance := k.bankKeeper.GetBalance(ctx, poolAccount, globalTypes.Denom).Amount.Uint64()

fundingsOfPool := k.fundersKeeper.GetFundingsOfPool(ctx, pool.Id)

fundings := make([]*fundersTypes.Funding, 0)
for index := range fundingsOfPool {
fundings = append(fundings, &fundingsOfPool[index])
}

return types.PoolResponse{
Id: pool.Id,
Data: pool,
Expand All @@ -73,5 +82,6 @@ func (k Keeper) parsePoolResponse(ctx sdk.Context, pool *poolTypes.Pool) types.P
Status: k.GetPoolStatus(ctx, pool),
Account: poolAccount.String(),
AccountBalance: poolBalance,
Fundings: fundings,
}
}
156 changes: 111 additions & 45 deletions x/query/types/pools.pb.go

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

0 comments on commit da34b10

Please sign in to comment.