-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rob Walworth <[email protected]>
- Loading branch information
Showing
15 changed files
with
816 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/*- | ||
* | ||
* Hedera C++ SDK | ||
* | ||
* Copyright (C) 2020 - 2022 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef HEDERA_SDK_CPP_TOPIC_INFO_H_ | ||
#define HEDERA_SDK_CPP_TOPIC_INFO_H_ | ||
|
||
#include "AccountId.h" | ||
#include "Key.h" | ||
#include "LedgerId.h" | ||
#include "TopicId.h" | ||
|
||
#include <chrono> | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <memory> | ||
#include <optional> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace proto | ||
{ | ||
class ConsensusGetTopicInfoResponse; | ||
} | ||
|
||
namespace Hedera | ||
{ | ||
/** | ||
* Response from a Hedera network when the client sends an TopicInfoQuery. | ||
*/ | ||
class TopicInfo | ||
{ | ||
public: | ||
/** | ||
* Construct a TopicInfo object from a ConsensusGetTopicInfoResponse protobuf object. | ||
* | ||
* @param proto The ConsensusGetTopicInfoResponse protobuf object from which to construct a TopicInfo object. | ||
* @return The constructed TopicInfo object. | ||
*/ | ||
[[nodiscard]] static TopicInfo fromProtobuf(const proto::ConsensusGetTopicInfoResponse& proto); | ||
|
||
/** | ||
* Construct a TopicInfo object from a byte array. | ||
* | ||
* @param bytes The byte array representing a TopicInfo object. | ||
* @return The constructed TopicInfo object. | ||
*/ | ||
[[nodiscard]] static TopicInfo fromBytes(const std::vector<std::byte>& bytes); | ||
|
||
/** | ||
* Construct a ConsensusGetTopicInfoResponse protobuf object from this TopicInfo object. | ||
* | ||
* @return A pointer to the created ConsensusGetTopicInfoResponse protobuf object. | ||
*/ | ||
[[nodiscard]] std::unique_ptr<proto::ConsensusGetTopicInfoResponse> toProtobuf() const; | ||
|
||
/** | ||
* Construct a representative byte array from this TopicInfo object. | ||
* | ||
* @return The byte array representing this TopicInfo object. | ||
*/ | ||
[[nodiscard]] std::vector<std::byte> toBytes() const; | ||
|
||
/** | ||
* The ID of the topic. | ||
*/ | ||
TopicId mTopicId; | ||
|
||
/** | ||
* The publicly visible memo for the new topic. | ||
*/ | ||
std::string mMemo; | ||
|
||
/** | ||
* The SHA384 running hash of [previousRunningHash, topicId, consensusTimestamp, sequenceNumber, message]. | ||
*/ | ||
std::vector<std::byte> mRunningHash; | ||
|
||
/** | ||
* The sequence number (which starts at one for the first message) of messages on the topic. | ||
*/ | ||
uint64_t mSequenceNumber = 0ULL; | ||
|
||
/** | ||
* The timestamp at which the topic will expire. | ||
*/ | ||
std::chrono::system_clock::time_point mExpirationTime = std::chrono::system_clock::now(); | ||
|
||
/** | ||
* The key used for access control to update or delete the topic. Nullptr if there is no admin key for the topic. | ||
*/ | ||
std::shared_ptr<Key> mAdminKey = nullptr; | ||
|
||
/** | ||
* The key that must sign to submit a message to the new topic (via a TopicMessageSubmitTransaction). Nullptr if there | ||
* is no submit key for the topic. | ||
*/ | ||
std::shared_ptr<Key> mSubmitKey = nullptr; | ||
|
||
/** | ||
* The amount of time by which to attempt to extend the topic's lifetime automatically at its expiration time. | ||
*/ | ||
std::optional<std::chrono::duration<double>> mAutoRenewPeriod; | ||
|
||
/** | ||
* The ID of the account that should be charged to extend the lifetime of the new topic at its expiration time. | ||
*/ | ||
std::optional<AccountId> mAutoRenewAccountId; | ||
|
||
/** | ||
* The ID of the ledger from which this response was returned. | ||
*/ | ||
LedgerId mLedgerId; | ||
}; | ||
|
||
} // namespace Hedera | ||
|
||
#endif // HEDERA_SDK_CPP_TOPIC_INFO_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/*- | ||
* | ||
* Hedera C++ SDK | ||
* | ||
* Copyright (C) 2020 - 2022 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef HEDERA_SDK_CPP_TOPIC_INFO_QUERY_H_ | ||
#define HEDERA_SDK_CPP_TOPIC_INFO_QUERY_H_ | ||
|
||
#include "Query.h" | ||
#include "TopicId.h" | ||
|
||
namespace Hedera | ||
{ | ||
class TopicInfo; | ||
class TransactionRecord; | ||
} | ||
|
||
namespace Hedera | ||
{ | ||
/** | ||
* A query that gets information about a topic instance. | ||
*/ | ||
class TopicInfoQuery : public Query<TopicInfoQuery, TopicInfo> | ||
{ | ||
public: | ||
/** | ||
* Set the ID of the topic of which to request the info. | ||
* | ||
* @param topic The ID of the topic of which to request the info. | ||
* @return A reference to this TopicInfoQuery object with the newly-set topic ID. | ||
*/ | ||
TopicInfoQuery& setTopicId(const TopicId& topicId); | ||
|
||
/** | ||
* Get the ID of the topic of which this query is currently configured to get the info. | ||
* | ||
* @return The ID of the topic for which this query is meant. | ||
*/ | ||
[[nodiscard]] inline TopicId getTopicId() const { return mTopicId; } | ||
|
||
private: | ||
/** | ||
* Derived from Executable. Construct a Query protobuf object from this TopicInfoQuery object. | ||
* | ||
* @param client The Client trying to construct this TopicInfoQuery. | ||
* @param node The Node to which this TopicInfoQuery will be sent. | ||
* @return A Query protobuf object filled with this TopicInfoQuery object's data. | ||
*/ | ||
[[nodiscard]] proto::Query makeRequest(const Client& client, | ||
const std::shared_ptr<internal::Node>& node) const override; | ||
|
||
/** | ||
* Derived from Executable. Construct a TopicInfo object from a Response protobuf object. | ||
* | ||
* @param response The Response protobuf object from which to construct a TopicInfo object. | ||
* @return A TopicInfo object filled with the Response protobuf object's data. | ||
*/ | ||
[[nodiscard]] TopicInfo mapResponse(const proto::Response& response) const override; | ||
|
||
/** | ||
* Derived from Executable. Get the status response code for a submitted TopicInfoQuery from a Response protobuf | ||
* object. | ||
* | ||
* @param response The Response protobuf object from which to grab the TopicInfoQuery status response code. | ||
* @return The TopicInfoQuery status response code of the input Response protobuf object. | ||
*/ | ||
[[nodiscard]] Status mapResponseStatus(const proto::Response& response) const override; | ||
|
||
/** | ||
* Derived from Executable. Submit this TopicInfoQuery to a Node. | ||
* | ||
* @param client The Client submitting this TopicInfoQuery. | ||
* @param deadline The deadline for submitting this TopicInfoQuery. | ||
* @param node Pointer to the Node to which this TopicInfoQuery should be submitted. | ||
* @param response Pointer to the Response protobuf object that gRPC should populate with the response information | ||
* from the gRPC server. | ||
* @return The gRPC status of the submission. | ||
*/ | ||
[[nodiscard]] grpc::Status submitRequest(const Client& client, | ||
const std::chrono::system_clock::time_point& deadline, | ||
const std::shared_ptr<internal::Node>& node, | ||
proto::Response* response) const override; | ||
|
||
/** | ||
* The ID of the topic of which this query should get the info. | ||
*/ | ||
TopicId mTopicId; | ||
}; | ||
|
||
} // namespace Hedera | ||
|
||
#endif // HEDERA_SDK_CPP_TOPIC_INFO_QUERY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.