From 22ce0b965b1f4add86bbaf456d4a6dfb93c1f7c6 Mon Sep 17 00:00:00 2001 From: tilacog Date: Thu, 8 Dec 2022 12:51:47 -0300 Subject: [PATCH] indexer-common: replace usage of `in` for `undefined` check A property may be present in an object but have value undefined. Therefore, x in obj is not the same as obj.x === undefined. --- .../indexer-common/src/indexer-management/types.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/indexer-common/src/indexer-management/types.ts b/packages/indexer-common/src/indexer-management/types.ts index c61a417c1..c498cf230 100644 --- a/packages/indexer-common/src/indexer-management/types.ts +++ b/packages/indexer-common/src/indexer-management/types.ts @@ -165,12 +165,14 @@ const Caip2ByChainId: { [key: number]: string } = { /// or chain ids (numbers). export function resolveChainId(key: number | string): string { if (typeof key === 'number') { - if (key in Caip2ByChainId) { - return Caip2ByChainId[key] + const chainId = Caip2ByChainId[key] + if (chainId !== undefined) { + return chainId } } else { - if (key in Caip2ByChainAlias) { - return Caip2ByChainAlias[key] + const chainId = Caip2ByChainAlias[key] + if (chainId !== undefined) { + return chainId } } throw new Error(`Failed to resolve CAIP2 ID from the provided network alias: ${key}`)