Skip to content

Commit

Permalink
indexer-common: replace usage of in for undefined check
Browse files Browse the repository at this point in the history
A property may be present in an object but have value undefined.
Therefore, x in obj is not the same as obj.x === undefined.
  • Loading branch information
tilacog committed Dec 8, 2022
1 parent ced81d3 commit 22ce0b9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/indexer-common/src/indexer-management/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down

0 comments on commit 22ce0b9

Please sign in to comment.