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

fix: custom rfox reward address display #7734

Merged
merged 10 commits into from
Sep 18, 2024
33 changes: 25 additions & 8 deletions src/pages/RFOX/components/AddressSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FormLabel,
Input,
Stack,
Tag,
} from '@chakra-ui/react'
import { fromAccountId, thorchainAssetId, thorchainChainId, toAccountId } from '@shapeshiftoss/caip'
import type { FC } from 'react'
Expand All @@ -15,6 +16,7 @@ import { useForm, useFormContext } from 'react-hook-form'
import { useTranslate } from 'react-polyglot'
import { AccountDropdown } from 'components/AccountDropdown/AccountDropdown'
import { InlineCopyButton } from 'components/InlineCopyButton'
import { MiddleEllipsis } from 'components/MiddleEllipsis/MiddleEllipsis'
import { validateAddress } from 'lib/address/address'
import {
selectAccountIdByAccountNumberAndChainId,
Expand Down Expand Up @@ -189,6 +191,9 @@ export const AddressSelection: FC<AddressSelectionProps> = ({
return fromAccountId(maybeRuneAccountId).account
}, [maybeRuneAccountId])

const filter = useMemo(() => ({ accountId: maybeRuneAccountId }), [maybeRuneAccountId])
const accountNumber = useAppSelector(state => selectAccountNumberByAccountId(state, filter))
NeOMakinG marked this conversation as resolved.
Show resolved Hide resolved
gomesalexandre marked this conversation as resolved.
Show resolved Hide resolved

const accountSelection = useMemo(() => {
if (isManualAddress) return null

Expand All @@ -197,16 +202,28 @@ export const AddressSelection: FC<AddressSelectionProps> = ({
isDisabled={!maybeSelectedRuneAddress}
value={maybeSelectedRuneAddress ?? ''}
>
<AccountDropdown
defaultAccountId={maybeRuneAccountId}
assetId={thorchainAssetId}
onChange={handleAccountIdChange}
boxProps={boxProps}
buttonProps={buttonProps}
/>
{accountNumber !== undefined ? (
<AccountDropdown
defaultAccountId={maybeRuneAccountId}
assetId={thorchainAssetId}
onChange={handleAccountIdChange}
boxProps={boxProps}
buttonProps={buttonProps}
/>
) : maybeSelectedRuneAddress ? (
<Tag colorScheme='gray'>
<MiddleEllipsis value={maybeSelectedRuneAddress} />
</Tag>
) : null}
gomesalexandre marked this conversation as resolved.
Show resolved Hide resolved
</InlineCopyButton>
)
}, [handleAccountIdChange, isManualAddress, maybeRuneAccountId, maybeSelectedRuneAddress])
}, [
handleAccountIdChange,
isManualAddress,
maybeRuneAccountId,
maybeSelectedRuneAddress,
accountNumber,
])

const addressSelectionLabel = useMemo(
() =>
Expand Down
Loading