import { LedgerExportForm } from '@vegaprotocol/ledger'; import { Loader, Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet-react'; 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) .filter((asset): asset is PartyAssetFieldsFragment => !!asset?.id) .reduce( (aggr, item) => Object.assign(aggr, { [item.id]: item.symbol }), {} 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 ( ); };