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: Reset the staking data when switching wallets #2701

Merged
merged 11 commits into from
Jul 31, 2023
2 changes: 1 addition & 1 deletion packages/app/src/constants/announcement.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MILLISECONDS_PER_DAY } from '@kwenta/sdk/constants'

// Shows or hides the home page banner entirely when set to true/false
export const BANNER_ENABLED = true
export const BANNER_ENABLED = false
// Sets the link destination for the banner component, or renders the banner as
// plain, un-clickable text if set to a falsey value (`false`, `null`, '', etc...)
export const BANNER_LINK_URL =
Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions packages/app/src/sections/dashboard/Stake/RedemptionTab.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import ROUTES from 'constants/routes'
import { selectTradePreview } from 'state/futures/selectors'
import { useAppSelector } from 'state/hooks'
import {
selectStakedEscrowedKwentaBalanceV2,
selectStakedKwentaBalanceV2,
selectStakedEscrowedKwentaBalance,
selectStakedKwentaBalance,
} from 'state/staking/selectors'
import { selectWallet } from 'state/wallet/selectors'

Expand All @@ -36,8 +36,8 @@ export const TradePanelFeeInfo = memo(() => {
const TradingRewardRow = memo(() => {
const { t } = useTranslation()
const walletAddress = useAppSelector(selectWallet)
const stakedEscrowedKwentaBalance = useAppSelector(selectStakedEscrowedKwentaBalanceV2)
const stakedKwentaBalance = useAppSelector(selectStakedKwentaBalanceV2)
const stakedEscrowedKwentaBalance = useAppSelector(selectStakedEscrowedKwentaBalance)
const stakedKwentaBalance = useAppSelector(selectStakedKwentaBalance)

const isRewardEligible = useMemo(
() => !!walletAddress && stakedKwentaBalance.add(stakedEscrowedKwentaBalance).gt(0),
Expand Down
11 changes: 2 additions & 9 deletions packages/app/src/sections/shared/Layout/HomeLayout/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,14 @@ const Banner = memo(() => {
const dispatch = useAppDispatch()
const showBanner = useAppSelector(selectShowBanner)
const storedTime: number = localStore.get('bannerIsClicked') || 0
const router = useRouter()

useEffect(
() => {
const currentTime = new Date().getTime()
dispatch(
setShowBanner(
currentTime - storedTime >= BANNER_WAITING_TIME &&
BANNER_ENABLED &&
router.pathname.includes('staking')
)
)
dispatch(setShowBanner(currentTime - storedTime >= BANNER_WAITING_TIME && BANNER_ENABLED))
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[storedTime, router.pathname]
[storedTime]
)

const handleDismiss = useCallback(
Expand Down
14 changes: 2 additions & 12 deletions packages/app/src/state/futures/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { useAppSelector, useFetchAction, usePollAction } from 'state/hooks'
import { fetchStakeMigrateData, fetchStakingV2Data } from 'state/staking/actions'
import {
selectSelectedEpoch,
selectStakingSupportedNetwork,
selectTradingRewardsSupportedNetwork,
} from 'state/staking/selectors'
import { fetchStakeMigrateData } from 'state/staking/actions'
import { selectSelectedEpoch, selectStakingSupportedNetwork } from 'state/staking/selectors'
import { selectNetwork, selectWallet } from 'state/wallet/selectors'

import {
Expand Down Expand Up @@ -38,18 +34,12 @@ export const usePollMarketFuturesData = () => {
const selectedAccountType = useAppSelector(selectFuturesType)
const networkSupportsCrossMargin = useAppSelector(selectFuturesSupportedNetwork)
const networkSupportsFutures = useAppSelector(selectFuturesSupportedNetwork)
const networkSupportsTradingRewards = useAppSelector(selectTradingRewardsSupportedNetwork)

useFetchAction(fetchCrossMarginAccount, {
dependencies: [networkId, wallet],
disabled: !wallet || !networkSupportsCrossMargin || selectedAccountType === 'isolated_margin',
})

useFetchAction(fetchStakingV2Data, {
dependencies: [networkId, wallet],
disabled: !wallet || !networkSupportsTradingRewards,
})

useFetchAction(fetchMarginTransfers, { dependencies: [networkId, wallet, selectedAccountType] })
usePollAction('fetchSharedFuturesData', fetchSharedFuturesData, {
dependencies: [networkId],
Expand Down
Loading
Loading