Skip to content

Commit

Permalink
Merge pull request #36 from initia-labs/fix/nft-query
Browse files Browse the repository at this point in the history
fix nft-query
  • Loading branch information
SeUkKim authored Apr 22, 2024
2 parents 65777b3 + 13511d8 commit 64a5325
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions submodules/move-nft/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,14 @@ func (sm MoveNftSubmodule) getTokensByCollection(ctx context.Context, req *nftty
return &v, nil
},
)

if err != nil {
return nil, handleCollectionErr(err)
}
res = slices.DeleteFunc(res, func(item *nfttypes.IndexedToken) bool {
return item == nil
})
res = slices.Clip(res)

return &nfttypes.QueryTokensResponse{
Tokens: res,
Expand Down Expand Up @@ -238,6 +243,10 @@ func (sm MoveNftSubmodule) getTokensByAccountAndCollection(ctx context.Context,
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
res = slices.DeleteFunc(res, func(item *nfttypes.IndexedToken) bool {
return item == nil
})
res = slices.Clip(res)

return &nfttypes.QueryTokensResponse{
Tokens: res,
Expand Down
8 changes: 8 additions & 0 deletions submodules/wasm-nft/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ func (sm WasmNFTSubmodule) getTokensByCollection(ctx context.Context, req *nftty
if err != nil {
return nil, handleCollectionErr(err)
}
res = slices.DeleteFunc(res, func(item *nfttypes.IndexedToken) bool {
return item == nil
})
res = slices.Clip(res)

return &nfttypes.QueryTokensResponse{
Tokens: res,
Expand Down Expand Up @@ -238,6 +242,10 @@ func (sm WasmNFTSubmodule) getTokensByAccountAndCollection(ctx context.Context,
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
res = slices.DeleteFunc(res, func(item *nfttypes.IndexedToken) bool {
return item == nil
})
res = slices.Clip(res)

return &nfttypes.QueryTokensResponse{
Tokens: res,
Expand Down

0 comments on commit 64a5325

Please sign in to comment.