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

refactor(x/ecocredit): reduce event fields and duplication #1086

Merged
merged 12 commits into from
May 6, 2022

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented May 4, 2022

Description

Closes: #1035

Removes unnecessary and redundant event fields. Also applies consistent use of present tense event names.

For basket EventCreate

  • Deprecating curator because we can look up the curator with the basket denom and the creator of the basket is always assigned as the curator

For basket EventPut

  • Deprecating credits because core EventTransfer (previously EventReceive) is emitted providing information about the sender, receiver, and credits transferred.

  • Deprecating amount because sdk coinbase is triggered providing information about the denom and amount minted and sdk transfer event provides information about sender, receiver, and coins transferred.

For basket EventTake

  • Deprecating credits because core EventTransfer (previously EventReceive) is emitted providing information about the sender, receiver, and credits transferred.

  • Deprecating amount because sdk burn event is emitted providing information about the denom and amount burned and sdk transfer event provides information about sender, receiver, and coins transferred.

For core EventReceive

  • Renamed to EventTransfer
  • Updated sender and receiver to module address
  • Removed basket_denom because the sender will be the module address in this case

For update events in general

  • Removed all fields except for the unique identifier used to look up the item that was updated

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 May 4, 2022

Codecov Report

Merging #1086 (e6a5fa1) into master (4af5dbb) will decrease coverage by 0.09%.
The diff coverage is 89.23%.

@@            Coverage Diff             @@
##           master    #1086      +/-   ##
==========================================
- Coverage   67.98%   67.89%   -0.10%     
==========================================
  Files         210      209       -1     
  Lines       20949    20929      -20     
==========================================
- Hits        14242    14209      -33     
- Misses       5387     5398      +11     
- Partials     1320     1322       +2     
Flag Coverage Δ
experimental-codecov 67.89% <89.23%> (-0.03%) ⬇️
stable-codecov ?

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

@ryanchristo ryanchristo marked this pull request as ready for review May 5, 2022 02:02
proto/regen/ecocredit/v1/events.proto Outdated Show resolved Hide resolved
OriginTx origin_tx = 2;
// issuer is the account address of the issuer of the credit batch that has
// minted credits to the credit batch.
string issuer = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

MintBatchCredits asserts that req.Issuer == batch.Issuer. if this is the intended functionality, i think we can remove issuer from this event. otherwise if accounts that != original issuer address should be able to mint, we should open a new issue to resolve that discrepancy

Copy link
Member Author

Choose a reason for hiding this comment

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

Only the original issuer should be able to mint and it looks like it is implemented correctly. Removed here and also removed in CreateBatch. Was thinking something different at the time but not needed. 👍 67b3232

x/ecocredit/server/core/keeper_test.go Outdated Show resolved Hide resolved
x/ecocredit/server/core/mint_batch_credits.go Outdated Show resolved Hide resolved
x/ecocredit/server/basket/keeper_test.go Outdated Show resolved Hide resolved
x/ecocredit/server/core/keeper_test.go Outdated Show resolved Hide resolved
x/ecocredit/server/invariants_test.go Outdated Show resolved Hide resolved
ryanchristo and others added 3 commits May 5, 2022 16:16
@@ -326,7 +326,7 @@ devdoc-update:
### Protobuf ###
###############################################################################

containerProtoVer=v0.6
containerProtoVer=v0.7
Copy link
Member Author

Choose a reason for hiding this comment

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

v0.7 required for go 1.18.

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

lgtm, just one sneaky json file leftover 😄

proposal.json Outdated Show resolved Hide resolved
Copy link
Contributor

@aleem1314 aleem1314 left a comment

Choose a reason for hiding this comment

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

lgtm

@ryanchristo ryanchristo enabled auto-merge (squash) May 6, 2022 20:48
@ryanchristo ryanchristo merged commit 5111e3c into master May 6, 2022
@ryanchristo ryanchristo deleted the ryan/1035-refactor-events branch May 6, 2022 21:08
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.

Remove unnecessary fields from events
3 participants