Skip to content

Commit

Permalink
Fix event unflattening with authz msg index addition (#52)
Browse files Browse the repository at this point in the history
* fix event parsing with new authz_msg_index key additions for messages
executed via authz

* update changelog, docker version targets
  • Loading branch information
nddeluca authored Oct 26, 2022
1 parent 277786a commit f5ccf3e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.6] - 2022-10-26

### Changed

- Fixed panic when parsing events modified through authz execution

## [2.0.5] - 2022-10-25

### Changed
Expand Down Expand Up @@ -72,8 +78,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Removed support for zero fee transactions

[Unreleased]: https://github.com/kava-labs/rosetta-kava/compare/v2.0.5...HEAD
[Unreleased]: https://github.com/kava-labs/rosetta-kava/compare/v2.0.6...HEAD

[2.0.6]: https://github.com/kava-labs/rosetta-kava/compare/v2.0.5...v2.0.6
[2.0.5]: https://github.com/kava-labs/rosetta-kava/compare/v2.0.2...v2.0.5
[2.0.2]: https://github.com/kava-labs/rosetta-kava/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/kava-labs/rosetta-kava/compare/v2.0.0...v2.0.1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN cd kava \
&& mkdir -p /app/cosmovisor/upgrades/v0.19.0/bin \
&& mv /go/bin/kava /app/cosmovisor/upgrades/v0.19.0/bin

ARG kava_rosetta_version=v2.0.5
ARG kava_rosetta_version=v2.0.6
ENV KAVA_ROSETTA_VERSION=$kava_rosetta_version

RUN git clone https://github.com/Kava-Labs/rosetta-kava.git \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ RUN cd kava \
&& mkdir -p /app/cosmovisor/upgrades/v0.19.5-testnet/bin \
&& mv /go/bin/kava /app/cosmovisor/upgrades/v0.19.5-testnet/bin

ARG kava_rosetta_version=v2.0.4-testnet
ARG kava_rosetta_version=v2.0.6
ENV KAVA_ROSETTA_VERSION=$kava_rosetta_version

RUN git clone https://github.com/Kava-Labs/rosetta-kava.git \
Expand Down
20 changes: 16 additions & 4 deletions kava/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,25 @@ func msgMultiSendToTransferOperations(msg *banktypes.MsgMultiSend, status *strin
}

func unflattenEvents(ev sdk.StringEvent, eventType string, numAttributes int) (events sdk.StringEvents) {
if len(ev.Attributes)%numAttributes != 0 {
panic(fmt.Sprintf("unexpected number of attributes in transfer event %s", ev.Attributes))
// drop authz_msg_index additions
attributes := []sdk.Attribute{}
for _, attribute := range ev.Attributes {
// remove authz_msg_index attributes
if attribute.Key == "authz_msg_index" {
continue
}

attributes = append(attributes, attribute)
}
numberOfEvents := len(ev.Attributes) / numAttributes

if len(attributes)%numAttributes != 0 {
panic(fmt.Sprintf("unexpected number of attributes in transfer event %s", attributes))
}

numberOfEvents := len(attributes) / numAttributes
for i := 0; i < numberOfEvents; i++ {
startingIndex := i * numAttributes
event := sdk.NewEvent(eventType, ev.Attributes[startingIndex:startingIndex+numAttributes]...)
event := sdk.NewEvent(eventType, attributes[startingIndex:startingIndex+numAttributes]...)
events = append(events, sdk.StringifyEvent(abci.Event(event)))
}
return events
Expand Down

0 comments on commit f5ccf3e

Please sign in to comment.