Skip to content

Commit

Permalink
feat: disable buy and sell buttons for assets table (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
vacekj authored Jan 24, 2025
1 parent 250d6fa commit 4eebfad
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions src/pages/portfolio/ui/assets-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,9 @@ import { BalancesResponse } from '@penumbra-zone/protobuf/penumbra/view/v1/view_
import { AssetIcon } from '@penumbra-zone/ui/AssetIcon';
import { getDisplayDenomExponent } from '@penumbra-zone/getters/metadata';
import { formatAmount } from '@penumbra-zone/types/amount';
import { useRouter } from 'next/navigation';
import { Button } from '@penumbra-zone/ui/Button';
import { useState, useEffect } from 'react';
import { AddressIndex } from '@penumbra-zone/protobuf/penumbra/core/keys/v1/keys_pb';
import { ViewService } from '@penumbra-zone/protobuf';
import { useQuery } from '@tanstack/react-query';
import { penumbra } from '@/shared/const/penumbra';

const useChainId = () => {
return useQuery({
queryKey: ['chainId'],
queryFn: async () => {
const { parameters } = await penumbra.service(ViewService).appParameters({});
return parameters?.chainId;
},
enabled: connectionStore.connected,
});
};

const LoadingState = () => {
return (
Expand Down Expand Up @@ -282,12 +267,10 @@ const calculateAssetDistribution = (balances: BalancesResponse[]): DistributionR
};

export const AssetsTable = observer(() => {
const router = useRouter();
const { connected } = connectionStore;
const addressIndex = new AddressIndex({ account: connectionStore.subaccount });
const { data: balances, isLoading: balancesLoading } = useBalances(addressIndex.account);
const { data: assets, isLoading: assetsLoading } = useAssets();
const { data: chainId } = useChainId();
const [distribution, setDistribution] = useState<DistributionResult>();

useEffect(() => {
Expand All @@ -296,9 +279,6 @@ export const AssetsTable = observer(() => {
}
}, [balances]);

const isTestnet = chainId !== 'penumbra-1';
const stableCoinSymbol = isTestnet ? 'UM' : 'USDC';

const isLoading = balancesLoading || assetsLoading || !balances || !assets || !distribution;

if (isLoading) {
Expand Down Expand Up @@ -405,22 +385,10 @@ export const AssetsTable = observer(() => {
</Table.Td>
<Table.Td hAlign='right'>
<div className='flex gap-2 justify-end'>
<Button
icon={ArrowDownRight}
iconOnly
onClick={() =>
router.push(`/trade/${stableCoinSymbol}/${metadata.symbol}`)
}
>
<Button icon={ArrowDownRight} iconOnly disabled>
Sell
</Button>
<Button
icon={ArrowUpRight}
iconOnly
onClick={() =>
router.push(`/trade/${metadata.symbol}/${stableCoinSymbol}`)
}
>
<Button icon={ArrowUpRight} iconOnly disabled>
Buy
</Button>
</div>
Expand Down

0 comments on commit 4eebfad

Please sign in to comment.