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

Chore: keep dex message evts [NTRN-439] #277

Open
wants to merge 2 commits into
base: neutron
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading