Skip to content

Commit

Permalink
Use default layer order in ParatimesCard
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Dec 16, 2024
1 parent 88d289d commit 41a5ccb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isStableDeploy, specialScopePaths } from '../../config'
import { getSearchTermFromRequest } from '../components/Search/search-utils'
import type { HasLayer } from '../../types/layers'
import { toChecksumAddress } from '@ethereumjs/util'
import { orderByLayer } 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 @@ -185,14 +186,15 @@ export abstract class RouteUtils {
static getAllLayersForNetwork(network: Network): { enabled: Layer[]; disabled: Layer[] } {
const enabled: Layer[] = []
const disabled: Layer[] = []

Object.values(Layer).forEach(layer => {
if ((!fixedLayer || layer === fixedLayer) && RouteUtils.ENABLED_LAYERS_FOR_NETWORK[network][layer]) {
enabled.push(layer)
} else {
disabled.push(layer)
}
})
Object.values(Layer)
.sort(orderByLayer)
.forEach(layer => {
if ((!fixedLayer || layer === fixedLayer) && RouteUtils.ENABLED_LAYERS_FOR_NETWORK[network][layer]) {
enabled.push(layer)
} else {
disabled.push(layer)
}
})

return {
enabled,
Expand Down
9 changes: 7 additions & 2 deletions src/types/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ const layerOrder: Record<Layer, number> = {
[Layer.pontusxtest]: 6,
}

export const orderByLayer = (itemA: HasLayer, itemB: HasLayer): number =>
layerOrder[itemA.layer] - layerOrder[itemB.layer]
export function orderByLayer(itemA: Layer, itemB: Layer): number
export function orderByLayer(itemA: HasLayer, itemB: HasLayer): number
export function orderByLayer(itemA: Layer | HasLayer, itemB: Layer | HasLayer): number {
const layerA = typeof itemA === 'string' ? itemA : itemA.layer
const layerB = typeof itemB === 'string' ? itemB : itemB.layer
return layerOrder[layerA] - layerOrder[layerB]
}

const layersWithEncryptedTransactions: Layer[] = [Layer.sapphire, Layer.cipher]

Expand Down

0 comments on commit 41a5ccb

Please sign in to comment.