Skip to content

Commit

Permalink
Merge pull request #277 from neutron-org/chore/keep_dex_message_evts
Browse files Browse the repository at this point in the history
Chore: keep dex message evts [NTRN-439]
  • Loading branch information
pr0n00gler authored Jan 22, 2025
2 parents ca66127 + 5435721 commit 8ab684b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion x/wasm/keeper/msg_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,23 @@ func isIBCEvent(event sdk.Event) bool {
return false
}

func isDexEvent(event sdk.Event) bool {
for _, attr := range event.Attributes {
// Indexing of dex events requires that all dev events are emitted
if attr.Key == sdk.AttributeKeyModule && attr.Value == "dex" {
return true
}
}
return false
}

func filterEvents(events []sdk.Event) []sdk.Event {
// pre-allocate space for efficiency
res := make([]sdk.Event, 0, len(events))
for _, ev := range events {
// we filter out all 'message' type events but if they are ibc events we must keep them for the IBC relayer (hermes particularly)
if ev.Type != "message" || isIBCEvent(ev) {
// we also keep dex events, this is required for proper indexing of dex messages
if ev.Type != "message" || isIBCEvent(ev) || isDexEvent(ev) {
res = append(res, ev)
}
}
Expand Down
2 changes: 2 additions & 0 deletions x/wasm/keeper/msg_dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ func TestDispatchSubmessages(t *testing.T) {
// we still emit this to the client, but not the contract
sdk.NewEvent("non-determinstic"),
sdk.NewEvent("message", sdk.NewAttribute("module", "ibc_channel")),
sdk.NewEvent("message", sdk.NewAttribute("module", "dex")),
}
return events, [][]byte{[]byte("subData")}, [][]*codectypes.Any{}, nil
},
Expand All @@ -413,6 +414,7 @@ func TestDispatchSubmessages(t *testing.T) {
expEvents: []sdk.Event{
sdk.NewEvent("non-determinstic"),
sdk.NewEvent("message", sdk.NewAttribute("module", "ibc_channel")),
sdk.NewEvent("message", sdk.NewAttribute("module", "dex")),
// the event from reply is also exposed
sdk.NewEvent("stargate-reply"),
},
Expand Down

0 comments on commit 8ab684b

Please sign in to comment.