/**
 * # Schedule Get Information
 * Query body and response to retrieve information about a scheduled
 * transaction.
 *
 * ### 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.scheduled">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

import "services_basic_types.proto";
import "services_timestamp.proto";
import "services_query_header.proto";
import "services_response_header.proto";
import "services_schedulable_transaction_body.proto";

/**
 * Request for information about a scheduled transaction.
 *
 * If the requested schedule does not exist, the network SHALL respond
 * with `INVALID_SCHEDULE_ID`.
 */
message ScheduleGetInfoQuery {
    /**
     * Standard information sent with every query operation.<br/>
     * This includes the signed payment and what kind of response is requested
     * (cost, state proof, both, or neither).
     */
    QueryHeader header = 1;

    /**
     * A schedule identifier.
     * <p>
     * This SHALL identify the schedule to retrieve.<br/>
     * This field is REQUIRED.
     */
    ScheduleID scheduleID = 2;
}

/**
 * Information summarizing schedule state
 */
message ScheduleInfo {
    /**
     * A schedule identifier.
     * <p>
     * This SHALL identify the schedule retrieved.
     */
    ScheduleID scheduleID = 1;

    oneof data {
        /**
         * A deletion timestamp.
         * <p>
         * If the schedule was deleted, this SHALL be set to the consensus
         * timestamp of the `deleteSchedule` transaction.<br/>
         * If the schedule is _not_ deleted, this field SHALL NOT be set.
         */
        Timestamp deletion_time = 2;

        /**
         * An execution timestamp.
         * <p>
         * If the schedule was completed, and the _scheduled_ transaction
         * executed, this SHALL be set to the consensus timestamp of the
         * transaction that initiated that execution.<br/>
         * If the schedule is _not_ complete, this field SHALL NOT be set.
         */
        Timestamp execution_time = 3;
    }

    /**
     * An expiration timestamp.<br/>
     * This represents the time at which the schedule will expire. For a
     * long-term schedule (if enabled) this is when the schedule will be
     * executed, assuming it meets signature requirements at that time.
     * For a short-term schedule, this is the deadline to complete the
     * signature requirements for the scheduled transaction to execute.
     * Regardless of schedule type, the schedule will be removed from
     * state when it expires.
     * <p>
     * A schedule SHALL be removed from state when it expires.<br/>
     * A short-term schedule MUST meet signature requirements strictly
     * before expiration or it SHALL NOT be executed.<br/>
     * A long-term schedule SHALL be executed if, and only if, all signature
     * requirements for the scheduled transaction are met at expiration.<br/>
     * A long-term schedule SHALL NOT be executed if any signature requirement
     * for the scheduled transaction are not met at expiration.<br/>
     */
    Timestamp expirationTime = 4;

    /**
     * A scheduled transaction.
     * <p>
     * This SHALL be a transaction type enabled in the network property
     * `scheduling.whitelist`, and SHALL NOT be any other
     * transaction type.<br/>
     * This transaction SHALL be executed if the schedule meets all signature
     * and execution time requirements for this transaction.<br/>
     * The signature requirements for this transaction SHALL be evaluated
     * at schedule creation, SHALL be reevaluated with each `signSchedule`
     * transaction, and, for long-term schedules, SHALL be reevaluated when
     * the schedule expires.<br/>
     */
    SchedulableTransactionBody scheduledTransactionBody = 5;

    /**
     * A short description for this schedule.
     * <p>
     * This value, if set, MUST NOT exceed `transaction.maxMemoUtf8Bytes`
     * (default 100) bytes when encoded as UTF-8.
     */
    string memo = 6;

    /**
     * The key used to delete the schedule from state
     */
    Key adminKey = 7;

    /**
     * A list of "valid" signatures for this schedule.<br/>
     * This list contains only "primitive" (i.e. cryptographic or contract)
     * signatures. The full signature requirements for the scheduled
     * transaction are evaluated as if this list of keys had signed the
     * scheduled transaction directly.
     * <p>
     * This list SHALL contain every "primitive" key that has signed the
     * original `createSchedule`, or any subsequent
     * `signSchedule` transaction.<br/>
     * This list MAY elide any signature not likely to be required by the
     * scheduled transaction. Such requirement SHOULD be evaluated when the
     * signature is presented (i.e. during evaluation of a `createSchedule` or
     * `signSchedule` transaction).
     */
    KeyList signers = 8;

    /**
     * An account identifier.
     * <p>
     * This SHALL identify the account that created this schedule.
     */
    AccountID creatorAccountID = 9;

    /**
     * An account identifier.
     * <p>
     * The identified account SHALL pay the full transaction fee for the
     * scheduled transaction _when it executes_.
     */
    AccountID payerAccountID = 10;

    /**
     * A transaction identifier.
     * <p>
     * This SHALL be recorded as the transaction identifier for the
     * _scheduled_ transaction, if (and when) it is executed.
     */
    TransactionID scheduledTransactionID = 11;

    /**
     * The 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 = 12;

    /**
     * A flag indicating this schedule will execute when it expires.
     * <p>
     * If this field is set
     * <ul>
     *   <li>This schedule SHALL be considered a "long-term" schedule.</li>
     *   <li>This schedule SHALL be evaluated when the network consensus time
     *       reaches the `expirationTime`, and if the signature requirements
     *       for the scheduled transaction are met at that time, the
     *       scheduled transaction SHALL be executed.</li>
     *   <li>This schedule SHALL NOT be executed before the network consensus
     *       time reaches the `expirationTime`.</li>
     * </ul>
     * If this field is not set
     * <ul>
     *   <li>This schedule SHALL be considered a "short-term" schedule.</li>
     *   <li>This schedule SHALL be evaluated when created, and reevaluated
     *       with each `signSchedule` transaction, and if the signature
     *       requirements for the scheduled transaction are met at that time,
     *       the scheduled transaction SHALL be executed immediately.</li>
     *   <li>This schedule SHALL be executed as soon as the signature
     *       requirements are met, and MUST be executed before the network
     *       consensus time reaches the `expirationTime`, if at all.</li>
     * </ul>
     */
    bool wait_for_expiry = 13;
}

/**
 * A response message for a `getScheduleInfo` query.
 */
message ScheduleGetInfoResponse {
    /**
     * The standard response information for queries.<br/>
     * This includes the values requested in the `QueryHeader`
     * (cost, state proof, both, or neither).
     */
    ResponseHeader header = 1;

    /**
     * Detail information for a schedule.
     * <p>
     * This field SHALL contain all available schedule detail.
     */
    ScheduleInfo scheduleInfo = 2;
}
