Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: provide specific error messages on x/collection queries #965

Merged
merged 2 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/collection) [\#938](https://github.com/line/lbm-sdk/pull/938) Add progress log into x/collection import-genesis
* (x/foundation) [\#952](https://github.com/line/lbm-sdk/pull/952) Address generation of the empty coins in x/foundation
* (x/collection,token,foundation) [\#963](https://github.com/line/lbm-sdk/pull/963) Check event determinism on original modules
* (x/collection) [\#965](https://github.com/line/lbm-sdk/pull/965) Provide specific error messages on x/collection queries

### Bug Fixes
* (swagger) [\#898](https://github.com/line/lbm-sdk/pull/898) fix a bug not added `lbm.tx.v1beta1.Service/GetBlockWithTxs` in swagger
Expand Down
10 changes: 10 additions & 0 deletions x/collection/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ func (s queryServer) TokenType(c context.Context, req *collection.QueryTokenType
}

ctx := sdk.UnwrapSDKContext(c)

if err := s.validateExistenceOfCollectionGRPC(ctx, req.ContractId); err != nil {
return nil, err
}

class, err := s.keeper.GetTokenClass(ctx, req.ContractId, classID)
if err != nil {
return nil, status.Error(codes.NotFound, err.Error())
Expand Down Expand Up @@ -454,6 +459,11 @@ func (s queryServer) Token(c context.Context, req *collection.QueryTokenRequest)
}

ctx := sdk.UnwrapSDKContext(c)

if err := s.validateExistenceOfCollectionGRPC(ctx, req.ContractId); err != nil {
return nil, err
}

legacyToken, err := s.getToken(ctx, req.ContractId, req.TokenId)
if err != nil {
return nil, status.Error(codes.NotFound, err.Error())
Expand Down
4 changes: 4 additions & 0 deletions x/collection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,10 @@ func (s *KeeperTestSuite) TestQueryToken() {
"invalid token id": {
contractID: s.contractID,
},
"collection not found": {
contractID: "deadbeef",
tokenID: ftTokenID,
},
"no such a fungible token": {
contractID: s.contractID,
tokenID: collection.NewFTID("00bab10c"),
Expand Down