diff --git a/CMakeLists.txt b/CMakeLists.txt index a3a5702f1..221087884 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,7 @@ endfunction() function(createBuildInfo) # Set build platform; to be written to BuildInfo.h + set(ETH_BUILD_PLATFORM ${TARGET_PLATFORM}) if (CMAKE_COMPILER_IS_MINGW) set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw") elseif (CMAKE_COMPILER_IS_MSYS) diff --git a/libethereum/Client.h b/libethereum/Client.h index 992ceb524..e83858323 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -108,7 +108,7 @@ struct WorkChannel: public LogChannel { static const char* name() { return "-W-" #define cworkout dev::LogOutputStream() template struct ABISerialiser {}; -template struct ABISerialiser> { static bytes serialise(FixedHash const& _t) { static_assert(N < 32, "Parameter sizes must be at most 32 bytes."); return bytes(32 - N, 0) + _t.asBytes(); } }; +template struct ABISerialiser> { static bytes serialise(FixedHash const& _t) { static_assert(N <= 32, "Cannot serialise hash > 32 bytes."); static_assert(N > 0, "Cannot serialise zero-length hash."); return bytes(32 - N, 0) + _t.asBytes(); } }; template <> struct ABISerialiser { static bytes serialise(u256 const& _t) { return h256(_t).asBytes(); } }; template <> struct ABISerialiser { static bytes serialise(u160 const& _t) { return bytes(12, 0) + h160(_t).asBytes(); } }; template <> struct ABISerialiser { static bytes serialise(string32 const& _t) { return bytesConstRef((byte const*)_t.data(), 32).toBytes(); } }; @@ -125,9 +125,9 @@ template bytes abiIn(std::string _id, T const& ... _t) } template struct ABIDeserialiser {}; -template struct ABIDeserialiser> { static FixedHash deserialise(bytesConstRef& io_t) { static_assert(N < 32, "Parameter sizes must be at most 32 bytes."); FixedHash ret; io_t.cropped(32 - N, N).populate(ret.ref()); io_t = io_t.cropped(32); return ret; } }; +template struct ABIDeserialiser> { static FixedHash deserialise(bytesConstRef& io_t) { static_assert(N <= 32, "Parameter sizes must be at most 32 bytes."); FixedHash ret; io_t.cropped(32 - N, N).populate(ret.ref()); io_t = io_t.cropped(32); return ret; } }; template <> struct ABIDeserialiser { static u256 deserialise(bytesConstRef& io_t) { u256 ret = fromBigEndian(io_t.cropped(0, 32)); io_t = io_t.cropped(32); return ret; } }; -template <> struct ABIDeserialiser { static u256 deserialise(bytesConstRef& io_t) { u160 ret = fromBigEndian(io_t.cropped(12, 20)); io_t = io_t.cropped(32); return ret; } }; +template <> struct ABIDeserialiser { static u160 deserialise(bytesConstRef& io_t) { u160 ret = fromBigEndian(io_t.cropped(12, 20)); io_t = io_t.cropped(32); return ret; } }; template <> struct ABIDeserialiser { static string32 deserialise(bytesConstRef& io_t) { string32 ret; io_t.cropped(0, 32).populate(vector_ref(ret.data(), 32)); io_t = io_t.cropped(32); return ret; } }; template T abiOut(bytes const& _data) diff --git a/libethereum/Utility.cpp b/libethereum/Utility.cpp index b6653fe39..31c5e278a 100644 --- a/libethereum/Utility.cpp +++ b/libethereum/Utility.cpp @@ -23,6 +23,7 @@ #include #include +#include using namespace std; using namespace dev; using namespace dev::eth; @@ -32,7 +33,7 @@ bytes dev::eth::parseData(string const& _args) bytes m_data; boost::smatch what; - static const boost::regex r("(@|\\$)?\"([^\"]*)\"(\\s.*)?"); + static const boost::regex r("(!|#|@|\\$)?\"([^\"]*)\"(\\s.*)?"); static const boost::regex d("(@|\\$)?([0-9]+)(\\s*(ether)|(finney)|(szabo))?(\\s.*)?"); static const boost::regex h("(@|\\$)?(0x)?(([a-fA-F0-9])+)(\\s.*)?"); @@ -67,13 +68,15 @@ bytes dev::eth::parseData(string const& _args) } else if (boost::regex_match(s, what, r)) { - for (auto i: (string)what[2]) - m_data.push_back((byte)i); - if (what[1] != "$") - for (int i = what[2].length(); i < 32; ++i) - m_data.push_back(0); + bytes d = asBytes(what[2]); + if (what[1] == "!") + m_data += FixedHash<4>(sha3(d)).asBytes(); + else if (what[1] == "#") + m_data += sha3(d).asBytes(); + else if (what[1] == "$") + m_data += d + bytes{0}; else - m_data.push_back(0); + m_data += d + bytes(32 - what[2].length() % 32, 0); s = what[3]; } else diff --git a/libjsqrc/js.qrc b/libjsqrc/js.qrc index eee8f6652..896ab472f 100644 --- a/libjsqrc/js.qrc +++ b/libjsqrc/js.qrc @@ -1,7 +1,7 @@ - - - es6-promise-2.0.0.js - setup.js - ethereumjs/dist/ethereum.js - + + + es6-promise-2.0.0.js + setup.js + ethereumjs/dist/ethereum.js + diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h index 657986b36..49df0f703 100644 --- a/libqethereum/QEthereum.h +++ b/libqethereum/QEthereum.h @@ -85,7 +85,7 @@ private: _frame->addToJavaScriptWindowObject("_web3", qweb, QWebFrame::ScriptOwnership); \ _frame->addToJavaScriptWindowObject("env", _env, QWebFrame::QtOwnership); \ _frame->evaluateJavaScript(contentsOfQResource(":/js/es6-promise-2.0.0.js")); \ - _frame->evaluateJavaScript(contentsOfQResource(":/js/ethereum.js")); \ + _frame->evaluateJavaScript(contentsOfQResource(":/js/webthree.js")); \ _frame->evaluateJavaScript(contentsOfQResource(":/js/setup.js")); \ } diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 874c14331..1fb284aaa 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -634,7 +634,7 @@ std::string WebThreeStubServer::eth_transact(Json::Value const& _json) { auto b = m_accounts.begin()->first; for (auto a: m_accounts) - if (client()->balanceAt(a.first) > client()->balanceAt(b)) + if (client()->balanceAt(a.first, 0) > client()->balanceAt(b, 0)) b = a.first; t.from = b; } @@ -643,7 +643,7 @@ std::string WebThreeStubServer::eth_transact(Json::Value const& _json) if (!t.gasPrice) t.gasPrice = 10 * dev::eth::szabo; if (!t.gas) - t.gas = min(client()->gasLimitRemaining(), client()->balanceAt(t.from) / t.gasPrice); + t.gas = min(client()->gasLimitRemaining(), client()->balanceAt(t.from, 0) / t.gasPrice); if (authenticate(t)) { if (t.to)