From 53c0bd4878ee98098c005c66c0ac737443dc55e3 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Mon, 22 Jan 2024 13:11:18 +0700 Subject: [PATCH] tm37 and cm38 --- packages/tendermint-rpc/src/comet38/encodings.ts | 6 +++++- packages/tendermint-rpc/src/tendermint37/encodings.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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 {