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 11, 2024
1 parent 80c15a3 commit 17d6258
Show file tree
Hide file tree
Showing 15 changed files with 2,986 additions and 1 deletion.
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
1 change: 1 addition & 0 deletions src/app/pages/HomePage/Graph/Graph/graph-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export abstract class GraphUtils {
y: 0.7 * height,
}
case Layer.sapphire:
case Layer.pontusx:
return {
scale: 2.4,
x: 0.31 * width,
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/HomePage/Graph/Graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const GraphCmp: ForwardRefRenderFunction<SVGSVGElement, GraphProps> = (
[Layer.consensus]: isLayerDisabled(Layer.consensus),
[Layer.cipher]: isLayerDisabled(Layer.cipher),
[Layer.sapphire]: isLayerDisabled(Layer.sapphire),
[Layer.pontusx]: isLayerDisabled(Layer.pontusx),
}

const enabledLayers: Layer[] = useMemo(() => RouteUtils.getEnabledLayersForNetwork(network), [network])
Expand Down
16 changes: 16 additions & 0 deletions src/app/pages/HomePage/Graph/GraphTooltipMobile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ const useLayerTooltipMap = (network: Network): Record<Layer, TooltipInfo> => {
const isEmeraldEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.emerald)
const isCipherEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.cipher)
const isConsensusEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.consensus)
const isPontusxEnabled = RouteUtils.getEnabledLayersForNetwork(network).includes(Layer.pontusx)

const isEmeraldOutOfDate = useRuntimeFreshness({ network, layer: Layer.emerald }).outOfDate
const isSapphireOutOfDate = useRuntimeFreshness({ network, layer: Layer.sapphire }).outOfDate
const isPontusxOutOfDate = useRuntimeFreshness({ network, layer: Layer.pontusx }).outOfDate
return {
[Layer.sapphire]: {
disabled: !isSapphireEnabled,
Expand All @@ -163,6 +165,20 @@ const useLayerTooltipMap = (network: Network): Record<Layer, TooltipInfo> => {
}
: {}),
},
[Layer.pontusx]: {
disabled: !isPontusxEnabled,
body: {
title: (t: TFunction) => t('common.pontusx'),
caption: (t: TFunction) =>
layerTooltipBodyCaption(t, Layer.pontusx, isPontusxEnabled, isPontusxOutOfDate),
body: (t: TFunction) => t('home.tooltip.pontusxParaTimeDesc'),
},
...(isPontusxEnabled
? {
failing: isPontusxOutOfDate,
}
: {}),
},
[Layer.emerald]: {
disabled: !isEmeraldEnabled,
body: {
Expand Down
19 changes: 19 additions & 0 deletions 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,6 +100,24 @@ const getContent = (t: TFunction) => {
},
},
[Layer.cipher]: undefined,
[Layer.pontusx]: {
// TODO: add proper data
primary: {
description: '',
header: '',
url: '',
},
secondary: {
description: '',
header: '',
url: '',
},
tertiary: {
description: '',
header: '',
url: '',
},
},
},
} satisfies SpecifiedPerEnabledRuntime<LayerContent>
}
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.

Loading

0 comments on commit 17d6258

Please sign in to comment.