profile refactor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useWalletBalance, usePortfolio, CHAINS } from '@features/wallet'
|
||||
import type { Chain, FormattedAmount } from '@features/wallet'
|
||||
import { useMe } from '@features/auth'
|
||||
import { getCoinIcon } from '@shared/assets/coins'
|
||||
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
|
||||
import { TOKENS, type Token } from './tokens'
|
||||
@@ -95,6 +96,13 @@ export function useChainTokenRows(chain: Chain) {
|
||||
|
||||
export function useAllWalletTokenRows() {
|
||||
const { data, isLoading } = usePortfolio()
|
||||
const { data: me } = useMe()
|
||||
|
||||
// Legal-entity portfolios return a fixed catalog of supported tokens that are
|
||||
// usually all zero for a fresh account. Filtering out zero balances would
|
||||
// leave this aggregate view blank, so show every wallet/token (matching the
|
||||
// per-chain pages). Individuals keep the non-zero-only view to avoid clutter.
|
||||
const showAll = me?.account_type === 'legal_entity'
|
||||
|
||||
if (!data) return { rows: [] as Token[], isLoading }
|
||||
|
||||
@@ -106,12 +114,12 @@ export function useAllWalletTokenRows() {
|
||||
|
||||
const chainRows: Token[] = []
|
||||
|
||||
if (chainData.native && hasBalance(chainData.native)) {
|
||||
if (chainData.native && (showAll || hasBalance(chainData.native))) {
|
||||
chainRows.push(nativeRowFor(chain, chainData.native))
|
||||
}
|
||||
|
||||
for (const [symbol, amount] of Object.entries(chainData.tokens ?? {})) {
|
||||
if (!hasBalance(amount)) continue
|
||||
if (!showAll && !hasBalance(amount)) continue
|
||||
chainRows.push(tokenRowFor(chain, symbol, amount))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user