Skip to content

Commit

Permalink
chore: improved account assets query
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler committed Jan 3, 2025
1 parent 3c181ca commit 03a1a21
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 81 deletions.
34 changes: 30 additions & 4 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,36 @@ paths:
delegation:
type: string
format: uint64
description: protocol_staking ...
description: >-
delegation is the amount in $KYVE this account has in total
delegated ...
delegation_unbonding:
type: string
format: uint64
description: protocol_staking_unbonding ...
outstanding_rewards:
description: >-
delegation_unbonding is the amount in $KYVE this account has
in total currently unbonding ...
delegation_rewards:
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: >-
delegation_rewards are the current unclaimed delegation
rewards
commission_rewards:
type: array
items:
type: object
Expand All @@ -213,7 +237,9 @@ paths:
method

signatures required by gogoproto.
description: protocol_rewards ...
title: >-
commission_rewards are the current unclaimed commission
rewards
protocol_funding:
type: array
items:
Expand Down
16 changes: 11 additions & 5 deletions proto/kyve/query/v1beta1/account.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,24 @@ message QueryAccountAssetsRequest {
message QueryAccountAssetsResponse {
// balance ...
uint64 balance = 1;
// protocol_staking ...
// delegation is the amount in $KYVE this account has in total delegated ...
uint64 delegation = 2;
// protocol_staking_unbonding ...
// delegation_unbonding is the amount in $KYVE this account has in total currently unbonding ...
uint64 delegation_unbonding = 3;
// protocol_rewards ...
repeated cosmos.base.v1beta1.Coin outstanding_rewards = 6 [
// delegation_rewards are the current unclaimed delegation rewards
repeated cosmos.base.v1beta1.Coin delegation_rewards = 6 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// commission_rewards are the current unclaimed commission rewards
repeated cosmos.base.v1beta1.Coin commission_rewards = 7 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// protocol_funding ...
repeated cosmos.base.v1beta1.Coin protocol_funding = 7 [
repeated cosmos.base.v1beta1.Coin protocol_funding = 8 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
Expand Down
4 changes: 3 additions & 1 deletion x/query/keeper/grpc_account_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ func (k Keeper) AccountAssets(goCtx context.Context, req *types.QueryAccountAsse
}

for _, validator := range validators.Validators {
response.OutstandingRewards = response.OutstandingRewards.Add(
response.DelegationRewards = response.DelegationRewards.Add(
k.stakerKeeper.GetOutstandingRewards(ctx, util.MustAccountAddressFromValAddress(validator.OperatorAddress), req.Address)...,
)
}

response.CommissionRewards = k.stakerKeeper.GetOutstandingCommissionRewards(ctx, util.MustAccountAddressFromValAddress(util.MustValaddressFromOperatorAddress(req.Address)))

delegatorBonded, err := k.stakingKeeper.GetDelegatorBonded(ctx, delegatorAddr)
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
Expand Down
Loading

0 comments on commit 03a1a21

Please sign in to comment.