|
|
@ -30,6 +30,7 @@ |
|
|
|
#include <jsonrpccpp/server.h> |
|
|
|
#include <libethcore/CommonJS.h> |
|
|
|
#include <libethereum/Transaction.h> |
|
|
|
#include <libdevcore/FixedHash.h> |
|
|
|
#include "DebuggingStateWrapper.h" |
|
|
|
#include "Exceptions.h" |
|
|
|
#include "QContractDefinition.h" |
|
|
@ -668,7 +669,7 @@ RecordLogEntry* ClientModel::lastBlock() const |
|
|
|
strGas << blockInfo.gasUsed; |
|
|
|
stringstream strNumber; |
|
|
|
strNumber << blockInfo.number; |
|
|
|
RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), tr(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(dev::toHex(blockInfo.hash().ref()))), QString(), QString(), QString(), false, RecordLogEntry::RecordType::Block, QString::fromStdString(strGas.str()), QString(), tr("Block"), QVariantMap()); |
|
|
|
RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), tr(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(dev::toHex(blockInfo.hash().ref()))), QString(), QString(), QString(), false, RecordLogEntry::RecordType::Block, QString::fromStdString(strGas.str()), QString(), tr("Block"), QVariantMap(), QVariantList()); |
|
|
|
QQmlEngine::setObjectOwnership(record, QQmlEngine::JavaScriptOwnership); |
|
|
|
return record; |
|
|
|
} |
|
|
@ -728,8 +729,10 @@ void ClientModel::onNewTransaction() |
|
|
|
Address contractAddress = (bool)tr.address ? tr.address : tr.contractAddress; |
|
|
|
auto contractAddressIter = m_contractNames.find(contractAddress); |
|
|
|
QVariantMap inputParameters; |
|
|
|
QVariantList logs; |
|
|
|
if (contractAddressIter != m_contractNames.end()) |
|
|
|
{ |
|
|
|
ContractCallDataEncoder encoder; |
|
|
|
CompiledContract const& compilerRes = m_codeModel->contract(contractAddressIter->second); |
|
|
|
const QContractDefinition* def = compilerRes.contract(); |
|
|
|
contract = def->name(); |
|
|
@ -739,7 +742,6 @@ void ClientModel::onNewTransaction() |
|
|
|
if (funcDef) |
|
|
|
{ |
|
|
|
function = funcDef->name(); |
|
|
|
ContractCallDataEncoder encoder; |
|
|
|
QStringList returnValues = encoder.decode(funcDef->returnParameters(), tr.result.output); |
|
|
|
returned += "("; |
|
|
|
returned += returnValues.join(", "); |
|
|
@ -751,13 +753,53 @@ void ClientModel::onNewTransaction() |
|
|
|
inputParameters.insert(funcDef->parametersList().at(k)->name(), parameters.at(k)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
LocalisedLogEntries logs = m_client->logs(); |
|
|
|
// Fill generated logs and decode parameters
|
|
|
|
for (auto const& log: tr.logs) |
|
|
|
{ |
|
|
|
QVariantMap l; |
|
|
|
l.insert("address", QString::fromStdString(log.address.hex())); |
|
|
|
auto const& sign = log.topics.front(); // first hash supposed to be the event signature. To check
|
|
|
|
auto dataIterator = log.data.begin(); |
|
|
|
int topicDataIndex = 1; |
|
|
|
for (auto const& event: def->eventsList()) |
|
|
|
{ |
|
|
|
if (sign == event->fullHash()) |
|
|
|
{ |
|
|
|
QVariantList paramsList; |
|
|
|
l.insert("name", event->name()); |
|
|
|
for (auto const& e: event->parametersList()) |
|
|
|
{ |
|
|
|
bytes data; |
|
|
|
QString param; |
|
|
|
if (!e->isIndexed()) |
|
|
|
{ |
|
|
|
data = bytes(dataIterator, dataIterator + 32); |
|
|
|
dataIterator = dataIterator + 32; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
data = log.topics.at(topicDataIndex).asBytes(); |
|
|
|
topicDataIndex++; |
|
|
|
} |
|
|
|
param = encoder.decode(e, data); |
|
|
|
QVariantMap p; |
|
|
|
p.insert("indexed", e->isIndexed()); |
|
|
|
p.insert("value", param); |
|
|
|
p.insert("name", e->name()); |
|
|
|
paramsList.push_back(p); |
|
|
|
} |
|
|
|
l.insert("param", paramsList); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
logs.push_back(l); |
|
|
|
} |
|
|
|
} |
|
|
|
QString sender = QString::fromStdString(dev::toHex(tr.sender.ref())); |
|
|
|
QString label = contract + "." + function + "()"; |
|
|
|
RecordLogEntry* log = new RecordLogEntry(recordIndex, transactionIndex, contract, function, value, address, returned, tr.isCall(), RecordLogEntry::RecordType::Transaction, |
|
|
|
gasUsed, sender, label, inputParameters); |
|
|
|
gasUsed, sender, label, inputParameters, logs); |
|
|
|
QQmlEngine::setObjectOwnership(log, QQmlEngine::JavaScriptOwnership); |
|
|
|
emit newRecord(log); |
|
|
|
} |
|
|
|