Skip to content

Commit

Permalink
Merge branch 'rc/v0.47.0-alpha1' into collection-query-parent
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech authored Apr 7, 2023
2 parents 98dd340 + 15314e4 commit d18d6bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* (x/collection) [\#955](https://github.com/line/lbm-sdk/pull/955) Return nil where the parent not exists in x/collection Query/Parent

### Removed
Expand Down
5 changes: 4 additions & 1 deletion x/collection/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 17 additions & 1 deletion x/collection/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand Down

0 comments on commit d18d6bb

Please sign in to comment.