|
|
@ -25,7 +25,9 @@ |
|
|
|
|
|
|
|
#include <libethereum/Defaults.h> |
|
|
|
#include <libdevcore/Common.h> |
|
|
|
#include <libdevcore/CommonData.h> |
|
|
|
#include <libdevcore/Log.h> |
|
|
|
#include <libdevcrypto/SHA3.h> |
|
|
|
|
|
|
|
|
|
|
|
using namespace dev; |
|
|
@ -62,14 +64,43 @@ std::string NatspecHandler::getUserNotice(std::string const& json, std::string c |
|
|
|
Json::Value natspec, userNotice; |
|
|
|
std::string retStr; |
|
|
|
m_reader.parse(json, natspec); |
|
|
|
retStr = natspec["methods"][_methodName]["notice"].toStyledString(); |
|
|
|
retStr = natspec["methods"][_methodName]["notice"].asString(); |
|
|
|
|
|
|
|
return (retStr == "null\n") ? "" : retStr; |
|
|
|
} |
|
|
|
|
|
|
|
std::string NatspecHandler::getUserNotice(std::string const& json, const dev::bytes& _transactionData) |
|
|
|
{ |
|
|
|
Json::Value natspec, userNotice; |
|
|
|
std::string retStr; |
|
|
|
m_reader.parse(json, natspec); |
|
|
|
bytes transactionFunctionPart(_transactionData.begin(), _transactionData.begin() + 4); |
|
|
|
FixedHash<4> transactionFunctionHash(transactionFunctionPart); |
|
|
|
|
|
|
|
// for (auto const& it: natspec["methods"])
|
|
|
|
Json::Value methods = natspec["methods"]; |
|
|
|
for (Json::ValueIterator it= methods.begin(); it != methods.end(); ++it ) |
|
|
|
{ |
|
|
|
std::string functionSig = it.key().asString(); |
|
|
|
FixedHash<4> functionHash(dev::sha3(functionSig)); |
|
|
|
|
|
|
|
if (functionHash == transactionFunctionHash) { |
|
|
|
return (*it)["notice"].asString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// not found
|
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
std::string NatspecHandler::getUserNotice(dev::h256 const& _contractHash, std::string const& _methodName) |
|
|
|
{ |
|
|
|
return getUserNotice(retrieve(_contractHash), _methodName); |
|
|
|
} |
|
|
|
|
|
|
|
std::string NatspecHandler::getUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData) |
|
|
|
{ |
|
|
|
return getUserNotice(retrieve(_contractHash), _transactionData); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|