// 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, { PropTypes, Component } from 'react'; import { observer } from 'mobx-react'; import { MenuItem } from 'material-ui'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import CircularProgress from 'material-ui/CircularProgress'; import moment from 'moment'; import ContentClear from 'material-ui/svg-icons/content/clear'; import SaveIcon from 'material-ui/svg-icons/content/save'; import ListIcon from 'material-ui/svg-icons/action/view-list'; import SettingsIcon from 'material-ui/svg-icons/action/settings'; import SendIcon from 'material-ui/svg-icons/content/send'; import { Actionbar, ActionbarExport, ActionbarImport, Button, Editor, Page, Select, Input } from '~/ui'; import { DeployContract, SaveContract, LoadContract } from '~/modals'; import { setupWorker } from '~/redux/providers/compilerActions'; import WriteContractStore from './writeContractStore'; import styles from './writeContract.css'; @observer class WriteContract extends Component { static propTypes = { accounts: PropTypes.object.isRequired, setupWorker: PropTypes.func.isRequired, worker: PropTypes.object, workerError: PropTypes.any }; store = WriteContractStore.get(); state = { resizing: false, size: 65 }; componentWillMount () { const { setupWorker, worker } = this.props; setupWorker(); if (worker) { this.store.setWorker(worker); } } componentDidMount () { this.store.setEditor(this.refs.editor); if (this.props.workerError) { this.store.setWorkerError(this.props.workerError); } // Wait for editor to be loaded window.setTimeout(() => { this.store.resizeEditor(); }, 2000); } // Set the worker if not set before (eg. first page loading) componentWillReceiveProps (nextProps) { if (!this.props.worker && nextProps.worker) { this.store.setWorker(nextProps.worker); } if (this.props.workerError !== nextProps.workerError) { this.store.setWorkerError(nextProps.workerError); } } render () { const { sourcecode } = this.store; const { size, resizing } = this.state; const annotations = this.store.annotations .slice() .filter((a) => a.contract === ''); return (
{ this.renderDeployModal() } { this.renderSaveModal() } { this.renderLoadModal() } { this.renderActionBar() }

{ this.renderTitle() }

Parameters

{ this.renderParameters() }
); } renderTitle () { const { selectedContract } = this.store; if (!selectedContract || !selectedContract.name) { return 'New Solidity Contract'; } return ( { selectedContract.name } (saved { moment(selectedContract.timestamp).fromNow() }) ); } renderActionBar () { const { sourcecode, selectedContract } = this.store; const filename = selectedContract && selectedContract.name ? selectedContract.name .replace(/[^a-z0-9]+/gi, '-') .replace(/-$/, '') .toLowerCase() : 'contract.sol'; const extension = /\.sol$/.test(filename) ? '' : '.sol'; const buttons = [