diff --git a/CHANGELOG.md b/CHANGELOG.md index 115746a460..58bf9b3e3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v1.0.1 +This release includes 1 bug fix. + +* [#338](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/338) fix: count total when pagination request is empty + ## v1.0.0 This release includes 2 new features. diff --git a/types/query/pagination.go b/types/query/pagination.go index de984dd2f8..bef2cd6575 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -81,9 +81,8 @@ func Paginate( if limit == 0 { limit = DefaultLimit - - // count total results when the limit is zero/not supplied - countTotal = true + // do not count total results when the limit is zero/not supplied + // countTotal = true } else if limit > DefaultLimit { // limit to protect the node would not be Query DoS limit = DefaultLimit diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index 4228b0cde9..a8119361d1 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -122,7 +122,8 @@ func (s *paginationTestSuite) TestPagination() { request := types.NewQueryAllBalancesRequest(addr1, pageReq) res, err := queryClient.AllBalances(gocontext.Background(), request) s.Require().NoError(err) - s.Require().Equal(res.Pagination.Total, uint64(numBalances)) + // default page request will not return total count + // s.Require().Equal(res.Pagination.Total, uint64(numBalances)) s.Require().NotNil(res.Pagination.NextKey) s.Require().LessOrEqual(res.Balances.Len(), defaultLimit)