// Copyright 2017-2026 @pezkuwi/app-explorer authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { DigestItem } from '@pezkuwi/types/interfaces'; import type { Codec, TypeDef } from '@pezkuwi/types/types'; import React, { useRef } from 'react'; import { Expander, Table } from '@pezkuwi/react-components'; import Params from '@pezkuwi/react-params'; import { Raw, Struct, Tuple, Vec } from '@pezkuwi/types'; import { getTypeDef } from '@pezkuwi/types/create'; import { useTranslation } from '../translate.js'; interface Props { value?: DigestItem[]; } function formatU8a (value: Raw): React.ReactNode { return ( ); } function formatStruct (struct: Struct): React.ReactNode { const params = Object.entries(struct.Type).map(([name, value]): { name: string; type: TypeDef } => ({ name, type: getTypeDef(value) })); const values = struct.toArray().map((value): { isValid: boolean; value: Codec } => ({ isValid: true, value })); return ( ); } function formatTuple (tuple: Tuple): React.ReactNode { const params = tuple.Types.map((type): { type: TypeDef } => ({ type: getTypeDef(type) })); const values = tuple.toArray().map((value): { isValid: boolean; value: Codec } => ({ isValid: true, value })); return ( ); } function formatVector (vector: Vec): React.ReactNode { const type = getTypeDef(vector.Type); const values = vector.toArray().map((value): { isValid: boolean; value: Codec } => ({ isValid: true, value })); const params = values.map((_, index): { name: string; type: TypeDef } => ({ name: `${index}`, type })); return ( ); } function formatItem (item: DigestItem): React.ReactNode { if (item.value instanceof Struct) { return formatStruct(item.value as Struct); } else if (item.value instanceof Tuple) { return formatTuple(item.value); } else if (item.value instanceof Vec) { return formatVector(item.value as Vec); } else if (item.value instanceof Raw) { return formatU8a(item.value); } return
{item.value.toString().split(',').join(', ')}
; } function Logs ({ value }: Props): React.ReactElement | null { const { t } = useTranslation(); const headerRef = useRef<([React.ReactNode?, string?, number?] | false)[]>([ [t('logs'), 'start'] ]); return ( {value?.map((log, index) => ( ))}
{formatItem(log)}
); } export default React.memo(Logs);