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 #840

Merged
merged 3 commits into from
Dec 10, 2024
Merged

fix #840

Changes from 2 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
23 changes: 15 additions & 8 deletions src/features/governance/PositionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import React, { useCallback, useMemo, useRef, useState } from 'react'
import { useAsync } from 'react-async-hook'
import { useTranslation } from 'react-i18next'
import { FadeIn, FadeOut } from 'react-native-reanimated'
import { EPOCH_LENGTH } from '@helium/helium-sub-daos-sdk'
import { MessagePreview } from '../../solana/MessagePreview'
import { useSolana } from '../../solana/SolanaProvider'
import { useWalletSign } from '../../solana/WalletSignProvider'
Expand Down Expand Up @@ -126,7 +127,7 @@ export const PositionCard = ({
})
}, [position, unixNow, positions])

const { lockup, hasGenesisMultiplier, votingMint } = position
const { lockup, isDelegated, hasGenesisMultiplier, votingMint } = position
const { info: mintAcc } = useMint(votingMint.mint)
const {
loading: loadingMetadata,
Expand All @@ -139,8 +140,13 @@ export const PositionCard = ({
? t('gov.positions.constant')
: t('gov.positions.decaying')
const hasActiveVotes = position.numActiveVotes > 0
const decayedEpoch = lockup.endTs.div(new BN(EPOCH_LENGTH))
const currentEpoch = new BN(unixNow).div(new BN(EPOCH_LENGTH))
const lockupExpired =
!isConstant && lockup.endTs.sub(new BN(unixNow || 0)).lt(new BN(0))
!isConstant &&
(isDelegated
? currentEpoch.gt(decayedEpoch)
: lockup.endTs.sub(new BN(unixNow || 0)).lt(new BN(0)))

const lockedTokens =
mintAcc && humanReadable(position.amountDepositedNative, mintAcc.decimals)
Expand Down Expand Up @@ -584,7 +590,7 @@ export const PositionCard = ({
)
return (
<>
{position.isDelegated ? (
{isDelegated ? (
<>
<ListItem
key="undelegate"
Expand Down Expand Up @@ -691,7 +697,7 @@ export const PositionCard = ({
/>
</>
)}
{canDelegate && !position.isDelegated && (
{canDelegate && !isDelegated && (
<ListItem
key="delegate"
title={t('gov.positions.delegate')}
Expand Down Expand Up @@ -871,11 +877,12 @@ export const PositionCard = ({
</Text>
<Text variant="body2" color="primaryText">
{isConstant
? getMinDurationFmt(
position.lockup.startTs,
position.lockup.endTs,
? getMinDurationFmt(lockup.startTs, lockup.endTs)
: isDelegated
? getTimeLeftFromNowFmt(
lockup.endTs.add(new BN(EPOCH_LENGTH)),
)
: getTimeLeftFromNowFmt(position.lockup.endTs)}
: getTimeLeftFromNowFmt(lockup.endTs)}
</Text>
</Box>
{hasGenesisMultiplier && (
Expand Down
Loading