Skip to content

Commit

Permalink
fix: use resp.Events to parse events instead of logs (cosmos#1271)
Browse files Browse the repository at this point in the history
* fix: use resp.Events to parse events instead of logs

* revert: use legacy behaviour as fallback mechanism

* refactor: use legacy approach first, fallback onto new parsing approach

---------

Co-authored-by: Justin Tieri <37750742+jtieri@users.noreply.github.com>
  • Loading branch information
colin-axner and jtieri authored Sep 5, 2023
1 parent dcd6d37 commit 2fadd37
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions relayer/chains/cosmos/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,22 @@ func parseEventsFromTxResponse(resp *sdk.TxResponse) []provider.RelayerEvent {
})
}
}

// After SDK v0.50, indexed events are no longer provided in the logs on
// transaction execution, the response events can be directly used
if len(events) == 0 {
for _, event := range resp.Events {
attributes := make(map[string]string)
for _, attribute := range event.Attributes {
attributes[attribute.Key] = attribute.Value
}
events = append(events, provider.RelayerEvent{
EventType: event.Type,
Attributes: attributes,
})
}
}

return events
}

Expand Down

0 comments on commit 2fadd37

Please sign in to comment.