Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
change switch to if/else statements
Browse files Browse the repository at this point in the history
  • Loading branch information
nuo-xu committed May 1, 2023
1 parent 43b3992 commit fcaf57b
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions Sources/BraveWallet/Extensions/BraveWalletSwiftUIExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,27 @@ extension BraveWallet.NetworkInfo: Identifiable {
}

private func assetIconNameByChainId(_ chainId: String) -> String? {
switch chainId.uppercased() {
case
BraveWallet.MainnetChainId.uppercased(),
BraveWallet.GoerliChainId.uppercased(),
BraveWallet.SepoliaChainId.uppercased():
if chainId.caseInsensitiveCompare(BraveWallet.MainnetChainId) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.GoerliChainId) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.SepoliaChainId) == .orderedSame {
return AssetImageName.ethereum.rawValue
case
BraveWallet.SolanaMainnet.uppercased(),
BraveWallet.SolanaDevnet.uppercased(),
BraveWallet.SolanaTestnet.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.SolanaMainnet) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.SolanaDevnet) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.SolanaTestnet) == .orderedSame {
return AssetImageName.solana.rawValue
case
BraveWallet.FilecoinMainnet.uppercased(),
BraveWallet.FilecoinTestnet.uppercased(),
BraveWallet.FilecoinEthereumMainnetChainId.uppercased(),
BraveWallet.FilecoinEthereumTestnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.FilecoinMainnet) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.FilecoinTestnet) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.FilecoinEthereumMainnetChainId) == .orderedSame || chainId.caseInsensitiveCompare(BraveWallet.FilecoinEthereumTestnetChainId) == .orderedSame {
return AssetImageName.filecoin.rawValue
case BraveWallet.PolygonMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.PolygonMainnetChainId) == .orderedSame {
return AssetImageName.polygon.rawValue
case BraveWallet.BinanceSmartChainMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.BinanceSmartChainMainnetChainId) == .orderedSame {
return AssetImageName.binance.rawValue
case BraveWallet.CeloMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.CeloMainnetChainId) == .orderedSame {
return AssetImageName.celo.rawValue
case BraveWallet.AvalancheMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.AvalancheMainnetChainId) == .orderedSame {
return AssetImageName.avalanche.rawValue
case BraveWallet.FantomMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.FantomMainnetChainId) == .orderedSame {
return AssetImageName.fantom.rawValue
case BraveWallet.AuroraMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.AuroraMainnetChainId) == .orderedSame {
return AssetImageName.aurora.rawValue
case BraveWallet.OptimismMainnetChainId.uppercased():
} else if chainId.caseInsensitiveCompare(BraveWallet.OptimismMainnetChainId) == .orderedSame {
return AssetImageName.optimism.rawValue
default:
} else {
return nil
}
}
Expand Down

0 comments on commit fcaf57b

Please sign in to comment.