Browse Source

Cleaned up some unused functions

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
08a1566b85
  1. 5
      alethzero/MainWin.cpp
  2. 1
      alethzero/MainWin.h
  3. 20
      alethzero/NatspecHandler.cpp
  4. 5
      alethzero/NatspecHandler.h
  5. 2
      alethzero/OurWebThreeStubServer.cpp
  6. 3
      libjsqrc/ethereumjs/example/natspec_contract.html

5
alethzero/MainWin.cpp

@ -2289,11 +2289,6 @@ std::string Main::lookupNatSpec(dev::h256 const& _contractHash) const
return m_natspecDB.retrieve(_contractHash); return m_natspecDB.retrieve(_contractHash);
} }
std::string Main::lookupNatSpecUserNotice(dev::h256 const& _contractHash, std::string const& _methodName)
{
return m_natspecDB.getUserNotice(_contractHash, _methodName);
}
std::string Main::lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData) std::string Main::lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData)
{ {
return m_natspecDB.getUserNotice(_contractHash, _transactionData); return m_natspecDB.getUserNotice(_contractHash, _transactionData);

1
alethzero/MainWin.h

@ -83,7 +83,6 @@ public:
std::shared_ptr<dev::shh::WhisperHost> whisper() const { return m_webThree->whisper(); } std::shared_ptr<dev::shh::WhisperHost> whisper() const { return m_webThree->whisper(); }
std::string lookupNatSpec(dev::h256 const& _contractHash) const; std::string lookupNatSpec(dev::h256 const& _contractHash) const;
std::string lookupNatSpecUserNotice(dev::h256 const& _contractHash, std::string const& _methodName);
std::string lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData); std::string lookupNatSpecUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData);
QList<dev::KeyPair> owned() const { return m_myIdentities + m_myKeys; } QList<dev::KeyPair> owned() const { return m_myIdentities + m_myKeys; }

20
alethzero/NatspecHandler.cpp

@ -42,7 +42,6 @@ NatspecHandler::NatspecHandler()
ldb::DB::Open(o, path + "/natspec", &m_db); ldb::DB::Open(o, path + "/natspec", &m_db);
} }
void NatspecHandler::add(dev::h256 const& _contractHash, std::string const& _doc) void NatspecHandler::add(dev::h256 const& _contractHash, std::string const& _doc)
{ {
bytes k = _contractHash.asBytes(); bytes k = _contractHash.asBytes();
@ -58,17 +57,6 @@ std::string NatspecHandler::retrieve(dev::h256 const& _contractHash) const
return ret; return ret;
} }
std::string NatspecHandler::getUserNotice(std::string const& json, std::string const& _methodName)
{
Json::Value natspec, userNotice;
std::string retStr;
m_reader.parse(json, natspec);
retStr = natspec["methods"][_methodName]["notice"].asString();
return (retStr == "null\n") ? "" : retStr;
}
std::string NatspecHandler::getUserNotice(std::string const& json, const dev::bytes& _transactionData) std::string NatspecHandler::getUserNotice(std::string const& json, const dev::bytes& _transactionData)
{ {
Json::Value natspec, userNotice; Json::Value natspec, userNotice;
@ -77,9 +65,8 @@ std::string NatspecHandler::getUserNotice(std::string const& json, const dev::by
bytes transactionFunctionPart(_transactionData.begin(), _transactionData.begin() + 4); bytes transactionFunctionPart(_transactionData.begin(), _transactionData.begin() + 4);
FixedHash<4> transactionFunctionHash(transactionFunctionPart); FixedHash<4> transactionFunctionHash(transactionFunctionPart);
// for (auto const& it: natspec["methods"])
Json::Value methods = natspec["methods"]; Json::Value methods = natspec["methods"];
for (Json::ValueIterator it= methods.begin(); it != methods.end(); ++it ) for (Json::ValueIterator it= methods.begin(); it != methods.end(); ++it)
{ {
std::string functionSig = it.key().asString(); std::string functionSig = it.key().asString();
FixedHash<4> functionHash(dev::sha3(functionSig)); FixedHash<4> functionHash(dev::sha3(functionSig));
@ -93,11 +80,6 @@ std::string NatspecHandler::getUserNotice(std::string const& json, const dev::by
return ""; 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) std::string NatspecHandler::getUserNotice(dev::h256 const& _contractHash, dev::bytes const& _transactionData)
{ {
return getUserNotice(retrieve(_contractHash), _transactionData); return getUserNotice(retrieve(_contractHash), _transactionData);

5
alethzero/NatspecHandler.h

@ -41,11 +41,8 @@ class NatspecHandler
/// Retrieves the natspec documentation as a string given a contract code hash /// Retrieves the natspec documentation as a string given a contract code hash
std::string retrieve(dev::h256 const& _contractHash) const; std::string retrieve(dev::h256 const& _contractHash) const;
/// Given a json natspec string, retrieve the user notice string /// Given a json natspec string and the transaction data return the user notice
std::string getUserNotice(std::string const& json, std::string const& _methodName);
std::string getUserNotice(std::string const& json, const dev::bytes& _transactionData); std::string getUserNotice(std::string const& json, const dev::bytes& _transactionData);
/// Given a contract code hash, retrieve the natspec documentation's user notice for that contract
std::string getUserNotice(dev::h256 const& _contractHash, std::string const& _methodName);
/// Given a contract code hash and the transaction's data retrieve the natspec documention's /// Given a contract code hash and the transaction's data retrieve the natspec documention's
/// user notice for that transaction. /// user notice for that transaction.
/// @returns The user notice or an empty string if no natspec for the contract exists /// @returns The user notice or an empty string if no natspec for the contract exists

2
alethzero/OurWebThreeStubServer.cpp

@ -53,7 +53,7 @@ bool OurWebThreeStubServer::authenticate(dev::TransactionSkeleton const& _t) con
{ {
// recipient has no code - nothing special about this transaction. // recipient has no code - nothing special about this transaction.
// TODO: show basic message for value transfer. // TODO: show basic message for value transfer.
return true; // or whatever. return true;
} }
//LTODO: Just for debugging here //LTODO: Just for debugging here

3
libjsqrc/ethereumjs/example/natspec_contract.html

@ -68,7 +68,8 @@
<button type="button" onClick="createExampleContract();">create example contract</button> <button type="button" onClick="createExampleContract();">create example contract</button>
</div> </div>
<div id='call' style='visibility: hidden;'> <div id='call' style='visibility: hidden;'>
<input type="number" id="value" onkeyup='callExampleContract()'></input> <input type="number" id="value"></input>
<button type="button" onClick="callExampleContract()">Call Contract</button>
</div> </div>
<div id="result"></div> <div id="result"></div>
</body> </body>

Loading…
Cancel
Save