don't load hidden mango accounts
This commit is contained in:
parent
9d7e2e2385
commit
93e31ce5eb
|
@ -9,6 +9,7 @@ import useNetworkSpeed from 'hooks/useNetworkSpeed'
|
|||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import useLocalStorageState from 'hooks/useLocalStorageState'
|
||||
import { DEFAULT_PRIORITY_FEE_LEVEL } from './settings/RpcSettings'
|
||||
import { useHiddenMangoAccounts } from 'hooks/useHiddenMangoAccounts'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
const actions = mangoStore.getState().actions
|
||||
|
@ -143,6 +144,7 @@ const ReadOnlyMangoAccount = () => {
|
|||
const router = useRouter()
|
||||
const groupLoaded = mangoStore((s) => s.groupLoaded)
|
||||
const ma = router.query?.address
|
||||
const { hiddenAccounts } = useHiddenMangoAccounts()
|
||||
|
||||
useEffect(() => {
|
||||
if (!groupLoaded) return
|
||||
|
@ -151,7 +153,7 @@ const ReadOnlyMangoAccount = () => {
|
|||
|
||||
async function loadUnownedMangoAccount() {
|
||||
try {
|
||||
if (!ma || !group) return
|
||||
if (!ma || !group || hiddenAccounts?.includes(ma as string)) return
|
||||
|
||||
const client = mangoStore.getState().client
|
||||
const pk = new PublicKey(ma)
|
||||
|
|
|
@ -19,8 +19,6 @@ import Change from '@components/shared/Change'
|
|||
import SheenLoader from '@components/shared/SheenLoader'
|
||||
import { PerformanceDataItem } from 'types'
|
||||
import useAccountHourlyVolumeStats from 'hooks/useAccountHourlyVolumeStats'
|
||||
import { useHiddenMangoAccounts } from 'hooks/useHiddenMangoAccounts'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
|
||||
const AccountHeroStats = ({
|
||||
accountPnl,
|
||||
|
@ -40,12 +38,6 @@ const AccountHeroStats = ({
|
|||
const { mangoAccount, mangoAccountAddress } = useMangoAccount()
|
||||
const { hourlyVolumeData, loadingHourlyVolume } =
|
||||
useAccountHourlyVolumeStats()
|
||||
const { hiddenAccounts } = useHiddenMangoAccounts()
|
||||
const { connected } = useWallet()
|
||||
const accountHidden =
|
||||
!connected &&
|
||||
mangoAccountAddress &&
|
||||
hiddenAccounts?.includes(mangoAccountAddress)
|
||||
|
||||
const totalInterestData = mangoStore(
|
||||
(s) => s.mangoAccount.interestTotals.data,
|
||||
|
@ -322,7 +314,7 @@ const AccountHeroStats = ({
|
|||
>
|
||||
<p className="tooltip-underline">{t('pnl')}</p>
|
||||
</Tooltip>
|
||||
{mangoAccountAddress && !accountHidden ? (
|
||||
{mangoAccountAddress ? (
|
||||
<div className="flex items-center space-x-3">
|
||||
<Tooltip
|
||||
className="hidden md:block"
|
||||
|
@ -353,35 +345,17 @@ const AccountHeroStats = ({
|
|||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{!accountHidden ? (
|
||||
<>
|
||||
<p className="mb-0.5 mt-1 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
|
||||
<FormatNumericValue
|
||||
value={accountPnl}
|
||||
decimals={2}
|
||||
isUsd={true}
|
||||
/>
|
||||
</p>
|
||||
<div className="flex space-x-1.5">
|
||||
<Change
|
||||
change={rollingDailyPnlChange}
|
||||
prefix="$"
|
||||
size="small"
|
||||
/>
|
||||
<p className="text-xs text-th-fgd-4">{t('rolling-change')}</p>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="mb-0.5 mt-1 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
|
||||
<FormatNumericValue value={0} decimals={2} isUsd={true} />
|
||||
</p>
|
||||
<div className="flex space-x-1.5">
|
||||
<Change change={0} prefix="$" size="small" />
|
||||
<p className="text-xs text-th-fgd-4">{t('rolling-change')}</p>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<p className="mb-0.5 mt-1 text-left text-2xl font-bold text-th-fgd-1 lg:text-xl xl:text-2xl">
|
||||
<FormatNumericValue
|
||||
value={accountPnl}
|
||||
decimals={2}
|
||||
isUsd={true}
|
||||
/>
|
||||
</p>
|
||||
<div className="flex space-x-1.5">
|
||||
<Change change={rollingDailyPnlChange} prefix="$" size="small" />
|
||||
<p className="text-xs text-th-fgd-4">{t('rolling-change')}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-6 border-t border-th-bkg-3 py-3 pl-6 pr-4 md:col-span-3 md:border-l lg:col-span-2 lg:border-l-0 2xl:col-span-1 2xl:border-l 2xl:border-t-0">
|
||||
|
|
|
@ -14,6 +14,24 @@ const HideMangoAccount = () => {
|
|||
const { accountHidden, refetch } = useMangoAccountHidden()
|
||||
const [signingForHide, setSigningForHide] = useState(false)
|
||||
|
||||
const handleHideMangoAccount = async () => {
|
||||
if (!publicKey || !mangoAccountPk || !signMessage) return
|
||||
setSigningForHide(true)
|
||||
try {
|
||||
await toggleMangoAccountHidden(
|
||||
mangoAccountPk,
|
||||
publicKey,
|
||||
!(accountHidden ?? false),
|
||||
signMessage,
|
||||
)
|
||||
refetch()
|
||||
setSigningForHide(false)
|
||||
} catch (e) {
|
||||
console.error('Error toggling account visibility', e)
|
||||
setSigningForHide(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-between border-t border-th-bkg-3 p-4">
|
||||
|
@ -23,21 +41,7 @@ const HideMangoAccount = () => {
|
|||
) : (
|
||||
<Switch
|
||||
checked={accountHidden ?? false}
|
||||
onChange={async () => {
|
||||
if (!publicKey) throw new Error('Wallet not connected!')
|
||||
if (!mangoAccountPk) throw new Error('MangoAccount not found!')
|
||||
if (!signMessage)
|
||||
throw new Error('Wallet does not support message signing!')
|
||||
setSigningForHide(true)
|
||||
await toggleMangoAccountHidden(
|
||||
mangoAccountPk,
|
||||
publicKey,
|
||||
!(accountHidden ?? false),
|
||||
signMessage,
|
||||
)
|
||||
setSigningForHide(false)
|
||||
refetch()
|
||||
}}
|
||||
onChange={handleHideMangoAccount}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
import mangoStore from '@store/mangoStore'
|
||||
import Switch from '@components/forms/Switch'
|
||||
import { CUSTOM_SKINS } from 'utils/theme'
|
||||
import HideMangoAccount from '@components/account/HideMangoAccount'
|
||||
|
||||
const NOTIFICATION_POSITIONS = [
|
||||
'bottom-left',
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { bs58 } from '@project-serum/anchor/dist/cjs/utils/bytes'
|
||||
import { PublicKey } from '@solana/web3.js'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { isMangoError } from 'types'
|
||||
import { MANGO_DATA_API_URL } from 'utils/constants'
|
||||
import { notify } from 'utils/notifications'
|
||||
import useMangoAccount from './useMangoAccount'
|
||||
|
||||
const fetchMangoAccountHidden = async (mangoAccountAddress: string) => {
|
||||
|
@ -73,13 +71,6 @@ export const toggleMangoAccountHidden = async (
|
|||
requestOptions,
|
||||
)
|
||||
} catch (e) {
|
||||
if (isMangoError(e)) {
|
||||
notify({
|
||||
title: 'idk',
|
||||
description: e.message,
|
||||
txid: e.txid,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
console.error('Failed to toggle mango account privacy', e)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue