diff --git a/CHANGELOG.md b/CHANGELOG.md index 966b9c28e2..22fe5b5f7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/foundation) [\#922](https://github.com/line/lbm-sdk/pull/922) Propagate events in x/foundation through sdk.Results * (x/foundation) [\#946](https://github.com/line/lbm-sdk/pull/946) Fix broken x/foundation invariant on treasury * (x/foundation) [\#947](https://github.com/line/lbm-sdk/pull/947) Unpack proposals in x/foundation import-genesis +* (x/collection) [\#953](https://github.com/line/lbm-sdk/pull/953) Allow zero amount of coin in x/collection Query/Balance ### Removed diff --git a/x/collection/keeper/grpc_query.go b/x/collection/keeper/grpc_query.go index 75d8f22de4..ec308776c5 100644 --- a/x/collection/keeper/grpc_query.go +++ b/x/collection/keeper/grpc_query.go @@ -51,7 +51,10 @@ func (s queryServer) Balance(c context.Context, req *collection.QueryBalanceRequ ctx := sdk.UnwrapSDKContext(c) balance := s.keeper.GetBalance(ctx, req.ContractId, addr, req.TokenId) - coin := collection.NewCoin(req.TokenId, balance) + coin := collection.Coin{ + TokenId: req.TokenId, + Amount: balance, + } return &collection.QueryBalanceResponse{Balance: coin}, nil } diff --git a/x/collection/keeper/grpc_query_test.go b/x/collection/keeper/grpc_query_test.go index b7bf82913c..363abafa77 100644 --- a/x/collection/keeper/grpc_query_test.go +++ b/x/collection/keeper/grpc_query_test.go @@ -27,7 +27,23 @@ func (s *KeeperTestSuite) TestQueryBalance() { tokenID: tokenID, valid: true, postTest: func(res *collection.QueryBalanceResponse) { - expected := collection.NewCoin(tokenID, s.balance) + expected := collection.Coin{ + TokenId: tokenID, + Amount: s.balance, + } + s.Require().Equal(expected, res.Balance) + }, + }, + "valid request with zero amount": { + contractID: s.contractID, + address: s.vendor, + tokenID: "deadbeefdeadbeef", + valid: true, + postTest: func(res *collection.QueryBalanceResponse) { + expected := collection.Coin{ + TokenId: "deadbeefdeadbeef", + Amount: sdk.ZeroInt(), + } s.Require().Equal(expected, res.Balance) }, },