// Copyright 2015, 2016 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 React, { Component, PropTypes } from 'react';
import { api } from '../../parity';
import AddressSelect from '../../AddressSelect';
import Container from '../../Container';
import styles from './deployment.css';
const ERRORS = {
name: 'specify a valid name >2 & <32 characters',
tla: 'specify a valid TLA, 3 characters in length',
usedtla: 'the TLA used is not available for registration',
supply: 'supply needs to be valid >999 & <1 trillion'
};
export default class Deployment extends Component {
static contextTypes = {
accounts: PropTypes.object.isRequired,
router: PropTypes.object.isRequired,
managerInstance: PropTypes.object.isRequired,
registryInstance: PropTypes.object.isRequired,
tokenregInstance: PropTypes.object.isRequired
}
state = {
base: null,
deployBusy: false,
deployDone: false,
deployError: null,
deployState: null,
globalReg: false,
globalFee: 0,
globalFeeText: '1.000',
fromAddress: null,
name: '',
nameError: ERRORS.name,
tla: '',
tlaError: ERRORS.tla,
totalSupply: '5000000',
totalSupplyError: null,
signerRequestId: null,
txHash: null
}
componentDidMount () {
const { managerInstance, tokenregInstance } = this.context;
Promise
.all([
managerInstance.base.call(),
tokenregInstance.fee.call()
])
.then(([base, globalFee]) => {
this.setState({
base,
baseText: base.toFormat(0),
globalFee,
globalFeeText: api.util.fromWei(globalFee).toFormat(3)
});
});
}
render () {
const { deployBusy } = this.state;
return deployBusy
? this.renderDeploying()
: this.renderForm();
}
renderDeploying () {
const { deployDone, deployError, deployState } = this.state;
if (deployDone) {
return (
Your token has been deployed
);
}
if (deployError) {
return (
Your deployment has encountered an error
{ deployError }
);
}
return (
Your token is currently being deployed to the network