import { Listbox, Transition } from '@headlessui/react' import { PythCluster } from '@pythnetwork/client' import { MultisigInstruction } from '@pythnetwork/xc-admin-common' import { getInstructionsSummary } from './utils' import { getMappingCluster } from '../../InstructionViews/utils' import CopyText from '../../common/CopyText' import Arrow from '@images/icons/down.inline.svg' import { Fragment, useState, useMemo, useContext } from 'react' import { usePythContext } from '../../../contexts/PythContext' import { ClusterContext } from '../../../contexts/ClusterContext' export const InstructionsSummary = ({ instructions, cluster, }: { instructions: MultisigInstruction[] cluster: PythCluster }) => (
{getInstructionsSummary({ instructions, cluster }).map((instruction) => ( ))}
) const SummaryItem = ({ instruction, }: { instruction: ReturnType[number] }) => { switch (instruction.name) { case 'addPublisher': case 'delPublisher': { return (
{instruction.name}: {instruction.count}
) } default: { return (
{instruction.name}: {instruction.count}
) } } } type AddRemovePublisherDetailsProps = { isAdd: boolean summaries: { readonly priceAccount: string readonly pub: string }[] } const AddRemovePublisherDetails = ({ isAdd, summaries, }: AddRemovePublisherDetailsProps) => { const { cluster } = useContext(ClusterContext) const { priceAccountKeyToSymbolMapping, publisherKeyToNameMapping } = usePythContext() const publisherKeyToName = publisherKeyToNameMapping[getMappingCluster(cluster)] const [groupBy, setGroupBy] = useState<'publisher' | 'price account'>( 'publisher' ) const grouped = useMemo( () => Object.groupBy(summaries, (summary) => groupBy === 'publisher' ? summary.pub : summary.priceAccount ), [groupBy, summaries] ) return (
Group by