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

fix: refactor queries of x/collection and x/token #957

Merged
merged 11 commits into from
Apr 13, 2023
Prev Previous commit
Next Next commit
Revert "Do not check existence of collection in Query/Balance"
This reverts commit 029c26a.
  • Loading branch information
0Tech committed Apr 12, 2023
commit a9a433206b9b55d79249614ba943c3180efd6798
4 changes: 4 additions & 0 deletions x/collection/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (s queryServer) Balance(c context.Context, req *collection.QueryBalanceRequ
return nil, err
}

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

balance := s.keeper.GetBalance(ctx, req.ContractId, addr, req.TokenId)
coin := collection.Coin{
TokenId: req.TokenId,
Expand Down
5 changes: 5 additions & 0 deletions x/collection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func (s *KeeperTestSuite) TestQueryBalance() {
address: sdk.AccAddress("notfound"),
tokenID: tokenID,
},
"collection not found": {
contractID: "deadbeef",
address: s.vendor,
tokenID: tokenID,
},
}

for name, tc := range testCases {
Expand Down