forked from aave/interface
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: adding support for blocking known bad addresses * fix: use temp url for testing * feat: added modal for showing blocked account * chore: i18n * chore: added some TODOs and comments * feat: adding env var for screening url * chore: updated text from legal chore: i18n * chore: rename to be consistent with file name * chore: rename variables to be consistent * chore: i18n * chore: cleanup * fix: block all markets, not just mainnet * chore: remove testing url from env * fix: lint * ci: add screening url to CI build * fix: added usePolling to handle any api errors and to re-screen address * chore: updated default env files * fix: url * feat: check for blocked address at app level to prevent access to entire app * fix: lint * fix: add navbar to address blocked screen * feat: add disconnect button to address blocked modal * chore: i18n * fix: added period Co-authored-by: Vladimir Yumatov <vladimir@aave.com>
- Loading branch information
Showing
10 changed files
with
153 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
NEXT_PUBLIC_ENV=prod | ||
NEXT_PUBLIC_ENV=prod | ||
NEXT_PUBLIC_SCREENING_URL=https://aave-api-v2.aave.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ReactNode } from 'react'; | ||
import { useAddressAllowed } from 'src/hooks/useAddressAllowed'; | ||
import { MainLayout } from 'src/layouts/MainLayout'; | ||
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; | ||
import { AddressBlockedModal } from './AddressBlockedModal'; | ||
|
||
export const AddressBlocked = ({ children }: { children: ReactNode }) => { | ||
const { currentAccount, disconnectWallet } = useWeb3Context(); | ||
const { isAllowed } = useAddressAllowed(currentAccount); | ||
|
||
if (!isAllowed) { | ||
return ( | ||
<MainLayout> | ||
<AddressBlockedModal address={currentAccount} onDisconnectWallet={disconnectWallet} />; | ||
</MainLayout> | ||
); | ||
} | ||
|
||
return <>{children}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ExclamationCircleIcon, LogoutIcon } from '@heroicons/react/outline'; | ||
import { Trans } from '@lingui/macro'; | ||
import { Box, Button, SvgIcon, Typography } from '@mui/material'; | ||
import { BasicModal } from './primitives/BasicModal'; | ||
import { Link } from './primitives/Link'; | ||
|
||
export interface AddressBlockedProps { | ||
address: string; | ||
onDisconnectWallet: () => void; | ||
} | ||
|
||
export const AddressBlockedModal = ({ address, onDisconnectWallet }: AddressBlockedProps) => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars | ||
const setOpen = (_value: boolean) => {}; // ignore, we want the modal to not be dismissable | ||
|
||
return ( | ||
<BasicModal open={true} withCloseButton={false} setOpen={setOpen}> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<SvgIcon sx={{ fontSize: '24px', color: 'warning.main', mb: 2 }}> | ||
<ExclamationCircleIcon /> | ||
</SvgIcon> | ||
<Typography variant="h2"> | ||
<Trans>Blocked Address</Trans> | ||
</Typography> | ||
<Typography variant="helperText" sx={{ my: 4 }}> | ||
{address} | ||
</Typography> | ||
<Typography variant="description" sx={{ textAlign: 'center', mb: 4 }}> | ||
<Trans> | ||
This address is blocked on app.aave.com because it is associated with one or more | ||
</Trans>{' '} | ||
<Link href="https://docs.aave.com/faq/#address-screening" underline="always"> | ||
<Trans>blocked activities</Trans> | ||
</Link> | ||
{'.'} | ||
</Typography> | ||
<Button variant="contained" onClick={onDisconnectWallet}> | ||
<SvgIcon fontSize="small" sx={{ mx: 1 }}> | ||
<LogoutIcon /> | ||
</SvgIcon> | ||
<Trans>Disconnect Wallet</Trans> | ||
</Button> | ||
</Box> | ||
</BasicModal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useState } from 'react'; | ||
import { usePolling } from './usePolling'; | ||
|
||
export interface AddressAllowedResult { | ||
isAllowed: boolean; | ||
} | ||
|
||
const TWO_MINUTES = 2 * 60 * 1000; | ||
|
||
export const useAddressAllowed = (address: string): AddressAllowedResult => { | ||
const [isAllowed, setIsAllowed] = useState(true); | ||
|
||
const screeningUrl = process.env.NEXT_PUBLIC_SCREENING_URL; | ||
|
||
const getIsAddressAllowed = async () => { | ||
if (screeningUrl && address) { | ||
try { | ||
const response = await fetch(`${screeningUrl}/addresses/status?address=${address}`); | ||
const data: { addressAllowed: boolean } = await response.json(); | ||
setIsAllowed(data.addressAllowed); | ||
} catch (e) {} | ||
} else { | ||
setIsAllowed(true); | ||
} | ||
}; | ||
|
||
usePolling(getIsAddressAllowed, TWO_MINUTES, false, [address]); | ||
|
||
return { | ||
isAllowed, | ||
}; | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters