Skip to content

Commit

Permalink
Let parseRawLog gracefully handle empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Mar 8, 2024
1 parent 188bb1f commit 874612b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ and this project adheres to
import { parseCoins } from "@cosmjs/amino";
```

- @cosmjs/stargate: Let `parseRawLog` gracefully handle empty strings to better
support Cosmos SDK 0.50 inputs. ([#1564])

[#1564]: https://github.com/cosmos/cosmjs/pull/1564

### Fixed

- @cosmjs/encoding: Avoid using replacement character in doc comment to make
Expand Down
5 changes: 4 additions & 1 deletion packages/stargate/src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export function parseLogs(input: unknown): readonly Log[] {
return input.map(parseLog);
}

export function parseRawLog(input = "[]"): readonly Log[] {
export function parseRawLog(input: string | undefined): readonly Log[] {
// Cosmos SDK >= 0.50 gives us an empty string here. This should be handled like undefined.
if (!input) return [];

const logsToParse = JSON.parse(input).map(({ events }: { events: readonly unknown[] }, i: number) => ({
msg_index: i,
events,
Expand Down

0 comments on commit 874612b

Please sign in to comment.