Skip to content

Commit 2bdff0a

Browse files
committed
common: return first chain alias if multiples, prefer non -mainnet suffix
1 parent 41e6c2c commit 2bdff0a

File tree

1 file changed

+8
-3
lines changed
  • packages/indexer-common/src/indexer-management

1 file changed

+8
-3
lines changed

packages/indexer-common/src/indexer-management/types.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,14 @@ export function resolveChainAlias(id: string): string {
304304
`Failed to match chain id, '${id}', to a network alias in Caip2ByChainAlias`,
305305
)
306306
} else {
307-
throw new Error(
308-
`Something has gone wrong, chain id, '${id}', matched more than one network alias in Caip2ByChainAlias`,
309-
)
307+
// Theres' more than one chain alias, now that we use the registry there could be multiple
308+
// prefer the alias that does not have -mainnet suffix
309+
const aliasWithoutSuffix = aliasMatches.find((name) => !name.endsWith('-mainnet'))
310+
if (aliasWithoutSuffix) {
311+
return aliasWithoutSuffix
312+
}
313+
// if we don't have an alias without suffix, then we have to return the first one
314+
return aliasMatches[0]
310315
}
311316
}
312317

0 commit comments

Comments
 (0)