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

feat(x/ecocredit): query all credit balances based on address #942

Merged
merged 8 commits into from
Mar 29, 2022

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Mar 25, 2022

Description

  • adds a query to get all credit balances of an address
  • changes the response type of the existing balance query to use BatchBalance from state.proto

ref: #167


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Mar 25, 2022

Codecov Report

Merging #942 (493247f) into master (a8b3e14) will increase coverage by 0.02%.
The diff coverage is 56.25%.

❗ Current head 493247f differs from pull request most recent head 0852978. Consider uploading reports for the commit 0852978 to get more accurate results

@@            Coverage Diff             @@
##           master     #942      +/-   ##
==========================================
+ Coverage   73.16%   73.18%   +0.02%     
==========================================
  Files         196      197       +1     
  Lines       23153    23144       -9     
==========================================
- Hits        16939    16938       -1     
+ Misses       4932     4923       -9     
- Partials     1282     1283       +1     
Flag Coverage Δ
experimental-codecov 73.06% <56.25%> (+<0.01%) ⬆️
stable-codecov 68.02% <56.25%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ryanchristo ryanchristo changed the title feat: query balances feat(x/ecocredit): query all credit balances based on address Mar 27, 2022
Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. A couple minor suggestions.

proto/regen/ecocredit/v1/query.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/v1/query.proto Outdated Show resolved Hide resolved
x/ecocredit/server/core/query_balances_test.go Outdated Show resolved Hide resolved
technicallyty and others added 3 commits March 28, 2022 12:05
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I thought we wanted to do separate PR with proto only ;)

return nil, err
}

pg, err := ormutil.GogoPageReqToPulsarPageReq(req.Pagination)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly related to this PR, I think this function name should have "Slow" suffix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense - it does call another slow method under the hood

return nil, err
}

balances := make([]*core.BatchBalance, 0, 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why starting with cap = 10?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking it might be good to add some arbitrary cap to avoid slice allocations. would you advise a smaller/bigger number or just not at all? maybe we could add a default constant if we want to define a capacity?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea what would be the most common one, that's why I asked ;) Maybe let's decrease to 8 and add a comment?
By default, go will double the capacity if it needs.

@technicallyty technicallyty enabled auto-merge (squash) March 29, 2022 19:37
@technicallyty technicallyty merged commit c086596 into master Mar 29, 2022
@technicallyty technicallyty deleted the ty/167-credit_balances branch March 29, 2022 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants