// Copyright 2017-2020 @polkadot/app-toolbox authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/react-components/types'; import { KeyringPair } from '@polkadot/keyring/types'; import React from 'react'; import { AddressRow, Button, Modal, Password, TxComponent } from '@polkadot/react-components'; import translate from './translate'; interface Props extends I18nProps { onClose: () => void; onUnlock: () => void; pair: KeyringPair | null; } interface State { address: string; password: string; unlockError: string | null; } class Unlock extends TxComponent { public state: State = { address: '', password: '', unlockError: null }; public static getDerivedStateFromProps ({ pair }: Props): Pick { return { address: (pair && pair.address) || '' }; } public render (): React.ReactNode { const { pair, t } = this.props; if (!pair) { return null; } return ( {this.renderContent()} {this.renderActions()} ); } private renderActions (): React.ReactNode { const { t } = this.props; return (