-
Notifications
You must be signed in to change notification settings - Fork 17
/
grpc_account_funded.go
42 lines (36 loc) · 1.13 KB
/
grpc_account_funded.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package keeper
import (
"context"
"github.com/KYVENetwork/chain/x/query/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k Keeper) AccountFundedList(goCtx context.Context, req *types.QueryAccountFundedListRequest) (*types.QueryAccountFundedListResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
var funded []types.Funded
pools := k.poolKeeper.GetAllPools(ctx)
for i := range pools {
pool := pools[i]
funded = append(funded, types.Funded{
Amount: pool.GetFunderAmount(req.Address),
Pool: &types.BasicPool{
Id: pool.Id,
Name: pool.Name,
Runtime: pool.Runtime,
Logo: pool.Logo,
OperatingCost: pool.OperatingCost,
UploadInterval: pool.UploadInterval,
TotalFunds: pool.TotalFunds,
TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id),
Status: k.GetPoolStatus(ctx, &pool),
},
})
}
return &types.QueryAccountFundedListResponse{
Funded: funded,
}, nil
}