Browse Source

ethconsole executable

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
ba64e80c4d
  1. 1
      CMakeLists.txt
  2. 16
      cmake/FindCURL.cmake
  3. 2
      eth/main.cpp
  4. 31
      ethconsole/CMakeLists.txt
  5. 23
      ethconsole/main.cpp
  6. 8
      libjsconsole/CMakeLists.txt
  7. 24
      libjsconsole/CURLRequest.cpp
  8. 24
      libjsconsole/CURLRequest.h
  9. 2
      libjsconsole/JSLocalConsole.cpp
  10. 5
      libjsconsole/JSLocalConsole.h
  11. 27
      libjsconsole/JSRemoteConsole.cpp
  12. 24
      libjsconsole/JSRemoteConsole.h
  13. 2
      libjsconsole/JSV8RemoteConnector.h
  14. 1
      libweb3jsonrpc/CMakeLists.txt

1
CMakeLists.txt

@ -375,6 +375,7 @@ endif ()
if (JSCONSOLE)
add_subdirectory(libjsengine)
add_subdirectory(libjsconsole)
add_subdirectory(ethconsole)
endif ()
add_subdirectory(secp256k1)

16
cmake/FindCURL.cmake

@ -1,26 +1,26 @@
# Find CURL
#
# Find the m_curl includes and library
# Find the curl includes and library
#
# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH
#
# This module defines
# CURL_INCLUDE_DIRS, where to find header, etc.
# CURL_LIBRARIES, the libraries needed to use m_curl.
# CURL_FOUND, If false, do not try to use m_curl.
# CURL_LIBRARIES, the libraries needed to use curl.
# CURL_FOUND, If false, do not try to use curl.
# only look in default directories
find_path(
CURL_INCLUDE_DIR
NAMES m_curl/m_curl.h
DOC "m_curl include dir"
NAMES curl/curl.h
DOC "curl include dir"
)
find_library(
CURL_LIBRARY
# names from cmake's FindCURL
NAMES m_curl curllib libcurl_imp curllib_static libcurl
DOC "m_curl library"
NAMES curl curllib libcurl_imp curllib_static libcurl
DOC "curl library"
)
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
@ -34,7 +34,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
find_library(
CURL_LIBRARY_DEBUG
NAMES curld libcurld
DOC "m_curl debug library"
DOC "curl debug library"
)
set(CURL_LIBRARIES optimized ${CURL_LIBRARIES} debug ${CURL_LIBRARY_DEBUG})

2
eth/main.cpp

@ -1696,7 +1696,7 @@ int main(int argc, char** argv)
if (useConsole)
{
#if ETH_JSCONSOLE
JSLocalConsole console(web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum();}, getAccountPassword, keyManager));
JSLocalConsole console;
while (!g_exit)
{
console.repl();

31
ethconsole/CMakeLists.txt

@ -0,0 +1,31 @@
cmake_policy(SET CMP0015 NEW)
set(CMAKE_AUTOMOC OFF)
aux_source_directory(. SRC_LIST)
include_directories(BEFORE ..)
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS})
include_directories(${CURL_INCLUDE_DIRS})
include_directories(${V8_INCLUDE_DIRS})
set(EXECUTABLE ethconsole)
file(GLOB HEADERS "*.h")
add_executable(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES})
if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW)
eth_copy_dlls(${EXECUTABLE} CURL_DLLS)
endif()
target_link_libraries(${EXECUTABLE} jsconsole)
if (APPLE)
install(TARGETS ${EXECUTABLE} DESTINATION bin)
else()
eth_install_executable(${EXECUTABLE})
endif()

23
ethconsole/main.cpp

@ -0,0 +1,23 @@
#include <libjsconsole/JSRemoteConsole.h>
using namespace std;
using namespace dev;
using namespace dev::eth;
int main(int argc, char** argv)
{
if (argc != 2)
{
cout << "You must provide remote url\n";
cout << "eg:\n";
cout << "./ethconsole http://localhost:8545\n";
return 1;
}
JSRemoteConsole console(argv[1]);
while (true)
console.repl();
return 0;
}

8
libjsconsole/CMakeLists.txt

@ -25,8 +25,12 @@ add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS})
target_link_libraries(${EXECUTABLE} jsengine)
target_link_libraries(${EXECUTABLE} devcore)
target_link_libraries(${EXECUTABLE} ${READLINE_LIBRARIES})
target_link_libraries(${EXECUTABLE} web3jsonrpc)
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_SERVER_LIBRARIES})
target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES})
if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW)
eth_copy_dlls(${EXECUTABLE} CURL_DLLS)
endif()
install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

24
libjsconsole/CURLRequest.cpp

@ -1,6 +1,24 @@
//
// Created by Marek Kotewicz on 15/06/15.
//
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CURLRequest.cpp
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Ethereum client.
*/
#include "CURLRequest.h"

24
libjsconsole/CURLRequest.h

@ -1,6 +1,24 @@
//
// Created by Marek Kotewicz on 15/06/15.
//
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CURLRequest.h
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Ethereum client.
*/
// based on http://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c/27026683#27026683

2
libjsconsole/JSLocalConsole.cpp

@ -29,7 +29,7 @@ using namespace std;
using namespace dev;
using namespace dev::eth;
JSLocalConsole::JSLocalConsole(WebThreeDirect& _web3, shared_ptr<AccountHolder> const& _accounts)
JSLocalConsole::JSLocalConsole()
{
m_jsonrpcConnector.reset(new JSV8Connector(m_engine));
// m_jsonrpcServer.reset(new WebThreeStubServer(*m_jsonrpcConnector.get(), _web3, _accounts, vector<KeyPair>()));

5
libjsconsole/JSLocalConsole.h

@ -39,11 +39,12 @@ class AccountHolder;
class JSLocalConsole: public JSConsole<JSV8Engine, JSV8Printer>
{
public:
JSLocalConsole(WebThreeDirect& _web3, std::shared_ptr<AccountHolder> const& _accounts);
JSLocalConsole();
virtual ~JSLocalConsole() {};
jsonrpc::AbstractServerConnector* connector() { return m_jsonrpcConnector.get(); }
private:
std::unique_ptr<WebThreeStubServer> m_jsonrpcServer;
std::unique_ptr<jsonrpc::AbstractServerConnector> m_jsonrpcConnector;
};

27
libjsconsole/JSRemoteConsole.cpp

@ -1,10 +1,23 @@
//
// Created by Marek Kotewicz on 15/06/15.
//
/*
This file is part of cpp-ethereum.
#include "JSRemoteConsole.h"
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
using namespace std;
using namespace dev;
using namespace dev::eth;
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file JSRemoteConsole.cpp
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Ethereum client.
*/
#include "JSRemoteConsole.h"

24
libjsconsole/JSRemoteConsole.h

@ -1,6 +1,24 @@
//
// Created by Marek Kotewicz on 15/06/15.
//
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file JSRemoteConsole.h
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Ethereum client.
*/
#pragma once

2
libjsconsole/JSV8RemoteConnector.h

@ -17,7 +17,7 @@ class JSV8RemoteConnector : public JSV8RPC
public:
JSV8RemoteConnector(JSV8Engine const& _engine, std::string _url): JSV8RPC(_engine), m_url(_url) {}
virtual ~JSV8RemoteConnector();
virtual ~JSV8RemoteConnector() {};
// implement JSV8RPC interface
void onSend(char const* _payload);

1
libweb3jsonrpc/CMakeLists.txt

@ -55,4 +55,3 @@ install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib L
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )
add_custom_target(aux_json SOURCES "spec.json")

Loading…
Cancel
Save