-
Notifications
You must be signed in to change notification settings - Fork 4
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: parse events instead of messages #395
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
6512d5c
to
fbc371b
Compare
@@ -22,39 +18,12 @@ func (m *Module) HandleMsgExec(index int, _ *authz.MsgExec, _ int, executedMsg s | |||
} | |||
|
|||
// 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IBC messages should be able to replace to event handler since these operation also emit events.
See:
https://github.com/desmos-labs/desmos/blob/master/x/profiles/ibc_module.go#L242
https://github.com/desmos-labs/desmos/blob/master/x/profiles/ibc_module.go#L273
https://github.com/desmos-labs/desmos/blob/master/x/profiles/ibc_module.go#L316
https://github.com/desmos-labs/desmos/blob/master/x/profiles/ibc_module.go#L365
@@ -11,7 +11,7 @@ import ( | |||
) | |||
|
|||
// 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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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) | ||
} |
There was a problem hiding this comment.
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?
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) |
There was a problem hiding this comment.
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?
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change