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

Feat stake OFAC #4203

Merged
merged 2 commits into from
Sep 19, 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
4 changes: 2 additions & 2 deletions src/components/common/BlockedAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRouter } from 'next/router'
import Disclaimer from '@/components/common/Disclaimer'
import { AppRoutes } from '@/config/routes'

export const BlockedAddress = ({ address }: { address?: string }): ReactElement => {
export const BlockedAddress = ({ address, featureTitle }: { address: string; featureTitle: string }): ReactElement => {
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
const displayAddress = address && isMobile ? shortenAddress(address) : address
Expand All @@ -19,7 +19,7 @@ export const BlockedAddress = ({ address }: { address?: string }): ReactElement
<Disclaimer
title="Blocked address"
subtitle={displayAddress}
content="The above address is part of the OFAC SDN list and the embedded swaps feature with CoW Swap is unavailable for sanctioned addresses."
content={`The above address is part of the OFAC SDN list and the ${featureTitle} is unavailable for sanctioned addresses.`}
onAccept={handleAccept}
/>
)
Expand Down
26 changes: 26 additions & 0 deletions src/features/stake/components/StakePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,38 @@ import WidgetDisclaimer from '@/components/common/WidgetDisclaimer'
import useStakeConsent from '@/features/stake/useStakeConsent'
import StakingWidget from '../StakingWidget'
import { useRouter } from 'next/router'
import { useGetIsSanctionedQuery } from '@/store/ofac'
import { skipToken } from '@reduxjs/toolkit/query/react'
import useWallet from '@/hooks/wallets/useWallet'
import useSafeInfo from '@/hooks/useSafeInfo'
import { getKeyWithTrueValue } from '@/utils/helpers'
import BlockedAddress from '@/components/common/BlockedAddress'

const StakePage = () => {
const { isConsentAccepted, onAccept } = useStakeConsent()
const router = useRouter()
const { asset } = router.query

const { safeAddress } = useSafeInfo()
const wallet = useWallet()

const { data: isSafeAddressBlocked } = useGetIsSanctionedQuery(safeAddress || skipToken)
const { data: isWalletAddressBlocked } = useGetIsSanctionedQuery(wallet?.address || skipToken)
const blockedAddresses = {
[safeAddress]: !!isSafeAddressBlocked,
[wallet?.address || '']: !!isWalletAddressBlocked,
}

const blockedAddress = getKeyWithTrueValue(blockedAddresses)

if (blockedAddress) {
return (
<Stack direction="column" alignItems="center" justifyContent="center" flex={1}>
<BlockedAddress address={blockedAddress} featureTitle="stake feature with Kiln" />
</Stack>
)
}

return (
<>
{isConsentAccepted === undefined ? null : isConsentAccepted ? (
Expand Down
2 changes: 1 addition & 1 deletion src/features/swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ const SwapWidget = ({ sell }: Params) => {
useCustomAppCommunicator(iframeRef, appData, chain)

if (blockedAddress) {
return <BlockedAddress address={blockedAddress} />
return <BlockedAddress address={blockedAddress} featureTitle="embedded swaps feature with CoW Swap" />
}

if (!isConsentAccepted) {
Expand Down
1 change: 1 addition & 0 deletions src/store/ofac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const ofacApi = createApi({
return { error: { status: 'CUSTOM_ERROR', data: (error as Error).message } }
}
},
keepUnusedDataFor: 24 * 60 * 60, // 24 hours
}),
}),
})
Expand Down
Loading