// Copyright 2017-2026 @pezkuwi/app-staking-async authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { SessionInfo } from './types.js'; import React, { useEffect, useState } from 'react'; import { Input, Modal } from '@pezkuwi/react-components'; import { useApi } from '@pezkuwi/react-hooks'; import { isHex } from '@pezkuwi/util'; import { useTranslation } from '../../translate.js'; import SenderInfo from './SenderInfo.js'; interface Props { className?: string; controllerId: string; onChange: (info: SessionInfo) => void; stashId: string; withFocus?: boolean; withSenders?: boolean; } const EMPTY_PROOF = new Uint8Array(); function SessionKey ({ className = '', controllerId, onChange, stashId, withFocus, withSenders }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const [keys, setKeys] = useState(null); useEffect((): void => { try { onChange({ sessionTx: isHex(keys) ? api?.tx.session.setKeys(keys, EMPTY_PROOF) : null }); } catch { onChange({ sessionTx: null }); } }, [api?.tx.session, keys, onChange]); return (
{withSenders && ( )}
); } export default React.memo(SessionKey);