Skip to content

Commit

Permalink
chore: implemented multiple coin funding
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Apr 29, 2024
1 parent 8941a06 commit e8d44e0
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 216 deletions.
178 changes: 156 additions & 22 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,36 @@ paths:
protocol_self_delegation_unbonding:
type: string
format: uint64
title: protocol_staking_unbonding
description: protocol_staking_unbonding ...
protocol_delegation:
type: string
format: uint64
description: protocol_delegation ...
protocol_delegation_unbonding:
type: string
format: uint64
title: protocol_delegation_unbonding
description: protocol_delegation_unbonding ...
protocol_rewards:
type: string
format: uint64
description: protocol_rewards ...
protocol_funding:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an amount.
NOTE: The amount field is an Int which implements the custom
method
signatures required by gogoproto.
description: protocol_funding ...
description: >-
QueryAccountAssetsResponse is the response type for the
Expand Down Expand Up @@ -645,8 +659,23 @@ paths:
upload_interval is the interval bundles
get created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination
and an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: >-
total_funds of the pool. If the pool runs
Expand Down Expand Up @@ -1011,10 +1040,25 @@ paths:
items:
type: object
properties:
amount:
type: string
format: uint64
description: amount ...
amounts:
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.
NOTE: The amount field is an Int which implements the
custom method
signatures required by gogoproto.
description: amounts ...
pool:
description: pool ...
type: object
Expand Down Expand Up @@ -1045,8 +1089,23 @@ paths:
format: uint64
title: upload_interval is the interval bundles get created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and an
amount.
NOTE: The amount field is an Int which implements
the custom method
signatures required by gogoproto.
title: |-
total_funds of the pool. If the pool runs
out of funds no more bundles will be produced
Expand Down Expand Up @@ -3888,8 +3947,23 @@ paths:
upload_interval is the interval bundles
get created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination
and an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: >-
total_funds of the pool. If the pool runs
Expand Down Expand Up @@ -6178,8 +6252,23 @@ paths:
upload_interval is the interval bundles get
created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: |-
total_funds of the pool. If the pool runs
out of funds no more bundles will be produced
Expand Down Expand Up @@ -6605,8 +6694,23 @@ paths:
upload_interval is the interval bundles get
created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: |-
total_funds of the pool. If the pool runs
out of funds no more bundles will be produced
Expand Down Expand Up @@ -7143,8 +7247,23 @@ paths:
upload_interval is the interval bundles
get created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination
and an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: >-
total_funds of the pool. If the pool runs
Expand Down Expand Up @@ -7614,8 +7733,23 @@ paths:
upload_interval is the interval bundles get
created
total_funds:
type: string
format: uint64
type: array
items:
type: object
properties:
denom:
type: string
amount:
type: string
description: >-
Coin defines a token with a denomination and
an amount.
NOTE: The amount field is an Int which
implements the custom method
signatures required by gogoproto.
title: |-
total_funds of the pool. If the pool runs
out of funds no more bundles will be produced
Expand Down
20 changes: 15 additions & 5 deletions proto/kyve/query/v1beta1/account.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package kyve.query.v1beta1;
import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";
import "kyve/query/v1beta1/query.proto";

option go_package = "github.com/KYVENetwork/chain/x/query/types";
Expand Down Expand Up @@ -48,16 +50,20 @@ message QueryAccountAssetsResponse {
uint64 balance = 1;
// protocol_staking ...
uint64 protocol_self_delegation = 2;
// protocol_staking_unbonding
// protocol_staking_unbonding ...
uint64 protocol_self_delegation_unbonding = 3;
// protocol_delegation ...
uint64 protocol_delegation = 4;
// protocol_delegation_unbonding
// protocol_delegation_unbonding ...
uint64 protocol_delegation_unbonding = 5;
// protocol_rewards ...
uint64 protocol_rewards = 6;
// protocol_funding ...
uint64 protocol_funding = 7;
repeated cosmos.base.v1beta1.Coin protocol_funding = 7 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// =======================================
Expand Down Expand Up @@ -112,8 +118,12 @@ message QueryAccountFundedListResponse {

// Funded ...
message Funded {
// amount ...
uint64 amount = 1;
// amounts ...
repeated cosmos.base.v1beta1.Coin amounts = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// pool ...
BasicPool pool = 2;
}
Expand Down
8 changes: 7 additions & 1 deletion proto/kyve/query/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ syntax = "proto3";
package kyve.query.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";
import "kyve/pool/v1beta1/pool.proto";

option go_package = "github.com/KYVENetwork/chain/x/query/types";
Expand Down Expand Up @@ -46,7 +48,11 @@ message BasicPool {

// total_funds of the pool. If the pool runs
// out of funds no more bundles will be produced
uint64 total_funds = 7;
repeated cosmos.base.v1beta1.Coin total_funds = 7 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

// total_delegation of the pool
uint64 total_delegation = 8;
Expand Down
2 changes: 1 addition & 1 deletion x/query/keeper/grpc_account_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (k Keeper) AccountAssets(goCtx context.Context, req *types.QueryAccountAsse

// Iterate all fundings of the user to get total funding amount
for _, funding := range k.fundersKeeper.GetFundingsOfFunder(ctx, req.Address) {
response.ProtocolFunding += funding.Amount
response.ProtocolFunding = response.ProtocolFunding.Add(funding.Amounts...)
}

return &response, nil
Expand Down
4 changes: 2 additions & 2 deletions x/query/keeper/grpc_account_funded.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ func (k Keeper) AccountFundedList(goCtx context.Context, req *types.QueryAccount
fundings := k.fundersKeeper.GetFundingsOfFunder(ctx, req.Address)

for _, funding := range fundings {
if funding.Amount > 0 {
if !funding.Amounts.IsZero() {
pool, found := k.poolKeeper.GetPool(ctx, funding.PoolId)
if !found {
return nil, status.Error(codes.Internal, "pool not found")
}
funded = append(funded, types.Funded{
Amount: funding.Amount,
Amounts: funding.Amounts,
Pool: &types.BasicPool{
Id: funding.PoolId,
Name: pool.Name,
Expand Down
Loading

0 comments on commit e8d44e0

Please sign in to comment.