// 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 IdleTimer from 'react-idle-timer';
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