Skip to content

Commit

Permalink
fix: get network name form evm networks too (#2679)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-obrien authored Jun 28, 2024
1 parent 9358ca2 commit ad1adc2
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import { DEFAULT_ISC_CHAINS_CONFIGURATIONS } from '../constants'
import {
DEFAULT_EVM_NETWORK_CONFIGURATIONS_FOR_STARDUST_NETWORK,
DEFAULT_ISC_CHAINS_CONFIGURATIONS,
} from '../constants'
import { getNetwork } from '../stores'
import { NetworkId } from '../types'

export function getNameFromNetworkId(networkId: NetworkId): string | undefined {
const networkName = getNetwork(networkId)?.name
if (networkName) {
return networkName
const knownNetworkName = getNetwork(networkId)?.name
if (knownNetworkName) {
return knownNetworkName
}

return Object.values(DEFAULT_ISC_CHAINS_CONFIGURATIONS).find((config) => config?.id === networkId)?.name
const potentialIscChainName = Object.values(DEFAULT_ISC_CHAINS_CONFIGURATIONS).find(
(config) => config?.id === networkId
)?.name

if (potentialIscChainName) {
return potentialIscChainName
}

const potentialEvmChainName = Object.values(DEFAULT_EVM_NETWORK_CONFIGURATIONS_FOR_STARDUST_NETWORK)
.flat()
.find((config) => config?.id === networkId)?.name

return potentialEvmChainName
}

0 comments on commit ad1adc2

Please sign in to comment.