/**
 * # Topic Information
 * Query response describing a topic of the Hedera Consensus Service (HCS).
 *
 * ### Keywords
 * The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
 * "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
 * document are to be interpreted as described in
 * [RFC2119](https://www.ietf.org/rfc/rfc2119) and clarified in
 * [RFC8174](https://www.ietf.org/rfc/rfc8174).
 */
syntax = "proto3";

package proto;

// SPDX-License-Identifier: Apache-2.0
option java_package = "com.hederahashgraph.api.proto.java";
// <<<pbj.java_package = "com.hedera.hapi.node.consensus">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

import "services_basic_types.proto";
import "services_custom_fees.proto";
import "services_duration.proto";
import "services_timestamp.proto";

/**
 * A query response describing the current state of a topic for the Hedera
 * Consensus Service (HCS).
 */
message ConsensusTopicInfo {
    /**
     * A short description of this topic.
     * <p>
     * This value, if set, MUST NOT exceed `transaction.maxMemoUtf8Bytes`
     * (default 100) bytes when encoded as UTF-8.
     */
    string memo = 1;

    /**
     * The latest running hash of the topic.
     * <p>
     * This 48-byte field is the output of a SHA-384 digest with input
     * data determined by the current version of the running hash algorithm
     * used by the network.<br/>
     * All new transactions SHALL use algorithm version `3`.<br/>
     * The bytes of each uint64 or uint32 encoded for the hash input
     * MUST be in Big-Endian format.
     * <p>
     * <hr/>
     * If the algorithm version is '3', then the input data to the
     * SHA-384 digest are, in order:
     * <ol>
     *   <li>The previous running hash of the topic (48 bytes)</li>
     *   <li>The `topicRunningHashVersion` (8 bytes)</li>
     *   <li>The payer account's shard (8 bytes)</li>
     *   <li>The payer account's realm (8 bytes)</li>
     *   <li>The payer account's number (8 bytes)</li>
     *   <li>The topic's shard (8 bytes)</li>
     *   <li>The topic's realm (8 bytes)</li>
     *   <li>The topic's number (8 bytes)</li>
     *   <li>The number of seconds since the epoch when the
     *       `ConsensusSubmitMessage` reached consensus (8 bytes)</li>
     *   <li>The number of nanoseconds within the second when the
     *       `ConsensusSubmitMessage` reached consensus (4 bytes)</li>
     *   <li>The `topicSequenceNumber` (8 bytes)</li>
     *   <li>The output of a SHA-384 digest of the message bytes from the
     *       `ConsensusSubmitMessage` (48 bytes)</li>
     * </ol>
     */
    bytes runningHash = 2;

    /**
     * A current sequence number (starting at 1 for the first message)
     * for messages on this topic.
     */
    uint64 sequenceNumber = 3;

    /**
     * An expiration time for this topic, in seconds since the epoch.
     * <p>
     * For this purpose, `epoch` SHALL be the UNIX epoch
     * with 0 at `1970-01-01T00:00:00.000Z`.
     */
    Timestamp expirationTime = 4;

    /**
     * A key that MUST sign any transaction to update or delete this topic.
     * <p>
     * If this value is not set (null) then the topic CANNOT be deleted,
     * modified, or updated.
     */
    Key adminKey = 5;

    /**
     * A key that MUST sign any transaction to submit a message to this topic.
     * <p>
     * If this value is not set (null) then any account MAY submit messages to
     * this topic.
     */
    Key submitKey = 6;

    /**
     * A duration, in seconds, to extend the `expirationTime` value when
     * this topic is automatically renewed.
     * <p>
     * If the `autoRenewAccount` value for this topic is set to a valid account
     * with sufficient HBAR balance to pay renewal fees when this topic
     * expires, the system SHALL automatically renew this topic, extending the
     * `expirationTime` value by the number of seconds described here.<br/>
     * If, however, the `autoRenewAccount` lacks sufficient HBAR balance
     * to pay renewal fees when this topic expires, this topic SHALL be
     * deleted after the time period specified in the `AUTORENEW_GRACE_PERIOD`
     * configuration value.
     */
    Duration autoRenewPeriod = 7;

    /**
     * An account that is designated to pay automatic renewal fees.
     * <p>
     * If this value is a valid account ID when this topic expires,
     * this account SHALL be charged the renewal fees for this topic,
     * if it holds sufficient HBAR balance. If the account does not hold
     * sufficient HBAR balance to pay renewal fees when necessary, then
     * this topic SHALL be deleted.<br/>
     * If this value is not set (null), or is not a valid account ID, when
     * this topic expires, then this topic SHALL be deleted after the time
     * period specified in the `AUTORENEW_GRACE_PERIOD` configuration value.
     */
    AccountID autoRenewAccount = 8;

    /**
     * A ledger ID of the network that generated this response.
     * <p>
     * This value SHALL identify the distributed ledger that responded to
     * this query.
     */
    bytes ledger_id = 9;

    /**
     * Access control for update/delete of custom fees.
     * <p>
     * If unset, custom fees CANNOT be set for this topic.<br/>
     * If not set when the topic is created, this field CANNOT be set via
     * update.<br/>
     * If set when the topic is created, this field MAY be changed via update.
     */
    Key fee_schedule_key = 10;

    /**
     * A set of keys.<br/>
     * Keys in this list are permitted to submit messages to this topic without
     * paying custom fees associated with this topic.
     * <p>
     * If a topic submit message is signed by _any_ key included in this set,
     * custom fees SHALL NOT be charged for that transaction.<br/>
     * `fee_exempt_key_list` MAY contain keys for accounts that are inactive,
     * deleted, or non-existent.<br/>
     * If not set, there SHALL NOT be any fee-exempt keys.  In particular, the
     * following keys SHALL NOT be implicitly or automatically added to this
     * list: `adminKey`, `submitKey`, `fee_schedule_key`.
     * A `fee_exempt_key_list` MUST NOT contain more than
     * `MAX_ENTRIES_FOR_FEE_EXEMPT_KEY_LIST` keys.
     * A `fee_exempt_key_list` MUST NOT contain any duplicate keys.
     */
    repeated Key fee_exempt_key_list = 11;

    /**
     * A set of custom fee definitions.<br/>
     * These are fees to be assessed for each submit to this topic.
     * <p>
     * Each fee defined in this set SHALL be evaluated for
     * each message submitted to this topic, and the resultant
     * total assessed fees SHALL be charged.<br/>
     * Custom fees defined here SHALL be assessed in addition to the base
     * network and node fees.
     */
    repeated FixedCustomFee custom_fees = 12;
}
