Skip to content

Commit

Permalink
fix: simplify MarketWarning component
Browse files Browse the repository at this point in the history
  • Loading branch information
defispartan committed Sep 16, 2022
1 parent 60c4ae9 commit b0c88b2
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 99 deletions.
57 changes: 41 additions & 16 deletions src/components/transactions/Warnings/MarketWarning.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,53 @@
import { Trans } from '@lingui/macro';
import { Link, Typography, AlertColor } from '@mui/material';
import { ReactNode } from 'react';
import { Link, Typography } from '@mui/material';

import { Warning } from '../../primitives/Warning';

const WarningMessage = ({ market }: { market: string }) => {
if (market === 'Harmony') {
return (
<Trans>
Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity
with Ethereum, which affects the Aave V3 Harmony market.
</Trans>
);
} else if (market === 'Fantom') {
return <Trans>Per the community, the Fantom market has been frozen.</Trans>;
} else {
return <></>;
}
};

const getLink = (market: string, forum: boolean | undefined): string => {
if (market === 'Harmony') {
if (forum) {
return 'https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614';
} else {
return 'https://snapshot.org/#/aave.eth/proposal/0x81a78109941e5e0ac6cb5ebf82597c839c20ad6821a8c3ff063dba39032533d4';
}
} else if (market === 'Fantom') {
if (forum) {
return 'https://governance.aave.com/t/arc-aave-v3-fantom-freeze-reserves/9166';
} else {
return 'https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647';
}
} else {
return '';
}
};

interface MarketWarningProps {
learnMore?: boolean; // Modify wording on link text,
warningMessage: ReactNode;
linkHref?: string;
warningType: AlertColor;
marketName: string;
forum?: boolean;
}

export const MarketWarning = ({
learnMore,
warningMessage,
linkHref,
warningType,
}: MarketWarningProps) => {
export const MarketWarning = ({ marketName, forum }: MarketWarningProps) => {
return (
<Warning severity={warningType}>
<Warning severity="error">
<Typography variant="caption">
{warningMessage}{' '}
<Link href={linkHref} target="_blank">
{learnMore ? <Trans>Learn More</Trans> : <Trans>Join the community discussion</Trans>}
<WarningMessage market={marketName} />{' '}
<Link href={getLink(marketName, forum)} target="_blank">
{forum ? <Trans>Join the community discussion</Trans> : <Trans>Learn more</Trans>}
</Link>
</Typography>
</Warning>
Expand Down
1 change: 0 additions & 1 deletion src/locales/en/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
'Isolated assets have limited borrowing power and other assets cannot be used as collateral.',
'Join the community discussion': 'Join the community discussion',
Language: 'Language',
'Learn More': 'Learn More',
'Learn more': 'Learn more',
'Learn more about risks involved': 'Learn more about risks involved',
'Learn more in our <0>FAQ guide</0>': 'Learn more in our <0>FAQ guide</0>',
Expand Down
15 changes: 3 additions & 12 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,7 @@ msgstr "Discord"
msgid "Due to a precision bug in the stETH contract, this asset can not be used in flashloan transactions"
msgstr "Due to a precision bug in the stETH contract, this asset can not be used in flashloan transactions"

#: src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsList.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
#: src/modules/markets/AssetsList.tsx
#: src/modules/reserve-overview/ReserveActions.tsx
#: src/components/transactions/Warnings/MarketWarning.tsx
msgid "Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity with Ethereum, which affects the Aave V3 Harmony market."
msgstr "Due to the Horizon bridge exploit, certain assets on the Harmony network are not at parity with Ethereum, which affects the Aave V3 Harmony market."

Expand Down Expand Up @@ -889,17 +886,14 @@ msgstr "Join the community discussion"
msgid "Language"
msgstr "Language"

#: src/components/transactions/Warnings/MarketWarning.tsx
msgid "Learn More"
msgstr "Learn More"

#: src/components/caps/DebtCeilingStatus.tsx
#: src/components/infoTooltips/BorrowCapMaxedTooltip.tsx
#: src/components/infoTooltips/DebtCeilingMaxedTooltip.tsx
#: src/components/infoTooltips/SupplyCapMaxedTooltip.tsx
#: src/components/transactions/StakeCooldown/StakeCooldownModalContent.tsx
#: src/components/transactions/Warnings/BorrowCapWarning.tsx
#: src/components/transactions/Warnings/DebtCeilingWarning.tsx
#: src/components/transactions/Warnings/MarketWarning.tsx
#: src/components/transactions/Warnings/SupplyCapWarning.tsx
#: src/modules/dashboard/LiquidationRiskParametresModal/LiquidationRiskParametresModal.tsx
#: src/modules/reserve-overview/ReserveConfiguration.tsx
Expand Down Expand Up @@ -1137,10 +1131,7 @@ msgstr "Participating in this {symbol} reserve gives annualized rewards."
msgid "Pending..."
msgstr "Pending..."

#: src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsList.tsx
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
#: src/modules/markets/AssetsList.tsx
#: src/modules/reserve-overview/ReserveActions.tsx
#: src/components/transactions/Warnings/MarketWarning.tsx
msgid "Per the community, the Fantom market has been frozen."
msgstr "Per the community, the Fantom market has been frozen."

Expand Down
19 changes: 2 additions & 17 deletions src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,11 @@ export const BorrowAssetsList = () => {
subChildrenComponent={
<Box sx={{ px: 6, mb: 4 }}>
{borrowDisabled && currentNetworkConfig.name === 'Harmony' && (
<MarketWarning
learnMore={true}
linkHref={`https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614`}
warningMessage={
<Trans>
Due to the Horizon bridge exploit, certain assets on the Harmony network are not
at parity with Ethereum, which affects the Aave V3 Harmony market.
</Trans>
}
warningType={'error'}
/>
<MarketWarning marketName="Harmony" />
)}

{borrowDisabled && currentNetworkConfig.name === 'Fantom' && (
<MarketWarning
linkHref={`https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647`}
learnMore={true}
warningMessage={<Trans>Per the community, the Fantom market has been frozen.</Trans>}
warningType={'error'}
/>
<MarketWarning marketName="Fantom" />
)}

{+collateralUsagePercent >= 0.98 && (
Expand Down
21 changes: 2 additions & 19 deletions src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,9 @@ export const SupplyAssetsList = () => {
<>
<Box sx={{ px: 6 }}>
{supplyDisabled && currentNetworkConfig.name === 'Harmony' ? (
<MarketWarning
learnMore={true}
linkHref={`https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614`}
warningMessage={
<Trans>
Due to the Horizon bridge exploit, certain assets on the Harmony network are not
at parity with Ethereum, which affects the Aave V3 Harmony market.
</Trans>
}
warningType={'error'}
/>
<MarketWarning marketName="Harmony" />
) : supplyDisabled && currentNetworkConfig.name === 'Fantom' ? (
<MarketWarning
linkHref={`https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647`}
learnMore={true}
warningMessage={
<Trans>Per the community, the Fantom market has been frozen.</Trans>
}
warningType={'error'}
/>
<MarketWarning marketName="Fantom" />
) : user?.isInIsolationMode ? (
<Warning severity="warning">
<Trans>
Expand Down
19 changes: 2 additions & 17 deletions src/modules/markets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,13 @@ export default function AssetsList() {
>
{marketFrozen && currentNetworkConfig.name === 'Harmony' && (
<Box sx={{ mx: '24px' }}>
<MarketWarning
learnMore={true}
linkHref={`https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614`}
warningMessage={
<Trans>
Due to the Horizon bridge exploit, certain assets on the Harmony network are not at
parity with Ethereum, which affects the Aave V3 Harmony market.
</Trans>
}
warningType={'error'}
/>
<MarketWarning marketName="Harmony" forum={true} />
</Box>
)}

{marketFrozen && currentNetworkConfig.name === 'Fantom' && (
<Box sx={{ mx: '24px' }}>
<MarketWarning
linkHref={`https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647`}
learnMore={true}
warningMessage={<Trans>Per the community, the Fantom market has been frozen.</Trans>}
warningType={'error'}
/>
<MarketWarning marketName="Fantom" forum={true} />
</Box>
)}

Expand Down
19 changes: 2 additions & 17 deletions src/modules/reserve-overview/ReserveActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,27 +308,12 @@ export const ReserveActions = ({ underlyingAsset }: ReserveActionsProps) => {

{poolReserve.isFrozen && currentNetworkConfig.name === 'Harmony' && (
<Row align="flex-start" mb={3}>
<MarketWarning
learnMore={true}
linkHref={`https://governance.aave.com/t/harmony-horizon-bridge-exploit-consequences-to-aave-v3-harmony/8614`}
warningMessage={
<Trans>
Due to the Horizon bridge exploit, certain assets on the Harmony network are not at
parity with Ethereum, which affects the Aave V3 Harmony market.
</Trans>
}
warningType={'error'}
/>
<MarketWarning marketName="Harmony" />
</Row>
)}
{poolReserve.isFrozen && currentNetworkConfig.name === 'Fantom' && (
<Row align="flex-start" mb={3}>
<MarketWarning
linkHref={`https://snapshot.org/#/aave.eth/proposal/0xeefcd76e523391a14cfd0a79b531ea0a3faf0eb4a058e255fac13a2d224cc647`}
learnMore={true}
warningMessage={<Trans>Per the community, the Fantom market has been frozen.</Trans>}
warningType={'error'}
/>
<MarketWarning marketName="Fantom" />
</Row>
)}

Expand Down

0 comments on commit b0c88b2

Please sign in to comment.