// Copyright 2017-2025 @pezkuwi/app-treasury authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Bytes, Option } from '@pezkuwi/types'; import type { Hash } from '@pezkuwi/types/interfaces'; import React from 'react'; import { useApi, useCall } from '@pezkuwi/react-hooks'; import { hexToString } from '@pezkuwi/util'; interface Props { hash: Hash; } const OPT = { transform: (optBytes: Option) => optBytes.isSome ? hexToString(optBytes.unwrap().toHex()) : null }; function TipReason ({ hash }: Props): React.ReactElement { const { api } = useApi(); const reasonText = useCall((api.query.tips || api.query.treasury).reasons, [hash], OPT); return ( {reasonText || hash.toHex()} ); } export default React.memo(TipReason);