5 #include <QJsonDocument> 10 static const QString RPC_SERACH_LOGS =
"searchlogs";
11 static const QString PARAM_FROM_BLOCK =
"fromBlock";
12 static const QString PARAM_TO_BLOCK =
"toBlock";
13 static const QString PARAM_ADDRESSES =
"address";
14 static const QString PARAM_TOPICS =
"topics";
22 for(
size_t i = 0; i < value.size(); i++)
24 array.append(QJsonValue(QString::fromStdString(value[i])));
26 json.insert(QString::fromStdString(key), array);
28 QJsonDocument doc(json);
29 QString retString(doc.toJson(QJsonDocument::Compact));
30 retString.insert(0,
"'");
31 retString.append(
"'");
40 QStringList lstMandatory;
41 lstMandatory.append(PARAM_FROM_BLOCK);
42 lstMandatory.append(PARAM_TO_BLOCK);
43 QStringList lstOptional;
44 lstOptional.append(PARAM_ADDRESSES);
45 lstOptional.append(PARAM_TOPICS);
58 bool EventLog::searchTokenTx(int64_t fromBlock, int64_t toBlock, std::string strContractAddress, std::string strSenderAddress, QVariant &result)
60 std::vector<std::string> addresses;
61 addresses.push_back(strContractAddress);
63 std::vector<std::string> topics;
66 topics.push_back(nullRecord);
68 topics.push_back(strSenderAddress);
70 topics.push_back(strSenderAddress);
72 return search(fromBlock, toBlock, addresses, topics, result);
75 bool EventLog::search(int64_t fromBlock, int64_t toBlock,
const std::vector<std::string> addresses,
const std::vector<std::string> topics, QVariant &result)
91 m_lstParams[PARAM_FROM_BLOCK] = QString::number(fromBlock);
96 m_lstParams[PARAM_TO_BLOCK] = QString::number(toBlock);
void setEndBlock(int64_t toBlock)
void setTopics(const std::vector< std::string > topics)
EventLog()
EventLog Constructor.
~EventLog()
~EventLog Destructor
bool searchTokenTx(int64_t fromBlock, int64_t toBlock, std::string strContractAddress, std::string strSenderAddress, QVariant &result)
searchTokenTx Search the event log for token transactions
bool exec(const QMap< QString, QString > ¶ms, QVariant &result, QString &resultJson, QString &errorMessage)
exec Execute the RPC command
std::string ToString() const
ExecRPCCommand * m_RPCCommand
QMap< QString, QString > m_lstParams
QString createJsonString(std::string key, const std::vector< std::string > value)
The ExecRPCCommand class Execution of RPC command line.
bool search(int64_t fromBlock, int64_t toBlock, const std::vector< std::string > addresses, const std::vector< std::string > topics, QVariant &result)
search Search for log events
void setAddresses(const std::vector< std::string > addresses)
void setStartBlock(int64_t fromBlock)