Skip to content

Commit 79cdf2d

Browse files
authored
chore: provide specific error messages on x/collection queries (#965)
* Provide better error message * Update CHANGELOG.md
1 parent f656c7a commit 79cdf2d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4646
* (x/collection) [\#938](https://github.com/line/lbm-sdk/pull/938) Add progress log into x/collection import-genesis
4747
* (x/foundation) [\#952](https://github.com/line/lbm-sdk/pull/952) Address generation of the empty coins in x/foundation
4848
* (x/collection,token,foundation) [\#963](https://github.com/line/lbm-sdk/pull/963) Check event determinism on original modules
49+
* (x/collection) [\#965](https://github.com/line/lbm-sdk/pull/965) Provide specific error messages on x/collection queries
4950

5051
### Bug Fixes
5152
* (swagger) [\#898](https://github.com/line/lbm-sdk/pull/898) fix a bug not added `lbm.tx.v1beta1.Service/GetBlockWithTxs` in swagger

x/collection/keeper/grpc_query.go

+10
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,11 @@ func (s queryServer) TokenType(c context.Context, req *collection.QueryTokenType
379379
}
380380

381381
ctx := sdk.UnwrapSDKContext(c)
382+
383+
if err := s.validateExistenceOfCollectionGRPC(ctx, req.ContractId); err != nil {
384+
return nil, err
385+
}
386+
382387
class, err := s.keeper.GetTokenClass(ctx, req.ContractId, classID)
383388
if err != nil {
384389
return nil, status.Error(codes.NotFound, err.Error())
@@ -454,6 +459,11 @@ func (s queryServer) Token(c context.Context, req *collection.QueryTokenRequest)
454459
}
455460

456461
ctx := sdk.UnwrapSDKContext(c)
462+
463+
if err := s.validateExistenceOfCollectionGRPC(ctx, req.ContractId); err != nil {
464+
return nil, err
465+
}
466+
457467
legacyToken, err := s.getToken(ctx, req.ContractId, req.TokenId)
458468
if err != nil {
459469
return nil, status.Error(codes.NotFound, err.Error())

x/collection/keeper/grpc_query_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,10 @@ func (s *KeeperTestSuite) TestQueryToken() {
681681
"invalid token id": {
682682
contractID: s.contractID,
683683
},
684+
"collection not found": {
685+
contractID: "deadbeef",
686+
tokenID: ftTokenID,
687+
},
684688
"no such a fungible token": {
685689
contractID: s.contractID,
686690
tokenID: collection.NewFTID("00bab10c"),

0 commit comments

Comments
 (0)