From ca7fed5d0fd6fff6ad53f5873a6dd21bffc025c6 Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:13:09 +0200 Subject: [PATCH 1/8] fix: start --- .../RFOX/components/AddressSelection.tsx | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/pages/RFOX/components/AddressSelection.tsx b/src/pages/RFOX/components/AddressSelection.tsx index bbdeef5bfda..959e329e7b4 100644 --- a/src/pages/RFOX/components/AddressSelection.tsx +++ b/src/pages/RFOX/components/AddressSelection.tsx @@ -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' @@ -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, @@ -189,6 +191,10 @@ export const AddressSelection: FC = ({ return fromAccountId(maybeRuneAccountId).account }, [maybeRuneAccountId]) + const filter = useMemo(() => ({ accountId: maybeRuneAccountId }), [maybeRuneAccountId]) + const accountNumber = useAppSelector(state => selectAccountNumberByAccountId(state, filter)) + console.log({ accountNumber, maybeRuneAccountId }) + const accountSelection = useMemo(() => { if (isManualAddress) return null @@ -197,16 +203,28 @@ export const AddressSelection: FC = ({ isDisabled={!maybeSelectedRuneAddress} value={maybeSelectedRuneAddress ?? ''} > - + {accountNumber !== undefined ? ( + + ) : ( + + + + )} ) - }, [handleAccountIdChange, isManualAddress, maybeRuneAccountId, maybeSelectedRuneAddress]) + }, [ + handleAccountIdChange, + isManualAddress, + maybeRuneAccountId, + maybeSelectedRuneAddress, + accountNumber, + ]) const addressSelectionLabel = useMemo( () => From ce20abe36624dc8e860df9a431e03dcac5887606 Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:05:22 +0200 Subject: [PATCH 2/8] fix: start --- src/pages/RFOX/components/AddressSelection.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/RFOX/components/AddressSelection.tsx b/src/pages/RFOX/components/AddressSelection.tsx index 959e329e7b4..76a7e9dac29 100644 --- a/src/pages/RFOX/components/AddressSelection.tsx +++ b/src/pages/RFOX/components/AddressSelection.tsx @@ -193,7 +193,6 @@ export const AddressSelection: FC = ({ const filter = useMemo(() => ({ accountId: maybeRuneAccountId }), [maybeRuneAccountId]) const accountNumber = useAppSelector(state => selectAccountNumberByAccountId(state, filter)) - console.log({ accountNumber, maybeRuneAccountId }) const accountSelection = useMemo(() => { if (isManualAddress) return null @@ -211,11 +210,11 @@ export const AddressSelection: FC = ({ boxProps={boxProps} buttonProps={buttonProps} /> - ) : ( + ) : maybeSelectedRuneAddress ? ( - + - )} + ) : null} ) }, [ From 73986b85950ba203adfc4172bc2a6ca5c130a29b Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:02:08 +0200 Subject: [PATCH 3/8] fix: stake address selection properly --- src/pages/RFOX/Widget.tsx | 2 +- .../RFOX/components/AddressSelection.tsx | 95 +++++++++++++++---- .../ChangeAddress/ChangeAddressInput.tsx | 1 + src/pages/RFOX/components/Stake/Stake.tsx | 15 +-- .../RFOX/components/Stake/StakeInput.tsx | 14 ++- src/pages/RFOX/components/Stake/types.ts | 1 + 6 files changed, 102 insertions(+), 26 deletions(-) diff --git a/src/pages/RFOX/Widget.tsx b/src/pages/RFOX/Widget.tsx index 2d5caf257fa..c1bd06fb14b 100644 --- a/src/pages/RFOX/Widget.tsx +++ b/src/pages/RFOX/Widget.tsx @@ -97,7 +97,7 @@ export const Widget: React.FC = () => { - + diff --git a/src/pages/RFOX/components/AddressSelection.tsx b/src/pages/RFOX/components/AddressSelection.tsx index 76a7e9dac29..5681ee4dfb1 100644 --- a/src/pages/RFOX/components/AddressSelection.tsx +++ b/src/pages/RFOX/components/AddressSelection.tsx @@ -17,6 +17,7 @@ import { useTranslate } from 'react-polyglot' import { AccountDropdown } from 'components/AccountDropdown/AccountDropdown' import { InlineCopyButton } from 'components/InlineCopyButton' import { MiddleEllipsis } from 'components/MiddleEllipsis/MiddleEllipsis' +import { Text } from 'components/Text' import { validateAddress } from 'lib/address/address' import { selectAccountIdByAccountNumberAndChainId, @@ -28,8 +29,10 @@ import { selectRuneAddress } from '../helpers' import { useRFOXContext } from '../hooks/useRfoxContext' import { useStakingInfoQuery } from '../hooks/useStakingInfoQuery' import type { AddressSelectionValues } from '../types' +import { RfoxTabIndex } from '../Widget' type AddressSelectionProps = { + setStepIndex: ((index: number) => void) | undefined onRuneAddressChange: (address: string | undefined) => void selectedAddress: string | undefined } & ( @@ -60,6 +63,7 @@ export const AddressSelection: FC = ({ isNewAddress, selectedAddress, validateIsNewAddress, + setStepIndex, }) => { const translate = useTranslate() @@ -79,6 +83,10 @@ export const AddressSelection: FC = ({ select: selectRuneAddress, }) + const shouldDisableAccountDropdown = useMemo(() => { + return Boolean(currentRuneAddress && setStepIndex) + }, [currentRuneAddress, setStepIndex]) + const [isManualAddress, setIsManualAddress] = useState(false) const handleAccountIdChange = useCallback( @@ -93,6 +101,10 @@ export const AddressSelection: FC = ({ setIsManualAddress(!isManualAddress) }, [isManualAddress, handleRuneAddressChange]) + const handleChangeAddressClick = useCallback(() => { + setStepIndex?.(RfoxTabIndex.ChangeAddress) + }, [setStepIndex]) + const manualAddressSelection = useMemo(() => { if (!isManualAddress) return null return ( @@ -179,12 +191,19 @@ export const AddressSelection: FC = ({ }, [accountIdsByAccountNumberAndChainId, stakingAssetAccountNumber]) const maybeRuneAccountId = useMemo(() => { - if (selectedAddress) return toAccountId({ account: selectedAddress, chainId: thorchainChainId }) + if (selectedAddress && !shouldDisableAccountDropdown) + return toAccountId({ account: selectedAddress, chainId: thorchainChainId }) if (currentRuneAddress) return toAccountId({ account: currentRuneAddress, chainId: thorchainChainId }) if (maybeMatchingRuneAccountId) return maybeMatchingRuneAccountId + return undefined - }, [currentRuneAddress, maybeMatchingRuneAccountId, selectedAddress]) + }, [ + currentRuneAddress, + maybeMatchingRuneAccountId, + selectedAddress, + shouldDisableAccountDropdown, + ]) const maybeSelectedRuneAddress = useMemo(() => { if (!maybeRuneAccountId) return @@ -194,6 +213,17 @@ export const AddressSelection: FC = ({ const filter = useMemo(() => ({ accountId: maybeRuneAccountId }), [maybeRuneAccountId]) const accountNumber = useAppSelector(state => selectAccountNumberByAccountId(state, filter)) + const CustomAddress = useCallback(() => { + if (!maybeSelectedRuneAddress) + return + + return ( + + + + ) + }, [maybeSelectedRuneAddress]) + const accountSelection = useMemo(() => { if (isManualAddress) return null @@ -202,19 +232,20 @@ export const AddressSelection: FC = ({ isDisabled={!maybeSelectedRuneAddress} value={maybeSelectedRuneAddress ?? ''} > - {accountNumber !== undefined ? ( + {(!Boolean(currentRuneAddress) && maybeRuneAccountId) || + accountNumber !== undefined || + !setStepIndex ? ( - ) : maybeSelectedRuneAddress ? ( - - - - ) : null} + ) : ( + + )} ) }, [ @@ -222,6 +253,10 @@ export const AddressSelection: FC = ({ isManualAddress, maybeRuneAccountId, maybeSelectedRuneAddress, + CustomAddress, + currentRuneAddress, + setStepIndex, + shouldDisableAccountDropdown, accountNumber, ]) @@ -237,6 +272,39 @@ export const AddressSelection: FC = ({ [isNewAddress, translate], ) + const TopRightButton = useCallback(() => { + if (Boolean(currentRuneAddress && setStepIndex)) { + return ( + + ) + } + + return ( + + ) + }, [ + currentRuneAddress, + handleToggleInputMethod, + handleChangeAddressClick, + isManualAddress, + translate, + setStepIndex, + ]) + return ( @@ -244,16 +312,7 @@ export const AddressSelection: FC = ({ {addressSelectionLabel} - + {accountSelection || manualAddressSelection} {addressSelectionDescription} diff --git a/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx b/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx index b26bb49d9e3..b1a4bfe5ff4 100644 --- a/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx +++ b/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx @@ -268,6 +268,7 @@ export const ChangeAddressInput: FC diff --git a/src/pages/RFOX/components/Stake/Stake.tsx b/src/pages/RFOX/components/Stake/Stake.tsx index eb13a601550..65c2f12a021 100644 --- a/src/pages/RFOX/components/Stake/Stake.tsx +++ b/src/pages/RFOX/components/Stake/Stake.tsx @@ -57,15 +57,15 @@ const BridgeStatus = makeSuspenseful( const StakeEntries = [StakeRoutePaths.Input, StakeRoutePaths.Confirm, StakeRoutePaths.Status] -export const Stake: React.FC = ({ headerComponent }) => { +export const Stake: React.FC = ({ headerComponent, setStepIndex }) => { return ( - + ) } -export const StakeRoutes: React.FC = ({ headerComponent }) => { +export const StakeRoutes: React.FC = ({ headerComponent, setStepIndex }) => { const location = useLocation() const { state: maybeBridgeQuote } = location @@ -102,11 +102,12 @@ export const StakeRoutes: React.FC = ({ headerComponent }) => { stakingAssetId={stakingAssetId} runeAddress={runeAddress} headerComponent={headerComponent} + setStepIndex={setStepIndex} onRuneAddressChange={setRuneAddress} setConfirmedQuote={setConfirmedQuote} /> ) - }, [headerComponent, runeAddress]) + }, [headerComponent, runeAddress, setStepIndex]) const renderStakeConfirm = useCallback(() => { if (!confirmedQuote) return null @@ -115,11 +116,12 @@ export const StakeRoutes: React.FC = ({ headerComponent }) => { ) - }, [confirmedQuote, headerComponent, stakeTxid]) + }, [confirmedQuote, headerComponent, stakeTxid, setStepIndex]) const renderStakeStatus = useCallback(() => { if (!confirmedQuote) return null @@ -129,11 +131,12 @@ export const StakeRoutes: React.FC = ({ headerComponent }) => { ) - }, [confirmedQuote, handleTxConfirmed, headerComponent, stakeTxid]) + }, [confirmedQuote, handleTxConfirmed, headerComponent, stakeTxid, setStepIndex]) const renderBridgeConfirm = useCallback(() => { if (!maybeBridgeQuote) return null diff --git a/src/pages/RFOX/components/Stake/StakeInput.tsx b/src/pages/RFOX/components/Stake/StakeInput.tsx index 0beb3999cba..76bab0925bc 100644 --- a/src/pages/RFOX/components/Stake/StakeInput.tsx +++ b/src/pages/RFOX/components/Stake/StakeInput.tsx @@ -27,8 +27,10 @@ import { useWallet } from 'hooks/useWallet/useWallet' import { useWalletSupportsChain } from 'hooks/useWalletSupportsChain/useWalletSupportsChain' import { bnOrZero } from 'lib/bignumber/bignumber' import { toBaseUnit } from 'lib/math' +import { selectRuneAddress } from 'pages/RFOX/helpers' import { useCooldownPeriodQuery } from 'pages/RFOX/hooks/useCooldownPeriodQuery' import { useRFOXContext } from 'pages/RFOX/hooks/useRfoxContext' +import { useStakingInfoQuery } from 'pages/RFOX/hooks/useStakingInfoQuery' import { marketApi } from 'state/slices/marketDataSlice/marketDataSlice' import { selectAssetById, @@ -79,11 +81,19 @@ export const StakeInput: React.FC = ({ onRuneAddressChange, runeAddress, setConfirmedQuote, + setStepIndex, }) => { const assetIds = useMemo(() => [stakingAssetId, l1AssetId], [l1AssetId, stakingAssetId]) const { selectedAssetId, setSelectedAssetId, selectedAssetAccountId, stakingAssetAccountId } = useRFOXContext() + const { data: currentRuneAddress } = useStakingInfoQuery({ + stakingAssetAccountAddress: stakingAssetAccountId + ? fromAccountId(stakingAssetAccountId).account + : undefined, + select: selectRuneAddress, + }) + const isAccountMetadataLoading = useAppSelector(selectIsAccountMetadataLoading) const isBridgeRequired = stakingAssetId !== selectedAssetId const dispatch = useAppDispatch() @@ -250,7 +260,7 @@ export const StakeInput: React.FC = ({ stakingAssetAccountId, stakingAssetId, stakingAmountCryptoBaseUnit: toBaseUnit(amountCryptoPrecision, stakingAsset.precision), - runeAddress, + runeAddress: currentRuneAddress ?? runeAddress, } setConfirmedQuote(_confirmedQuote) @@ -280,6 +290,7 @@ export const StakeInput: React.FC = ({ isBridgeRequired, history, selectedAssetId, + currentRuneAddress, ]) const buyAssetSearch = useModal('buyAssetSearch') @@ -488,6 +499,7 @@ export const StakeInput: React.FC = ({ {stakingAssetAccountId && ( diff --git a/src/pages/RFOX/components/Stake/types.ts b/src/pages/RFOX/components/Stake/types.ts index 86a4ec43458..38e8cdaa3a0 100644 --- a/src/pages/RFOX/components/Stake/types.ts +++ b/src/pages/RFOX/components/Stake/types.ts @@ -10,6 +10,7 @@ export enum StakeRoutePaths { export type StakeRouteProps = { headerComponent?: JSX.Element + setStepIndex: (index: number) => void } export type RfoxStakingQuote = { From 80fbb34e9999aaae8e34fd5957e0d3cf5324b7e8 Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:46:39 +0200 Subject: [PATCH 4/8] fix: review feedbacks --- .../TradeInput/components/ConfirmSummary.tsx | 8 +++++++- src/pages/RFOX/components/AddressSelection.tsx | 7 ++++++- .../components/ChangeAddress/ChangeAddressInput.tsx | 11 ++++++++--- src/pages/RFOX/components/Stake/StakeInput.tsx | 7 ++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx b/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx index 48bdb4e068f..81f7d3b4b84 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx @@ -238,6 +238,10 @@ export const ConfirmSummary = ({ translate, ]) + const buttonText = useMemo(() => { + return + }, [quoteStatusTranslation]) + return ( <> diff --git a/src/pages/RFOX/components/AddressSelection.tsx b/src/pages/RFOX/components/AddressSelection.tsx index 5681ee4dfb1..45adf492266 100644 --- a/src/pages/RFOX/components/AddressSelection.tsx +++ b/src/pages/RFOX/components/AddressSelection.tsx @@ -11,7 +11,7 @@ import { } from '@chakra-ui/react' import { fromAccountId, thorchainAssetId, thorchainChainId, toAccountId } from '@shapeshiftoss/caip' import type { FC } from 'react' -import { useCallback, useMemo, useState } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import { useForm, useFormContext } from 'react-hook-form' import { useTranslate } from 'react-polyglot' import { AccountDropdown } from 'components/AccountDropdown/AccountDropdown' @@ -83,6 +83,11 @@ export const AddressSelection: FC = ({ select: selectRuneAddress, }) + useEffect(() => { + handleRuneAddressChange(undefined) + setIsManualAddress(false) + }, [stakingAssetAccountId, handleRuneAddressChange]) + const shouldDisableAccountDropdown = useMemo(() => { return Boolean(currentRuneAddress && setStepIndex) }, [currentRuneAddress, setStepIndex]) diff --git a/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx b/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx index b1a4bfe5ff4..f5db5093758 100644 --- a/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx +++ b/src/pages/RFOX/components/ChangeAddress/ChangeAddressInput.tsx @@ -17,6 +17,7 @@ import { useTranslate } from 'react-polyglot' import { useHistory } from 'react-router' import { encodeFunctionData } from 'viem' import { Amount } from 'components/Amount/Amount' +import { InlineCopyButton } from 'components/InlineCopyButton' import { Row } from 'components/Row/Row' import { SlideTransition } from 'components/SlideTransition' import { RawText, Text } from 'components/Text' @@ -233,9 +234,13 @@ export const ChangeAddressInput: FC - {currentRuneAddress - ? middleEllipsis(currentRuneAddress) - : translate('RFOX.noAddressFound')} + {currentRuneAddress ? ( + + {middleEllipsis(currentRuneAddress)} + + ) : ( + translate('RFOX.noAddressFound') + )} diff --git a/src/pages/RFOX/components/Stake/StakeInput.tsx b/src/pages/RFOX/components/Stake/StakeInput.tsx index 76bab0925bc..14d748fd9b6 100644 --- a/src/pages/RFOX/components/Stake/StakeInput.tsx +++ b/src/pages/RFOX/components/Stake/StakeInput.tsx @@ -248,7 +248,7 @@ export const StakeInput: React.FC = ({ !( selectedAssetAccountId && stakingAssetAccountId && - runeAddress && + (runeAddress || currentRuneAddress) && selectedAsset && stakingAsset && isValidStakingAmount @@ -260,7 +260,8 @@ export const StakeInput: React.FC = ({ stakingAssetAccountId, stakingAssetId, stakingAmountCryptoBaseUnit: toBaseUnit(amountCryptoPrecision, stakingAsset.precision), - runeAddress: currentRuneAddress ?? runeAddress, + // typescript is borked, one of them is defined because of the early return + runeAddress: currentRuneAddress ? currentRuneAddress : runeAddress ?? '', } setConfirmedQuote(_confirmedQuote) @@ -554,7 +555,7 @@ export const StakeInput: React.FC = ({ isValidWallet={Boolean(isChainSupportedByWallet || isAccountMetadataLoading)} isDisabled={Boolean( errors.amountFieldInput || - !runeAddress || + (!runeAddress && !currentRuneAddress) || !isValidStakingAmount || !(isStakeFeesSuccess || isGetApprovalFeesSuccess) || isAccountMetadataLoading || From 0c6963cd85fe2940eea20b7baf031677defb058d Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:49:46 +0200 Subject: [PATCH 5/8] fix: reset --- .../components/TradeInput/components/ConfirmSummary.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx b/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx index 81f7d3b4b84..48bdb4e068f 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/ConfirmSummary.tsx @@ -238,10 +238,6 @@ export const ConfirmSummary = ({ translate, ]) - const buttonText = useMemo(() => { - return - }, [quoteStatusTranslation]) - return ( <> From 0140283f2ea4458462c0a38261b3b119b9a2eb8c Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:44:09 +0200 Subject: [PATCH 6/8] fix: short circuit --- src/pages/RFOX/components/Stake/StakeInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/RFOX/components/Stake/StakeInput.tsx b/src/pages/RFOX/components/Stake/StakeInput.tsx index 14d748fd9b6..c3a7376ff08 100644 --- a/src/pages/RFOX/components/Stake/StakeInput.tsx +++ b/src/pages/RFOX/components/Stake/StakeInput.tsx @@ -261,7 +261,7 @@ export const StakeInput: React.FC = ({ stakingAssetId, stakingAmountCryptoBaseUnit: toBaseUnit(amountCryptoPrecision, stakingAsset.precision), // typescript is borked, one of them is defined because of the early return - runeAddress: currentRuneAddress ? currentRuneAddress : runeAddress ?? '', + runeAddress: currentRuneAddress || runeAddress, } setConfirmedQuote(_confirmedQuote) From 7a6ebfb6e8c84746ff5387f6228337eb787fe3a8 Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:53:48 +0200 Subject: [PATCH 7/8] fix: short circuit --- src/pages/RFOX/components/Stake/StakeInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/RFOX/components/Stake/StakeInput.tsx b/src/pages/RFOX/components/Stake/StakeInput.tsx index c3a7376ff08..ebed60547db 100644 --- a/src/pages/RFOX/components/Stake/StakeInput.tsx +++ b/src/pages/RFOX/components/Stake/StakeInput.tsx @@ -261,7 +261,7 @@ export const StakeInput: React.FC = ({ stakingAssetId, stakingAmountCryptoBaseUnit: toBaseUnit(amountCryptoPrecision, stakingAsset.precision), // typescript is borked, one of them is defined because of the early return - runeAddress: currentRuneAddress || runeAddress, + runeAddress: currentRuneAddress || runeAddress || '', } setConfirmedQuote(_confirmedQuote) From f79b7b42a0882d52ddcd290fad0162f018b24ff9 Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:29:23 +0200 Subject: [PATCH 8/8] fix: fuck --- src/pages/RFOX/components/AddressSelection.tsx | 11 +++++++++-- src/pages/RFOX/components/Stake/StakeInput.tsx | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pages/RFOX/components/AddressSelection.tsx b/src/pages/RFOX/components/AddressSelection.tsx index 45adf492266..067c501d224 100644 --- a/src/pages/RFOX/components/AddressSelection.tsx +++ b/src/pages/RFOX/components/AddressSelection.tsx @@ -22,6 +22,7 @@ import { validateAddress } from 'lib/address/address' import { selectAccountIdByAccountNumberAndChainId, selectAccountNumberByAccountId, + selectPortfolioAccountIdsByAssetIdFilter, } from 'state/slices/selectors' import { useAppSelector } from 'state/store' @@ -218,6 +219,11 @@ export const AddressSelection: FC = ({ const filter = useMemo(() => ({ accountId: maybeRuneAccountId }), [maybeRuneAccountId]) const accountNumber = useAppSelector(state => selectAccountNumberByAccountId(state, filter)) + const accountsFilter = useMemo(() => ({ assetId: thorchainAssetId }), []) + const runeAccounts = useAppSelector(state => + selectPortfolioAccountIdsByAssetIdFilter(state, accountsFilter), + ) + const CustomAddress = useCallback(() => { if (!maybeSelectedRuneAddress) return @@ -237,9 +243,9 @@ export const AddressSelection: FC = ({ isDisabled={!maybeSelectedRuneAddress} value={maybeSelectedRuneAddress ?? ''} > - {(!Boolean(currentRuneAddress) && maybeRuneAccountId) || + {(!Boolean(currentRuneAddress) && maybeRuneAccountId && setStepIndex) || accountNumber !== undefined || - !setStepIndex ? ( + (!setStepIndex && runeAccounts.length) ? ( = ({ setStepIndex, shouldDisableAccountDropdown, accountNumber, + runeAccounts, ]) const addressSelectionLabel = useMemo( diff --git a/src/pages/RFOX/components/Stake/StakeInput.tsx b/src/pages/RFOX/components/Stake/StakeInput.tsx index ebed60547db..c563a6eb624 100644 --- a/src/pages/RFOX/components/Stake/StakeInput.tsx +++ b/src/pages/RFOX/components/Stake/StakeInput.tsx @@ -216,7 +216,7 @@ export const StakeInput: React.FC = ({ }, } = useRfoxStake({ amountCryptoBaseUnit, - runeAddress, + runeAddress: currentRuneAddress || runeAddress, stakingAssetId, stakingAssetAccountId, hasEnoughBalance,