mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
work on hedera task for able to create topics
This commit is contained in:
parent
e5e4a07441
commit
5bb34f26a2
@ -83,6 +83,23 @@ HederaRequestReturn HederaRequest::request(model::hedera::Query* query, model::h
|
|||||||
return HEDERA_REQUEST_UNKNOWN_QUERY;
|
return HEDERA_REQUEST_UNKNOWN_QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HederaRequestReturn HederaRequest::request(model::hedera::TransactionGetReceiptQuery* query, model::hedera::Response* response)
|
||||||
|
{
|
||||||
|
auto channel = grpc::CreateChannel(query->getConnectionString(), grpc::InsecureChannelCredentials());
|
||||||
|
|
||||||
|
grpc::ClientContext context;
|
||||||
|
std::chrono::system_clock::time_point deadline = std::chrono::system_clock::now() +
|
||||||
|
std::chrono::milliseconds(5000);
|
||||||
|
context.set_deadline(deadline);
|
||||||
|
|
||||||
|
auto proto_query = query->getProto();
|
||||||
|
auto proto_response = response->getResponsePtr();
|
||||||
|
grpc::Status status;
|
||||||
|
|
||||||
|
auto stub = proto::CryptoService::NewStub(channel);
|
||||||
|
status = stub->getTransactionReceipts(&context, *proto_query, proto_response);
|
||||||
|
}
|
||||||
|
|
||||||
HederaRequestReturn HederaRequest::request(model::hedera::Transaction* transaction, model::hedera::Response* response)
|
HederaRequestReturn HederaRequest::request(model::hedera::Transaction* transaction, model::hedera::Response* response)
|
||||||
{
|
{
|
||||||
auto channel = grpc::CreateChannel(transaction->getConnectionString(), grpc::InsecureChannelCredentials());
|
auto channel = grpc::CreateChannel(transaction->getConnectionString(), grpc::InsecureChannelCredentials());
|
||||||
@ -106,7 +123,8 @@ HederaRequestReturn HederaRequest::request(model::hedera::Transaction* transacti
|
|||||||
context.set_deadline(deadline);
|
context.set_deadline(deadline);
|
||||||
auto transaction_type = transaction->getType();
|
auto transaction_type = transaction->getType();
|
||||||
task->setTransactionId(transaction->getTransactionId());
|
task->setTransactionId(transaction->getTransactionId());
|
||||||
if (model::hedera::TRANSACTION_CONSENSUS_SUBMIT_MESSAGE == transaction_type) {
|
if (model::hedera::TRANSACTION_CONSENSUS_SUBMIT_MESSAGE == transaction_type ||
|
||||||
|
model::hedera::TRANSACTION_CONSENSUS_CREATE_TOPIC == transaction_type) {
|
||||||
auto stub = proto::ConsensusService::NewStub(channel);
|
auto stub = proto::ConsensusService::NewStub(channel);
|
||||||
|
|
||||||
auto status = stub->submitMessage(&context, *transaction->getTransaction(), task->getTransactionResponse()->getProtoResponse());
|
auto status = stub->submitMessage(&context, *transaction->getTransaction(), task->getTransactionResponse()->getProtoResponse());
|
||||||
@ -119,7 +137,8 @@ HederaRequestReturn HederaRequest::request(model::hedera::Transaction* transacti
|
|||||||
return HEDERA_REQUEST_RETURN_ERROR;
|
return HEDERA_REQUEST_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addError(new ParamError("Hedera Request", "not implemnetet or unknown transaction type", transaction_type));
|
|
||||||
|
addError(new ParamError("Hedera Request", "not implementet or unknown transaction type", transaction_type));
|
||||||
return HEDERA_REQUEST_UNKNOWN_TRANSACTION;
|
return HEDERA_REQUEST_UNKNOWN_TRANSACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "../controller/NodeServer.h"
|
#include "../controller/NodeServer.h"
|
||||||
#include "../model/hedera/Query.h"
|
#include "../model/hedera/Query.h"
|
||||||
|
#include "../model/hedera/TransactionGetReceiptQuery.h"
|
||||||
#include "../model/hedera/Transaction.h"
|
#include "../model/hedera/Transaction.h"
|
||||||
#include "../model/hedera/Response.h"
|
#include "../model/hedera/Response.h"
|
||||||
#include "../model/hedera/TransactionResponse.h"
|
#include "../model/hedera/TransactionResponse.h"
|
||||||
@ -36,6 +37,7 @@ public:
|
|||||||
~HederaRequest();
|
~HederaRequest();
|
||||||
|
|
||||||
HederaRequestReturn request(model::hedera::Query* query, model::hedera::Response* response, Poco::UInt64 fee = 0);
|
HederaRequestReturn request(model::hedera::Query* query, model::hedera::Response* response, Poco::UInt64 fee = 0);
|
||||||
|
HederaRequestReturn request(model::hedera::TransactionGetReceiptQuery* query, model::hedera::Response* response);
|
||||||
HederaRequestReturn request(model::hedera::Transaction* transaction, model::hedera::Response* response);
|
HederaRequestReturn request(model::hedera::Transaction* transaction, model::hedera::Response* response);
|
||||||
//!
|
//!
|
||||||
//! \param task goes into HederaTaskManager and will be run after transaction
|
//! \param task goes into HederaTaskManager and will be run after transaction
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
#include "HederaRequest.h"
|
#include "HederaRequest.h"
|
||||||
#include "../lib/Success.h"
|
#include "../lib/Success.h"
|
||||||
|
|
||||||
|
#include "../model/hedera/ConsensusCreateTopic.h"
|
||||||
|
#include "../model/hedera/Transaction.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
HederaTopic::HederaTopic(model::table::HederaTopic* dbModel)
|
HederaTopic::HederaTopic(model::table::HederaTopic* dbModel)
|
||||||
{
|
{
|
||||||
@ -64,10 +67,6 @@ namespace controller {
|
|||||||
return mAutoRenewAccount;
|
return mAutoRenewAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Poco::UInt64 HederaTopic::hederaCreateTopic()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HederaTopic::updateWithGetTopicInfos(Poco::AutoPtr<User> user)
|
bool HederaTopic::updateWithGetTopicInfos(Poco::AutoPtr<User> user)
|
||||||
{
|
{
|
||||||
@ -124,4 +123,41 @@ namespace controller {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Poco::AutoPtr<HederaTask> HederaTopic::createTopic(Poco::AutoPtr<controller::HederaAccount> operatorAccount, Poco::AutoPtr<controller::User> user)
|
||||||
|
{
|
||||||
|
static const char* function_name = "HederaTopic::createTopic";
|
||||||
|
auto model = getModel();
|
||||||
|
Poco::AutoPtr<controller::HederaId> autoRenewAccountId(nullptr);
|
||||||
|
if (model->getAutoRenewAccountId()) {
|
||||||
|
autoRenewAccountId = controller::HederaId::load(model->getAutoRenewAccountId());
|
||||||
|
}
|
||||||
|
model::hedera::ConsensusCreateTopic hederaCreateTopic(autoRenewAccountId, model->getAutoRenewPeriod());
|
||||||
|
auto hederaTransactionBody = operatorAccount->createTransactionBody();
|
||||||
|
hederaTransactionBody->setCreateTopic(hederaCreateTopic);
|
||||||
|
model::hedera::Transaction hederaTransaction;
|
||||||
|
if (!hederaTransaction.sign(operatorAccount->getCryptoKey()->getKeyPair(user), std::move(hederaTransactionBody))) {
|
||||||
|
addError(new Error(function_name, "error signing hedera transaction"));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Poco::AutoPtr<HederaTask> receiptTask(new HederaTask(&hederaTransaction));
|
||||||
|
HederaRequest request;
|
||||||
|
auto result = request.request(&hederaTransaction, receiptTask.get());
|
||||||
|
if (HEDERA_REQUEST_RETURN_OK == result) {
|
||||||
|
if (proto::OK == receiptTask->getTransactionResponse()->getPrecheckCode()) {
|
||||||
|
|
||||||
|
return receiptTask;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addError(new ParamError(function_name, "precheck code error", receiptTask->getTransactionResponse()->getPrecheckCodeString()));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addError(new Error(function_name, "error in hedera request"));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -15,6 +15,7 @@
|
|||||||
#include "HederaId.h"
|
#include "HederaId.h"
|
||||||
#include "HederaAccount.h"
|
#include "HederaAccount.h"
|
||||||
|
|
||||||
|
#include "../tasks/HederaTask.h"
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
class HederaTopic : public TableControllerBase, public NotificationList
|
class HederaTopic : public TableControllerBase, public NotificationList
|
||||||
@ -26,16 +27,18 @@ namespace controller {
|
|||||||
static Poco::AutoPtr<HederaTopic> create(const std::string& name, int autoRenewAccountId, int autoRenewPeriod, int groupId);
|
static Poco::AutoPtr<HederaTopic> create(const std::string& name, int autoRenewAccountId, int autoRenewPeriod, int groupId);
|
||||||
static std::vector<Poco::AutoPtr<HederaTopic>> listAll();
|
static std::vector<Poco::AutoPtr<HederaTopic>> listAll();
|
||||||
static Poco::AutoPtr<HederaTopic> load(int id);
|
static Poco::AutoPtr<HederaTopic> load(int id);
|
||||||
//! \brief hedera call to create a hedera topic
|
|
||||||
Poco::UInt64 hederaCreateTopic();
|
|
||||||
bool updateWithGetTopicInfos(Poco::AutoPtr<User> user);
|
bool updateWithGetTopicInfos(Poco::AutoPtr<User> user);
|
||||||
|
|
||||||
|
|
||||||
inline bool deleteFromDB() { return mDBModel->deleteFromDB(); }
|
inline bool deleteFromDB() { return mDBModel->deleteFromDB(); }
|
||||||
Poco::AutoPtr<HederaId> getTopicHederaId();
|
Poco::AutoPtr<HederaId> getTopicHederaId();
|
||||||
Poco::AutoPtr<HederaAccount> getAutoRenewAccount();
|
Poco::AutoPtr<HederaAccount> getAutoRenewAccount();
|
||||||
|
|
||||||
|
//! \brief hedera call to create a hedera topic
|
||||||
|
Poco::AutoPtr<HederaTask> createTopic(Poco::AutoPtr<controller::HederaAccount> operatorAccount, Poco::AutoPtr<controller::User> user);
|
||||||
|
|
||||||
|
|
||||||
inline Poco::AutoPtr<model::table::HederaTopic> getModel() { return _getModel<model::table::HederaTopic>(); }
|
inline Poco::AutoPtr<model::table::HederaTopic> getModel() { return _getModel<model::table::HederaTopic>(); }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,9 @@ namespace model {
|
|||||||
auto_renew_period->set_seconds(autoRenewPeriod);
|
auto_renew_period->set_seconds(autoRenewPeriod);
|
||||||
|
|
||||||
auto auto_renew_account = mProtoCreateTopic->mutable_autorenewaccount();
|
auto auto_renew_account = mProtoCreateTopic->mutable_autorenewaccount();
|
||||||
autoRenewHederaAccountId->copyToProtoAccountId(auto_renew_account);
|
if (!autoRenewHederaAccountId.isNull()) {
|
||||||
|
autoRenewHederaAccountId->copyToProtoAccountId(auto_renew_account);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ConsensusCreateTopic::~ConsensusCreateTopic()
|
ConsensusCreateTopic::~ConsensusCreateTopic()
|
||||||
|
|||||||
@ -67,10 +67,10 @@ namespace model {
|
|||||||
|
|
||||||
query->mTransactionBody = new TransactionBody(payerAccountId, connection);
|
query->mTransactionBody = new TransactionBody(payerAccountId, connection);
|
||||||
CryptoTransferTransaction crypto_transaction;
|
CryptoTransferTransaction crypto_transaction;
|
||||||
// 0.002809 Hashbars
|
// 0.003317 Hashbars
|
||||||
// fee from https://www.hedera.com/fees
|
// fee from https://www.hedera.com/fees
|
||||||
crypto_transaction.addSender(payerAccountId, 2809);
|
crypto_transaction.addSender(payerAccountId, 3317);
|
||||||
crypto_transaction.addReceiver(connection.hederaId, 2809);
|
crypto_transaction.addReceiver(connection.hederaId, 3317);
|
||||||
query->mTransactionBody->setCryptoTransfer(crypto_transaction);
|
query->mTransactionBody->setCryptoTransfer(crypto_transaction);
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
#include "QueryHeader.h"
|
#include "QueryHeader.h"
|
||||||
|
|
||||||
|
#include "Transaction.h"
|
||||||
|
|
||||||
namespace model {
|
namespace model {
|
||||||
namespace hedera {
|
namespace hedera {
|
||||||
QueryHeader::QueryHeader(Transaction* paymentTransaction)
|
|
||||||
|
QueryHeader::QueryHeader()
|
||||||
{
|
{
|
||||||
mProtoQueryHeader.set_responsetype(proto::ANSWER_ONLY);
|
mProtoQueryHeader.set_responsetype(proto::ANSWER_ONLY);
|
||||||
}
|
}
|
||||||
@ -12,5 +15,29 @@ namespace model {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Poco::AutoPtr<QueryHeader> QueryHeader::createWithPaymentTransaction(
|
||||||
|
Poco::AutoPtr<controller::HederaAccount> operatorAccount,
|
||||||
|
const controller::NodeServerConnection& connection,
|
||||||
|
Poco::AutoPtr<controller::User> keyHolder,
|
||||||
|
Poco::UInt32 cost
|
||||||
|
) {
|
||||||
|
Poco::AutoPtr<QueryHeader> query_header(new QueryHeader);
|
||||||
|
auto proto_query_header = query_header->getProtoQueryHeader();
|
||||||
|
auto payment_transaction = proto_query_header->payment();
|
||||||
|
|
||||||
|
query_header->mConnectionString = connection.getUriWithPort();
|
||||||
|
|
||||||
|
Transaction transactionObj(&payment_transaction);
|
||||||
|
TransactionBody body(operatorAccount->getHederaId(), connection);
|
||||||
|
CryptoTransferTransaction transfer_transaction;
|
||||||
|
transfer_transaction.addSender(operatorAccount->getHederaId(), cost);
|
||||||
|
transfer_transaction.addReceiver(connection.hederaId, cost);
|
||||||
|
body.setCryptoTransfer(transfer_transaction);
|
||||||
|
transactionObj.sign(operatorAccount->getCryptoKey()->getKeyPair(keyHolder), &body);
|
||||||
|
transactionObj.resetPointer();
|
||||||
|
|
||||||
|
return query_header;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,20 +4,37 @@
|
|||||||
#include "../proto/hedera/QueryHeader.pb.h"
|
#include "../proto/hedera/QueryHeader.pb.h"
|
||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
|
|
||||||
|
#include "../../controller/User.h"
|
||||||
|
#include "../../controller/HederaAccount.h"
|
||||||
|
|
||||||
namespace model {
|
namespace model {
|
||||||
namespace hedera {
|
namespace hedera {
|
||||||
class QueryHeader
|
class QueryHeader : public Poco::RefCountedObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QueryHeader(Transaction* paymentTransaction);
|
|
||||||
~QueryHeader();
|
~QueryHeader();
|
||||||
|
|
||||||
|
//! for cost look here: https://www.hedera.com/fees
|
||||||
|
//! or make query first with response type COST_ANSWER
|
||||||
|
//! TODO: get cost from network
|
||||||
|
static Poco::AutoPtr<QueryHeader> createWithPaymentTransaction(
|
||||||
|
Poco::AutoPtr<controller::HederaAccount> operatorAccount,
|
||||||
|
const controller::NodeServerConnection& connection,
|
||||||
|
Poco::AutoPtr<controller::User> keyHolder,
|
||||||
|
Poco::UInt32 cost
|
||||||
|
);
|
||||||
|
|
||||||
void setResponseType(proto::ResponseType type) { mProtoQueryHeader.set_responsetype(type); };
|
void setResponseType(proto::ResponseType type) { mProtoQueryHeader.set_responsetype(type); };
|
||||||
proto::ResponseType getResponseType() const { return mProtoQueryHeader.responsetype(); }
|
proto::ResponseType getResponseType() const { return mProtoQueryHeader.responsetype(); }
|
||||||
|
|
||||||
|
proto::QueryHeader* getProtoQueryHeader() { return &mProtoQueryHeader; }
|
||||||
|
|
||||||
|
const std::string& getConnectionString() const { return mConnectionString; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
proto::QueryHeader mProtoQueryHeader;
|
proto::QueryHeader mProtoQueryHeader;
|
||||||
|
std::string mConnectionString;
|
||||||
|
QueryHeader();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,11 @@ namespace model {
|
|||||||
{
|
{
|
||||||
mTransaction = new proto::Transaction;
|
mTransaction = new proto::Transaction;
|
||||||
}
|
}
|
||||||
|
Transaction::Transaction(proto::Transaction* transaction)
|
||||||
|
: mTransaction(transaction)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Transaction::~Transaction()
|
Transaction::~Transaction()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -20,6 +20,7 @@ namespace model {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Transaction();
|
Transaction();
|
||||||
|
Transaction(proto::Transaction* transaction);
|
||||||
~Transaction();
|
~Transaction();
|
||||||
|
|
||||||
bool sign(std::unique_ptr<KeyPairHedera> keyPairHedera, const TransactionBody* transactionBody);
|
bool sign(std::unique_ptr<KeyPairHedera> keyPairHedera, const TransactionBody* transactionBody);
|
||||||
|
|||||||
15
src/cpp/model/hedera/TransactionGetReceipt.cpp
Normal file
15
src/cpp/model/hedera/TransactionGetReceipt.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "TransactionGetReceipt.h"
|
||||||
|
|
||||||
|
namespace model {
|
||||||
|
namespace hedera {
|
||||||
|
TransactionGetReceipt::TransactionGetReceipt()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionGetReceipt::~TransactionGetReceipt()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/cpp/model/hedera/TransactionGetReceipt.h
Normal file
17
src/cpp/model/hedera/TransactionGetReceipt.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_H
|
||||||
|
#define GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_H
|
||||||
|
|
||||||
|
namespace model {
|
||||||
|
namespace hedera {
|
||||||
|
class TransactionGetReceipt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TransactionGetReceipt();
|
||||||
|
~TransactionGetReceipt();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_H
|
||||||
18
src/cpp/model/hedera/TransactionGetReceiptQuery.cpp
Normal file
18
src/cpp/model/hedera/TransactionGetReceiptQuery.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include "TransactionGetReceiptQuery.h"
|
||||||
|
|
||||||
|
namespace model {
|
||||||
|
namespace hedera {
|
||||||
|
TransactionGetReceiptQuery::TransactionGetReceiptQuery(Poco::AutoPtr<QueryHeader> queryHeader, const Transaction* target)
|
||||||
|
: mQueryHeader(queryHeader)
|
||||||
|
{
|
||||||
|
mProtoReceiptQuery.set_allocated_header(queryHeader->getProtoQueryHeader());
|
||||||
|
auto transaction_id = mProtoReceiptQuery.transactionid();
|
||||||
|
transaction_id = target->getTransactionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransactionGetReceiptQuery::~TransactionGetReceiptQuery()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/cpp/model/hedera/TransactionGetReceiptQuery.h
Normal file
29
src/cpp/model/hedera/TransactionGetReceiptQuery.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_QUERY_H
|
||||||
|
#define GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_QUERY_H
|
||||||
|
|
||||||
|
#include "QueryHeader.h"
|
||||||
|
#include "../../proto/hedera/TransactionGetReceipt.pb.h"
|
||||||
|
|
||||||
|
namespace model {
|
||||||
|
namespace hedera {
|
||||||
|
class TransactionGetReceiptQuery
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TransactionGetReceiptQuery(Poco::AutoPtr<QueryHeader> queryHeader, const Transaction* target);
|
||||||
|
~TransactionGetReceiptQuery();
|
||||||
|
|
||||||
|
proto::TransactionGetReceiptQuery* getProto() { return &mProtoReceiptQuery; }
|
||||||
|
|
||||||
|
const std::string& getConnectionString() const { return mQueryHeader->getConnectionString(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Poco::AutoPtr<QueryHeader> mQueryHeader;
|
||||||
|
proto::TransactionGetReceiptQuery mProtoReceiptQuery;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //GRADIDO_LOGIN_SERVER_MODEL_HEDERA_TRANSACTION_GET_RECEIPT_QUERY_H
|
||||||
@ -18,6 +18,7 @@ namespace model {
|
|||||||
TASK_TYPE_HEDERA_TOPIC_CREATE = 20,
|
TASK_TYPE_HEDERA_TOPIC_CREATE = 20,
|
||||||
TASK_TYPE_HEDERA_TOPIC_MESSAGE = 21,
|
TASK_TYPE_HEDERA_TOPIC_MESSAGE = 21,
|
||||||
TASK_TYPE_HEDERA_ACCOUNT_CREATE = 25,
|
TASK_TYPE_HEDERA_ACCOUNT_CREATE = 25,
|
||||||
|
TASK_TYPE_HEDERA_ACCOUNT_TRANSFER = 26
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,28 @@ HederaTask::HederaTask(const model::gradido::Transaction* transaction)
|
|||||||
hedera_task_model->setTaskType(model::table::TASK_TYPE_HEDERA_TOPIC_MESSAGE);
|
hedera_task_model->setTaskType(model::table::TASK_TYPE_HEDERA_TOPIC_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HederaTask::HederaTask(const model::hedera::Transaction* transaction)
|
||||||
|
: controller::PendingTask(new model::table::PendingTask), mTransactionReceipt(nullptr)
|
||||||
|
{
|
||||||
|
auto hedera_task_model = getModel();
|
||||||
|
//auto gradido_task_model = transaction->getModel();
|
||||||
|
//hedera_task_model->setUserId(gradido_task_model->getUserId());
|
||||||
|
model::table::TaskType task_type;
|
||||||
|
auto transaction_type = transaction->getType();
|
||||||
|
switch (transaction_type) {
|
||||||
|
case model::hedera::TRANSACTION_CONSENSUS_CREATE_TOPIC:
|
||||||
|
task_type = model::table::TASK_TYPE_HEDERA_TOPIC_CREATE; break;
|
||||||
|
case model::hedera::TRANSACTION_CONSENSUS_SUBMIT_MESSAGE:
|
||||||
|
task_type = model::table::TASK_TYPE_HEDERA_TOPIC_MESSAGE; break;
|
||||||
|
case model::hedera::TRANSACTION_CRYPTO_CREATE:
|
||||||
|
task_type = model::table::TASK_TYPE_HEDERA_ACCOUNT_CREATE; break;
|
||||||
|
case model::hedera::TRANSACTION_CRYPTO_TRANSFER:
|
||||||
|
task_type = model::table::TASK_TYPE_HEDERA_ACCOUNT_TRANSFER; break;
|
||||||
|
}
|
||||||
|
hedera_task_model->setTaskType(task_type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
HederaTask::HederaTask(model::table::PendingTask* dbModel)
|
HederaTask::HederaTask(model::table::PendingTask* dbModel)
|
||||||
: controller::PendingTask(dbModel), mTransactionReceipt(nullptr)
|
: controller::PendingTask(dbModel), mTransactionReceipt(nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
#include "../model/hedera/TransactionResponse.h"
|
#include "../model/hedera/TransactionResponse.h"
|
||||||
#include "../model/hedera/TransactionReceipt.h"
|
#include "../model/hedera/TransactionReceipt.h"
|
||||||
|
#include "../model/hedera/Transaction.h"
|
||||||
#include "../proto/hedera/BasicTypes.pb.h"
|
#include "../proto/hedera/BasicTypes.pb.h"
|
||||||
#include "../proto/hedera/Duration.pb.h"
|
#include "../proto/hedera/Duration.pb.h"
|
||||||
|
|
||||||
#include "../model/gradido/Transaction.h"
|
#include "../model/gradido/Transaction.h"
|
||||||
|
|
||||||
#include "../controller/PendingTask.h"
|
#include "../controller/PendingTask.h"
|
||||||
|
#include "../controller/HederaAccount.h"
|
||||||
|
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
|
||||||
@ -27,6 +29,7 @@ class HederaTask : public controller::PendingTask, public NotificationList
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
HederaTask(const model::gradido::Transaction* transaction);
|
HederaTask(const model::gradido::Transaction* transaction);
|
||||||
|
HederaTask(const model::hedera::Transaction* transaction);
|
||||||
HederaTask(model::table::PendingTask* dbModel);
|
HederaTask(model::table::PendingTask* dbModel);
|
||||||
~HederaTask();
|
~HederaTask();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user