Skip to content

Commit 9923625

Browse files
committed
Add support for overriding names of special scopes
Normally, the name of a scope is derived by concatenating the name of the layer (i.e. "Sapphire") and the name of the network (i.e. "Testnet") ==> "Sapphire Testnet" However, in some specific cases, we might want to have something different. This can be achieved by this override function.
1 parent 0ec1962 commit 9923625

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Layer } from './oasis-nexus/generated/api'
44
import { NativeToken, NativeTokenInfo } from './types/ticker'
55
import { SearchScope } from './types/searchScope'
6+
import { Network } from './types/network'
67

78
export const consensusDecimals = 9
89
/**
@@ -202,3 +203,8 @@ export const getFiatCurrencyForScope = (scope: SearchScope | undefined) =>
202203
(scope ? paraTimesConfig[scope.layer]?.[scope.network]?.fiatCurrency : undefined) ?? 'usd'
203204

204205
export const showFiatValues = process.env.REACT_APP_SHOW_FIAT_VALUES === 'true'
206+
207+
export const specialScopeNames: Partial<Record<Network, Partial<Record<Layer, string>>>> = {
208+
[Network.mainnet]: {},
209+
[Network.testnet]: {},
210+
}

src/types/searchScope.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getNetworkNames, Network } from './network'
22
import { getLayerLabels } from '../app/utils/content'
33
import { HasScope, Layer } from '../oasis-nexus/api'
44
import { TFunction } from 'i18next'
5+
import { specialScopeNames } from '../config'
56

67
export interface SearchScope {
78
network: Network
@@ -14,6 +15,7 @@ export const MainnetEmerald: SearchScope = {
1415
}
1516

1617
export const getNameForScope = (t: TFunction, scope: SearchScope) =>
18+
specialScopeNames[scope.network]?.[scope.layer] ??
1719
`${getLayerLabels(t)[scope.layer]} ${getNetworkNames(t)[scope.network]}`
1820

1921
export const getKeyForScope: (scope: SearchScope) => string = ({ network, layer }) => `${network}.${layer}`

0 commit comments

Comments
 (0)