From 5820373d73d0440c9fa5fa15cb05cb2487149987 Mon Sep 17 00:00:00 2001 From: caktux Date: Wed, 17 Sep 2014 20:10:20 -0400 Subject: [PATCH] use s for stateAt block number param to prevent conflict with bData and such, some style fixes --- eth/EthStubServer.cpp | 4 ++-- eth/EthStubServer.h | 2 +- eth/abstractethstubserver.h | 4 ++-- eth/eth.js | 18 +++++++----------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/eth/EthStubServer.cpp b/eth/EthStubServer.cpp index dd82541de..c82d61103 100644 --- a/eth/EthStubServer.cpp +++ b/eth/EthStubServer.cpp @@ -138,9 +138,9 @@ std::string EthStubServer::storageAt(const std::string& _a, const std::string& x return toJS(m_client.stateAt(jsToAddress(_a), jsToU256(x), 0)); } -std::string EthStubServer::stateAt(const std::string& _a, const std::string& x, const std::string& b) +std::string EthStubServer::stateAt(const std::string& _a, const std::string& x, const std::string& s) { - return toJS(m_client.stateAt(jsToAddress(_a), jsToU256(x), std::atol(b.c_str()))); + return toJS(m_client.stateAt(jsToAddress(_a), jsToU256(x), std::atol(s.c_str()))); } Json::Value EthStubServer::transact(const std::string& _aDest, const std::string& _bData, const std::string& _sec, const std::string& _xGas, const std::string& _xGasPrice, const std::string& _xValue) diff --git a/eth/EthStubServer.h b/eth/EthStubServer.h index 8046eb4ca..1034dbc5e 100644 --- a/eth/EthStubServer.h +++ b/eth/EthStubServer.h @@ -49,7 +49,7 @@ public: virtual Json::Value keys(); virtual int peerCount(); virtual std::string storageAt(const std::string& a, const std::string& x); - virtual std::string stateAt(const std::string& a, const std::string& x, const std::string& b); + virtual std::string stateAt(const std::string& a, const std::string& x, const std::string& s); virtual Json::Value transact(const std::string& aDest, const std::string& bData, const std::string& sec, const std::string& xGas, const std::string& xGasPrice, const std::string& xValue); virtual std::string txCountAt(const std::string& a); virtual std::string secretToAddress(const std::string& a); diff --git a/eth/abstractethstubserver.h b/eth/abstractethstubserver.h index e6e21fcf9..7f110513d 100644 --- a/eth/abstractethstubserver.h +++ b/eth/abstractethstubserver.h @@ -30,7 +30,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerbindAndAddMethod(new jsonrpc::Procedure("procedures", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_ARRAY, NULL), &AbstractEthStubServer::proceduresI); this->bindAndAddMethod(new jsonrpc::Procedure("secretToAddress", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::secretToAddressI); this->bindAndAddMethod(new jsonrpc::Procedure("storageAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"x",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::storageAtI); - this->bindAndAddMethod(new jsonrpc::Procedure("stateAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"x",jsonrpc::JSON_STRING,"b",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::stateAtI); + this->bindAndAddMethod(new jsonrpc::Procedure("stateAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING,"x",jsonrpc::JSON_STRING,"s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::stateAtI); this->bindAndAddMethod(new jsonrpc::Procedure("transact", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "aDest",jsonrpc::JSON_STRING,"bData",jsonrpc::JSON_STRING,"sec",jsonrpc::JSON_STRING,"xGas",jsonrpc::JSON_STRING,"xGasPrice",jsonrpc::JSON_STRING,"xValue",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::transactI); this->bindAndAddMethod(new jsonrpc::Procedure("txCountAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "a",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::txCountAtI); @@ -123,7 +123,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerstateAt(request["a"].asString(), request["x"].asString(), request["b"].asString()); + response = this->stateAt(request["a"].asString(), request["x"].asString(), request["s"].asString()); } inline virtual void transactI(const Json::Value& request, Json::Value& response) diff --git a/eth/eth.js b/eth/eth.js index d507ba0cc..791386a0b 100644 --- a/eth/eth.js +++ b/eth/eth.js @@ -25,7 +25,7 @@ var spec = [ { "method": "peerCount", "params": null, "order": [], "returns" : 0 }, { "method": "balanceAt", "params": { "a": "" }, "order": ["a"], "returns" : "" }, { "method": "storageAt", "params": { "a": "", "x": "" }, "order": ["a", "x"], "returns" : "" }, - { "method": "stateAt", "params": { "a": "", "x": "", "b": "" }, "order": ["a", "x", "b"], "returns" : "" }, + { "method": "stateAt", "params": { "a": "", "x": "", "s": "" }, "order": ["a", "x", "s"], "returns" : "" }, { "method": "txCountAt", "params": { "a": "" },"order": ["a"], "returns" : "" }, { "method": "isContractAt", "params": { "a": "" }, "order": ["a"], "returns" : false }, { "method": "create", "params": { "sec": "", "xEndowment": "", "bCode": "", "xGas": "", "xGasPrice": "" }, "order": ["sec", "xEndowment", "bCode", "xGas", "xGasPrice"] , "returns": "" }, @@ -72,17 +72,13 @@ window.eth = (function ethScope() { var am = "get" + m.slice(0, 1).toUpperCase() + m.slice(1); var getParams = function(a) { var p = s.params ? {} : null; - for (j in s.order) { - if (m == "stateAt") { - if (typeof(a[j]) == 'undefined') { - p[s.order[j]] = "0"; - } - else - p[s.order[j]] = String(a[j]); - } + if (m == "stateAt") + if (a.length == 2) + a[2] = "0"; else - p[s.order[j]] = a[j]; - } + a[2] = String(a[2]); + for (j in s.order) + p[s.order[j]] = (s.order[j][0] === "b") ? a[j].unbin() : a[j]; return p }; if (m == "create" || m == "transact")