// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
import BigNumber from 'bignumber.js';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { eip20 } from '@parity/shared/contracts/abi';
import { api } from '../../parity';
import { loadBalances } from '../../services';
import AddressSelect from '../../AddressSelect';
import Container from '../../Container';
import styles from './send.css';
export default class Send extends Component {
static contextTypes = {
accounts: PropTypes.object.isRequired
}
state = {
loading: true,
tokens: null,
selectedToken: null,
availableBalances: [],
fromAddress: null,
fromBalance: null,
toAddress: null,
toKnown: true,
amount: 0,
amountError: null,
sendBusy: false,
sendError: null,
sendState: null,
sendDone: false,
signerRequestId: null,
txHash: null,
txReceipt: null
}
componentDidMount () {
this.loadBalances();
this.onAmountChange({ target: { value: '0' } });
}
render () {
const { loading } = this.state;
return loading
? this.renderLoading()
: this.renderBody();
}
renderBody () {
const { sendBusy } = this.state;
return sendBusy
? this.renderSending()
: this.renderForm();
}
renderSending () {
const { sendDone, sendError, sendState } = this.state;
if (sendDone) {
return (