// Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity. // // SPDX-License-Identifier: BSD-3-Clause import React, { Component } from 'react'; import { Field, Form } from 'react-final-form'; import { Form as FetherForm, Header } from 'fether-ui'; import { inject, observer } from 'mobx-react'; import { Link, Redirect } from 'react-router-dom'; import { withProps } from 'recompose'; import i18n, { packageNS } from '../../i18n'; import RequireHealthOverlay from '../../RequireHealthOverlay'; import TokenAddress from '../../Tokens/TokensList/TokenAddress'; import withAccount from '../../utils/withAccount.js'; import withTokens from '../../utils/withTokens'; @inject('sendStore') @withAccount @withTokens @withProps(({ match: { params: { tokenAddress } }, tokens }) => ({ token: tokens[tokenAddress] })) @observer class Unlock extends Component { handleAccept = values => { const { account: { address }, history, sendStore, token } = this.props; return sendStore .send(values.password) .then(() => history.push(`/send/${token.address}/from/${address}/sent`)) .catch(error => ({ password: error.text === 'Method not found' ? "Please enable the 'personal' api in the --ws-apis launch flag of Parity Ethereum." : error.text })); }; render () { const { account: { address }, history, sendStore: { tx }, token } = this.props; if (!tx || !token) { return ; } return (
{i18n.t(`${packageNS}:navigation.close`)} } title={ token && (

{i18n.t(`${packageNS}:tx.header_send_prefix`, { token: token.name })}

) } />
,
(

{i18n.t(`${packageNS}:tx.form.label_unlock`)}

)} /> ]} shortAddress={false} />
); } } export default Unlock;