Skip to content

Commit 9491080

Browse files
authored
Merge pull request #2102 from oasisprotocol/csillag/improve-pontusx-faucet-display
Improve Testnet Faucet info for Pontus-X runtime
2 parents 3cb5c3e + 8e72472 commit 9491080

5 files changed

Lines changed: 80 additions & 30 deletions

File tree

.changelog/2102.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Customize test faucet wording for Pontus-X

src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getLayerLabels } from '../../utils/content'
1212
import { TestnetFaucet } from './TestnetFaucet'
1313
import { RuntimeScope } from '../../../types/searchScope'
1414
import { Snapshot, StyledGrid } from 'app/components/Snapshots/Snapshot'
15-
import { getFaucetLink } from '../../utils/faucet-links'
15+
import { getFaucetInfo } from '../../utils/faucet-links'
1616
import { ErrorBoundary } from '../../components/ErrorBoundary'
1717

1818
export const ParaTimeSnapshot: FC<{ scope: RuntimeScope }> = ({ scope }) => {
@@ -23,7 +23,7 @@ export const ParaTimeSnapshot: FC<{ scope: RuntimeScope }> = ({ scope }) => {
2323
const tokens = getTokensForScope(scope)
2424
const mainToken = tokens[0]
2525
const mainTicker = mainToken.ticker
26-
const faucetLink = getFaucetLink(scope.network, scope.layer, mainTicker)
26+
const faucetInfo = getFaucetInfo(t, scope.network, scope.layer, mainTicker)
2727
const handleDurationSelectedChange = (duration: ChartDuration | null) => {
2828
if (!duration) {
2929
return
@@ -55,7 +55,7 @@ export const ParaTimeSnapshot: FC<{ scope: RuntimeScope }> = ({ scope }) => {
5555
</StyledGrid>
5656
<StyledGrid item xs={22} md={5}>
5757
{showFiatValues && !mainToken.free && <TokenPriceCard token={mainToken} />}
58-
{faucetLink && <TestnetFaucet network={scope.network} layer={scope.layer} ticker={mainTicker} />}
58+
{faucetInfo && <TestnetFaucet network={scope.network} layer={scope.layer} ticker={mainTicker} />}
5959
</StyledGrid>
6060
</Snapshot>
6161
</ErrorBoundary>
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { FC } from 'react'
2-
import { useTranslation } from 'react-i18next'
32
import { SnapshotCardExternalLink } from '../../components/Snapshots/SnapshotCardExternalLink'
4-
import { getFaucetLink } from '../../utils/faucet-links'
3+
import { getFaucetInfo } from '../../utils/faucet-links'
54
import { Layer } from '../../../oasis-nexus/api'
65
import { Ticker } from '../../../types/ticker'
76
import { Network } from '../../../types/network'
7+
import { useTranslation } from 'react-i18next'
88

99
type TestnetFaucetProps = {
1010
network: Network
@@ -14,14 +14,7 @@ type TestnetFaucetProps = {
1414

1515
export const TestnetFaucet: FC<TestnetFaucetProps> = ({ network, layer, ticker }) => {
1616
const { t } = useTranslation()
17-
const link = getFaucetLink(network, layer, ticker)
17+
const info = getFaucetInfo(t, network, layer, ticker)
1818

19-
return link ? (
20-
<SnapshotCardExternalLink
21-
description={t('testnetFaucet.description')}
22-
label={t('testnetFaucet.request')}
23-
title={t('testnetFaucet.header')}
24-
url={link}
25-
/>
26-
) : null
19+
return info ? <SnapshotCardExternalLink {...info} /> : null
2720
}

src/app/utils/faucet-links.ts

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,72 @@ import { Ticker } from 'types/ticker'
22
import { Network } from '../../types/network'
33
import { Layer } from '../../oasis-nexus/api'
44
import { faucets } from './externalLinks'
5+
import { TFunction } from 'i18next'
56

6-
const faucetLinks: Partial<Record<Network, Partial<Record<Layer, Partial<Record<Ticker, string>>>>>> = {
7-
testnet: {
8-
consensus: { [Ticker.TEST]: faucets.oasisTestnet },
9-
emerald: { [Ticker.TEST]: `${faucets.oasisTestnet}?paratime=emerald` },
10-
sapphire: { [Ticker.TEST]: `${faucets.oasisTestnet}?paratime=sapphire` },
11-
cipher: { [Ticker.TEST]: `${faucets.oasisTestnet}?paratime=cipher` },
12-
pontusxdev: {
13-
[Ticker.EUROe]: `mailto:contact@delta-dao.com?subject=${encodeURIComponent('Request test tokens for Pontus-X Devnet')}`,
14-
},
15-
pontusxtest: {
16-
[Ticker.EUROe]: `mailto:contact@delta-dao.com?subject=${encodeURIComponent('Request test tokens for Pontus-X Testnet')}`,
17-
},
18-
},
7+
type FaucetInfo = {
8+
url: string
9+
description: string
10+
title: string
11+
label: string
1912
}
2013

21-
export const getFaucetLink = (network: Network, layer: Layer, ticker: Ticker) =>
22-
faucetLinks[network]?.[layer]?.[ticker]
14+
export const getFaucetInfo = (
15+
t: TFunction,
16+
network: Network,
17+
layer: Layer,
18+
ticker: Ticker,
19+
): FaucetInfo | undefined => {
20+
const faucetLinks: Partial<Record<Network, Partial<Record<Layer, Partial<Record<Ticker, FaucetInfo>>>>>> = {
21+
testnet: {
22+
consensus: {
23+
[Ticker.TEST]: {
24+
url: faucets.oasisTestnet,
25+
description: t('testnetFaucet.description'),
26+
title: t('testnetFaucet.header'),
27+
label: t('testnetFaucet.request'),
28+
},
29+
},
30+
emerald: {
31+
[Ticker.TEST]: {
32+
url: `${faucets.oasisTestnet}?paratime=emerald`,
33+
description: t('testnetFaucet.description'),
34+
title: t('testnetFaucet.header'),
35+
label: t('testnetFaucet.request'),
36+
},
37+
},
38+
sapphire: {
39+
[Ticker.TEST]: {
40+
url: `${faucets.oasisTestnet}?paratime=sapphire`,
41+
description: t('testnetFaucet.description'),
42+
title: t('testnetFaucet.header'),
43+
label: t('testnetFaucet.request'),
44+
},
45+
},
46+
cipher: {
47+
[Ticker.TEST]: {
48+
url: `${faucets.oasisTestnet}?paratime=cipher`,
49+
description: t('testnetFaucet.description'),
50+
title: t('testnetFaucet.header'),
51+
label: t('testnetFaucet.request'),
52+
},
53+
},
54+
pontusxdev: {
55+
[Ticker.EUROe]: {
56+
url: `mailto:contact@delta-dao.com?subject=${encodeURIComponent('Request test tokens for Pontus-X Devnet')}`,
57+
description: t('pontusx.testTokens.description'),
58+
title: t('pontusx.testTokens.header'),
59+
label: t('pontusx.testTokens.request'),
60+
},
61+
},
62+
pontusxtest: {
63+
[Ticker.EUROe]: {
64+
url: `mailto:contact@delta-dao.com?subject=${encodeURIComponent('Request test tokens for Pontus-X Testnet')}`,
65+
description: t('pontusx.testTokens.description'),
66+
title: t('pontusx.testTokens.header'),
67+
label: t('pontusx.testTokens.request'),
68+
},
69+
},
70+
},
71+
}
72+
return faucetLinks[network]?.[layer]?.[ticker]
73+
}

src/locales/en/translation.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,12 @@
715715
},
716716
"pontusx": {
717717
"devnet": "Pontus-X devnet",
718-
"testnet": "Pontus-X"
718+
"testnet": "Pontus-X",
719+
"testTokens": {
720+
"description": "Do you need some tokens for testing?",
721+
"header": "Test tokens",
722+
"request": "Contact us"
723+
}
719724
},
720725
"rofl": {
721726
"active": "Active",

0 commit comments

Comments
 (0)