// 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 React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { observer } from 'mobx-react';
import { connect } from 'react-redux';
import moment from 'moment';
import { throttle } from 'lodash';
import { Actionbar, ActionbarExport, ActionbarImport, Button, Dropdown, Input, Loading, Page, Toggle, Tab } from '@parity/ui';
import { CancelIcon, ListIcon, SaveIcon, SendIcon, SettingsIcon } from '@parity/ui/Icons';
import Editor from '@parity/ui/Editor';
import DeployContract from '@parity/dapp-contracts/DeployContract';
import LoadContract from './LoadContract';
import SaveContract from './SaveContract';
import ContractDevelopStore from './store';
import styles from './contractDevelop.css';
import { Debugger, TransactButton, Contract, DropdownBond } from 'parity-reactive-ui';
import { Bond } from 'oo7';
import { bonds } from 'oo7-parity';
const traceOptions = [{ text: 'trace', value: 'trace' }, { text: 'vmTrace', value: 'vmTrace' }, { text: 'stateDiff', value: 'stateDiff' }];
@observer
class ContractDevelop extends Component {
static propTypes = {
accounts: PropTypes.object.isRequired,
worker: PropTypes.object,
workerError: PropTypes.any
};
store = ContractDevelopStore.get();
state = {
resizing: false,
size: 65
};
debugDeploy = this.debugDeploy.bind(this);
componentWillMount () {
const { worker } = this.props;
if (worker !== undefined) {
this.store.setWorker(worker);
}
this.throttledResize = throttle(this.applyResize, 100, { leading: true });
}
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 === undefined && nextProps.worker !== undefined) {
this.store.setWorker(nextProps.worker);
}
if (this.props.workerError !== nextProps.workerError) {
this.store.setWorkerError(nextProps.workerError);
}
}
render () {
console.log('render contractDevelopment');
const { sourcecode } = this.store;
const { size, resizing } = this.state;
const annotations = this.store.annotations
.slice()
.filter((a) => a.contract === '');
const panes = [
{ menuItem: 'Parameters', render: () =>