// Copyright 2017-2023 @polkadot/react-components authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Call, Extrinsic } from '@polkadot/types/interfaces'; import type { BN } from '@polkadot/util'; import React, { useMemo } from 'react'; import CallDisplay from './Call'; import Expander from './Expander'; interface Props { children?: React.ReactNode; className?: string; idString?: string; isHeader?: boolean; labelHash?: React.ReactNode; labelSignature?: React.ReactNode; mortality?: string; onError?: () => void; stringId?: string; tip?: BN; value?: Call | Extrinsic | null; withBorder?: boolean; withHash?: boolean; withSignature?: boolean; } function CallExpander ({ children, className = '', isHeader, labelHash, labelSignature, mortality, onError, stringId, tip, value, withBorder, withHash, withSignature }: Props): React.ReactElement | null { const call = useMemo( () => value && value.callIndex ? value.registry.findMetaCall(value.callIndex) : null, [value] ); if (!call || !value) { return null; } const { meta, method, section } = call; const callName = `${section}.${method}`; return (
{stringId && `#${stringId}: `}{callName} } summaryMeta={meta} > {children}
); } export default React.memo(CallExpander);