Skip to content

Conversation

@RiccardoM
Copy link
Contributor

@RiccardoM RiccardoM commented Jan 23, 2024

Description

This PR completely changes how the various data are parsed by relying on events instead of messages. This ensures that custom smart contracts also get their data parsed properly.


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
  • provided a link to the relevant issue or specification
  • 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 API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@3d144db). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #395   +/-   ##
=======================================
  Coverage        ?   17.96%           
=======================================
  Files           ?       14           
  Lines           ?     1286           
  Branches        ?        0           
=======================================
  Hits            ?      231           
  Misses          ?     1040           
  Partials        ?       15           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RiccardoM RiccardoM requested a review from dadamu January 23, 2024 08:00
@RiccardoM RiccardoM force-pushed the riccardom/parse-events-instead-of-messages branch from 6512d5c to fbc371b Compare January 23, 2024 08:06

// HandleMsg implements modules.MessageModule
func (m *Module) HandleMsg(index int, msg sdk.Msg, tx *juno.Tx) error {
func (m *Module) HandleMsg(_ int, msg sdk.Msg, tx *juno.Tx) error {
Copy link
Contributor

Choose a reason for hiding this comment

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


// HandleMsg implements modules.MessageModule
func (m *Module) HandleMsg(index int, msg sdk.Msg, tx *juno.Tx) error {
func (m *Module) HandleMsg(_ int, msg sdk.Msg, tx *juno.Tx) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

// --------------------------------------------------------------------------------------------------------------------

// parseCreateRelationshipEvent allows to properly handle a relationship creation event
func (m *Module) parseCreateRelationshipEvent(tx *juno.Tx, event abci.Event) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to have name handle{EventName}event for all parse{EventName}Event like what subspaces does.

Comment on lines +247 to +258
func (m *Module) handleSetUserPermissionsEvent(tx *juno.Tx, event abci.Event) error {
subspaceID, err := GetSubspaceIDFromEvent(event)
if err != nil {
return err
}
user, err := GetUserFromEvent(event)
if err != nil {
return err
}

return m.updateUserPermissions(tx.Height, subspaceID, user)
}
Copy link
Contributor

@dadamu dadamu Jan 24, 2024

Choose a reason for hiding this comment

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

I think it would be better to add section_id attribute to Desmos core in the future so it can query by UserPermissions directly rather than updating all the sections permissions.. What do you think?

Comment on lines +143 to +159
func (m *Module) parseAnswerPollEvent(tx *juno.Tx, event abci.Event) error {
subspaceID, err := events.GetSubspaceIDFromEvent(event)
if err != nil {
return err
}

postID, err := GetPostIDFromEvent(event)
if err != nil {
return err
}

pollID, err := GetPollIDFromEvent(event)
if err != nil {
return err
}

return m.updatePollAnswers(tx.Height, subspaceID, postID, pollID)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to add answer_indexes and answerer attribute to Desmos core in the future so it can be updated directly rather than updating all the poll answers. What do you think?

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