Skip to content

Commit

Permalink
Add Pontus-X as a hidden layer
Browse files Browse the repository at this point in the history
- It's not shown on the landing page graph
- It's not listed in the layer selector
- It can be accessed using the correct URL
- Currently all the data is mock data, coming for Sapphire
  • Loading branch information
csillag committed Feb 13, 2024
1 parent fea1c18 commit b23a39c
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 7 deletions.
1 change: 1 addition & 0 deletions .changelog/1245.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Pontus-X as a hidden layer
8 changes: 8 additions & 0 deletions src/app/components/Search/search-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const searchSuggestionTerms = {
suggestedTokenFragment: 'mock',
},
cipher: undefined,
pontusx: undefined,
consensus: undefined,
},
testnet: {
Expand All @@ -49,6 +50,13 @@ export const searchSuggestionTerms = {
suggestedTokenFragment: 'USD',
},
cipher: undefined,
pontusx: {
// TODO: provide proper suggestions
suggestedBlock: '4260',
suggestedTransaction: '0xd9b5c08be1cb74229abedd9b3e1afb8b43228085a6abf72993db415959ab6b35',
suggestedAccount: '0xfA3AC9f65C9D75EE3978ab76c6a1105f03156204',
suggestedTokenFragment: 'USD',
},
consensus: undefined,
},
} satisfies SpecifiedPerEnabledLayer<LayerSuggestions>
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/HomePage/Graph/Graph/graph-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export abstract class GraphUtils {
x: 1.2 * width,
y: 0.7 * height,
}
case Layer.pontusx:
// TODO: update this if/when we want to display this layer
// We meed this case here since this switch/case is declared to be exhaustive.
return initialValue
case Layer.sapphire:
return {
scale: 2.4,
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/HomePage/Graph/Graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ const GraphCmp: ForwardRefRenderFunction<SVGSVGElement, GraphProps> = (
return !RouteUtils.getEnabledLayersForNetwork(network).includes(Layer)
}

const disabledMap: Record<Layer, boolean> = {
const disabledMap: Partial<Record<Layer, boolean>> = {
[Layer.emerald]: isLayerDisabled(Layer.emerald),
[Layer.consensus]: isLayerDisabled(Layer.consensus),
[Layer.cipher]: isLayerDisabled(Layer.cipher),
Expand Down
6 changes: 4 additions & 2 deletions src/app/pages/HomePage/Graph/GraphTooltipMobile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const layerTooltipBodyCaption = (t: TFunction, layer: Layer, enabled: boolean, o
: t('common.paraTimeOnline')
}

const useLayerTooltipMap = (network: Network): Record<Layer, TooltipInfo> => {
const useLayerTooltipMap = (network: Network): Partial<Record<Layer, TooltipInfo>> => {
const isSapphireEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.sapphire)
const isEmeraldEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.emerald)
const isCipherEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.cipher)
Expand Down Expand Up @@ -270,7 +270,9 @@ export const GraphTooltipMobile: FC<GraphTooltipMobileProps> = ({ network, layer
const navigate = useNavigate()
const { t } = useTranslation()
const { isMobile } = useScreenSize()
const { body, disabled, failing } = useLayerTooltipMap(network)[layer]
const tooltip = useLayerTooltipMap(network)[layer]
if (!tooltip) return
const { body, disabled, failing } = tooltip

const navigateTo = () => {
if (disabled) {
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/ParatimeDashboardPage/LearningMaterials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const getContent = (t: TFunction) => {
},
},
[Layer.cipher]: undefined,
[Layer.pontusx]: undefined,
},
[Network.testnet]: {
[Layer.emerald]: {
Expand Down Expand Up @@ -99,8 +100,9 @@ const getContent = (t: TFunction) => {
},
},
[Layer.cipher]: undefined,
[Layer.pontusx]: undefined,
},
} satisfies SpecifiedPerEnabledRuntime<LayerContent>
} satisfies SpecifiedPerEnabledRuntime<LayerContent | undefined>
}

export const LearningMaterials: FC<{ scope: SearchScope }> = ({ scope }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/SearchResultsPage/GlobalSearchResultsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '../../../types/network'
import { HideMoreResults, ShowMoreResults } from './notifications'
import { getThemesForNetworks } from '../../../styles/theme'
import { orderByLayer } from '../../../types/layers'
import { isNotOnHiddenLayer, orderByLayer } from '../../../types/layers'
import { useRedirectIfSingleResult } from './useRedirectIfSingleResult'

export const GlobalSearchResultsView: FC<{
Expand All @@ -33,7 +33,7 @@ export const GlobalSearchResultsView: FC<{
const otherNetworks = RouteUtils.getEnabledNetworks().filter(isNotMainnet)
const notificationTheme = themes[Network.testnet]
const mainnetResults = searchResults.filter(isOnMainnet).sort(orderByLayer)
const otherResults = searchResults.filter(isNotOnMainnet).sort(orderByLayer)
const otherResults = searchResults.filter(isNotOnMainnet).filter(isNotOnHiddenLayer).sort(orderByLayer)

return (
<>
Expand Down
1 change: 1 addition & 0 deletions src/app/utils/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const getLayerLabels = (t: TFunction): Record<Layer, string> => ({
[Layer.emerald]: t('common.emerald'),
[Layer.sapphire]: t('common.sapphire'),
[Layer.cipher]: t('common.cipher'),
[Layer.pontusx]: t('common.pontusx'),
[Layer.consensus]: t('common.consensus'),
})

Expand Down
1 change: 1 addition & 0 deletions src/app/utils/externalLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const faucet = {
[Layer.consensus]: faucetUrl,
[Layer.emerald]: `${faucetParaTimeBaseUrl}emerald`,
[Layer.sapphire]: `${faucetParaTimeBaseUrl}sapphire`,
[Layer.pontusx]: `${faucetParaTimeBaseUrl}pontusx`,
[Layer.cipher]: `${faucetParaTimeBaseUrl}cipher`,
}

Expand Down
2 changes: 2 additions & 0 deletions src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ export abstract class RouteUtils {
[Layer.emerald]: true,
[Layer.sapphire]: true,
[Layer.cipher]: false,
[Layer.pontusx]: false,
// Disable WIP Consensus on production an staging
[Layer.consensus]: !isStableDeploy,
},
[Network.testnet]: {
[Layer.emerald]: true,
[Layer.sapphire]: true,
[Layer.cipher]: false,
[Layer.pontusx]: true,
[Layer.consensus]: false,
},
} satisfies Record<Network, Record<Layer, boolean>>
Expand Down
1 change: 1 addition & 0 deletions src/app/utils/rpc-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const LAYER_DECIMALS: Record<Layer, number> = {
[Layer.emerald]: paraTimesConfig[Layer.emerald].decimals,
[Layer.sapphire]: paraTimesConfig[Layer.sapphire].decimals,
[Layer.cipher]: paraTimesConfig[Layer.cipher].decimals,
[Layer.pontusx]: paraTimesConfig[Layer.pontusx].decimals,
[Layer.consensus]: consensusDecimals,
}

Expand Down
27 changes: 27 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,32 @@ const sapphireConfig: LayerConfig = {
outOfDateThreshold: 2 * 60 * 1000,
}

const pontusxConfig: LayerConfig = {
mainnet: {
activeNodes: undefined,
address: undefined,
blockGasLimit: undefined,
runtimeId: undefined,
},
testnet: {
activeNodes: 8, // TODO use correct number
address: 'oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd', // TODO use correct address
// See max_batch_gas https://github.com/oasisprotocol/sapphire-paratime/blob/main/runtime/src/lib.rs#L166
blockGasLimit: 15_000_000,
runtimeId: '000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c',
},
local: {
activeNodes: undefined,
address: undefined,
blockGasLimit: undefined,
runtimeId: undefined,
},

decimals: 18,
type: RuntimeTypes.Evm,
outOfDateThreshold: 2 * 60 * 1000,
}

type LayersConfig = {
[key in Layer]: LayerConfig | null
}
Expand All @@ -116,6 +142,7 @@ export const paraTimesConfig = {
[Layer.cipher]: cipherConfig,
[Layer.emerald]: emeraldConfig,
[Layer.sapphire]: sapphireConfig,
[Layer.pontusx]: pontusxConfig,
[Layer.consensus]: null,
} satisfies LayersConfig

Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"paratime": "Paratime",
"parentheses": "({{subject}})",
"percentage": "Percentage",
"pontusx": "Pontus-X",
"proposal": "Proposal",
"proposer": "Proposer",
"rank": "Rank",
Expand Down Expand Up @@ -472,6 +473,7 @@
"sapphireParaTimeDesc": "Confidential EVM Compatible ParaTime providing a smart contract development environment with EVM compatibility",
"emeraldParaTimeDesc": "EVM Compatible ParaTime providing smart contract environment with EVM compatibility.",
"cipherParaTimeDesc": "The Cipher ParaTime is a Confidential ParaTime for executing Wasm smart contracts.",
"pontusxParaTimeDesc": "Pontus-X ParaTime",
"consensusDesc": "Our scalable, high-throughput, secure, proof-of-stake consensus layer run by a decentralized set of validator nodes.",
"close": "Close"
},
Expand Down
9 changes: 9 additions & 0 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ function arrayify<T>(arrayOrItem: null | undefined | T | T[]): T[] {
return arrayOrItem
}

// TODO: remove when pontusx API is ready
axios.interceptors.request.use(config => {
// Mock pontusx
if (config.url?.includes('/v1/pontusx')) {
config.url = config.url.replace('/v1/pontusx', '/v1/sapphire')
}
return config
})

export const useGetConsensusTransactions: typeof generated.useGetConsensusTransactions = (
network,
params?,
Expand Down
2 changes: 2 additions & 0 deletions src/oasis-nexus/generated/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/types/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const getLayerNames = (t: TFunction): Record<Layer, string> => ({
[Layer.emerald]: t('common.emerald'),
[Layer.sapphire]: t('common.sapphire'),
[Layer.cipher]: t('common.cipher'),
[Layer.pontusx]: t('common.pontusx'),
[Layer.consensus]: t('common.consensus'),
})

Expand All @@ -24,9 +25,10 @@ const layerOrder: Record<Layer, number> = {
[Layer.sapphire]: 2,
[Layer.emerald]: 3,
[Layer.cipher]: 4,
[Layer.pontusx]: 5,
}

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

export const orderByLayer = (itemA: HasLayer, itemB: HasLayer): number =>
layerOrder[itemA.layer] - layerOrder[itemB.layer]
Expand All @@ -40,3 +42,5 @@ export const doesAnyOfTheseLayersSupportEncryptedTransactions = (layers: Layer[]
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 b23a39c

Please sign in to comment.