import { useWeb3React } from '@web3-react/core';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import { getButtonClasses, Button } from '@vegaprotocol/ui-toolkit';
import {
AppStateActionType,
useAppState,
} from '../../contexts/app-state/app-state-context';
import { usePendingTransactions } from '../../hooks/use-pending-transactions';
import vegaVesting from '../../images/vega_vesting.png';
import vegaWhite from '../../images/vega_white.png';
import { BigNumber } from '../../lib/bignumber';
import { truncateMiddle } from '../../lib/truncate-middle';
import { Routes } from '../../routes/router-config';
import { LockedProgress } from '../locked-progress';
import {
WalletCard,
WalletCardActions,
WalletCardAsset,
WalletCardContent,
WalletCardHeader,
WalletCardRow,
} from '../wallet-card';
import { Loader } from '@vegaprotocol/ui-toolkit';
import { theme } from '@vegaprotocol/tailwindcss-config';
const Colors = theme.colors;
const removeLeadingAddressSymbol = (key: string) => {
if (key && key.length > 2 && key.slice(0, 2) === '0x') {
return truncateMiddle(key.substring(2));
}
return truncateMiddle(key);
};
const AssociatedAmounts = ({
associations,
notAssociated,
}: {
associations: { [key: string]: BigNumber };
notAssociated: BigNumber;
}) => {
const { t } = useTranslation();
const vestingAssociationByVegaKey = React.useMemo(
() =>
Object.entries(associations).filter(([, amount]) =>
amount.isGreaterThan(0)
),
[associations]
);
const associationAmounts = React.useMemo(() => {
const totals = vestingAssociationByVegaKey.map(([, amount]) => amount);
const associated = BigNumber.sum.apply(null, [new BigNumber(0), ...totals]);
return {
total: associated.plus(notAssociated),
associated,
notAssociated,
};
}, [notAssociated, vestingAssociationByVegaKey]);
return (
<>