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

Small cleanups #1285

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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/1285.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Various small cleanups
3 changes: 0 additions & 3 deletions src/app/components/Balance/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { AllTokenPrices } from '../../../coin-gecko/api'
import BigNumber from 'bignumber.js'
import { Ticker } from '../../../types/ticker'

export const hasRuntimeBalance = (balances: RuntimeSdkBalance[] = []) =>
balances.some(balance => balance.token_decimals)

export type FiatValueInfo = {
/**
* Do we have any known real value?
Expand Down
13 changes: 12 additions & 1 deletion src/app/components/Snapshots/SnapshotCardExternalLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ type SnapshotCardExternalLinkProps = {
label?: string
title: string
url?: string

/**
* Should we accept "mailto:" links?
*
* Those are more dangerous than other types, since they can
* facilitate displaying malicious URLs like javascript: and mailto:?attach=
*
* In order to prevent this, only enable this flag if we can be sure that the link is safe.
*/
emailAccepted?: boolean
}

export const SnapshotCardExternalLink: FC<SnapshotCardExternalLinkProps> = ({
description,
label,
title,
url,
emailAccepted,
}) => {
return (
<SnapshotCard title={title} withContentPadding={false}>
Expand All @@ -40,7 +51,7 @@ export const SnapshotCardExternalLink: FC<SnapshotCardExternalLinkProps> = ({
>
{description}
</Typography>
{url && hasValidProtocol(url) && (
{url && (hasValidProtocol(url) || (emailAccepted && url.startsWith('mailto:'))) && (
<Button href={url} target="_blank" rel="noopener noreferrer" color="secondary" variant="outlined">
{label}
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/ParatimeDashboardPage/TestnetFaucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const TestnetFaucet: FC<TestnetFaucetProps> = ({ network, layer, ticker }
label={t('testnetFaucet.request')}
title={t('testnetFaucet.header')}
url={link}
emailAccepted={true}
/>
) : null
}
13 changes: 12 additions & 1 deletion src/app/pages/ValidatorDetailsPage/ExternalLinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ import { SnapshotCardExternalLink } from 'app/components/Snapshots/SnapshotCardE

type ExternalLinkCardProps = {
link?: string

/**
* Should we accept "mailto:" links?
*
* Those are more dangerous than other types, since they can
* facilitate displaying malicious URLs like javascript: and mailto:?attach=
*
* In order to prevent this, only enable this flag if we can be sure that the link is safe.
*/
emailAccepted?: boolean
}

export const ExternalLinkCard: FC<ExternalLinkCardProps> = ({ link }) => {
export const ExternalLinkCard: FC<ExternalLinkCardProps> = ({ link, emailAccepted }) => {
const { t } = useTranslation()

return (
Expand All @@ -15,6 +25,7 @@ export const ExternalLinkCard: FC<ExternalLinkCardProps> = ({ link }) => {
label={link}
title={t('validator.externalLink')}
url={link}
emailAccepted={emailAccepted}
/>
)
}
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:', 'mailto:']
const validProtocols = ['http:', 'https:', 'ftp:', 'ipfs:', 'data:']

csillag marked this conversation as resolved.
Show resolved Hide resolved
export const hasValidProtocol = (url: string | undefined): boolean => {
if (!url) {
Expand Down
2 changes: 1 addition & 1 deletion src/coin-gecko/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const useAllTokenPrices = (fiatCurrency: string): AllTokenPrices => {
isFree: !!token.free,
hasUsedCoinGecko: !!token.geckoId,
price: token.geckoId && geckoPrices ? (geckoPrices as any)[token.geckoId] : undefined,
fiatCurrency: token.geckoId && geckoPrices ? fiatCurrency : 'xx',
fiatCurrency,
}
})
return results
Expand Down
9 changes: 2 additions & 7 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,13 +748,8 @@ export const useGetRuntimeEvents: typeof generated.useGetRuntimeEvents = (
event.body.amount.Denomination === ''
? {
...event.body.amount,
Amount: fromBaseUnits(
event.body.amount.Amount,
paraTimesConfig[runtime].decimals,
),
Denomination:
event.body?.Denomination ??
getTokensForScope({ network, layer: runtime })[0].ticker,
Amount: fromBaseUnits(event.body.Amount, paraTimesConfig[runtime].decimals),
Denomination: getTokensForScope({ network, layer: runtime })[0].ticker,
Comment on lines +751 to +752
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 more wrong

Copy link
Member

Choose a reason for hiding this comment

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

Fix in #1539

}
: event.body.amount,
},
Expand Down
Loading