Browse Source

ethereum.js not minified, serpent compiler, jsonrpc handles compilers exceptions

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
4c4dd302f2
  1. 1034
      libjsqrc/ethereum.js
  2. 1
      libjsqrc/ethereum.min.js
  3. 2
      libjsqrc/js.qrc
  4. 1
      libweb3jsonrpc/CMakeLists.txt
  5. 45
      libweb3jsonrpc/WebThreeStubServer.cpp
  6. 1
      libweb3jsonrpc/WebThreeStubServer.h
  7. 7
      libweb3jsonrpc/abstractwebthreestubserver.h
  8. 1
      libweb3jsonrpc/spec.json
  9. 13
      test/webthreestubclient.h

1034
libjsqrc/ethereum.js

File diff suppressed because it is too large

1
libjsqrc/ethereum.min.js

File diff suppressed because one or more lines are too long

2
libjsqrc/js.qrc

@ -2,6 +2,6 @@
<qresource prefix="/js">
<file>es6-promise-2.0.0.js</file>
<file>setup.js</file>
<file>ethereum.min.js</file>
<file>ethereum.js</file>
</qresource>
</RCC>

1
libweb3jsonrpc/CMakeLists.txt

@ -19,6 +19,7 @@ target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} gmp)
target_link_libraries(${EXECUTABLE} solidity)
target_link_libraries(${EXECUTABLE} serpent)
if(MINIUPNPC_LS)
target_link_libraries(${EXECUTABLE} ${MINIUPNPC_LS})
endif()

45
libweb3jsonrpc/WebThreeStubServer.cpp

@ -33,6 +33,8 @@
#include <libwhisper/WhisperHost.h>
#include <libsolidity/CompilerStack.h>
#include <libsolidity/Scanner.h>
#include <libsolidity/SourceReferenceFormatter.h>
#include <libserpent/funcs.h>
using namespace std;
using namespace dev;
@ -538,17 +540,56 @@ Json::Value WebThreeStubServer::eth_compilers()
Json::Value ret(Json::arrayValue);
ret.append("lll");
ret.append("solidity");
ret.append("serpent");
return ret;
}
std::string WebThreeStubServer::eth_lll(std::string const& _code)
{
return toJS(dev::eth::compileLLL(_code));
string res;
vector<string> errors;
res = toJS(dev::eth::compileLLL(_code, true, &errors));
cwarn << "LLL compilation errors: " << errors;
return res;
}
std::string WebThreeStubServer::eth_serpent(std::string const& _code)
{
string res;
try
{
res = toJS(dev::asBytes(::compile(_code)));
}
catch (string err)
{
cwarn << "Solidity compilation error: " << err;
}
catch (...)
{
cwarn << "Uncought serpent compilation exception";
}
return res;
}
std::string WebThreeStubServer::eth_solidity(std::string const& _code)
{
return toJS(dev::solidity::CompilerStack::staticCompile(_code, false));
string res;
dev::solidity::CompilerStack compiler;
try
{
res = toJS(compiler.compile(_code, true));
}
catch (dev::Exception const& exception)
{
ostringstream error;
solidity::SourceReferenceFormatter::printExceptionInformation(error, exception, "Error", compiler.getScanner());
cwarn << "Solidity compilation error: " << error.str();
}
catch (...)
{
cwarn << "Uncought solidity compilation exception";
}
return res;
}
int WebThreeStubServer::eth_number()

1
libweb3jsonrpc/WebThreeStubServer.h

@ -87,6 +87,7 @@ public:
virtual bool eth_setDefaultBlock(int const& _block);
virtual bool eth_setListening(bool const& _listening);
virtual std::string eth_lll(std::string const& _s);
virtual std::string eth_serpent(std::string const& _s);
virtual bool eth_setMining(bool const& _mining);
virtual std::string eth_solidity(std::string const& _code);
virtual std::string eth_stateAt(std::string const& _address, std::string const& _storage);

7
libweb3jsonrpc/abstractwebthreestubserver.h

@ -37,6 +37,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(new jsonrpc::Procedure("eth_newFilterString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newFilterStringI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_number", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_numberI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_peerCountI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_serpent", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_serpentI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setCoinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_setCoinbaseI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setDefaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_setDefaultBlockI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_setListening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setListeningI);
@ -181,6 +182,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
response = this->eth_peerCount();
}
inline virtual void eth_serpentI(const Json::Value& request, Json::Value& response)
{
response = this->eth_serpent(request[0u].asString());
}
inline virtual void eth_setCoinbaseI(const Json::Value& request, Json::Value& response)
{
response = this->eth_setCoinbase(request[0u].asString());
@ -311,6 +317,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual int eth_newFilterString(const std::string& param1) = 0;
virtual int eth_number() = 0;
virtual int eth_peerCount() = 0;
virtual std::string eth_serpent(const std::string& param1) = 0;
virtual bool eth_setCoinbase(const std::string& param1) = 0;
virtual bool eth_setDefaultBlock(const int& param1) = 0;
virtual bool eth_setListening(const bool& param1) = 0;

1
libweb3jsonrpc/spec.json

@ -31,6 +31,7 @@
{ "method": "eth_compilers", "params": [], "order": [], "returns": []},
{ "method": "eth_lll", "params": [""], "order": [], "returns": ""},
{ "method": "eth_solidity", "params": [""], "order": [], "returns": ""},
{ "method": "eth_serpent", "params": [""], "order": [], "returns": ""},
{ "method": "eth_newFilter", "params": [{}], "order": [], "returns": 0},
{ "method": "eth_newFilterString", "params": [""], "order": [], "returns": 0},

13
test/webthreestubclient.h

@ -328,6 +328,19 @@ p.append(param3);
}
std::string eth_serpent(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->client->CallMethod("eth_serpent",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_setCoinbase(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;

Loading…
Cancel
Save