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!: Record retirement location for ecocredit module (#328) #384

Merged
merged 9 commits into from
Jul 6, 2021

Conversation

ruhatch
Copy link
Contributor

@ruhatch ruhatch commented Jun 15, 2021

Description

Closes: #328

This PR introduces retirement locations for ecocredits. The retirement location is the location of the beneficiary or buyer of the retired credits. It is a string of the form <country-code>[-<sub-national-code>[-<postal-code>]], with the first two fields conforming to the ISO 3166-2 standard. The location is emitted during retirement events and can therefore be tracked by an indexer.


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)

@ruhatch ruhatch requested a review from a team June 15, 2021 14:47
@codecov
Copy link

codecov bot commented Jun 15, 2021

Codecov Report

Merging #384 (21e4ac3) into master (13c18cf) will decrease coverage by 1.22%.
The diff coverage is 36.66%.

@@            Coverage Diff             @@
##           master     #384      +/-   ##
==========================================
- Coverage   61.08%   59.85%   -1.23%     
==========================================
  Files          51       56       +5     
  Lines        3325     3403      +78     
==========================================
+ Hits         2031     2037       +6     
- Misses       1030     1102      +72     
  Partials      264      264              
Flag Coverage Δ
experimental-codecov 59.85% <36.66%> (-1.23%) ⬇️
stable-codecov 59.85% <36.66%> (-1.23%) ⬇️

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

@ruhatch ruhatch force-pushed the ruhatch/retirement-location branch from f74b52e to 7780fc6 Compare June 16, 2021 11:58
@ruhatch ruhatch enabled auto-merge (squash) June 16, 2021 12:11
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

Nice work, lgtm overall. I'm just not 100% certain we can use the github.com/TheBookPeople/iso3166 library

proto/regen/ecocredit/v1alpha1/events.proto Outdated Show resolved Hide resolved
x/ecocredit/server/msg_server.go Outdated Show resolved Hide resolved
x/ecocredit/server/testsuite/suite.go Show resolved Hide resolved
@ruhatch ruhatch requested review from clevinson and blushi June 17, 2021 10:02
Copy link
Member

@blushi blushi 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 overall, see small comments and follow-up on the ISO 3166 validation.

proto/regen/ecocredit/v1alpha1/events.proto Outdated Show resolved Hide resolved
x/ecocredit/server/msg_server.go Outdated Show resolved Hide resolved
x/ecocredit/server/msg_server.go Outdated Show resolved Hide resolved
x/ecocredit/server/msg_server.go Outdated Show resolved Hide resolved
x/ecocredit/server/msg_server.go Outdated Show resolved Hide resolved
proto/regen/ecocredit/v1alpha1/tx.proto Show resolved Hide resolved
x/ecocredit/server/location_test.go Outdated Show resolved Hide resolved
x/ecocredit/server/location.go Outdated Show resolved Hide resolved
x/ecocredit/server/location.go Outdated Show resolved Hide resolved
@ruhatch ruhatch disabled auto-merge June 18, 2021 09:23
@ruhatch
Copy link
Contributor Author

ruhatch commented Jun 18, 2021

Also need to add client/tx for locations

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Let's also add the location validation logic to the Msg.ValidateBasic methods

@ruhatch ruhatch force-pushed the ruhatch/retirement-location branch from d93d6bb to 8a03ae6 Compare June 29, 2021 19:20
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

A few small comments, but pre-approving. Thanks @ruhatch !

x/ecocredit/location_test.go Outdated Show resolved Hide resolved
x/ecocredit/location_test.go Outdated Show resolved Hide resolved
x/ecocredit/location_test.go Outdated Show resolved Hide resolved
proto/regen/ecocredit/v1alpha1/tx.proto Outdated Show resolved Hide resolved
if err != nil {
return err
}

if !retiredUnits.IsZero() {
err = validateLocation(iss.RetirementLocation)
Copy link
Member

Choose a reason for hiding this comment

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

@blushi @clevinson do we always require a valid location? Could someone retire credits without providing a location theoretically?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, this should be required as long as credits get retired

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blushi is it worth a final check with Ron?

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

nice! lgtm

@ruhatch ruhatch merged commit 81f1347 into master Jul 6, 2021
@ruhatch ruhatch deleted the ruhatch/retirement-location branch July 6, 2021 14:11
@clevinson clevinson mentioned this pull request Jul 27, 2021
7 tasks
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.

Record retirement location for ecocredit module
5 participants