syntax = "proto3";
package cosmos.upgrade.v1beta1;

import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "cosmos/upgrade/v1beta1/upgrade.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types";

// Query defines the gRPC upgrade querier service.
service Query {
  // CurrentPlan queries the current upgrade plan.
  rpc CurrentPlan(QueryCurrentPlanRequest) returns (QueryCurrentPlanResponse) {
    option (google.api.http).get = "/cosmos/upgrade/v1beta1/current_plan";
  }

  // AppliedPlan queries a previously applied upgrade plan by its name.
  rpc AppliedPlan(QueryAppliedPlanRequest) returns (QueryAppliedPlanResponse) {
    option (google.api.http).get = "/cosmos/upgrade/v1beta1/applied_plan/{name}";
  }

  // UpgradedConsensusState queries the consensus state that will serve
  // as a trusted kernel for the next version of this chain. It will only be
  // stored at the last height of this chain.
  // UpgradedConsensusState RPC not supported with legacy querier
  rpc UpgradedConsensusState(QueryUpgradedConsensusStateRequest) returns (QueryUpgradedConsensusStateResponse) {
    option (google.api.http).get = "/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}";
  }
}

// QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC
// method.
message QueryCurrentPlanRequest {}

// QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC
// method.
message QueryCurrentPlanResponse {
  // plan is the current upgrade plan.
  Plan plan = 1;
}

// QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC
// method.
message QueryAppliedPlanRequest {
  // name is the name of the applied plan to query for.
  string name = 1;
}

// QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC
// method.
message QueryAppliedPlanResponse {
  // height is the block height at which the plan was applied.
  int64 height = 1;
}

// QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState
// RPC method.
message QueryUpgradedConsensusStateRequest {
  // last height of the current chain must be sent in request
  // as this is the height under which next consensus state is stored
  int64 last_height = 1;
}

// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState
// RPC method.
message QueryUpgradedConsensusStateResponse {
  google.protobuf.Any upgraded_consensus_state = 1;
}
