From b121491080c60a9c3752f38d23af6e302ca17558 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 12 Dec 2014 12:40:59 +0100 Subject: [PATCH] removed walleth, libpyserpent, iethxi and QmlEthereum class --- CMakeLists.txt | 19 -- iethxi/CMakeLists.txt | 91 ------- iethxi/EthereumMacOSXBundleInfo.plist.in | 38 --- iethxi/Main.ui | 168 ------------- iethxi/MainWin.cpp | 59 ----- iethxi/MainWin.h | 18 -- iethxi/Resources.qrc | 5 - iethxi/Simple.qml | 9 - iethxi/main.cpp | 9 - libpyserpent/CMakeLists.txt | 22 -- libpyserpent/pyserpent.cpp | 173 ------------- libqethereum/QmlEthereum.cpp | 180 -------------- libqethereum/QmlEthereum.h | 283 --------------------- walleth/CMakeLists.txt | 102 -------- walleth/EthereumMacOSXBundleInfo.plist.in | 38 --- walleth/Main.ui | 168 ------------- walleth/MainWin.cpp | 286 ---------------------- walleth/MainWin.h | 84 ------- walleth/Resources.qrc | 5 - walleth/Simple.qml | 38 --- walleth/main.cpp | 11 - 21 files changed, 1806 deletions(-) delete mode 100644 iethxi/CMakeLists.txt delete mode 100644 iethxi/EthereumMacOSXBundleInfo.plist.in delete mode 100644 iethxi/Main.ui delete mode 100644 iethxi/MainWin.cpp delete mode 100644 iethxi/MainWin.h delete mode 100644 iethxi/Resources.qrc delete mode 100644 iethxi/Simple.qml delete mode 100644 iethxi/main.cpp delete mode 100644 libpyserpent/CMakeLists.txt delete mode 100644 libpyserpent/pyserpent.cpp delete mode 100644 libqethereum/QmlEthereum.cpp delete mode 100644 libqethereum/QmlEthereum.h delete mode 100644 walleth/CMakeLists.txt delete mode 100644 walleth/EthereumMacOSXBundleInfo.plist.in delete mode 100644 walleth/Main.ui delete mode 100644 walleth/MainWin.cpp delete mode 100644 walleth/MainWin.h delete mode 100644 walleth/Resources.qrc delete mode 100644 walleth/Simple.qml delete mode 100644 walleth/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c57d11e89..d6bf59636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,14 +112,6 @@ include(EthExecutableHelper) createBuildInfo() -# TODO discuss that during PR. are we still using that? - -if(NOT APPLE) - if(PYTHON_LS) - add_subdirectory(libpyserpent) - endif() -endif() - add_subdirectory(libdevcore) add_subdirectory(libevmcore) add_subdirectory(liblll) @@ -158,11 +150,6 @@ if (NOT LANGUAGES) add_subdirectory(neth) endif () - # TODO discuss that during PR. are we still using that? - #if(QTQML) - #add_definitions(-DETH_QTQML) - #endif() - if (NOT HEADLESS) add_subdirectory(libjsqrc) @@ -170,12 +157,6 @@ if (NOT LANGUAGES) add_subdirectory(alethzero) add_subdirectory(third) add_subdirectory(mix) - - # TODO discuss that during PR. are we still using that? - #if(QTQML) - #add_subdirectory(iethxi) - #add_subdirectory(walleth) // resurect once we want to submit ourselves to QML. - #endif() endif() endif() diff --git a/iethxi/CMakeLists.txt b/iethxi/CMakeLists.txt deleted file mode 100644 index c2203a4f6..000000000 --- a/iethxi/CMakeLists.txt +++ /dev/null @@ -1,91 +0,0 @@ -cmake_policy(SET CMP0015 OLD) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -aux_source_directory(. SRC_LIST) - -include_directories(..) -link_directories(../libethcore) -link_directories(../libethereum) -link_directories(../libqethereum) - -qt5_wrap_ui(ui_Main.h Main.ui) -qt5_add_resources(RESOURCE_ADDED Resources.qrc) - -# Set name of binary and add_executable() -if (APPLE) - set(EXECUTABLE IEthXi) - set(CMAKE_INSTALL_PREFIX ./) - set(BIN_INSTALL_DIR ".") - set(DOC_INSTALL_DIR ".") - - set(PROJECT_VERSION "${ETH_VERSION}") - set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") - set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") - set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") - set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTABLE}) - include(BundleUtilities) - - add_executable(${EXECUTABLE} MACOSX_BUNDLE Main.ui ${RESOURCE_ADDED} ${SRC_LIST}) -else () - set(EXECUTABLE iethxi) - add_executable(${EXECUTABLE} Main.ui ${RESOURCE_ADDED} ${SRC_LIST}) -endif () - -qt5_use_modules(${EXECUTABLE} Core Gui Widgets Network Quick Qml) -target_link_libraries(${EXECUTABLE} qethereum) -target_link_libraries(${EXECUTABLE} ethereum) -target_link_libraries(${EXECUTABLE} secp256k1) - -if (APPLE) - if (${ADDFRAMEWORKS}) - set_target_properties(${EXECUTABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") - endif () - - SET_SOURCE_FILES_PROPERTIES(${EXECUTABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) - - # This is a workaround for when the build-type defaults to Debug, and when a multi-config generator like xcode is used, where the type - # will not be set but defaults to release. - set(generator_lowercase "${CMAKE_GENERATOR}") - string(TOLOWER "${CMAKE_GENERATOR}" generator_lowercase) - if ("${generator_lowercase}" STREQUAL "xcode") - # TODO: Not sure how to resolve this. Possibly \${TARGET_BUILD_DIR} - set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}/Debug") - else () - set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}") - endif () - - set(APPS ${binary_build_dir}/${EXECUTABLE}.app) - - # This tool and the next will automatically looked at the linked libraries in order to determine what dependencies are required. Thus, target_link_libaries only needs to add ethereum and secp256k1 (above) - install(CODE " - include(BundleUtilities) - set(BU_CHMOD_BUNDLE_ITEMS 1) - fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") - " COMPONENT RUNTIME ) - - if (${ADDFRAMEWORKS}) - add_custom_target(addframeworks ALL - COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTABLE}.app - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - DEPENDS ${PROJECT_NAME} - ) - endif () - -elseif ("${TARGET_PLATFORM}" STREQUAL "w64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport -static-libgcc -static-libstdc++ -static") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-s -Wl,-subsystem,windows -mthreads -L/usr/x86_64-w64-mingw32/plugins/platforms") - target_link_libraries(${EXECUTABLE} gcc) - target_link_libraries(${EXECUTABLE} mingw32 qtmain mswsock iphlpapi qwindows shlwapi Qt5PlatformSupport gdi32 comdlg32 oleaut32 imm32 winmm ole32 uuid ws2_32) - target_link_libraries(${EXECUTABLE} boost_system-mt-s) - target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s) - target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s) - target_link_libraries(${EXECUTABLE} Qt5PlatformSupport) - set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) -elseif (UNIX) -else () - message(ERROR "platform not supported") -endif () - diff --git a/iethxi/EthereumMacOSXBundleInfo.plist.in b/iethxi/EthereumMacOSXBundleInfo.plist.in deleted file mode 100644 index 684ad7908..000000000 --- a/iethxi/EthereumMacOSXBundleInfo.plist.in +++ /dev/null @@ -1,38 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} - CFBundleGetInfoString - ${MACOSX_BUNDLE_INFO_STRING} - CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} - CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} - CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} - CFBundleSignature - ???? - CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} - CSResourcesFileMapped - - LSRequiresCarbon - - NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} - NSHighResolutionCapable - - - diff --git a/iethxi/Main.ui b/iethxi/Main.ui deleted file mode 100644 index fe289ba9f..000000000 --- a/iethxi/Main.ui +++ /dev/null @@ -1,168 +0,0 @@ - - - Main - - - - 0 - 0 - 562 - 488 - - - - Walleth - - - true - - - QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::VerticalTabs - - - true - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - 0 wei - - - - - - - 0 peers - - - - - - - 1 block - - - - - - - - - - - 0 - 0 - 562 - 25 - - - - - &File - - - - - - &Network - - - - - - - - T&ools - - - - - - - - &Help - - - - - - - - - - - - &Quit - - - - - true - - - true - - - Use &UPnP - - - - - &Connect to Peer... - - - - - true - - - Enable &Network - - - - - true - - - &Mine - - - - - &New Address - - - - - &About... - - - - - true - - - &Preview - - - - - - - diff --git a/iethxi/MainWin.cpp b/iethxi/MainWin.cpp deleted file mode 100644 index 2d5b57094..000000000 --- a/iethxi/MainWin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "BuildInfo.h" -#include "MainWin.h" -#include "ui_Main.h" -using namespace std; -using namespace eth; - -Main::Main(QWidget *parent) : - QObject(parent) -{ -/* qRegisterMetaType("eth::u256"); - qRegisterMetaType("eth::KeyPair"); - qRegisterMetaType("eth::Secret"); - qRegisterMetaType("eth::Address"); - qRegisterMetaType("QmlAccount*"); - qRegisterMetaType("QmlEthereum*"); - - qmlRegisterType("org.ethereum", 1, 0, "Ethereum"); - qmlRegisterType("org.ethereum", 1, 0, "Account"); - qmlRegisterSingletonType("org.ethereum", 1, 0, "Balance", QmlEthereum::constructU256Helper); - qmlRegisterSingletonType("org.ethereum", 1, 0, "Key", QmlEthereum::constructKeyHelper); -*/ - /* - ui->librariesView->setModel(m_libraryMan); - ui->graphsView->setModel(m_graphMan); - */ - - - - -// QQmlContext* context = m_view->rootContext(); -// context->setContextProperty("u256", new U256Helper(this)); -} - -Main::~Main() -{ -} - -// extra bits needed to link on VS -#ifdef _MSC_VER - -// include moc file, ofuscated to hide from automoc -#include\ -"moc_MainWin.cpp" - -#endif diff --git a/iethxi/MainWin.h b/iethxi/MainWin.h deleted file mode 100644 index acbea8ca8..000000000 --- a/iethxi/MainWin.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef MAIN_H -#define MAIN_H - -#include - -class Main: public QObject -{ - Q_OBJECT - -public: - explicit Main(QWidget *parent = 0); - ~Main(); - -private: - QQmlApplicationEngine* m_view; -}; - -#endif // MAIN_H diff --git a/iethxi/Resources.qrc b/iethxi/Resources.qrc deleted file mode 100644 index 1789216ed..000000000 --- a/iethxi/Resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - Simple.qml - - diff --git a/iethxi/Simple.qml b/iethxi/Simple.qml deleted file mode 100644 index ac9dc5e37..000000000 --- a/iethxi/Simple.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick.Controls 1.1 - -ApplicationWindow { - title: "My App" - Button { - text: "Push Me" - anchors.centerIn: parent - } -} diff --git a/iethxi/main.cpp b/iethxi/main.cpp deleted file mode 100644 index 569b6d17c..000000000 --- a/iethxi/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QQmlApplicationEngine app(QUrl("qrc:/Simple.qml")); - return a.exec(); -} diff --git a/libpyserpent/CMakeLists.txt b/libpyserpent/CMakeLists.txt deleted file mode 100644 index 1ffa49ac0..000000000 --- a/libpyserpent/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_policy(SET CMP0015 NEW) - -aux_source_directory(. SRC_LIST) - -set(EXECUTABLE pyserpent) - -file(GLOB HEADERS "*.h") - -# set(CMAKE_INSTALL_PREFIX ../lib) -add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) - -include_directories(..) - -target_link_libraries(${EXECUTABLE} serpent) -target_link_libraries(${EXECUTABLE} lll) -target_link_libraries(${EXECUTABLE} evmcore) -target_link_libraries(${EXECUTABLE} devcore) -target_link_libraries(${EXECUTABLE} ${PYTHON_LS}) - -install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) -install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) - diff --git a/libpyserpent/pyserpent.cpp b/libpyserpent/pyserpent.cpp deleted file mode 100644 index ff8813fcf..000000000 --- a/libpyserpent/pyserpent.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include "structmember.h" - -#include -#include -#include -#include - -#define PYMETHOD(name, FROM, method, TO) \ - static PyObject * name(PyObject *, PyObject *args) { \ - try { \ - FROM(med) \ - return TO(method(med)); \ - } \ - catch (std::string e) { \ - PyErr_SetString(PyExc_Exception, e.c_str()); \ - return NULL; \ - } \ - } - -#define FROMSTR(v) \ - const char *command; \ - int len; \ - if (!PyArg_ParseTuple(args, "s#", &command, &len)) \ - return NULL; \ - std::string v = std::string(command, len); \ - -#define FROMNODE(v) \ - PyObject *node; \ - if (!PyArg_ParseTuple(args, "O", &node)) \ - return NULL; \ - Node v = cppifyNode(node); - -#define FROMLIST(v) \ - PyObject *node; \ - if (!PyArg_ParseTuple(args, "O", &node)) \ - return NULL; \ - std::vector v = cppifyNodeList(node); - -// Convert metadata into python wrapper form [file, ln, ch] -PyObject* pyifyMetadata(Metadata m) { - PyObject* a = PyList_New(0); - PyList_Append(a, Py_BuildValue("s#", m.file.c_str(), m.file.length())); - PyList_Append(a, Py_BuildValue("i", m.ln)); - PyList_Append(a, Py_BuildValue("i", m.ch)); - return a; -} - -// Convert node into python wrapper form -// [token=0/astnode=1, val, metadata, args] -PyObject* pyifyNode(Node n) { - PyObject* a = PyList_New(0); - PyList_Append(a, Py_BuildValue("i", n.type == ASTNODE)); - PyList_Append(a, Py_BuildValue("s#", n.val.c_str(), n.val.length())); - PyList_Append(a, pyifyMetadata(n.metadata)); - for (unsigned i = 0; i < n.args.size(); i++) - PyList_Append(a, pyifyNode(n.args[i])); - return a; -} - -// Convert string into python wrapper form -PyObject* pyifyString(std::string s) { - return Py_BuildValue("s#", s.c_str(), s.length()); -} - -// Convert list of nodes into python wrapper form -PyObject* pyifyNodeList(std::vector n) { - PyObject* a = PyList_New(0); - for (unsigned i = 0; i < n.size(); i++) - PyList_Append(a, pyifyNode(n[i])); - return a; -} - -// Convert pyobject int into normal form -int cppifyInt(PyObject* o) { - int out; - if (!PyArg_Parse(o, "i", &out)) - err("Argument should be integer", Metadata()); - return out; -} - -// Convert pyobject string into normal form -std::string cppifyString(PyObject* o) { - const char *command; - if (!PyArg_Parse(o, "s", &command)) - err("Argument should be string", Metadata()); - return std::string(command); -} - -// Convert metadata from python wrapper form -Metadata cppifyMetadata(PyObject* o) { - std::string file = cppifyString(PyList_GetItem(o, 0)); - int ln = cppifyInt(PyList_GetItem(o, 1)); - int ch = cppifyInt(PyList_GetItem(o, 2)); - return Metadata(file, ln, ch); -} - -// Convert node from python wrapper form -Node cppifyNode(PyObject* o) { - Node n; - int isAstNode = cppifyInt(PyList_GetItem(o, 0)); - n.type = isAstNode ? ASTNODE : TOKEN; - n.val = cppifyString(PyList_GetItem(o, 1)); - n.metadata = cppifyMetadata(PyList_GetItem(o, 2)); - std::vector args; - for (int i = 3; i < PyList_Size(o); i++) { - args.push_back(cppifyNode(PyList_GetItem(o, i))); - } - n.args = args; - return n; -} - -//Convert list of nodes into normal form -std::vector cppifyNodeList(PyObject* o) { - std::vector out; - for (int i = 0; i < PyList_Size(o); i++) { - out.push_back(cppifyNode(PyList_GetItem(o,i))); - } - return out; -} - -PYMETHOD(ps_compile, FROMSTR, compile, pyifyString) -PYMETHOD(ps_compile_chunk, FROMSTR, compileChunk, pyifyString) -PYMETHOD(ps_compile_to_lll, FROMSTR, compileToLLL, pyifyNode) -PYMETHOD(ps_compile_chunk_to_lll, FROMSTR, compileChunkToLLL, pyifyNode) -PYMETHOD(ps_compile_lll, FROMNODE, compileLLL, pyifyString) -PYMETHOD(ps_parse, FROMSTR, parseSerpent, pyifyNode) -PYMETHOD(ps_rewrite, FROMNODE, rewrite, pyifyNode) -PYMETHOD(ps_rewrite_chunk, FROMNODE, rewriteChunk, pyifyNode) -PYMETHOD(ps_pretty_compile, FROMSTR, prettyCompile, pyifyNodeList) -PYMETHOD(ps_pretty_compile_chunk, FROMSTR, prettyCompileChunk, pyifyNodeList) -PYMETHOD(ps_pretty_compile_lll, FROMNODE, prettyCompileLLL, pyifyNodeList) -PYMETHOD(ps_serialize, FROMLIST, serialize, pyifyString) -PYMETHOD(ps_deserialize, FROMSTR, deserialize, pyifyNodeList) -PYMETHOD(ps_parse_lll, FROMSTR, parseLLL, pyifyNode) - - -static PyMethodDef PyextMethods[] = { - {"compile", ps_compile, METH_VARARGS, - "Compile code."}, - {"compile_chunk", ps_compile_chunk, METH_VARARGS, - "Compile code chunk (no wrappers)."}, - {"compile_to_lll", ps_compile_to_lll, METH_VARARGS, - "Compile code to LLL."}, - {"compile_chunk_to_lll", ps_compile_chunk_to_lll, METH_VARARGS, - "Compile code chunk to LLL (no wrappers)."}, - {"compile_lll", ps_compile_lll, METH_VARARGS, - "Compile LLL to EVM."}, - {"parse", ps_parse, METH_VARARGS, - "Parse serpent"}, - {"rewrite", ps_rewrite, METH_VARARGS, - "Rewrite parsed serpent to LLL"}, - {"rewrite_chunk", ps_rewrite_chunk, METH_VARARGS, - "Rewrite parsed serpent to LLL (no wrappers)"}, - {"pretty_compile", ps_pretty_compile, METH_VARARGS, - "Compile to EVM opcodes"}, - {"pretty_compile_chunk", ps_pretty_compile_chunk, METH_VARARGS, - "Compile chunk to EVM opcodes (no wrappers)"}, - {"pretty_compile_lll", ps_pretty_compile_lll, METH_VARARGS, - "Compile LLL to EVM opcodes"}, - {"serialize", ps_serialize, METH_VARARGS, - "Convert EVM opcodes to bin"}, - {"deserialize", ps_deserialize, METH_VARARGS, - "Convert EVM bin to opcodes"}, - {"parse_lll", ps_parse_lll, METH_VARARGS, - "Parse LLL"}, - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - -PyMODINIT_FUNC initserpent_pyext(void) -{ - Py_InitModule( "serpent_pyext", PyextMethods ); -} diff --git a/libqethereum/QmlEthereum.cpp b/libqethereum/QmlEthereum.cpp deleted file mode 100644 index 812247b36..000000000 --- a/libqethereum/QmlEthereum.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#if ETH_QTQML -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include "QmlEthereum.h" -using namespace std; - -// types -using dev::bytes; -using dev::bytesConstRef; -using dev::h160; -using dev::h256; -using dev::u160; -using dev::u256; -using dev::u256s; -using dev::RLP; -using dev::Address; -using dev::eth::BlockInfo; -using dev::eth::Client; -using dev::eth::Instruction; -using dev::KeyPair; -using dev::eth::NodeMode; -using dev::Secret; -using dev::eth::Transaction; -using dev::p2p::PeerInfo; - -// functions -using dev::toHex; -using dev::fromHex; -using dev::right160; -using dev::simpleDebugOut; -using dev::toLog2; -using dev::toString; -using dev::eth::disassemble; -using dev::eth::formatBalance; -using dev::eth::units; - -// vars -using dev::g_logPost; -using dev::g_logVerbosity; - -// Horrible global for the mainwindow. Needed for the QmlEthereums to find the Main window which acts as multiplexer for now. -// Can get rid of this once we've sorted out ITC for signalling & multiplexed querying. -dev::eth::Client* g_qmlClient; -QObject* g_qmlMain; -#if 0 -QmlAccount::QmlAccount(QObject*) -{ -} - -QmlAccount::~QmlAccount() -{ -} - -void QmlAccount::setEthereum(QmlEthereum* _eth) -{ - if (m_eth == _eth) - return; -// if (m_eth) -// disconnect(m_eth, SIGNAL(changed()), this, SIGNAL(changed())); - m_eth = _eth; -// if (m_eth) -// connect(m_eth, SIGNAL(changed()), this, SIGNAL(changed())); - ethChanged(); -// changed(); -} - -dev::u256 QmlAccount::balance() const -{ - if (m_eth) - return m_eth->balanceAt(m_address); - return u256(0); -} - -double QmlAccount::txCount() const -{ - if (m_eth) - return m_eth->txCountAt(m_address); - return 0; -} - -bool QmlAccount::isContract() const -{ - if (m_eth) - return m_eth->isContractAt(m_address); - return 0; -} - -QmlEthereum::QmlEthereum(QObject* _p): QObject(_p) -{ -// connect(g_qmlMain, SIGNAL(changed()), SIGNAL(changed())); -} - -QmlEthereum::~QmlEthereum() -{ -} - -Client* QmlEthereum::client() const -{ - return g_qmlClient; -} - -Address QmlEthereum::coinbase() const -{ - return client()->address(); -} - -void QmlEthereum::setCoinbase(Address _a) -{ - if (client()->address() != _a) - { - client()->setAddress(_a); -// changed(); - } -} - -u256 QmlEthereum::balanceAt(Address _a) const -{ - return client()->postState().balance(_a); -} - -bool QmlEthereum::isContractAt(Address _a) const -{ - return client()->postState().addressHasCode(_a); -} - -bool QmlEthereum::isMining() const -{ - return client()->isMining(); -} - -bool QmlEthereum::isListening() const -{ - return client()->haveNetwork(); -} - -void QmlEthereum::setMining(bool _l) -{ - if (_l) - client()->startMining(); - else - client()->stopMining(); -} - -void QmlEthereum::setListening(bool _l) -{ - if (_l) - client()->startNetwork(); - else - client()->stopNetwork(); -} - -double QmlEthereum::txCountAt(Address _a) const -{ - return (double)client()->postState().transactionsFrom(_a); -} - -unsigned QmlEthereum::peerCount() const -{ - return (unsigned)client()->peerCount(); -} - -void QmlEthereum::transact(Secret _secret, u256 _amount, u256 _gasPrice, u256 _gas, QByteArray _init) -{ - client()->transact(_secret, _amount, bytes(_init.data(), _init.data() + _init.size()), _gas, _gasPrice); -} - -void QmlEthereum::transact(Secret _secret, Address _dest, u256 _amount, u256 _gasPrice, u256 _gas, QByteArray _data) -{ - client()->transact(_secret, _amount, _dest, bytes(_data.data(), _data.data() + _data.size()), _gas, _gasPrice); -} - -#endif - diff --git a/libqethereum/QmlEthereum.h b/libqethereum/QmlEthereum.h deleted file mode 100644 index d242540a1..000000000 --- a/libqethereum/QmlEthereum.h +++ /dev/null @@ -1,283 +0,0 @@ -#pragma once - -#include -#if ETH_QTQML -#include -#endif -#include -#include - -namespace dev { namespace eth { -class Client; -class State; -}} - -class QQmlEngine; -class QmlAccount; -class QmlEthereum; - -extern dev::eth::Client* g_qmlClient; -extern QObject* g_qmlMain; - -Q_DECLARE_METATYPE(dev::u256) -Q_DECLARE_METATYPE(dev::Address) -Q_DECLARE_METATYPE(dev::Secret) -Q_DECLARE_METATYPE(dev::KeyPair) -//Q_DECLARE_METATYPE(QmlAccount*) -//Q_DECLARE_METATYPE(QmlEthereum*) - -class QmlU256Helper: public QObject -{ - Q_OBJECT - -public: - QmlU256Helper(QObject* _p = nullptr): QObject(_p) {} - - Q_INVOKABLE dev::u256 add(dev::u256 _a, dev::u256 _b) const { return _a + _b; } - Q_INVOKABLE dev::u256 sub(dev::u256 _a, dev::u256 _b) const { return _a - _b; } - Q_INVOKABLE dev::u256 mul(dev::u256 _a, int _b) const { return _a * _b; } - Q_INVOKABLE dev::u256 mul(int _a, dev::u256 _b) const { return _a * _b; } - Q_INVOKABLE dev::u256 div(dev::u256 _a, int _b) const { return _a / _b; } - - Q_INVOKABLE dev::u256 wei(double _s) const { return (dev::u256)_s; } - Q_INVOKABLE dev::u256 szabo(double _s) const { return (dev::u256)(_s * (double)dev::eth::szabo); } - Q_INVOKABLE dev::u256 finney(double _s) const { return (dev::u256)(_s * (double)dev::eth::finney); } - Q_INVOKABLE dev::u256 ether(double _s) const { return (dev::u256)(_s * (double)dev::eth::ether); } - Q_INVOKABLE dev::u256 wei(unsigned _s) const { return (dev::u256)_s; } - Q_INVOKABLE dev::u256 szabo(unsigned _s) const { return (dev::u256)(_s * dev::eth::szabo); } - Q_INVOKABLE dev::u256 finney(unsigned _s) const { return (dev::u256)(_s * dev::eth::finney); } - Q_INVOKABLE dev::u256 ether(unsigned _s) const { return (dev::u256)(_s * dev::eth::ether); } - Q_INVOKABLE double toWei(dev::u256 _t) const { return (double)_t; } - Q_INVOKABLE double toSzabo(dev::u256 _t) const { return toWei(_t) / (double)dev::eth::szabo; } - Q_INVOKABLE double toFinney(dev::u256 _t) const { return toWei(_t) / (double)dev::eth::finney; } - Q_INVOKABLE double toEther(dev::u256 _t) const { return toWei(_t) / (double)dev::eth::ether; } - - Q_INVOKABLE double value(dev::u256 _t) const { return (double)_t; } - - Q_INVOKABLE QString stringOf(dev::u256 _t) const { return QString::fromStdString(dev::eth::formatBalance(_t)); } -}; - -class QmlKeyHelper: public QObject -{ - Q_OBJECT - -public: - QmlKeyHelper(QObject* _p = nullptr): QObject(_p) {} - - Q_INVOKABLE dev::KeyPair create() const { return dev::KeyPair::create(); } - Q_INVOKABLE dev::Address address(dev::KeyPair _p) const { return _p.address(); } - Q_INVOKABLE dev::Secret secret(dev::KeyPair _p) const { return _p.secret(); } - Q_INVOKABLE dev::KeyPair keypair(dev::Secret _k) const { return dev::KeyPair(_k); } - - Q_INVOKABLE bool isNull(dev::Address _a) const { return !_a; } - - Q_INVOKABLE dev::Address addressOf(QString _s) const { return dev::Address(_s.toStdString()); } - Q_INVOKABLE QString stringOf(dev::Address _a) const { return QString::fromStdString(dev::toHex(_a.asArray())); } - Q_INVOKABLE QString toAbridged(dev::Address _a) const { return QString::fromStdString(_a.abridged()); } -}; -#if 0 -class QmlAccount: public QObject -{ - Q_OBJECT - -public: - QmlAccount(QObject* _p = nullptr); - virtual ~QmlAccount(); - - Q_INVOKABLE QmlEthereum* ethereum() const { return m_eth; } - Q_INVOKABLE dev::u256 balance() const; - Q_INVOKABLE double txCount() const; - Q_INVOKABLE bool isContract() const; - Q_INVOKABLE dev::Address address() const { return m_address; } - - // TODO: past transactions models. - -public slots: - void setEthereum(QmlEthereum* _eth); - void setAddress(dev::Address _a) { m_address = _a; } - -signals: - void changed(); - void ethChanged(); - -private: - QmlEthereum* m_eth = nullptr; - dev::Address m_address; - - Q_PROPERTY(dev::u256 balance READ balance NOTIFY changed STORED false) - Q_PROPERTY(double txCount READ txCount NOTIFY changed STORED false) - Q_PROPERTY(bool isContract READ isContract NOTIFY changed STORED false) - Q_PROPERTY(dev::Address address READ address WRITE setAddress NOTIFY changed) - Q_PROPERTY(QmlEthereum* ethereum READ ethereum WRITE setEthereum NOTIFY ethChanged) -}; - -class QmlEthereum: public QObject -{ - Q_OBJECT - -public: - QmlEthereum(QObject* _p = nullptr); - virtual ~QmlEthereum(); - - dev::eth::Client* client() const; - - static QObject* constructU256Helper(QQmlEngine*, QJSEngine*) { return new QmlU256Helper; } - static QObject* constructKeyHelper(QQmlEngine*, QJSEngine*) { return new QmlKeyHelper; } - - Q_INVOKABLE dev::Address coinbase() const; - - Q_INVOKABLE bool isListening() const; - Q_INVOKABLE bool isMining() const; - - Q_INVOKABLE dev::u256 balanceAt(dev::Address _a) const; - Q_INVOKABLE double txCountAt(dev::Address _a) const; - Q_INVOKABLE bool isContractAt(dev::Address _a) const; - - Q_INVOKABLE unsigned peerCount() const; - - Q_INVOKABLE QmlEthereum* self() { return this; } - -public slots: - void transact(dev::Secret _secret, dev::Address _dest, dev::u256 _amount, dev::u256 _gasPrice, dev::u256 _gas, QByteArray _data); - void transact(dev::Secret _secret, dev::u256 _amount, dev::u256 _gasPrice, dev::u256 _gas, QByteArray _init); - void setCoinbase(dev::Address); - void setMining(bool _l); - - void setListening(bool _l); - -signals: - void coinbaseChanged(); -// void netChanged(); -// void miningChanged(); - -private: - Q_PROPERTY(dev::Address coinbase READ coinbase WRITE setCoinbase NOTIFY coinbaseChanged) - Q_PROPERTY(bool listening READ isListening WRITE setListening) - Q_PROPERTY(bool mining READ isMining WRITE setMining) -}; -#endif -#if 0 -template T to(QVariant const& _s) { if (_s.type() != QVariant::String) return T(); auto s = _s.toString().toLatin1(); assert(s.size() == sizeof(T)); return *(T*)s.data(); } -template QVariant toQJS(T const& _s) { QLatin1String ret((char*)&_s, sizeof(T)); assert(QVariant(QString(ret)).toString().toLatin1().size() == sizeof(T)); assert(*(T*)(QVariant(QString(ret)).toString().toLatin1().data()) == _s); return QVariant(QString(ret)); } - -class U256Helper: public QObject -{ - Q_OBJECT - -public: - U256Helper(QObject* _p = nullptr): QObject(_p) {} - - static dev::u256 in(QVariant const& _s) { return to(_s); } - static QVariant out(dev::u256 const& _s) { return toQJS(_s); } - - Q_INVOKABLE QVariant add(QVariant _a, QVariant _b) const { return out(in(_a) + in(_b)); } - Q_INVOKABLE QVariant sub(QVariant _a, QVariant _b) const { return out(in(_a) - in(_b)); } - Q_INVOKABLE QVariant mul(QVariant _a, int _b) const { return out(in(_a) * in(_b)); } - Q_INVOKABLE QVariant mul(int _a, QVariant _b) const { return out(in(_a) * in(_b)); } - Q_INVOKABLE QVariant div(QVariant _a, int _b) const { return out(in(_a) / in(_b)); } - - Q_INVOKABLE QVariant wei(double _s) const { return out(dev::u256(_s)); } - Q_INVOKABLE QVariant szabo(double _s) const { return out(dev::u256(_s * (double)dev::eth::szabo)); } - Q_INVOKABLE QVariant finney(double _s) const { return out(dev::u256(_s * (double)dev::eth::finney)); } - Q_INVOKABLE QVariant ether(double _s) const { return out(dev::u256(_s * (double)dev::eth::ether)); } - Q_INVOKABLE QVariant wei(unsigned _s) const { return value(_s); } - Q_INVOKABLE QVariant szabo(unsigned _s) const { return out(dev::u256(_s) * dev::eth::szabo); } - Q_INVOKABLE QVariant finney(unsigned _s) const { return out(dev::u256(_s) * dev::eth::finney); } - Q_INVOKABLE QVariant ether(unsigned _s) const { return out(dev::u256(_s) * dev::eth::ether); } - Q_INVOKABLE double toWei(QVariant _t) const { return toValue(_t); } - Q_INVOKABLE double toSzabo(QVariant _t) const { return toWei(_t) / (double)dev::eth::szabo; } - Q_INVOKABLE double toFinney(QVariant _t) const { return toWei(_t) / (double)dev::eth::finney; } - Q_INVOKABLE double toEther(QVariant _t) const { return toWei(_t) / (double)dev::eth::ether; } - - Q_INVOKABLE QVariant value(unsigned _s) const { return out(dev::u256(_s)); } - Q_INVOKABLE double toValue(QVariant _t) const { return (double)in(_t); } - - Q_INVOKABLE QString ethOf(QVariant _t) const { return QString::fromStdString(dev::eth::formatBalance(in(_t))); } - Q_INVOKABLE QString stringOf(QVariant _t) const { return QString::fromStdString(dev::eth::toString(in(_t))); } - - Q_INVOKABLE QByteArray bytesOf(QVariant _t) const { dev::h256 b = in(_t); return QByteArray((char const*)&b, sizeof(dev::h256)); } - Q_INVOKABLE QVariant fromHex(QString _s) const { return out((dev::u256)dev::h256(_s.toStdString())); } - - Q_INVOKABLE QVariant fromAddress(QVariant/*dev::Address*/ _a) const { return out((dev::eth::u160)to(_a)); } - Q_INVOKABLE QVariant toAddress(QVariant/*dev::Address*/ _a) const { return toQJS((dev::eth::u160)in(_a)); } - - Q_INVOKABLE bool isNull(QVariant/*dev::Address*/ _a) const { return !in(_a); } -}; - -class KeyHelper: public QObject -{ - Q_OBJECT - -public: - KeyHelper(QObject* _p = nullptr): QObject(_p) {} - - static dev::Address in(QVariant const& _s) { return to(_s); } - static QVariant out(dev::Address const& _s) { return toQJS(_s); } - - Q_INVOKABLE QVariant/*dev::KeyPair*/ create() const { return toQJS(dev::KeyPair::create()); } - Q_INVOKABLE QVariant/*dev::Address*/ address(QVariant/*dev::KeyPair*/ _p) const { return out(to(_p).address()); } - Q_INVOKABLE QVariant/*dev::Secret*/ secret(QVariant/*dev::KeyPair*/ _p) const { return toQJS(to(_p).secret()); } - Q_INVOKABLE QVariant/*dev::KeyPair*/ keypair(QVariant/*dev::Secret*/ _k) const { return toQJS(dev::KeyPair(to(_k))); } - - Q_INVOKABLE bool isNull(QVariant/*dev::Address*/ _a) const { return !in(_a); } - - Q_INVOKABLE QVariant/*dev::Address*/ addressOf(QString _s) const { return out(dev::Address(_s.toStdString())); } - Q_INVOKABLE QString stringOf(QVariant/*dev::Address*/ _a) const { return QString::fromStdString(dev::eth::toHex(in(_a).asArray())); } - Q_INVOKABLE QString toAbridged(QVariant/*dev::Address*/ _a) const { return QString::fromStdString(in(_a).abridged()); } - -}; - -class BytesHelper: public QObject -{ - Q_OBJECT - -public: - BytesHelper(QObject* _p = nullptr): QObject(_p) {} - - Q_INVOKABLE QByteArray concat(QVariant _v, QVariant _w) const - { - QByteArray ba; - if (_v.type() == QVariant::ByteArray) - ba = _v.toByteArray(); - else - ba = _v.toString().toLatin1(); - QByteArray ba2; - if (_w.type() == QVariant::ByteArray) - ba2 = _w.toByteArray(); - else - ba2 = _w.toString().toLatin1(); - ba.append(ba2); - return QByteArray(ba); - } - Q_INVOKABLE QByteArray concat(QByteArray _v, QByteArray _w) const - { - _v.append(_w); - return _v; - } - Q_INVOKABLE QByteArray fromString(QString _s) const - { - return _s.toLatin1(); - } - Q_INVOKABLE QByteArray fromString(QString _s, unsigned _padding) const - { - QByteArray b = _s.toLatin1(); - for (unsigned i = b.size(); i < _padding; ++i) - b.append((char)0); - b.resize(_padding); - return b; - } - Q_INVOKABLE QString toString(QByteArray _b) const - { - while (_b.size() && !_b[_b.size() - 1]) - _b.resize(_b.size() - 1); - return QString::fromLatin1(_b); - } - Q_INVOKABLE QVariant u256of(QByteArray _s) const - { - while (_s.size() < 32) - _s.append((char)0); - dev::h256 ret((uint8_t const*)_s.data(), dev::h256::ConstructFromPointer); - return toQJS(ret); - } -}; -#endif diff --git a/walleth/CMakeLists.txt b/walleth/CMakeLists.txt deleted file mode 100644 index 44bf5f0f9..000000000 --- a/walleth/CMakeLists.txt +++ /dev/null @@ -1,102 +0,0 @@ -cmake_policy(SET CMP0015 NEW) - -if ("${TARGET_PLATFORM}" STREQUAL "w64") - cmake_policy(SET CMP0020 NEW) -endif () - - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -aux_source_directory(. SRC_LIST) - -include_directories(..) -link_directories(../libethcore) -link_directories(../libethereum) -link_directories(../libqethereum) - -# Find Qt5 for Apple and update src_list for windows -if (APPLE) - # homebrew defaults to qt4 and installs qt5 as 'keg-only' - # which places it into /usr/local/opt insteadof /usr/local. - - set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) - include_directories(/usr/local/opt/qt5/include /usr/local/include) -elseif ("${TARGET_PLATFORM}" STREQUAL "w64") - set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) -elseif (UNIX) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") -endif () - - -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Gui REQUIRED) -find_package(Qt5Quick REQUIRED) -find_package(Qt5Qml REQUIRED) -find_package(Qt5Network REQUIRED) -qt5_wrap_ui(ui_Main.h Main.ui) -qt5_add_resources(RESOURCE_ADDED Resources.qrc) - -# Set name of binary and add_executable() -if (APPLE) - set(EXECUTEABLE Walleth) - set(CMAKE_INSTALL_PREFIX ./) - set(BIN_INSTALL_DIR ".") - set(DOC_INSTALL_DIR ".") - - set(PROJECT_VERSION "${ETH_VERSION}") - set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") - set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") - set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") - set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTEABLE}) - include(BundleUtilities) - - add_executable(${EXECUTEABLE} MACOSX_BUNDLE Main.ui ${RESOURCE_ADDED} ${SRC_LIST}) -else () - set(EXECUTEABLE walleth) - add_executable(${EXECUTEABLE} Main.ui ${RESOURCE_ADDED} ${SRC_LIST}) -endif () - -qt5_use_modules(${EXECUTEABLE} Core Gui Widgets Network Quick Qml) -target_link_libraries(${EXECUTEABLE} qethereum ethereum secp256k1) - -if (APPLE) - if (${ADDFRAMEWORKS}) - set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") - endif () - - SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) - - # This is a workaround for when the build-type defaults to Debug, and when a multi-config generator like xcode is used, where the type - # will not be set but defaults to release. - set(generator_lowercase "${CMAKE_GENERATOR}") - string(TOLOWER "${CMAKE_GENERATOR}" generator_lowercase) - if ("${generator_lowercase}" STREQUAL "xcode") - # TODO: Not sure how to resolve this. Possibly \${TARGET_BUILD_DIR} - set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}/Debug") - else () - set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}") - endif () - - set(APPS ${binary_build_dir}/${EXECUTEABLE}.app) - - # This tool and the next will automatically looked at the linked libraries in order to determine what dependencies are required. Thus, target_link_libaries only needs to add ethereum and secp256k1 (above) - install(CODE " - include(BundleUtilities) - set(BU_CHMOD_BUNDLE_ITEMS 1) - fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") - " COMPONENT RUNTIME ) - - if (${ADDFRAMEWORKS}) - add_custom_target(addframeworks ALL - COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTEABLE}.app - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - DEPENDS ${PROJECT_NAME} - ) - endif () - -else () - install( TARGETS ${EXECUTEABLE} RUNTIME DESTINATION bin ) -endif () - diff --git a/walleth/EthereumMacOSXBundleInfo.plist.in b/walleth/EthereumMacOSXBundleInfo.plist.in deleted file mode 100644 index 684ad7908..000000000 --- a/walleth/EthereumMacOSXBundleInfo.plist.in +++ /dev/null @@ -1,38 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${MACOSX_BUNDLE_EXECUTABLE_NAME} - CFBundleGetInfoString - ${MACOSX_BUNDLE_INFO_STRING} - CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} - CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} - CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} - CFBundleSignature - ???? - CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} - CSResourcesFileMapped - - LSRequiresCarbon - - NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} - NSHighResolutionCapable - - - diff --git a/walleth/Main.ui b/walleth/Main.ui deleted file mode 100644 index 6904590a8..000000000 --- a/walleth/Main.ui +++ /dev/null @@ -1,168 +0,0 @@ - - - Main - - - - 0 - 0 - 562 - 488 - - - - Walleth - - - true - - - QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::VerticalTabs - - - true - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - 0 wei - - - - - - - 0 peers - - - - - - - 1 block - - - - - - - - - - - 0 - 0 - 562 - 20 - - - - - &File - - - - - - &Network - - - - - - - - T&ools - - - - - - - - &Help - - - - - - - - - - - - &Quit - - - - - true - - - true - - - Use &UPnP - - - - - &Connect to Peer... - - - - - true - - - Enable &Network - - - - - true - - - &Mine - - - - - &New Address - - - - - &About... - - - - - true - - - &Preview - - - - - - - diff --git a/walleth/MainWin.cpp b/walleth/MainWin.cpp deleted file mode 100644 index f56cad65d..000000000 --- a/walleth/MainWin.cpp +++ /dev/null @@ -1,286 +0,0 @@ -#include -#include -//#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "BuildInfo.h" -#include "MainWin.h" -#include "ui_Main.h" -using namespace std; - -// types -using dev::bytes; -using dev::bytesConstRef; -using dev::h160; -using dev::h256; -using dev::u160; -using dev::u256; -using dev::u256s; -using dev::Address; -using dev::eth::BlockInfo; -using dev::eth::Client; -using dev::eth::Instruction; -using dev::KeyPair; -using dev::eth::NodeMode; -using dev::p2p::PeerInfo; -using dev::RLP; -using dev::Secret; -using dev::eth::Transaction; - -// functions -using dev::toHex; -using dev::fromHex; -using dev::right160; -using dev::simpleDebugOut; -using dev::toLog2; -using dev::toString; -using dev::eth::units; -using dev::eth::disassemble; -using dev::eth::formatBalance; - -// vars -using dev::g_logPost; -using dev::g_logVerbosity; - -Main::Main(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::Main) -{ - setWindowFlags(Qt::Window); - ui->setupUi(this); - setWindowIcon(QIcon(":/Ethereum.png")); - - g_qmlMain = this; - - m_client.reset(new Client("Walleth", Address(), dev::getDataDir() + "/Walleth")); - - g_qmlClient = m_client.get(); - - qRegisterMetaType("dev::u256"); - qRegisterMetaType("dev::KeyPair"); - qRegisterMetaType("dev::Secret"); - qRegisterMetaType("dev::Address"); - qRegisterMetaType("QmlAccount*"); - qRegisterMetaType("QmlEthereum*"); - - qmlRegisterType("org.ethereum", 1, 0, "Ethereum"); - qmlRegisterType("org.ethereum", 1, 0, "Account"); - qmlRegisterSingletonType("org.ethereum", 1, 0, "Balance", QmlEthereum::constructU256Helper); - qmlRegisterSingletonType("org.ethereum", 1, 0, "Key", QmlEthereum::constructKeyHelper); - - /* - ui->librariesView->setModel(m_libraryMan); - ui->graphsView->setModel(m_graphMan); - */ - - m_view = new QQuickView(); - -// QQmlContext* context = m_view->rootContext(); -// context->setContextProperty("u256", new U256Helper(this)); - - m_view->setSource(QUrl("qrc:/Simple.qml")); - - QWidget* w = QWidget::createWindowContainer(m_view); - m_view->setResizeMode(QQuickView::SizeRootObjectToView); - ui->fullDisplay->insertWidget(0, w); - m_view->create(); - -// m_timelinesItem = m_view->rootObject()->findChild("timelines"); - - readSettings(); - refresh(); - - m_refreshNetwork = new QTimer(this); - connect(m_refreshNetwork, SIGNAL(timeout()), SLOT(refreshNetwork())); - m_refreshNetwork->start(1000); - - connect(&m_webCtrl, &QNetworkAccessManager::finished, [&](QNetworkReply* _r) - { - m_servers = QString::fromUtf8(_r->readAll()).split("\n", QString::SkipEmptyParts); - if (m_servers.size()) - { - ui->net->setChecked(true); - on_net_triggered(true); - } - }); - QNetworkRequest r(QUrl("http://www.ethereum.org/servers.poc" + QString(dev::Version).section('.', 1, 1) + ".txt")); - r.setHeader(QNetworkRequest::UserAgentHeader, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1712.0 Safari/537.36"); - m_webCtrl.get(r); - srand(time(0)); - - startTimer(200); - - statusBar()->addPermanentWidget(ui->balance); - statusBar()->addPermanentWidget(ui->peerCount); - statusBar()->addPermanentWidget(ui->blockCount); -} - -Main::~Main() -{ - writeSettings(); -} - -void Main::timerEvent(QTimerEvent *) -{ - -} - -void Main::on_about_triggered() -{ - QMessageBox::about(this, "About Walleth PoC-" + QString(dev::Version).section('.', 1, 1), QString("Walleth/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) "\n" DEV_QUOTED(ETH_COMMIT_HASH) + (ETH_CLEAN_REPO ? "\nCLEAN" : "\n+ LOCAL CHANGES") + "\n\nBy Gav Wood, 2014.\nBased on a design by Vitalik Buterin.\n\nThanks to the various contributors including: Alex Leverington, Tim Hughes, caktux, Eric Lombrozo, Marko Simovic."); -} - -void Main::writeSettings() -{ - QSettings s("ethereum", "walleth"); - QByteArray b; - b.resize(sizeof(Secret) * m_myKeys.size()); - auto p = b.data(); - for (auto i: m_myKeys) - { - memcpy(p, &(i.secret()), sizeof(Secret)); - p += sizeof(Secret); - } - s.setValue("address", b); - - s.setValue("upnp", ui->upnp->isChecked()); - s.setValue("clientName", m_clientName); - s.setValue("idealPeers", m_idealPeers); - s.setValue("port", m_port); - - bytes d = client()->savePeers(); - if (d.size()) - m_peers = QByteArray((char*)d.data(), (int)d.size()); - s.setValue("peers", m_peers); - - s.setValue("geometry", saveGeometry()); - s.setValue("windowState", saveState()); -} - -void Main::readSettings() -{ - QSettings s("ethereum", "walleth"); - - restoreGeometry(s.value("geometry").toByteArray()); - restoreState(s.value("windowState").toByteArray()); - - QByteArray b = s.value("address").toByteArray(); - if (b.isEmpty()) - m_myKeys.append(KeyPair::create()); - else - { - h256 k; - for (unsigned i = 0; i < b.size() / sizeof(Secret); ++i) - { - memcpy(&k, b.data() + i * sizeof(Secret), sizeof(Secret)); - m_myKeys.append(KeyPair(k)); - } - } - //m_eth->setAddress(m_myKeys.last().address()); - m_peers = s.value("peers").toByteArray(); - ui->upnp->setChecked(s.value("upnp", true).toBool()); - m_clientName = s.value("clientName", "").toString(); - m_idealPeers = s.value("idealPeers", 5).toInt(); - m_port = s.value("port", 30303).toInt(); -} - -void Main::refreshNetwork() -{ - auto ps = client()->peers(); - ui->peerCount->setText(QString::fromStdString(toString(ps.size())) + " peer(s)"); -} - -void Main::refresh() -{ - auto d = client()->blockChain().details(); - auto diff = BlockInfo(client()->blockChain().block()).difficulty; - ui->blockCount->setText(QString("#%1 @%3 T%2").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff))); - - m_keysChanged = false; - u256 totalBalance = 0; - for (auto i: m_myKeys) - { - u256 b = m_client->balanceAt(i.address()); - totalBalance += b; - } - ui->balance->setText(QString::fromStdString(formatBalance(totalBalance))); -} - -void Main::on_net_triggered(bool _auto) -{ - string n = string("Walleth/v") + dev::Version; - if (m_clientName.size()) - n += "/" + m_clientName.toStdString(); - n += "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM); - client()->setClientVersion(n); - if (ui->net->isChecked()) - { - if (_auto) - { - QString s = m_servers[rand() % m_servers.size()]; - client()->startNetwork(m_port, s.section(':', 0, 0).toStdString(), s.section(':', 1).toInt(), NodeMode::Full, m_idealPeers, "", ui->upnp->isChecked()); - } - else - client()->startNetwork(m_port, string(), 0, NodeMode::Full, m_idealPeers, "", ui->upnp->isChecked()); - if (m_peers.size()) - client()->restorePeers(bytesConstRef((byte*)m_peers.data(), m_peers.size())); - } - else - client()->stopNetwork(); -} - -void Main::on_connect_triggered() -{ - if (!ui->net->isChecked()) - { - ui->net->setChecked(true); - on_net_triggered(); - } - bool ok = false; - QString s = QInputDialog::getItem(this, "Connect to a Network Peer", "Enter a peer to which a connection may be made:", m_servers, m_servers.count() ? rand() % m_servers.count() : 0, true, &ok); - if (ok && s.contains(":")) - { - string host = s.section(":", 0, 0).toStdString(); - unsigned short port = s.section(":", 1).toInt(); - client()->connect(host, port); - } -} - -void Main::on_mine_triggered() -{ - if (ui->mine->isChecked()) - { - client()->setAddress(m_myKeys.last().address()); - client()->startMining(); - } - else - client()->stopMining(); -} - -void Main::on_create_triggered() -{ - m_myKeys.append(KeyPair::create()); - m_keysChanged = true; -} - -// extra bits needed to link on VS -#ifdef _MSC_VER - -// include moc file, ofuscated to hide from automoc -#include\ -"moc_MainWin.cpp" - -// include qrc content -#include\ -"qrc_Resources.cpp" - -#endif diff --git a/walleth/MainWin.h b/walleth/MainWin.h deleted file mode 100644 index 860db8bc9..000000000 --- a/walleth/MainWin.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef MAIN_H -#define MAIN_H - -#include -#include -#include -#include -#include -#include - -namespace Ui { -class Main; -} - -namespace dev { namespace eth { -class Client; -class State; -}} - -class QQuickView; -class QQmlEngine; -class QJSEngine; - -class Main : public QMainWindow -{ - Q_OBJECT - -public: - explicit Main(QWidget *parent = 0); - ~Main(); - - dev::eth::Client* client() const { return m_client.get(); } - -private slots: - void on_connect_triggered(); - void on_mine_triggered(); - void on_create_triggered(); - void on_net_triggered(bool _auto = false); - void on_about_triggered(); - void on_preview_triggered() { refresh(); } - void on_quit_triggered() { close(); } - - void refresh(); - void refreshNetwork(); - -protected: - virtual void timerEvent(QTimerEvent *); - -private: -/* QString pretty(dev::Address _a) const; - QString render(dev::Address _a) const; - dev::Address fromString(QString const& _a) const; -*/ - dev::eth::State const& state() const; - - void updateFee(); - void readSettings(); - void writeSettings(); - - dev::u256 fee() const; - dev::u256 total() const; - dev::u256 value() const; - - std::unique_ptr ui; - - QByteArray m_peers; - QMutex m_guiLock; - QTimer* m_refresh; - QTimer* m_refreshNetwork; - QVector m_myKeys; - bool m_keysChanged = false; - int m_port; - int m_idealPeers; - QString m_clientName; - QStringList m_servers; - - QQuickView* m_view; - - QNetworkAccessManager m_webCtrl; - - std::unique_ptr m_client; -}; - -#endif // MAIN_H diff --git a/walleth/Resources.qrc b/walleth/Resources.qrc deleted file mode 100644 index 1789216ed..000000000 --- a/walleth/Resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - Simple.qml - - diff --git a/walleth/Simple.qml b/walleth/Simple.qml deleted file mode 100644 index 53cb7def4..000000000 --- a/walleth/Simple.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQml 2.2 -import QtQuick 2.1 -import QtQuick.Controls 1.0 -import QtQuick.Layouts 1.0 -import Qt.labs.settings 1.0 -import org.ethereum 1.0 - -Item { - id: main - anchors.fill: parent - anchors.margins: 9 - -// Qt.application.name: "Walleth" -// Qt.application.organization: "Ethereum" -// Qt.application.domain: "org.ethereum" - - Ethereum { - id: eth - } - - Account { - id: myAccount - address: Key.addressOf("84fc4ba9373c30bfe32d8c5a502854e7f1175878") - ethereum: eth - // TODO: state: eth.latest // could be eth.pending - // will provide balance, txCount, isContract, incomingTransactions (list model), outgoingTransactions (list model). - // transaction lists' items will provide value, from, to, final balance. - } - - // KeyPair provides makeTransaction(recvAddress, value, data (array)) - - Text { - text: "Balance: " + Balance.stringOf(myAccount.balance) + " [" + myAccount.txCount + "]" + "\nAccount: " + Key.stringOf(myAccount.address) - Layout.minimumHeight: 30 - Layout.fillHeight: true - Layout.fillWidth: true - } -} diff --git a/walleth/main.cpp b/walleth/main.cpp deleted file mode 100644 index 42afd5e66..000000000 --- a/walleth/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "MainWin.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Main w; - w.show(); - - return a.exec(); -}