Skip to content

Commit

Permalink
fix: use chain not supported component rfox unstake and change address (
Browse files Browse the repository at this point in the history
#7600)

Co-authored-by: Apotheosis <0xapotheosis@gmail.com>
  • Loading branch information
NeOMakinG and 0xApotheosis authored Aug 25, 2024
1 parent 2367d40 commit 66952c1
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 27 deletions.
22 changes: 21 additions & 1 deletion src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { Box, Button, CardFooter, Collapse, Flex, Input, Skeleton, Stack } from '@chakra-ui/react'
import {
Box,
Button,
CardBody,
CardFooter,
Collapse,
Flex,
Input,
Skeleton,
Stack,
} from '@chakra-ui/react'
import { fromAccountId, fromAssetId } from '@shapeshiftoss/caip'
import { foxStakingV1Abi } from 'contracts/abis/FoxStakingV1'
import { RFOX_PROXY_CONTRACT_ADDRESS } from 'contracts/constants'
Expand Down Expand Up @@ -30,6 +40,7 @@ import {
import { useAppSelector } from 'state/store'

import { AddressSelection } from '../AddressSelection'
import { ChainNotSupported } from '../Shared/ChainNotSupported'
import type { ChangeAddressInputValues, RfoxChangeAddressQuote } from './types'
import { ChangeAddressRoutePaths, type ChangeAddressRouteProps } from './types'

Expand Down Expand Up @@ -202,6 +213,15 @@ export const ChangeAddressInput: FC<ChangeAddressRouteProps & ChangeAddressInput
trigger('newRuneAddress')
}, [trigger, currentRuneAddress])

if (!stakingAssetAccountAddress)
return (
<SlideTransition>
<Stack>{headerComponent}</Stack>
<CardBody py={12}>
<ChainNotSupported chainId={stakingAsset?.chainId} />
</CardBody>
</SlideTransition>
)
if (!stakingAsset) return null

return (
Expand Down
28 changes: 3 additions & 25 deletions src/pages/RFOX/components/Claim/ClaimSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Button, CardBody, Center, Flex, Skeleton, Stack } from '@chakra-ui/react'
import { type ChainId, foxAssetId, fromAccountId } from '@shapeshiftoss/caip'
import { foxAssetId, fromAccountId } from '@shapeshiftoss/caip'
import dayjs from 'dayjs'
import { type FC, useCallback, useMemo } from 'react'
import { useTranslate } from 'react-polyglot'
import { useHistory } from 'react-router'
import { AssetIcon } from 'components/AssetIcon'
import { ClaimStatus } from 'components/ClaimRow/types'
import { SlideTransition } from 'components/SlideTransition'
import { RawText, Text } from 'components/Text'
import { Text } from 'components/Text'
import { fromBaseUnit } from 'lib/math'
import { chainIdToChainDisplayName } from 'lib/utils'
import { useGetUnstakingRequestsQuery } from 'pages/RFOX/hooks/useGetUnstakingRequestsQuery'
import { useRFOXContext } from 'pages/RFOX/hooks/useRfoxContext'
import { RfoxTabIndex } from 'pages/RFOX/Widget'
import { selectAssetById } from 'state/slices/selectors'
import { useAppSelector } from 'state/store'

import { ChainNotSupported } from '../Shared/ChainNotSupported'
import { ClaimRow } from './ClaimRow'
import type { RfoxClaimQuote } from './types'
import { ClaimRoutePaths, type ClaimRouteProps } from './types'
Expand Down Expand Up @@ -55,28 +55,6 @@ const NoClaimsAvailable: FC<NoClaimsAvailableProps> = ({ isError, setStepIndex }
)
}

type ChainNotSupportedProps = {
chainId: ChainId | undefined
}

const ChainNotSupported: FC<ChainNotSupportedProps> = ({ chainId }) => {
const translate = useTranslate()

if (!chainId) return null

const chainLabel = chainIdToChainDisplayName(chainId)

return (
<Center flexDir={'column'}>
<AssetIcon size='lg' assetId={foxAssetId} showNetworkIcon={false} mb={4} />
<Text translation='RFOX.noSupportedChains' fontSize='xl' fontWeight={'bold'} mb={4} />
<RawText fontSize='md' color='gray.400' mb={4} textAlign={'center'}>
{translate('RFOX.noSupportedChainsDescription', { chainLabel })}
</RawText>
</Center>
)
}

export const ClaimSelect: FC<ClaimSelectProps & ClaimRouteProps> = ({
headerComponent,
setConfirmedQuote,
Expand Down
30 changes: 30 additions & 0 deletions src/pages/RFOX/components/Shared/ChainNotSupported.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Center } from '@chakra-ui/react'
import type { ChainId } from '@shapeshiftoss/caip'
import { foxAssetId } from '@shapeshiftoss/caip'
import type { FC } from 'react'
import { useTranslate } from 'react-polyglot'
import { AssetIcon } from 'components/AssetIcon'
import { RawText, Text } from 'components/Text'
import { chainIdToChainDisplayName } from 'lib/utils'

type ChainNotSupportedProps = {
chainId: ChainId | undefined
}

export const ChainNotSupported: FC<ChainNotSupportedProps> = ({ chainId }) => {
const translate = useTranslate()

if (!chainId) return null

const chainLabel = chainIdToChainDisplayName(chainId)

return (
<Center flexDir={'column'}>
<AssetIcon size='lg' assetId={foxAssetId} showNetworkIcon={false} mb={4} />
<Text translation='RFOX.noSupportedChains' fontSize='xl' fontWeight={'bold'} mb={4} />
<RawText fontSize='md' color='gray.400' mb={4} textAlign={'center'}>
{translate('RFOX.noSupportedChainsDescription', { chainLabel })}
</RawText>
</Center>
)
}
13 changes: 12 additions & 1 deletion src/pages/RFOX/components/Unstake/UnstakeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CardFooter, Collapse, Flex, Skeleton, Stack } from '@chakra-ui/react'
import { CardBody, CardFooter, Collapse, Flex, Skeleton, Stack } from '@chakra-ui/react'
import { fromAccountId, fromAssetId } from '@shapeshiftoss/caip'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { FormProvider, useForm, useWatch } from 'react-hook-form'
Expand Down Expand Up @@ -30,6 +30,7 @@ import {
} from 'state/slices/selectors'
import { useAppSelector } from 'state/store'

import { ChainNotSupported } from '../Shared/ChainNotSupported'
import { UnstakeSummary } from './components/UnstakeSummary'
import { useRfoxUnstake } from './hooks/useRfoxUnstake'
import type { RfoxUnstakingQuote, UnstakeInputValues, UnstakeRouteProps } from './types'
Expand Down Expand Up @@ -295,6 +296,16 @@ export const UnstakeInput: React.FC<UnstakeRouteProps & UnstakeInputProps> = ({
return translate('trade.errors.quoteUnsupportedChain')
}, [isChainSupportedByWallet, translate])

if (!stakingAssetAccountAddress)
return (
<SlideTransition>
<Stack>{headerComponent}</Stack>
<CardBody py={12}>
<ChainNotSupported chainId={stakingAsset?.chainId} />
</CardBody>
</SlideTransition>
)

if (!stakingAsset) return null

return (
Expand Down

0 comments on commit 66952c1

Please sign in to comment.