Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hiding all fiat values #1281

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/1281.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for hiding all fiat values
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
REACT_APP_SHOW_BUILD_BANNERS=true
# REACT_APP_FIXED_NETWORK=testnet
# REACT_APP_FIXED_LAYER=sapphire
REACT_APP_SHOW_FIAT_VALUES=true
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ REACT_APP_STAGING_URLS=https://explorer.stg.oasis.io
REACT_APP_SHOW_BUILD_BANNERS=true
# REACT_APP_FIXED_NETWORK=testnet
# REACT_APP_FIXED_LAYER=sapphire
REACT_APP_SHOW_FIAT_VALUES=true
4 changes: 2 additions & 2 deletions src/app/components/Account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AccountAvatar } from '../AccountAvatar'
import { RuntimeBalanceDisplay } from '../Balance/RuntimeBalanceDisplay'
import { calculateFiatValue } from '../Balance/hooks'
import { FiatMoneyAmount } from '../Balance/FiatMoneyAmount'
import { getFiatCurrencyForScope, getTokensForScope } from '../../../config'
import { getFiatCurrencyForScope, getTokensForScope, showFiatValues } from '../../../config'

type AccountProps = {
account?: RuntimeAccount
Expand Down Expand Up @@ -115,7 +115,7 @@ export const Account: FC<AccountProps> = ({ account, token, isLoading, tokenPric
<TokenPills account={account} tokens={account.evm_balances} />
</dd>

{!fiatValueInfo.loading && fiatValueInfo.hasValue && (
{showFiatValues && !fiatValueInfo.loading && fiatValueInfo.hasValue && (
<>
<dt>{t('common.fiatValue')}</dt>
<dd>
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ActiveAccounts } from './ActiveAccounts'
import { ChartDuration } from '../../utils/chart-utils'
import { useTranslation } from 'react-i18next'
import { useConstant } from '../../hooks/useConstant'
import { getTokensForScope } from '../../../config'
import { getTokensForScope, showFiatValues } from '../../../config'
import { getLayerLabels } from '../../utils/content'
import { TestnetFaucet } from './TestnetFaucet'
import { SearchScope } from '../../../types/searchScope'
Expand Down Expand Up @@ -53,7 +53,7 @@ export const ParaTimeSnapshot: FC<{ scope: SearchScope }> = ({ scope }) => {
<Nodes scope={scope} />
</StyledGrid>
<StyledGrid item xs={22} md={5}>
{!mainToken.free && <TokenPriceCard token={mainToken} />}
{showFiatValues && !mainToken.free && <TokenPriceCard token={mainToken} />}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what non-free token are we hiding now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Pontus-X guys don't want to see any fiat values anywhere in their version, not even the price card. So, in their deployment, showFiatValue will be set to false via .env, and so the token price card (for EUROe) will be hidden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our version, including the current master branch, on the PontusX paratime dashboard, we can see the current price of EUROe.

{faucetLink && <TestnetFaucet network={scope.network} layer={scope.layer} ticker={mainTicker} />}
</StyledGrid>
</Snapshot>
Expand Down
5 changes: 3 additions & 2 deletions src/app/pages/RuntimeTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { LongDataDisplay } from '../../components/LongDataDisplay'
import { getPreciseNumberFormat } from '../../../locales/getPreciseNumberFormat'
import { base64ToHex } from '../../utils/helpers'
import { DappBanner } from '../../components/DappBanner'
import { getFiatCurrencyForScope } from '../../../config'
import { getFiatCurrencyForScope, showFiatValues } from '../../../config'

type TransactionSelectionResult = {
wantedTransaction?: RuntimeTransaction
Expand Down Expand Up @@ -327,7 +327,8 @@ export const RuntimeTransactionDetailView: FC<{
: t('common.missing')}
</dd>

{transaction.amount !== undefined &&
{showFiatValues &&
transaction.amount !== undefined &&
!!tokenPriceInfo &&
!tokenPriceInfo.isLoading &&
!tokenPriceInfo.isFree &&
Expand Down
4 changes: 3 additions & 1 deletion src/app/utils/faucet-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const faucetLinks: Partial<Record<Network, Partial<Record<Layer, Partial<Record<
[Layer.consensus]: { [Ticker.TEST]: testnetFaucetUrl },
[Layer.emerald]: { [Ticker.TEST]: `${faucetParaTimeBaseUrl}emerald` },
[Layer.sapphire]: { [Ticker.TEST]: `${faucetParaTimeBaseUrl}sapphire` },
[Layer.pontusx]: { [Ticker.TEST]: 'mailto:[email protected]?subject=tokens' },
[Layer.pontusx]: {
[Ticker.EUROe]: `mailto:[email protected]?subject=${encodeURIComponent('Request test tokens')}`,
},
[Layer.cipher]: { [Ticker.TEST]: `${faucetParaTimeBaseUrl}cipher` },
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const validProtocols = ['http:', 'https:', 'ftp:', 'ipfs:', 'data:']
const validProtocols = ['http:', 'https:', 'ftp:', 'ipfs:', 'data:', 'mailto:']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous oasisprotocol/wallet#228

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but to frame this properly, currently the only place we are using mailto links are the faucet links, which are hardwired in the code.

Maybe we should add this as an exception for the faucet link only, and not in the general frunction?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but to frame this properly, currently the only place we are using mailto links are the faucet links, which are hardwired in the code.

no, it was ensuring safety of validator logos and NFT links too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add this as an exception for the faucet link only, and not in the general frunction?

sure, we can consider all our external links as safe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #1285.

export const hasValidProtocol = (url: string | undefined): boolean => {
if (!url) {
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,5 @@ export const getTokensForScope = (scope: SearchScope | undefined): NativeTokenIn

export const getFiatCurrencyForScope = (scope: SearchScope | undefined) =>
(scope ? paraTimesConfig[scope.layer]?.[scope.network]?.fiatCurrency : undefined) ?? 'usd'

export const showFiatValues = process.env.REACT_APP_SHOW_FIAT_VALUES === 'true'
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare global {
REACT_APP_STAGING_URLS?: string
REACT_APP_FIXED_NETWORK?: string
REACT_APP_FIXED_LAYER?: string
REACT_APP_SHOW_FIAT_VALUES?: string
}
}
}
Loading