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: improve x/rewards codebase and tests #94

Merged
merged 4 commits into from
Aug 27, 2024

Conversation

RiccardoM
Copy link
Contributor

@RiccardoM RiccardoM commented Aug 27, 2024

Description

This PR improves a bit the codebase of x/rewards by adding missing comments as well as adding tests and improving existing ones.


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)

@RiccardoM RiccardoM merged commit 411915e into main Aug 27, 2024
25 checks passed
@RiccardoM RiccardoM deleted the riccardom/improve-rewards branch August 27, 2024 16:47
Comment on lines +67 to +74
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeCreateRewardsPlan,
sdk.NewAttribute(types.AttributeKeyRewardsPlanID, fmt.Sprint(plan.ID)),
sdk.NewAttribute(servicestypes.AttributeKeyServiceID, fmt.Sprint(msg.ServiceID)),
),
})

Copy link
Contributor

Choose a reason for hiding this comment

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

@RiccardoM Why did you move this event emission to here?

Copy link
Contributor Author

@RiccardoM RiccardoM Aug 29, 2024

Choose a reason for hiding this comment

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

It's because this event should only be emitted when a message to create a plan is created, like all other message handlers. We should emit events inside the Keeper only if one method is called by multiple parties and we are interested in that event because of different reasons. This was not the case, and thus I have moved it inside the msg_server to have the same structure as other message handlers.

Also, by emitting events inside the msg_server rather than the keeper, it's easier to quickly identify whether some events are missing or not. This was actually the case for another handler that was not emitting any event.

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.

2 participants