From fbd70ac939e4c814603a43a597bda2d2bb41b822 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 15 Oct 2014 11:49:53 +0200 Subject: [PATCH] jsonrpc renaming properties in request --- libethrpc/EthStubServer.cpp | 16 ++++++++-------- libethrpc/EthStubServer.h | 8 ++++---- libethrpc/abstractethstubserver.h | 24 ++++++++++++------------ libethrpc/eth.js | 9 ++++----- libethrpc/spec.json | 8 ++++---- test/ethstubclient.h | 18 +++++++++--------- 6 files changed, 41 insertions(+), 42 deletions(-) diff --git a/libethrpc/EthStubServer.cpp b/libethrpc/EthStubServer.cpp index 14f744e76..6a0a11564 100644 --- a/libethrpc/EthStubServer.cpp +++ b/libethrpc/EthStubServer.cpp @@ -105,9 +105,9 @@ dev::eth::Interface* EthStubServer::client() const return &(*m_web3.ethereum()); } -std::string EthStubServer::balanceAt(const string &a, const int& block) +std::string EthStubServer::balanceAt(const string &address, const int& block) { - return jsToDecimal(toJS(client()->balanceAt(jsToAddress(a), block))); + return jsToDecimal(toJS(client()->balanceAt(jsToAddress(address), block))); } //TODO BlockDetails? @@ -174,9 +174,9 @@ std::string EthStubServer::call(const Json::Value &json) return ret; } -std::string EthStubServer::codeAt(const string &a, const int& block) +std::string EthStubServer::codeAt(const string &address, const int& block) { - return client() ? jsFromBinary(client()->codeAt(jsToAddress(a), block)) : ""; + return client() ? jsFromBinary(client()->codeAt(jsToAddress(address), block)) : ""; } std::string EthStubServer::coinbase() @@ -184,9 +184,9 @@ std::string EthStubServer::coinbase() return client() ? toJS(client()->address()) : ""; } -double EthStubServer::countAt(const string &a, const int& block) +double EthStubServer::countAt(const string &address, const int& block) { - return client() ? (double)(uint64_t)client()->countAt(jsToAddress(a), block) : 0; + return client() ? (double)(uint64_t)client()->countAt(jsToAddress(address), block) : 0; } int EthStubServer::defaultBlock() @@ -348,9 +348,9 @@ std::string EthStubServer::sha3(const string &s) return toJS(dev::eth::sha3(jsToBytes(s))); } -std::string EthStubServer::stateAt(const string &a, const int& block, const string &s) +std::string EthStubServer::stateAt(const string &address, const int& block, const string &storage) { - return client() ? toJS(client()->stateAt(jsToAddress(a), jsToU256(s), block)) : ""; + return client() ? toJS(client()->stateAt(jsToAddress(address), jsToU256(storage), block)) : ""; } std::string EthStubServer::toAscii(const string &s) diff --git a/libethrpc/EthStubServer.h b/libethrpc/EthStubServer.h index 302fb527c..aec1757ac 100644 --- a/libethrpc/EthStubServer.h +++ b/libethrpc/EthStubServer.h @@ -36,12 +36,12 @@ class EthStubServer: public AbstractEthStubServer public: EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::WebThreeDirect& _web3); - virtual std::string balanceAt(const std::string& a, const int& block); + virtual std::string balanceAt(const std::string& address, const int& block); virtual Json::Value block(const std::string& numberOrHash); virtual std::string call(const Json::Value& json); - virtual std::string codeAt(const std::string& a, const int& block); + virtual std::string codeAt(const std::string& address, const int& block); virtual std::string coinbase(); - virtual double countAt(const std::string& a, const int& block); + virtual double countAt(const std::string& address, const int& block); virtual int defaultBlock(); virtual std::string fromAscii(const int& padding, const std::string& s); virtual double fromFixed(const std::string& s); @@ -59,7 +59,7 @@ public: virtual bool setListening(const bool& listening); virtual bool setMining(const bool& mining); virtual std::string sha3(const std::string& s); - virtual std::string stateAt(const std::string& a, const int& block, const std::string& s); + virtual std::string stateAt(const std::string& address, const int& block, const std::string& storage); virtual std::string toAscii(const std::string& s); virtual std::string toDecimal(const std::string& s); virtual std::string toFixed(const double& s); diff --git a/libethrpc/abstractethstubserver.h b/libethrpc/abstractethstubserver.h index def5ca55d..db0c57c98 100644 --- a/libethrpc/abstractethstubserver.h +++ b/libethrpc/abstractethstubserver.h @@ -13,12 +13,12 @@ class AbstractEthStubServer : public jsonrpc::AbstractServer(conn) { - this->bindAndAddMethod(new jsonrpc::Procedure("balanceAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::balanceAtI); + this->bindAndAddMethod(new jsonrpc::Procedure("balanceAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "address",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::balanceAtI); this->bindAndAddMethod(new jsonrpc::Procedure("block", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "numberOrHash",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::blockI); this->bindAndAddMethod(new jsonrpc::Procedure("call", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "json",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::callI); - this->bindAndAddMethod(new jsonrpc::Procedure("codeAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::codeAtI); + this->bindAndAddMethod(new jsonrpc::Procedure("codeAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "address",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::codeAtI); this->bindAndAddMethod(new jsonrpc::Procedure("coinbase", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::coinbaseI); - this->bindAndAddMethod(new jsonrpc::Procedure("countAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_REAL, "a",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::countAtI); + this->bindAndAddMethod(new jsonrpc::Procedure("countAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_REAL, "address",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::countAtI); this->bindAndAddMethod(new jsonrpc::Procedure("defaultBlock", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::defaultBlockI); this->bindAndAddMethod(new jsonrpc::Procedure("fromAscii", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "padding",jsonrpc::JSON_INTEGER,"s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::fromAsciiI); this->bindAndAddMethod(new jsonrpc::Procedure("fromFixed", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_REAL, "s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::fromFixedI); @@ -36,7 +36,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerbindAndAddMethod(new jsonrpc::Procedure("setListening", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_BOOLEAN, "listening",jsonrpc::JSON_BOOLEAN, NULL), &AbstractEthStubServer::setListeningI); this->bindAndAddMethod(new jsonrpc::Procedure("setMining", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_BOOLEAN, "mining",jsonrpc::JSON_BOOLEAN, NULL), &AbstractEthStubServer::setMiningI); this->bindAndAddMethod(new jsonrpc::Procedure("sha3", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::sha3I); - this->bindAndAddMethod(new jsonrpc::Procedure("stateAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER,"s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::stateAtI); + this->bindAndAddMethod(new jsonrpc::Procedure("stateAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "address",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER,"storage",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::stateAtI); this->bindAndAddMethod(new jsonrpc::Procedure("toAscii", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::toAsciiI); this->bindAndAddMethod(new jsonrpc::Procedure("toDecimal", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::toDecimalI); this->bindAndAddMethod(new jsonrpc::Procedure("toFixed", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_REAL, NULL), &AbstractEthStubServer::toFixedI); @@ -49,7 +49,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerbalanceAt(request["a"].asString(), request["block"].asInt()); + response = this->balanceAt(request["address"].asString(), request["block"].asInt()); } inline virtual void blockI(const Json::Value& request, Json::Value& response) @@ -64,7 +64,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServercodeAt(request["a"].asString(), request["block"].asInt()); + response = this->codeAt(request["address"].asString(), request["block"].asInt()); } inline virtual void coinbaseI(const Json::Value& request, Json::Value& response) @@ -74,7 +74,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServercountAt(request["a"].asString(), request["block"].asInt()); + response = this->countAt(request["address"].asString(), request["block"].asInt()); } inline virtual void defaultBlockI(const Json::Value& request, Json::Value& response) @@ -164,7 +164,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerstateAt(request["a"].asString(), request["block"].asInt(), request["s"].asString()); + response = this->stateAt(request["address"].asString(), request["block"].asInt(), request["storage"].asString()); } inline virtual void toAsciiI(const Json::Value& request, Json::Value& response) @@ -203,12 +203,12 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerclient; } - std::string balanceAt(const std::string& a, const int& block) throw (jsonrpc::JsonRpcException) + std::string balanceAt(const std::string& address, const int& block) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["a"] = a; + p["address"] = address; p["block"] = block; Json::Value result = this->client->CallMethod("balanceAt",p); @@ -59,10 +59,10 @@ p["block"] = block; } - std::string codeAt(const std::string& a, const int& block) throw (jsonrpc::JsonRpcException) + std::string codeAt(const std::string& address, const int& block) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["a"] = a; + p["address"] = address; p["block"] = block; Json::Value result = this->client->CallMethod("codeAt",p); @@ -85,10 +85,10 @@ p["block"] = block; } - double countAt(const std::string& a, const int& block) throw (jsonrpc::JsonRpcException) + double countAt(const std::string& address, const int& block) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["a"] = a; + p["address"] = address; p["block"] = block; Json::Value result = this->client->CallMethod("countAt",p); @@ -313,12 +313,12 @@ p["s"] = s; } - std::string stateAt(const std::string& a, const int& block, const std::string& s) throw (jsonrpc::JsonRpcException) + std::string stateAt(const std::string& address, const int& block, const std::string& storage) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["a"] = a; + p["address"] = address; p["block"] = block; -p["s"] = s; +p["storage"] = storage; Json::Value result = this->client->CallMethod("stateAt",p); if (result.isString())