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

import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/distribution/v1beta1/distribution.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

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

// Query defines the gRPC querier service for distribution module.
service Query {
  // Params queries params of the distribution module.
  rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/params";
  }

  // ValidatorDistributionInfo queries validator commission and self-delegation rewards for validator
  rpc ValidatorDistributionInfo(QueryValidatorDistributionInfoRequest)
      returns (QueryValidatorDistributionInfoResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}";
  }

  // ValidatorOutstandingRewards queries rewards of a validator address.
  rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest)
      returns (QueryValidatorOutstandingRewardsResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/"
                                   "{validator_address}/outstanding_rewards";
  }

  // ValidatorCommission queries accumulated commission for a validator.
  rpc ValidatorCommission(QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/"
                                   "{validator_address}/commission";
  }

  // ValidatorSlashes queries slash events of a validator.
  rpc ValidatorSlashes(QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes";
  }

  // DelegationRewards queries the total rewards accrued by a delegation.
  rpc DelegationRewards(QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/"
                                   "{validator_address}";
  }

  // DelegationTotalRewards queries the total rewards accrued by each
  // validator.
  rpc DelegationTotalRewards(QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards";
  }

  // DelegatorValidators queries the validators of a delegator.
  rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/"
                                   "{delegator_address}/validators";
  }

  // DelegatorWithdrawAddress queries withdraw address of a delegator.
  rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/"
                                   "{delegator_address}/withdraw_address";
  }

  // CommunityPool queries the community pool coins.
  //
  // WARNING: This query will fail if an external community pool is used.
  rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {
    option (google.api.http).get = "/cosmos/distribution/v1beta1/community_pool";
  }
}

// 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 defines the parameters of the module.
  Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

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

// QueryValidatorDistributionInfoResponse is the response type for the Query/ValidatorDistributionInfo RPC method.
message QueryValidatorDistributionInfoResponse {
  // operator_address defines the validator operator address.
  string operator_address = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
  // self_bond_rewards defines the self delegations rewards.
  repeated cosmos.base.v1beta1.DecCoin self_bond_rewards = 2 [
    (gogoproto.nullable)     = false,
    (amino.dont_omitempty)   = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
  ];
  // commission defines the commission the validator received.
  repeated cosmos.base.v1beta1.DecCoin commission = 3
      [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}

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

// QueryValidatorOutstandingRewardsResponse is the response type for the
// Query/ValidatorOutstandingRewards RPC method.
message QueryValidatorOutstandingRewardsResponse {
  ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

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

// QueryValidatorCommissionResponse is the response type for the
// Query/ValidatorCommission RPC method
message QueryValidatorCommissionResponse {
  // commission defines the commission the validator received.
  ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// QueryValidatorSlashesRequest is the request type for the
// Query/ValidatorSlashes RPC method
message QueryValidatorSlashesRequest {
  option (gogoproto.goproto_getters) = false;

  // validator_address defines the validator address to query for.
  string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
  // starting_height defines the optional starting height to query the slashes.
  uint64 starting_height = 2;
  // starting_height defines the optional ending height to query the slashes.
  uint64 ending_height = 3;
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 4;
}

// QueryValidatorSlashesResponse is the response type for the
// Query/ValidatorSlashes RPC method.
message QueryValidatorSlashesResponse {
  // slashes defines the slashes the validator received.
  repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

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

// QueryDelegationRewardsRequest is the request type for the
// Query/DelegationRewards RPC method.
message QueryDelegationRewardsRequest {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // delegator_address defines the delegator address to query for.
  string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
  // validator_address defines the validator address to query for.
  string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"];
}

// QueryDelegationRewardsResponse is the response type for the
// Query/DelegationRewards RPC method.
message QueryDelegationRewardsResponse {
  // rewards defines the rewards accrued by a delegation.
  repeated cosmos.base.v1beta1.DecCoin rewards = 1 [
    (gogoproto.nullable)     = false,
    (amino.dont_omitempty)   = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
  ];
}

// QueryDelegationTotalRewardsRequest is the request type for the
// Query/DelegationTotalRewards RPC method.
message QueryDelegationTotalRewardsRequest {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;
  // delegator_address defines the delegator address to query for.
  string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryDelegationTotalRewardsResponse is the response type for the
// Query/DelegationTotalRewards RPC method.
message QueryDelegationTotalRewardsResponse {
  // rewards defines all the rewards accrued by a delegator.
  repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
  // total defines the sum of all the rewards.
  repeated cosmos.base.v1beta1.DecCoin total = 2 [
    (gogoproto.nullable)     = false,
    (amino.dont_omitempty)   = true,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
  ];
}

// QueryDelegatorValidatorsRequest is the request type for the
// Query/DelegatorValidators RPC method.
message QueryDelegatorValidatorsRequest {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // delegator_address defines the delegator address to query for.
  string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryDelegatorValidatorsResponse is the response type for the
// Query/DelegatorValidators RPC method.
message QueryDelegatorValidatorsResponse {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // validators defines the validators a delegator is delegating for.
  repeated string validators = 1;
}

// QueryDelegatorWithdrawAddressRequest is the request type for the
// Query/DelegatorWithdrawAddress RPC method.
message QueryDelegatorWithdrawAddressRequest {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // delegator_address defines the delegator address to query for.
  string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryDelegatorWithdrawAddressResponse is the response type for the
// Query/DelegatorWithdrawAddress RPC method.
message QueryDelegatorWithdrawAddressResponse {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // withdraw_address defines the delegator address to query for.
  string withdraw_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC
// method.
message QueryCommunityPoolRequest {}

// QueryCommunityPoolResponse is the response type for the Query/CommunityPool
// RPC method.
message QueryCommunityPoolResponse {
  // pool defines community pool's coins.
  repeated cosmos.base.v1beta1.DecCoin pool = 1 [
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
    (gogoproto.nullable)     = false,
    (amino.dont_omitempty)   = true
  ];
}
