Skip to content

Commit 51ef949

Browse files
committed
Get rid of Network constants
1 parent e43e2b0 commit 51ef949

File tree

33 files changed

+83
-106
lines changed

33 files changed

+83
-106
lines changed

src/app/components/Account/__tests__/ShowMoreTokensLink.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { describe, expect, it } from 'vitest'
22
import { screen } from '@testing-library/react'
33
import { renderWithProviders } from '../../../utils/__tests__/renderWithProviders.test'
4-
import { ShowMoreTokensLink } from './../ShowMoreTokensLink'
5-
import { Layer, EvmTokenType, RuntimeAccount, Token } from '../../../../oasis-nexus/api'
6-
import { Network } from '../../../../types/network'
4+
import { ShowMoreTokensLink } from '../ShowMoreTokensLink'
5+
import { EvmTokenType, RuntimeAccount, Token } from '../../../../oasis-nexus/api'
76

87
const mockedAccount = {
98
address: 'oasis1qrvha284gfztn7wwq6z50c86ceu28jp7csqhpx9t',
109
layer: 'emerald',
11-
network: Network.mainnet,
10+
network: 'mainnet',
1211
} as RuntimeAccount
1312

1413
const mockedToken1: Token = {

src/app/components/AnalyticsConsent/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Link from '@mui/material/Link'
77
import { Trans, useTranslation } from 'react-i18next'
88
import * as matomo from './initializeMatomo'
99
import { ThemeByScope } from '../ThemeByScope'
10-
import { Network } from '../../../types/network'
1110
import { AnalyticsIsBlocked } from './AnalyticsIsBlocked'
1211
import { AnalyticsDialogLayout } from './AnalyticsDialogLayout'
1312

@@ -66,7 +65,7 @@ export const AnalyticsConsentProvider = (props: { children: React.ReactNode }) =
6665
>
6766
{props.children}
6867
{/* Theme is needed because AnalyticsConsentProvider is outside network-themed routes */}
69-
<ThemeByScope isRootTheme={false} network={Network.mainnet}>
68+
<ThemeByScope isRootTheme={false} network={'mainnet'}>
7069
<AnalyticsConsentView
7170
isOpen={hasAccepted === 'not-chosen'}
7271
onAccept={async () => {

src/app/components/ContractVerificationIcon/AbiPlaygroundLink.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export const AbiPlaygroundLink: FC<{
1414
const { t } = useTranslation()
1515

1616
const scopeToPlaygroundURL: Record<Network, Partial<Record<Layer, string>>> = {
17-
[Network.mainnet]: {
17+
mainnet: {
1818
emerald: `${externalLinks.dapps.abiPlayground}?network=42262&contractAddress=${address_eth}`,
1919
sapphire: `${externalLinks.dapps.abiPlayground}?network=23294&contractAddress=${address_eth}`,
2020
},
21-
[Network.testnet]: {
21+
testnet: {
2222
emerald: `${externalLinks.dapps.abiPlayground}?network=42261&contractAddress=${address_eth}`,
2323
sapphire: `${externalLinks.dapps.abiPlayground}?network=23295&contractAddress=${address_eth}`,
2424
},
25-
[Network.localnet]: {
25+
localnet: {
2626
emerald: `${externalLinks.dapps.abiPlayground}?network=42260&contractAddress=${address_eth}`,
2727
sapphire: `${externalLinks.dapps.abiPlayground}?network=23293&contractAddress=${address_eth}`,
2828
},

src/app/components/LayerPicker/LayerDetails.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type LayerDetailsContent = {
3434
type NetworkDetails = Partial<Record<Layer, LayerDetailsContent>>
3535
type Details = Record<Network, NetworkDetails>
3636
const getDetails = (t: TFunction): Details => ({
37-
[Network.mainnet]: {
37+
mainnet: {
3838
emerald: {
3939
description: t('layerPicker.mainnet.emerald'),
4040
rpcHttp: 'https://emerald.oasis.io',
@@ -52,7 +52,7 @@ const getDetails = (t: TFunction): Details => ({
5252
docs: docs.sapphire,
5353
},
5454
},
55-
[Network.testnet]: {
55+
testnet: {
5656
emerald: {
5757
description: t('layerPicker.testnet.emerald'),
5858
rpcHttp: 'https://testnet.emerald.oasis.io',
@@ -86,7 +86,7 @@ const getDetails = (t: TFunction): Details => ({
8686
docs: docs.pontusx1,
8787
},
8888
},
89-
[Network.localnet]: {
89+
localnet: {
9090
sapphire: {
9191
chainHexId: '0x5afd',
9292
chainDecimalId: '23293',

src/app/components/OfflineBanner/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { StickyAlert } from '../StickyAlert'
1010
export const NetworkOfflineBanner: FC<{ wantedNetwork?: Network }> = ({ wantedNetwork }) => {
1111
const scope = useScopeParam()
1212
const { t } = useTranslation()
13-
const targetNetwork = wantedNetwork || scope?.network || Network.mainnet
13+
const targetNetwork = wantedNetwork ?? scope?.network ?? 'mainnet'
1414
const isNetworkReachable = useIsApiReachable(targetNetwork)
1515
const networkNames = getNetworkNames(t)
1616
const target = networkNames[targetNetwork]

src/app/components/PageLayout/NetworkSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const NetworkSelectorView: FC<NetworkSelectorViewProps> = ({ isOutOfDate, layer,
8888
{!isMobile && (
8989
<NetworkButton isOutOfDate={isOutOfDate} layer={layer} network={network} onClick={handleDrawerOpen} />
9090
)}
91-
{!fixedNetwork && !fixedLayer && !isTablet && network !== Network.mainnet && (
91+
{!fixedNetwork && !fixedLayer && !isTablet && network !== 'mainnet' && (
9292
<StyledBox>
9393
<Typography
9494
component="span"

src/app/components/PageLayout/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { useScopeParam } from '../../hooks/useScopeParam'
99
import { NetworkOfflineBanner, RuntimeOfflineBanner, ConsensusOfflineBanner } from '../OfflineBanner'
1010
import { Search } from '../Search'
1111
import { useIsApiReachable } from '../OfflineBanner/hook'
12-
import { Network } from '../../../types/network'
1312

1413
interface PageLayoutProps {
1514
mobileFooterAction?: ReactNode
@@ -23,7 +22,7 @@ export const PageLayout: FC<PropsWithChildren<PageLayoutProps>> = ({ children, m
2322
const theme = useTheme()
2423
const { isMobile, isTablet } = useScreenSize()
2524
const scope = useScopeParam()
26-
const isApiReachable = useIsApiReachable(scope?.network || Network.mainnet).reachable
25+
const isApiReachable = useIsApiReachable(scope?.network ?? 'mainnet').reachable
2726

2827
return (
2928
<>

src/app/components/Search/SearchSuggestionsButtons.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import TokenIcon from '@mui/icons-material/Token'
1111
import { searchSuggestionTerms } from './search-utils'
1212
import { OptionalBreak } from '../OptionalBreak'
1313
import { SearchScope } from '../../../types/searchScope'
14-
import { Network } from '../../../types/network'
1514

1615
const StyledPlainTextButton = styled(Button)({
1716
fontSize: 'inherit',
@@ -39,7 +38,7 @@ export const SearchSuggestionsButtons: FC<Props> = ({ scope, onClickSuggestion }
3938
const { t } = useTranslation()
4039
const { suggestedBlock, suggestedTransaction, suggestedAccount, suggestedTokenFragment } =
4140
(scope?.network && scope?.layer && searchSuggestionTerms[scope.network][scope.layer]) ??
42-
searchSuggestionTerms[Network.mainnet]['sapphire']!
41+
searchSuggestionTerms.mainnet.sapphire!
4342
const defaultComponents = {
4443
OptionalBreak: <OptionalBreak />,
4544
BlockIcon: <WidgetsIcon sx={{ fontSize: '18px' }} />,

src/app/components/Search/SearchSuggestionsLinksForNoResults.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { OptionalBreak } from '../OptionalBreak'
1212
import { SearchScope } from '../../../types/searchScope'
1313
import { useScreenSize } from '../../hooks/useScreensize'
1414
import { SxProps } from '@mui/material/styles'
15-
import { Network } from '../../../types/network'
1615

1716
interface Props {
1817
scope: SearchScope | undefined
@@ -31,7 +30,7 @@ export const SearchSuggestionsLinksForNoResults: FC<Props> = ({ scope }) => {
3130
const { isMobile } = useScreenSize()
3231
const { suggestedBlock, suggestedTransaction, suggestedAccount, suggestedTokenFragment } =
3332
(scope?.network && scope?.layer && searchSuggestionTerms[scope.network][scope.layer]) ??
34-
searchSuggestionTerms[Network.mainnet].sapphire!
33+
searchSuggestionTerms.mainnet.sapphire!
3534
const defaultComponents = {
3635
OptionalBreak: <OptionalBreak />,
3736
BlockIcon: isMobile ? empty : <WidgetsIcon sx={iconSxProps} />,

src/app/components/ThemeByScope/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ export const ThemeByScope: FC<{
1919
)
2020

2121
export const withDefaultTheme = (node: ReactNode, alwaysMainnet = false) => (
22-
<ThemeByScope
23-
isRootTheme={true}
24-
network={alwaysMainnet ? Network.mainnet : (fixedNetwork ?? Network.mainnet)}
25-
>
22+
<ThemeByScope isRootTheme={true} network={alwaysMainnet ? 'mainnet' : (fixedNetwork ?? 'mainnet')}>
2623
{node}
2724
</ThemeByScope>
2825
)

0 commit comments

Comments
 (0)