Let parseRawLog gracefully handle empty strings

This commit is contained in:
Simon Warta 2024-03-08 12:26:53 +01:00
parent 188bb1ff3f
commit 874612b0df
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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,