import { LedgerExportForm } from '@vegaprotocol/ledger'; import { Loader, Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { useEnvironment } from '@vegaprotocol/environment'; import type { PartyAssetFieldsFragment } from '@vegaprotocol/assets'; import { usePartyAssetsQuery } from '@vegaprotocol/assets'; import { useT } from '../../lib/use-t'; export const LedgerContainer = () => { const t = useT(); const VEGA_URL = useEnvironment((store) => store.VEGA_URL); const { pubKey } = useVegaWallet(); const { data, loading } = usePartyAssetsQuery({ variables: { partyId: pubKey || '' }, skip: !pubKey, }); const assets = (data?.party?.accountsConnection?.edges ?? []) .map( (item) => item?.node?.asset ?? ({} as PartyAssetFieldsFragment) ) .reduce((aggr, item) => { if ('id' in item && 'symbol' in item) { aggr[item.id as string] = item.symbol as string; } return aggr; }, {} as Record); if (!pubKey) { return (

{t('Please connect Vega wallet')}

); } if (!VEGA_URL) { return (

{t('Environment not configured')}

); } if (loading) { return (
); } if (!Object.keys(assets).length) { return (

{t('No ledger entries to export')}

); } return ( ); };