Skip to content

Commit

Permalink
Merge pull request #1542 from oasisprotocol/lw/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
lukaw3d authored Sep 13, 2024
2 parents 762446e + 4e1fd6c commit 63101a6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 34 deletions.
1 change: 1 addition & 0 deletions .changelog/1542.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cleanup
15 changes: 6 additions & 9 deletions src/app/components/RoundedBalance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Trans, useTranslation } from 'react-i18next'
import BigNumber from 'bignumber.js'
import Tooltip from '@mui/material/Tooltip'
import { tooltipDelay } from '../../../styles/theme'
import { getNameForTicker } from '../../../types/ticker'
import { SearchScope } from '../../../types/searchScope'
import { TokenLink } from '../Tokens/TokenLink'
import { PlaceholderLabel } from '../../utils/PlaceholderLabel'
Expand All @@ -27,7 +26,7 @@ export const RoundedBalance: FC<RoundedBalanceProps> = ({
compactLargeNumbers,
scope,
showSign,
ticker,
ticker = '',
tickerAsLink,
tokenAddress,
value,
Expand All @@ -41,21 +40,19 @@ export const RoundedBalance: FC<RoundedBalanceProps> = ({
const number = new BigNumber(value)
const truncatedNumber = number.decimalPlaces(numberOfDecimals, BigNumber.ROUND_DOWN)

const tickerName = ticker ? getNameForTicker(t, ticker) : ''

const tickerLink =
tickerAsLink && !!scope && !!tokenAddress ? (
<TokenLink scope={scope} address={tokenAddress} name={tickerName} />
<TokenLink scope={scope} address={tokenAddress} name={ticker} />
) : (
<PlaceholderLabel label={tickerName} />
<PlaceholderLabel label={ticker} />
)

if (compactAllNumbers || (number.isGreaterThan(100_000) && compactLargeNumbers)) {
return (
<Tooltip
arrow
placement="top"
title={t('common.valueInToken', { ...getPreciseNumberFormat(value), ticker: tickerName })}
title={t('common.valueInToken', { ...getPreciseNumberFormat(value), ticker: ticker })}
enterDelay={tooltipDelay}
enterNextDelay={tooltipDelay}
>
Expand All @@ -70,7 +67,7 @@ export const RoundedBalance: FC<RoundedBalanceProps> = ({
},
})}
&nbsp;
{tickerName}
{ticker}
</span>
</Tooltip>
)
Expand All @@ -94,7 +91,7 @@ export const RoundedBalance: FC<RoundedBalanceProps> = ({
<Tooltip
arrow
placement="top"
title={t('common.valueInToken', { ...getPreciseNumberFormat(value), ticker: tickerName })}
title={t('common.valueInToken', { ...getPreciseNumberFormat(value), ticker: ticker })}
enterDelay={tooltipDelay}
enterNextDelay={tooltipDelay}
>
Expand Down
9 changes: 4 additions & 5 deletions src/app/pages/RuntimeTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { TransactionLink } from '../../components/Transactions/TransactionLink'
import { RuntimeTransactionEvents } from '../../components/Transactions/RuntimeTransactionEvents'
import { useRequiredScopeParam } from '../../hooks/useScopeParam'
import { DashboardLink } from '../ParatimeDashboardPage/DashboardLink'
import { getNameForTicker, Ticker } from '../../../types/ticker'
import { Ticker } from '../../../types/ticker'
import { AllTokenPrices, useAllTokenPrices } from '../../../coin-gecko/api'
import { CurrentFiatValue } from '../../components/CurrentFiatValue'
import { AddressSwitch, AddressSwitchOption } from '../../components/AddressSwitch'
Expand Down Expand Up @@ -170,7 +170,6 @@ export const RuntimeTransactionDetailView: FC<{
const to = isOasisAddressFormat ? transaction?.to : transaction?.to_eth

const ticker = transaction?.ticker || Ticker.ROSE
const tickerName = getNameForTicker(t, ticker)
const tokenPriceInfo = tokenPrices[ticker]

const gasPrice = getGasPrice({ fee: transaction?.charged_fee, gasUsed: transaction?.gas_used.toString() })
Expand Down Expand Up @@ -287,7 +286,7 @@ export const RuntimeTransactionDetailView: FC<{
{transaction.amount != null
? t('common.valueInToken', {
...getPreciseNumberFormat(transaction.amount),
ticker: tickerName,
ticker: ticker,
})
: t('common.missing')}
</dd>
Expand All @@ -310,7 +309,7 @@ export const RuntimeTransactionDetailView: FC<{
<dd>
{t('common.valueInToken', {
...getPreciseNumberFormat(transaction.charged_fee),
ticker: tickerName,
ticker: ticker,
})}
</dd>

Expand All @@ -320,7 +319,7 @@ export const RuntimeTransactionDetailView: FC<{
<dd>
{t('common.valueInToken', {
...getPreciseNumberFormat(convertToNano(gasPrice)),
ticker: `n${tickerName}`,
ticker: `n${ticker}`,
})}
</dd>
</>
Expand Down
12 changes: 3 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,9 @@ export const isStableDeploy = stableDeploys.some(url => window.location.origin =
export const getAppTitle = () => process.env.REACT_APP_META_TITLE

export const getTokensForScope = (scope: SearchScope | undefined): NativeTokenInfo[] => {
if (!scope) {
return []
}

if (scope.layer !== Layer.consensus) {
return paraTimesConfig[scope.layer][scope.network].tokens
} else {
return consensusConfig[scope.network].tokens
}
if (!scope) return []
if (scope.layer === Layer.consensus) return consensusConfig[scope.network].tokens
return paraTimesConfig[scope.layer][scope.network].tokens
}

export const getFiatCurrencyForScope = (scope: SearchScope | undefined) =>
Expand Down
4 changes: 0 additions & 4 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ declare module './generated/api' {
rank: number
}

export interface Validator {
ticker: Ticker
}

export interface Proposal {
network: Network
layer: typeof Layer.consensus
Expand Down
7 changes: 0 additions & 7 deletions src/types/ticker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { TFunction } from 'i18next'

export type Ticker = (typeof Ticker)[keyof typeof Ticker]

// eslint-disable-next-line @typescript-eslint/no-redeclare
Expand Down Expand Up @@ -29,8 +27,3 @@ export const NativeToken = {
geckoId: 'euroe-stablecoin',
},
} as const

export const getNameForTicker = (_t: TFunction, ticker: string): string => {
// TODO: how do we translate ticker names?
return ticker
}

0 comments on commit 63101a6

Please sign in to comment.