// Copyright 2017-2019 @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/ui-app/types'; import { KeyringPair } from '@polkadot/keyring/types'; import React from 'react'; import { AddressRow, Button, Modal, Password, TxComponent } from '@polkadot/ui-app'; import translate from './translate'; type Props = I18nProps & { onClose: () => void, pair: KeyringPair | null }; type State = { address: string, password: string, unlockError: string | null }; class Unlock extends TxComponent { state: State = { address: '', password: '', unlockError: null }; static getDerivedStateFromProps ({ pair }: Props): State { return { address: pair ? pair.address() : '' } as State; } render () { const { pair, t } = this.props; if (!pair) { return null; } return ( {t('Unlock account')} {this.renderContent()} {this.renderActions()} ); } private renderActions () { const { t } = this.props; return (