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

Chore/2.10.2 to main #847

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,34 @@
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-rtk-query": "^3.1.1",
"@helium/account-fetch-cache": "0.9.14",
"@helium/account-fetch-cache-hooks": "0.9.14",
"@helium/account-fetch-cache": "0.9.18",
"@helium/account-fetch-cache-hooks": "0.9.18",
"@helium/address": "4.10.2",
"@helium/circuit-breaker-sdk": "^0.9.14",
"@helium/circuit-breaker-sdk": "^0.9.18",
"@helium/crypto-react-native": "4.8.0",
"@helium/currency-utils": "^0.9.14",
"@helium/data-credits-sdk": "^0.9.14",
"@helium/distributor-oracle": "0.9.14",
"@helium/fanout-sdk": "^0.9.14",
"@helium/helium-entity-manager-sdk": "^0.9.14",
"@helium/helium-react-hooks": "0.9.14",
"@helium/helium-sub-daos-sdk": "^0.9.14",
"@helium/currency-utils": "^0.9.18",
"@helium/data-credits-sdk": "^0.9.18",
"@helium/distributor-oracle": "0.9.18",
"@helium/fanout-sdk": "^0.9.18",
"@helium/helium-entity-manager-sdk": "^0.9.18",
"@helium/helium-react-hooks": "0.9.18",
"@helium/helium-sub-daos-sdk": "^0.9.18",
"@helium/http": "4.7.5",
"@helium/idls": "0.9.14",
"@helium/lazy-distributor-sdk": "^0.9.14",
"@helium/idls": "0.9.18",
"@helium/lazy-distributor-sdk": "^0.9.18",
"@helium/modular-governance-hooks": "^0.0.13",
"@helium/modular-governance-idls": "0.0.13",
"@helium/onboarding": "4.11.0",
"@helium/organization-sdk": "^0.0.13",
"@helium/proto-ble": "4.0.0",
"@helium/react-native-sdk": "3.0.5",
"@helium/spl-utils": "0.9.14",
"@helium/spl-utils": "0.9.18",
"@helium/state-controller-sdk": "^0.0.13",
"@helium/sus": "0.9.14",
"@helium/sus": "0.9.18",
"@helium/transactions": "4.8.1",
"@helium/treasury-management-sdk": "^0.9.14",
"@helium/voter-stake-registry-hooks": "0.9.14",
"@helium/voter-stake-registry-sdk": "0.9.14",
"@helium/treasury-management-sdk": "^0.9.18",
"@helium/voter-stake-registry-hooks": "0.9.18",
"@helium/voter-stake-registry-sdk": "0.9.18",
"@helium/wallet-link": "4.11.0",
"@jup-ag/api": "^6.0.6",
"@keystonehq/keystone-sdk": "^0.8.0",
Expand Down Expand Up @@ -294,11 +294,11 @@
"@types/react": "18",
"react": "18.2.0",
"@solana/wallet-adapter-react": "0.15.33",
"@helium/account-fetch-cache": "^0.9.14",
"@helium/account-fetch-cache-hooks": "^0.9.14",
"@helium/helium-react-hooks": "^0.9.14",
"@helium/voter-stake-registry-hooks": "^0.9.14",
"@helium/voter-stake-registry-sdk": "^0.9.14",
"@helium/account-fetch-cache": "^0.9.18",
"@helium/account-fetch-cache-hooks": "^0.9.18",
"@helium/helium-react-hooks": "^0.9.18",
"@helium/voter-stake-registry-hooks": "^0.9.18",
"@helium/voter-stake-registry-sdk": "^0.9.18",
"@helium/modular-governance-hooks": "^0.0.13",
"@helium/onboarding": "4.11.0"
},
Expand Down
28 changes: 18 additions & 10 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 '@features/solana/MessagePreview'
import { useSolana } from '@features/solana/SolanaProvider'
import { useWalletSign } from '@features/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 lockupExpired =
!isConstant && lockup.endTs.sub(new BN(unixNow || 0)).lt(new BN(0))
const decayedEpoch = lockup.endTs.div(new BN(EPOCH_LENGTH))
const currentEpoch = new BN(unixNow).div(new BN(EPOCH_LENGTH))
const isDecayed =
!isConstant &&
(isDelegated
? currentEpoch.gt(decayedEpoch)
: lockup.endTs.lte(new BN(unixNow)))

const lockedTokens =
mintAcc && humanReadable(position.amountDepositedNative, mintAcc.decimals)
Expand Down Expand Up @@ -436,6 +442,7 @@ export const PositionCard = ({
onInstructions: async (ixs, sigs) => {
await decideAndExecute({
header: t('gov.transactions.splitPosition'),
sequentially: true,
message: t('gov.positions.splitMessage', {
amount: values.amount,
symbol,
Expand Down Expand Up @@ -583,7 +590,7 @@ export const PositionCard = ({
)
return (
<>
{position.isDelegated ? (
{isDelegated ? (
<>
<ListItem
key="undelegate"
Expand All @@ -599,7 +606,7 @@ export const PositionCard = ({
</>
) : (
<>
{lockupExpired ? (
{isDecayed ? (
<ListItem
key="close"
title={t('gov.positions.close')}
Expand Down Expand Up @@ -690,7 +697,7 @@ export const PositionCard = ({
/>
</>
)}
{canDelegate && !position.isDelegated && (
{canDelegate && !isDelegated && (
<ListItem
key="delegate"
title={t('gov.positions.delegate')}
Expand Down Expand Up @@ -878,11 +885,12 @@ export const PositionCard = ({
</Text>
<Text variant="textSmRegular" 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
Loading