Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add funders back to pool query (backport #160) #166

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ An '!' indicates a state machine breaking change.
### 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.

## [v1.4.0](https://github.com/KYVENetwork/chain/releases/tag/v1.4.0) - 2023-11-17

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.

Loading