/* This file is part of cpp-ethereum. cpp-ethereum 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. cpp-ethereum 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 cpp-ethereum. If not, see . */ /** @file MainWin.h * @author Gav Wood * @date 2014 */ #pragma once #ifdef Q_MOC_RUN #define BOOST_MPL_IF_HPP_INCLUDED #endif #include #include #include #include #include #include #include #include #include #include #include #include "Context.h" #include "Debugger.h" #include "NatspecHandler.h" namespace Ui { class Main; } namespace dev { namespace eth { class Client; class State; }} namespace jsonrpc { class HttpServer; } class QQuickView; class OurWebThreeStubServer; using WatchHandler = std::function; QString contentsOfQResource(std::string const& res); class Main: public QMainWindow, public Context { Q_OBJECT public: explicit Main(QWidget *parent = 0); ~Main(); dev::WebThreeDirect* web3() const { return m_webThree.get(); } dev::eth::Client* ethereum() const { return m_webThree->ethereum(); } std::shared_ptr whisper() const { return m_webThree->whisper(); } std::string lookupNatSpec(dev::h256 const& _contractHash) const; std::string lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData); QList owned() const { return m_myIdentities + m_myKeys; } QVariant evalRaw(QString const& _js); QString pretty(dev::Address _a) const override; QString prettyU256(dev::u256 _n) const override; QString render(dev::Address _a) const override; dev::Address fromString(QString const& _a) const override; std::string renderDiff(dev::eth::StateDiff const& _d) const override; public slots: void load(QString _file); void note(QString _entry); void debug(QString _entry); void warn(QString _entry); QString contents(QString _file); int authenticate(QString _title, QString _text); void onKeysChanged(); private slots: void eval(QString const& _js); // Application void on_about_triggered(); void on_quit_triggered() { close(); } // Network void on_go_triggered(); void on_net_triggered(); void on_connect_triggered(); void on_idealPeers_valueChanged(); // Mining void on_mine_triggered(); // View void on_refresh_triggered(); void on_showAll_triggered() { refreshBlockChain(); } void on_showAllAccounts_triggered() { refreshAccounts(); } void on_preview_triggered(); // Transacting void on_value_valueChanged() { updateFee(); } void on_gas_valueChanged() { updateFee(); } void on_valueUnits_currentIndexChanged() { updateFee(); } void on_gasPriceUnits_currentIndexChanged() { updateFee(); } void on_gasPrice_valueChanged() { updateFee(); } void on_destination_currentTextChanged(); void on_data_textChanged(); void on_send_clicked(); void on_debug_clicked(); // Account management void on_newAccount_triggered(); void on_killAccount_triggered(); void on_importKey_triggered(); void on_importKeyFile_triggered(); void on_exportKey_triggered(); // Tools void on_loadJS_triggered(); // Stuff concerning the blocks/transactions/accounts panels void ourAccountsRowsMoved(); void on_ourAccounts_doubleClicked(); void on_accounts_doubleClicked(); void on_contracts_doubleClicked(); void on_contracts_currentItemChanged(); void on_transactionQueue_currentItemChanged(); void on_blockChainFilter_textChanged(); void on_blocks_currentItemChanged(); // Logging void on_log_doubleClicked(); void on_verbosity_valueChanged(); // Misc void on_urlEdit_returnPressed(); void on_jsInput_returnPressed(); void on_nameReg_textChanged(); // Special (debug) stuff void on_paranoia_triggered(); void on_killBlockchain_triggered(); void on_clearPending_triggered(); void on_inject_triggered(); void on_forceMining_triggered(); void on_usePrivate_triggered(); void on_enableOptimizer_triggered(); void on_turboMining_triggered(); void on_jitvm_triggered(); // Debugger void on_debugCurrent_triggered(); void on_debugDumpState_triggered(int _add = 1); void on_debugDumpStatePre_triggered(); // Whisper void on_newIdentity_triggered(); void on_post_clicked(); void refreshWhisper(); void refreshBlockChain(); void addNewId(QString _ids); signals: void poll(); private: dev::p2p::NetworkPreferences netPrefs() const; QString lookup(QString const& _n) const; dev::Address getNameReg() const; dev::Address getCurrencies() const; void updateFee(); void readSettings(bool _skipGeometry = false); void writeSettings(); bool isCreation() const; dev::u256 fee() const; dev::u256 total() const; dev::u256 value() const; dev::u256 gasPrice() const; unsigned installWatch(dev::eth::LogFilter const& _tf, WatchHandler const& _f); unsigned installWatch(dev::h256 _tf, WatchHandler const& _f); void uninstallWatch(unsigned _w); void keysChanged(); void onNewPending(); void onNewBlock(); void onNameRegChange(); void onCurrenciesChange(); void onBalancesChange(); void installWatches(); void installCurrenciesWatch(); void installNameRegWatch(); void installBalancesWatch(); virtual void timerEvent(QTimerEvent*); void refreshNetwork(); void refreshMining(); void refreshWhispers(); void refreshAll(); void refreshPending(); void refreshAccounts(); void refreshDestination(); void refreshBlockCount(); void refreshBalances(); /// Attempts to infer that @c _source contains Solidity code bool sourceIsSolidity(std::string const& _source); /// @eturns all method hashes of a Solidity contract in a string std::string const getFunctionHashes(dev::solidity::CompilerStack const &_compiler, std::string const& _contractName = ""); std::unique_ptr ui; std::unique_ptr m_webThree; std::map m_handlers; unsigned m_nameRegFilter = (unsigned)-1; unsigned m_currenciesFilter = (unsigned)-1; unsigned m_balancesFilter = (unsigned)-1; QByteArray m_networkConfig; QStringList m_servers; QList m_myKeys; QList m_myIdentities; QString m_privateChain; dev::bytes m_data; dev::Address m_nameReg; unsigned m_backupGas; bool m_enableOptimizer = true; QNetworkAccessManager m_webCtrl; QList> m_consoleHistory; QMutex m_logLock; QString m_logHistory; bool m_logChanged = true; std::unique_ptr m_httpConnector; std::unique_ptr m_server; static QString fromRaw(dev::h256 _n, unsigned* _inc = nullptr); NatspecHandler m_natspecDB; };