diff --git a/packages/tendermint-rpc/src/comet38/encodings.ts b/packages/tendermint-rpc/src/comet38/encodings.ts index 037b506898..9f57713efe 100644 --- a/packages/tendermint-rpc/src/comet38/encodings.ts +++ b/packages/tendermint-rpc/src/comet38/encodings.ts @@ -124,7 +124,11 @@ export function assertNotEmpty(value: T): T { // may will run the transform if value is defined, otherwise returns undefined export function may(transform: (val: T) => U, value: T | null | undefined): U | undefined { - return value === undefined || value === null ? undefined : transform(value); + return value === undefined || + value === null || + (typeof value === "object" && Object.keys(value).length === 0) + ? undefined + : transform(value); } export function dictionaryToStringMap(obj: Record): Map { diff --git a/packages/tendermint-rpc/src/tendermint37/encodings.ts b/packages/tendermint-rpc/src/tendermint37/encodings.ts index 037b506898..9f57713efe 100644 --- a/packages/tendermint-rpc/src/tendermint37/encodings.ts +++ b/packages/tendermint-rpc/src/tendermint37/encodings.ts @@ -124,7 +124,11 @@ export function assertNotEmpty(value: T): T { // may will run the transform if value is defined, otherwise returns undefined export function may(transform: (val: T) => U, value: T | null | undefined): U | undefined { - return value === undefined || value === null ? undefined : transform(value); + return value === undefined || + value === null || + (typeof value === "object" && Object.keys(value).length === 0) + ? undefined + : transform(value); } export function dictionaryToStringMap(obj: Record): Map {