Skip to content

Commit

Permalink
Move hidden layer configuration
Browse files Browse the repository at this point in the history
Move config out of the types file,
into route utils, where the last of
the network/layer/scope configuration lives.
  • Loading branch information
csillag committed Jun 13, 2024
1 parent 7336f91 commit 4068398
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/app/components/LayerPicker/LayerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Tooltip from '@mui/material/Tooltip'
import { COLORS } from '../../../styles/theme/colors'
import { Layer } from '../../../oasis-nexus/api'
import { getLayerLabels } from '../../utils/content'
import { RouteUtils } from '../../utils/route-utils'
import { isLayerHidden, RouteUtils } from '../../utils/route-utils'
import { Network } from '../../../types/network'
import { isLayerHidden, orderByLayer } from '../../../types/layers'
import { orderByLayer } from '../../../types/layers'
import { useScreenSize } from '../../hooks/useScreensize'
import { useScopeParam } from '../../hooks/useScopeParam'

Expand Down
3 changes: 1 addition & 2 deletions src/app/pages/ConsensusDashboardPage/ParaTimesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import CardHeader from '@mui/material/CardHeader'
import CardContent from '@mui/material/CardContent'
import { styled } from '@mui/material/styles'
import { Layer, Runtime } from '../../../oasis-nexus/api'
import { isNotOnHiddenLayer } from '../../../types/layers'
import { COLORS } from '../../../styles/theme/colors'
import { CardHeaderWithCounter } from '../../components/CardHeaderWithCounter'
import { RouteUtils } from '../../utils/route-utils'
import { isNotOnHiddenLayer, RouteUtils } from '../../utils/route-utils'
import { SearchScope } from '../../../types/searchScope'
import { EnabledRuntimePreview, InactiveRuntimePreview } from './RuntimePreview'

Expand Down
8 changes: 7 additions & 1 deletion src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Network } from '../../types/network'
import { SearchScope } from '../../types/searchScope'
import { isStableDeploy } from '../../config'
import { getSearchTermFromRequest } from '../components/Search/search-utils'
import { isLayerHidden } from '../../types/layers'
import type { HasLayer } from '../../types/layers'

export const fixedNetwork = process.env.REACT_APP_FIXED_NETWORK as Network | undefined
export const fixedLayer = process.env.REACT_APP_FIXED_LAYER as Layer | undefined
Expand Down Expand Up @@ -37,6 +37,12 @@ export type SpecifiedPerEnabledLayer<T = any, ExcludeLayers = never> = {

export type SpecifiedPerEnabledRuntime<T = any> = SpecifiedPerEnabledLayer<T, typeof Layer.consensus>

export const hiddenLayers: Layer[] = [Layer.pontusxdev, Layer.pontusx]

export const isLayerHidden = (layer: Layer): boolean => hiddenLayers.includes(layer)

export const isNotOnHiddenLayer = (item: HasLayer) => !isLayerHidden(item.layer)

export abstract class RouteUtils {
private static ENABLED_LAYERS_FOR_NETWORK = {
[Network.mainnet]: {
Expand Down
8 changes: 1 addition & 7 deletions src/types/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { uniq } from '../app/utils/helpers'
// eslint-disable-next-line no-restricted-imports
import { Layer } from '../oasis-nexus/generated/api'

interface HasLayer {
export interface HasLayer {
layer: Layer
}

Expand All @@ -20,8 +20,6 @@ const layerOrder: Record<Layer, number> = {
[Layer.pontusx]: 6,
}

const hiddenLayers: Layer[] = [Layer.pontusxdev, Layer.pontusx]

export const orderByLayer = (itemA: HasLayer, itemB: HasLayer): number =>
layerOrder[itemA.layer] - layerOrder[itemB.layer]

Expand All @@ -32,7 +30,3 @@ export const doesLayerSupportEncryptedTransactions = (layer: Layer): boolean =>

export const doesAnyOfTheseLayersSupportEncryptedTransactions = (layers: Layer[] | undefined): boolean =>
uniq(layers).some(doesLayerSupportEncryptedTransactions)

export const isLayerHidden = (layer: Layer): boolean => hiddenLayers.includes(layer)

export const isNotOnHiddenLayer = (item: HasLayer) => !isLayerHidden(item.layer)

0 comments on commit 4068398

Please sign in to comment.