Browse Source

logs in spec

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
e2948c7040
  1. 19
      libweb3jsonrpc/abstractwebthreestubserver.h
  2. 3
      libweb3jsonrpc/spec.json
  3. 35
      test/webthreestubclient.h

19
libweb3jsonrpc/abstractwebthreestubserver.h

@ -28,10 +28,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
this->bindAndAddMethod(new jsonrpc::Procedure("eth_compilers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_compilersI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_compilers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_compilersI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_countAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_countAtI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_countAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_countAtI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_defaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_defaultBlockI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_defaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_defaultBlockI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_getMessages", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_getMessagesI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_listeningI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_listeningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_lll", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_lllI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_lll", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_lllI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI);
this->bindAndAddMethod(new jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI); this->bindAndAddMethod(new jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI);
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_newFilterString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newFilterStringI);
@ -137,14 +138,14 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
response = this->eth_defaultBlock(); response = this->eth_defaultBlock();
} }
inline virtual void eth_gasPriceI(const Json::Value& request, Json::Value& response) inline virtual void eth_filterLogsI(const Json::Value& request, Json::Value& response)
{ {
response = this->eth_gasPrice(); response = this->eth_filterLogs(request[0u].asInt());
} }
inline virtual void eth_getMessagesI(const Json::Value& request, Json::Value& response) inline virtual void eth_gasPriceI(const Json::Value& request, Json::Value& response)
{ {
response = this->eth_getMessages(request[0u].asInt()); response = this->eth_gasPrice();
} }
inline virtual void eth_listeningI(const Json::Value& request, Json::Value& response) inline virtual void eth_listeningI(const Json::Value& request, Json::Value& response)
@ -157,6 +158,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
response = this->eth_lll(request[0u].asString()); response = this->eth_lll(request[0u].asString());
} }
inline virtual void eth_logsI(const Json::Value& request, Json::Value& response)
{
response = this->eth_logs(request[0u]);
}
inline virtual void eth_miningI(const Json::Value& request, Json::Value& response) inline virtual void eth_miningI(const Json::Value& request, Json::Value& response)
{ {
response = this->eth_mining(); response = this->eth_mining();
@ -308,10 +314,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
virtual Json::Value eth_compilers() = 0; virtual Json::Value eth_compilers() = 0;
virtual double eth_countAt(const std::string& param1) = 0; virtual double eth_countAt(const std::string& param1) = 0;
virtual int eth_defaultBlock() = 0; virtual int eth_defaultBlock() = 0;
virtual Json::Value eth_filterLogs(const int& param1) = 0;
virtual std::string eth_gasPrice() = 0; virtual std::string eth_gasPrice() = 0;
virtual Json::Value eth_getMessages(const int& param1) = 0;
virtual bool eth_listening() = 0; virtual bool eth_listening() = 0;
virtual std::string eth_lll(const std::string& param1) = 0; virtual std::string eth_lll(const std::string& param1) = 0;
virtual Json::Value eth_logs(const Json::Value& param1) = 0;
virtual bool eth_mining() = 0; virtual bool eth_mining() = 0;
virtual int eth_newFilter(const Json::Value& param1) = 0; virtual int eth_newFilter(const Json::Value& param1) = 0;
virtual int eth_newFilterString(const std::string& param1) = 0; virtual int eth_newFilterString(const std::string& param1) = 0;

3
libweb3jsonrpc/spec.json

@ -37,7 +37,8 @@
{ "method": "eth_newFilterString", "params": [""], "order": [], "returns": 0}, { "method": "eth_newFilterString", "params": [""], "order": [], "returns": 0},
{ "method": "eth_uninstallFilter", "params": [0], "order": [], "returns": true}, { "method": "eth_uninstallFilter", "params": [0], "order": [], "returns": true},
{ "method": "eth_changed", "params": [0], "order": [], "returns": false}, { "method": "eth_changed", "params": [0], "order": [], "returns": false},
{ "method": "eth_getMessages", "params": [0], "order": [], "returns": []}, { "method": "eth_filterLogs", "params": [0], "order": [], "returns": []},
{ "method": "eth_logs", "params": [{}], "order": [], "returns": []},
{ "method": "db_put", "params": ["", "", ""], "order": [], "returns": true}, { "method": "db_put", "params": ["", "", ""], "order": [], "returns": true},
{ "method": "db_get", "params": ["", ""], "order": [], "returns": ""}, { "method": "db_get", "params": ["", ""], "order": [], "returns": ""},

35
test/webthreestubclient.h

@ -216,26 +216,26 @@ p.append(param3);
} }
std::string eth_gasPrice() throw (jsonrpc::JsonRpcException) Json::Value eth_filterLogs(const int& param1) throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p = Json::nullValue; p.append(param1);
Json::Value result = this->client->CallMethod("eth_gasPrice",p);
if (result.isString()) Json::Value result = this->client->CallMethod("eth_filterLogs",p);
return result.asString(); if (result.isArray())
return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
} }
Json::Value eth_getMessages(const int& param1) throw (jsonrpc::JsonRpcException) std::string eth_gasPrice() throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;
p.append(param1); p = Json::nullValue;
Json::Value result = this->client->CallMethod("eth_gasPrice",p);
Json::Value result = this->client->CallMethod("eth_getMessages",p); if (result.isString())
if (result.isArray()) return result.asString();
return result;
else else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
@ -266,6 +266,19 @@ p.append(param3);
} }
Json::Value eth_logs(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->client->CallMethod("eth_logs",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_mining() throw (jsonrpc::JsonRpcException) bool eth_mining() throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;

Loading…
Cancel
Save