syntax = "proto3";
package band.feeds.v1beta1;

option go_package = "github.com/bandprotocol/chain/v3/x/feeds/types";

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "band/feeds/v1beta1/feeds.proto";
import "band/feeds/v1beta1/params.proto";

// Query defines the gRPC querier service.
service Query {
  // CurrentFeeds is an RPC method that returns a list of current supported feeds.
  rpc CurrentFeeds(QueryCurrentFeedsRequest) returns (QueryCurrentFeedsResponse) {
    option (google.api.http).get = "/feeds/v1beta1/current_feeds";
  }

  // IsFeeder is an RPC method that returns whether an account is a feeder for a specified validator.
  rpc IsFeeder(QueryIsFeederRequest) returns (QueryIsFeederResponse) {
    option (google.api.http).get = "/feeds/v1beta1/feeder/{validator}/{feeder}";
  }

  // Params is an RPC method that returns all parameters of the module.
  rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
    option (google.api.http).get = "/feeds/v1beta1/params";
  }

  // Price is an RPC method that returns price by signal id.
  rpc Price(QueryPriceRequest) returns (QueryPriceResponse) {
    option (google.api.http).get = "/feeds/v1beta1/prices/{signal_id}";
  }

  // Prices is an RPC method that prices by signal ids.
  rpc Prices(QueryPricesRequest) returns (QueryPricesResponse) {
    option (google.api.http).get = "/feeds/v1beta1/prices";
  }

  // AllPrices is an RPC method that returns all prices.
  rpc AllPrices(QueryAllPricesRequest) returns (QueryAllPricesResponse) {
    option (google.api.http).get = "/feeds/v1beta1/all_prices";
  }

  // ReferenceSourceConfig is an RPC method that returns information on the reference price source.
  rpc ReferenceSourceConfig(QueryReferenceSourceConfigRequest) returns (QueryReferenceSourceConfigResponse) {
    option (google.api.http).get = "/feeds/v1beta1/reference_source_config";
  }

  // SignalTotalPowers is an RPC method that returns all signal-total-powers or specified signal-total-power by signal
  // id.
  rpc SignalTotalPowers(QuerySignalTotalPowersRequest) returns (QuerySignalTotalPowersResponse) {
    option (google.api.http).get = "/feeds/v1beta1/signal_total_powers";
  }

  // ValidValidator is an RPC method that returns a flag to show if the validator is required to send prices.
  rpc ValidValidator(QueryValidValidatorRequest) returns (QueryValidValidatorResponse) {
    option (google.api.http).get = "/feeds/v1beta1/validators/{validator}/valid";
  }

  // ValidatorPrices is an RPC method that returns prices of a validator.
  rpc ValidatorPrices(QueryValidatorPricesRequest) returns (QueryValidatorPricesResponse) {
    option (google.api.http).get = "/feeds/v1beta1/validators/{validator}/prices";
  }

  // Vote is an RPC method that returns signals of a voter.
  rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) {
    option (google.api.http).get = "/feeds/v1beta1/voters/{voter}/vote";
  }
}

// QueryCurrentFeedsRequest is the request type for the Query/CurrentFeeds RPC method.
message QueryCurrentFeedsRequest {}

// QueryCurrentFeedsResponse is the response type for the Query/CurrentFeeds RPC method.
message QueryCurrentFeedsResponse {
  // current_feeds is a list of currently supported feed-with-deviations, and its last update time and block.
  CurrentFeedWithDeviations current_feeds = 1 [(gogoproto.nullable) = false];
}

// QueryIsFeederRequest is the request type for the Query/IsFeeder RPC method.
message QueryIsFeederRequest {
  // validator is a validator address.
  string validator = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
  // feeder is a candidate account.
  string feeder = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryIsFeederResponse is the response type for the Query/IsFeeder RPC method.
message QueryIsFeederResponse {
  // is_feeder is true if this account has been granted by validator.
  bool is_feeder = 1;
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
  // params is the parameters of the module.
  Params params = 1 [(gogoproto.nullable) = false];
}

// QueryPriceRequest is the request type for the Query/Price RPC method.
message QueryPriceRequest {
  // signal_id is the signal id to query the price for.
  string signal_id = 1;
}

// QueryPriceResponse is the response type for the Query/Price RPC method.
message QueryPriceResponse {
  // price is the aggregated price of the signal id.
  Price price = 1 [(gogoproto.nullable) = false];
}

// QueryPricesRequest is the request type for the Query/Prices RPC method.
message QueryPricesRequest {
  // signal_ids is a list of signal ids to query prices for.
  repeated string signal_ids = 1;
}

// QueryPricesResponse is the response type for the Query/Prices RPC method.
message QueryPricesResponse {
  // prices is a list of prices.
  repeated Price prices = 1 [(gogoproto.nullable) = false];
}

// QueryAllPricesRequest is the request type for the Query/AllPrices RPC method.
message QueryAllPricesRequest {
  // pagination is the pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryAllPricesResponse is the response type for the Query/AllPrices RPC method.
message QueryAllPricesResponse {
  // prices is a list of prices.
  repeated Price prices = 1 [(gogoproto.nullable) = false];

  // pagination is the pagination information in the response.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryReferenceSourceConfigRequest is the request type for the Query/ReferenceSourceConfig RPC method.
message QueryReferenceSourceConfigRequest {}

// QueryReferenceSourceConfigResponse is the response type for the Query/ReferenceSourceConfig RPC method.
message QueryReferenceSourceConfigResponse {
  // reference_source_config is the information about the reference price source.
  ReferenceSourceConfig reference_source_config = 1 [(gogoproto.nullable) = false];
}

// QuerySignalTotalPowersRequest is the request type for the Query/SignalTotalPowers RPC method.
message QuerySignalTotalPowersRequest {
  // signal_ids is a list of signal ids to query.
  repeated string signal_ids = 1;

  // pagination is the pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QuerySignalTotalPowersResponse is the response type for the Query/SignalTotalPowers RPC method.
message QuerySignalTotalPowersResponse {
  // signal_total_powers is a list of signal-total-powers.
  repeated Signal signal_total_powers = 1;

  // pagination is the pagination information in the response.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryValidValidatorRequest is the request type for the Query/ValidValidator RPC method.
message QueryValidValidatorRequest {
  // validator is the validator address to query the flag.
  string validator = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
}

// QueryValidValidatorResponse is the response type for the Query/ValidValidator RPC method.
message QueryValidValidatorResponse {
  // valid is a valid flag.
  bool valid = 1;
}

// QueryValidatorPricesRequest is the request type for the Query/ValidatorPrices RPC method.
message QueryValidatorPricesRequest {
  // validator is the validator address to query prices for.
  string validator = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];

  // signal_ids is the list of signal ids to query the price for.
  repeated string signal_ids = 2;
}

// QueryValidatorPricesResponse is the response type for the Query/ValidatorPrices RPC method.
message QueryValidatorPricesResponse {
  // validator_prices is a list of prices submitted by the validator.
  repeated ValidatorPrice validator_prices = 1 [(gogoproto.nullable) = false];
}

// QueryVoteRequest is the request type for the Query/Vote RPC method.
message QueryVoteRequest {
  // voter is the voter address to query signal for.
  string voter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryVoteResponse is the response type for the Query/Vote RPC method.
message QueryVoteResponse {
  // signals is a list of signals submitted by the voter.
  repeated Signal signals = 1 [(gogoproto.nullable) = false];
}
