-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
init: Implement ADR 032 typed events #7564
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7564 +/- ##
==========================================
+ Coverage 54.11% 54.12% +0.01%
==========================================
Files 611 611
Lines 38571 38620 +49
==========================================
+ Hits 20871 20902 +31
- Misses 15573 15582 +9
- Partials 2127 2136 +9 |
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 implementation looks good to me overall, would like to see an Any
test.
types/events_test.go
Outdated
coin2 := sdk.NewCoin("fakedenom2", sdk.NewInt(1999999)) | ||
|
||
s.Require().NoError(em.EmitTypedEvents(&coin1)) | ||
s.Require().NoError(em.EmitTypedEvent(&coin2)) |
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.
This didn't cross my mind while reading the ADR, but does now. It seems weird that we can send an event that is a Coin.
Maybe we should create some convention, like the type name should be Event...
or Msg...Response
? (can be for another PR of course)
// TypedEventToEvent takes typed event and converts to Event object | ||
func TypedEventToEvent(tev proto.Message) (Event, error) { | ||
evtType := proto.MessageName(tev) | ||
evtJSON, err := codec.ProtoMarshalJSON(tev, nil) |
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 that the nil
argument won't work if tev
contains an Any
... or maybe it will. Just to be sure, would you mind adding a test with Any
in TestEventManagerTypedEvents
?
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.
Looks good, great work @akhilkumarpilli
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.
utACK, nice!
* Add EmitTypedEvent in events * Add parseTypedEvent method * Use jsonpb * Modify unmarshal proto in events * Add a test for typed events * Fix reflect issue in parseTypedEvent * Modify event tests and add comments * Add EmitTypedEvents and refactor other methods * Fix golangci-lint issues * Update ProtoMarshalJSON params * Address PR comments Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Description
Implement
EmitTypedEvent
,EmitTypedEvents
andParseTypedEvent
functions.ref: #7563
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes