-
Notifications
You must be signed in to change notification settings - Fork 17
/
grpc_query_feeds.go
37 lines (29 loc) · 993 Bytes
/
grpc_query_feeds.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
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/jackalLabs/canine-chain/v3/x/oracle/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k Keeper) Feed(c context.Context, req *types.QueryFeedRequest) (*types.QueryFeedResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(c)
ctx.Logger().Debug(req.Name)
feed, found := k.GetFeed(ctx, req.Name)
ctx.Logger().Debug(feed.Name)
if !found {
return nil, status.Error(codes.NotFound, "not found")
}
return &types.QueryFeedResponse{Feed: feed}, nil
}
func (k Keeper) AllFeeds(c context.Context, req *types.QueryAllFeedsRequest) (*types.QueryAllFeedsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(c)
f := k.GetAllFeeds(ctx)
return &types.QueryAllFeedsResponse{Feed: f, Pagination: nil}, nil
}