Browse Source

removed walleth, libpyserpent, iethxi and QmlEthereum class

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
b121491080
  1. 19
      CMakeLists.txt
  2. 91
      iethxi/CMakeLists.txt
  3. 38
      iethxi/EthereumMacOSXBundleInfo.plist.in
  4. 168
      iethxi/Main.ui
  5. 59
      iethxi/MainWin.cpp
  6. 18
      iethxi/MainWin.h
  7. 5
      iethxi/Resources.qrc
  8. 9
      iethxi/Simple.qml
  9. 9
      iethxi/main.cpp
  10. 22
      libpyserpent/CMakeLists.txt
  11. 173
      libpyserpent/pyserpent.cpp
  12. 180
      libqethereum/QmlEthereum.cpp
  13. 283
      libqethereum/QmlEthereum.h
  14. 102
      walleth/CMakeLists.txt
  15. 38
      walleth/EthereumMacOSXBundleInfo.plist.in
  16. 168
      walleth/Main.ui
  17. 286
      walleth/MainWin.cpp
  18. 84
      walleth/MainWin.h
  19. 5
      walleth/Resources.qrc
  20. 38
      walleth/Simple.qml
  21. 11
      walleth/main.cpp

19
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()

91
iethxi/CMakeLists.txt

@ -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 ()

38
iethxi/EthereumMacOSXBundleInfo.plist.in

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

168
iethxi/Main.ui

@ -1,168 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Main</class>
<widget class="QMainWindow" name="Main">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>488</height>
</rect>
</property>
<property name="windowTitle">
<string>Walleth</string>
</property>
<property name="dockNestingEnabled">
<bool>true</bool>
</property>
<property name="dockOptions">
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::VerticalTabs</set>
</property>
<property name="sizeGripEnabled" stdset="0">
<bool>true</bool>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="fullDisplay">
<item>
<widget class="QLabel" name="balance">
<property name="text">
<string>0 wei</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="peerCount">
<property name="text">
<string>0 peers</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="blockCount">
<property name="text">
<string>1 block</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="quit"/>
</widget>
<widget class="QMenu" name="menu_Network">
<property name="title">
<string>&amp;Network</string>
</property>
<addaction name="upnp"/>
<addaction name="net"/>
<addaction name="connect"/>
</widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
<string>T&amp;ools</string>
</property>
<addaction name="mine"/>
<addaction name="create"/>
<addaction name="preview"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="about"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Network"/>
<addaction name="menu_Tools"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="quit">
<property name="text">
<string>&amp;Quit</string>
</property>
</action>
<action name="upnp">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Use &amp;UPnP</string>
</property>
</action>
<action name="connect">
<property name="text">
<string>&amp;Connect to Peer...</string>
</property>
</action>
<action name="net">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable &amp;Network</string>
</property>
</action>
<action name="mine">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Mine</string>
</property>
</action>
<action name="create">
<property name="text">
<string>&amp;New Address</string>
</property>
</action>
<action name="about">
<property name="text">
<string>&amp;About...</string>
</property>
</action>
<action name="preview">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Preview</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

59
iethxi/MainWin.cpp

@ -1,59 +0,0 @@
#include <QtNetwork/QNetworkReply>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlEngine>
#include <QtQml/QtQml>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QInputDialog>
#include <QtGui/QClipboard>
#include <QtCore/QtCore>
#include <libethcore/FileSystem.h>
#include <libethcore/Dagger.h>
#include <libevmcore/Instruction.h>
#include <libethereum/Client.h>
#include <libethereum/EthereumHost.h>
#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>("eth::u256");
qRegisterMetaType<eth::KeyPair>("eth::KeyPair");
qRegisterMetaType<eth::Secret>("eth::Secret");
qRegisterMetaType<eth::Address>("eth::Address");
qRegisterMetaType<QmlAccount*>("QmlAccount*");
qRegisterMetaType<QmlEthereum*>("QmlEthereum*");
qmlRegisterType<QmlEthereum>("org.ethereum", 1, 0, "Ethereum");
qmlRegisterType<QmlAccount>("org.ethereum", 1, 0, "Account");
qmlRegisterSingletonType<QmlU256Helper>("org.ethereum", 1, 0, "Balance", QmlEthereum::constructU256Helper);
qmlRegisterSingletonType<QmlKeyHelper>("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

18
iethxi/MainWin.h

@ -1,18 +0,0 @@
#ifndef MAIN_H
#define MAIN_H
#include <QtQml/QQmlApplicationEngine>
class Main: public QObject
{
Q_OBJECT
public:
explicit Main(QWidget *parent = 0);
~Main();
private:
QQmlApplicationEngine* m_view;
};
#endif // MAIN_H

5
iethxi/Resources.qrc

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>Simple.qml</file>
</qresource>
</RCC>

9
iethxi/Simple.qml

@ -1,9 +0,0 @@
import QtQuick.Controls 1.1
ApplicationWindow {
title: "My App"
Button {
text: "Push Me"
anchors.centerIn: parent
}
}

9
iethxi/main.cpp

@ -1,9 +0,0 @@
#include <QtQml/QQmlApplicationEngine>
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QQmlApplicationEngine app(QUrl("qrc:/Simple.qml"));
return a.exec();
}

22
libpyserpent/CMakeLists.txt

@ -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} )

173
libpyserpent/pyserpent.cpp

@ -1,173 +0,0 @@
#include <Python.h>
#include "structmember.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <libserpent/funcs.h>
#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<Node> 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<Node> 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<Node> 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<Node> cppifyNodeList(PyObject* o) {
std::vector<Node> 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 );
}

180
libqethereum/QmlEthereum.cpp

@ -1,180 +0,0 @@
#if ETH_QTQML
#include <QtQml/QtQml>
#endif
#include <QtCore/QtCore>
#include <QtWebKitWidgets/QWebFrame>
#include <libdevcrypto/FileSystem.h>
#include <libevmcore/Instruction.h>
#include <liblll/Compiler.h>
#include <libethereum/Client.h>
#include <libethereum/EthereumHost.h>
#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

283
libqethereum/QmlEthereum.h

@ -1,283 +0,0 @@
#pragma once
#include <QtCore/QAbstractListModel>
#if ETH_QTQML
#include <QtQml/QtQml>
#endif
#include <libdevcore/CommonIO.h>
#include <libethcore/CommonEth.h>
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 <class T> 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 <class T> 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<dev::u256>(_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<dev::Address>(_a)); }
Q_INVOKABLE QVariant toAddress(QVariant/*dev::Address*/ _a) const { return toQJS<dev::Address>((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<dev::Address>(_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<dev::KeyPair>(_p).address()); }
Q_INVOKABLE QVariant/*dev::Secret*/ secret(QVariant/*dev::KeyPair*/ _p) const { return toQJS(to<dev::KeyPair>(_p).secret()); }
Q_INVOKABLE QVariant/*dev::KeyPair*/ keypair(QVariant/*dev::Secret*/ _k) const { return toQJS(dev::KeyPair(to<dev::Secret>(_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<dev::u256>(ret);
}
};
#endif

102
walleth/CMakeLists.txt

@ -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 ()

38
walleth/EthereumMacOSXBundleInfo.plist.in

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

168
walleth/Main.ui

@ -1,168 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Main</class>
<widget class="QMainWindow" name="Main">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>488</height>
</rect>
</property>
<property name="windowTitle">
<string>Walleth</string>
</property>
<property name="dockNestingEnabled">
<bool>true</bool>
</property>
<property name="dockOptions">
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::VerticalTabs</set>
</property>
<property name="sizeGripEnabled" stdset="0">
<bool>true</bool>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="fullDisplay">
<item>
<widget class="QLabel" name="balance">
<property name="text">
<string>0 wei</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="peerCount">
<property name="text">
<string>0 peers</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="blockCount">
<property name="text">
<string>1 block</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="quit"/>
</widget>
<widget class="QMenu" name="menu_Network">
<property name="title">
<string>&amp;Network</string>
</property>
<addaction name="upnp"/>
<addaction name="net"/>
<addaction name="connect"/>
</widget>
<widget class="QMenu" name="menu_Tools">
<property name="title">
<string>T&amp;ools</string>
</property>
<addaction name="mine"/>
<addaction name="create"/>
<addaction name="preview"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="about"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Network"/>
<addaction name="menu_Tools"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="quit">
<property name="text">
<string>&amp;Quit</string>
</property>
</action>
<action name="upnp">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Use &amp;UPnP</string>
</property>
</action>
<action name="connect">
<property name="text">
<string>&amp;Connect to Peer...</string>
</property>
</action>
<action name="net">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Enable &amp;Network</string>
</property>
</action>
<action name="mine">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Mine</string>
</property>
</action>
<action name="create">
<property name="text">
<string>&amp;New Address</string>
</property>
</action>
<action name="about">
<property name="text">
<string>&amp;About...</string>
</property>
</action>
<action name="preview">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Preview</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

286
walleth/MainWin.cpp

@ -1,286 +0,0 @@
#include <QtNetwork/QNetworkReply>
#include <QtQuick/QQuickView>
//#include <QtQml/QQmlContext>
//#include <QtQml/QQmlEngine>
#include <QtQml/QtQml>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QInputDialog>
#include <QtGui/QClipboard>
#include <QtCore/QtCore>
#include <libdevcrypto/FileSystem.h>
#include <libethcore/Dagger.h>
#include <libevmcore/Instruction.h>
#include <libethereum/Client.h>
#include <libethereum/EthereumHost.h>
#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>("dev::u256");
qRegisterMetaType<dev::KeyPair>("dev::KeyPair");
qRegisterMetaType<dev::Secret>("dev::Secret");
qRegisterMetaType<dev::Address>("dev::Address");
qRegisterMetaType<QmlAccount*>("QmlAccount*");
qRegisterMetaType<QmlEthereum*>("QmlEthereum*");
qmlRegisterType<QmlEthereum>("org.ethereum", 1, 0, "Ethereum");
qmlRegisterType<QmlAccount>("org.ethereum", 1, 0, "Account");
qmlRegisterSingletonType<QmlU256Helper>("org.ethereum", 1, 0, "Balance", QmlEthereum::constructU256Helper);
qmlRegisterSingletonType<QmlKeyHelper>("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<TimelinesItem*>("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

84
walleth/MainWin.h

@ -1,84 +0,0 @@
#ifndef MAIN_H
#define MAIN_H
#include <QtNetwork/QNetworkAccessManager>
#include <QtCore/QAbstractListModel>
#include <QtCore/QMutex>
#include <QtWidgets/QMainWindow>
#include <libethcore/CommonEth.h>
#include <libqethereum/QmlEthereum.h>
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::Main> ui;
QByteArray m_peers;
QMutex m_guiLock;
QTimer* m_refresh;
QTimer* m_refreshNetwork;
QVector<dev::KeyPair> 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<dev::eth::Client> m_client;
};
#endif // MAIN_H

5
walleth/Resources.qrc

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>Simple.qml</file>
</qresource>
</RCC>

38
walleth/Simple.qml

@ -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
}
}

11
walleth/main.cpp

@ -1,11 +0,0 @@
#include "MainWin.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Main w;
w.show();
return a.exec();
}
Loading…
Cancel
Save