-
Notifications
You must be signed in to change notification settings - Fork 1
/
grpc_query_asset_list.go
36 lines (28 loc) · 1.06 KB
/
grpc_query_asset_list.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
package query
import (
"context"
"github.com/Timwood0x10/sei-chain/x/dex/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k KeeperWrapper) AssetList(c context.Context, req *types.QueryAssetListRequest) (*types.QueryAssetListResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(c)
allAssetMetadata := k.GetAllAssetMetadata(ctx)
return &types.QueryAssetListResponse{AssetList: allAssetMetadata}, nil
}
func (k KeeperWrapper) AssetMetadata(c context.Context, req *types.QueryAssetMetadataRequest) (*types.QueryAssetMetadataResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(c)
assetMetadata, found := k.GetAssetMetadataByDenom(ctx, req.Denom)
if !found {
return nil, sdkerrors.ErrKeyNotFound
}
return &types.QueryAssetMetadataResponse{Metadata: &assetMetadata}, nil
}