syntax = "proto3";
package provenance.marker.v1;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/bank/v1beta1/bank.proto";
import "cosmos_proto/cosmos.proto";
import "google/api/annotations.proto";
import "provenance/marker/v1/marker.proto";
import "provenance/marker/v1/accessgrant.proto";
import "cosmos/query/v1/query.proto";

option go_package          = "github.com/provenance-io/provenance/x/marker/types";
option java_package        = "io.provenance.marker.v1";
option java_multiple_files = true;

// Query defines the gRPC querier service for marker module.
service Query {
  // Params queries the parameters of x/bank module.
  rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/params";
  }

  // Returns a list of all markers on the blockchain
  rpc AllMarkers(QueryAllMarkersRequest) returns (QueryAllMarkersResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/all";
  }

  // query for a single marker by denom or address
  rpc Marker(QueryMarkerRequest) returns (QueryMarkerResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/detail/{id}";
  }

  // query for all accounts holding the given marker coins
  rpc Holding(QueryHoldingRequest) returns (QueryHoldingResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/holding/{id}";
  }

  // query for supply of coin on a marker account
  // This endpoint returns the initial/target supply from marker account, not actual circulating supply.
  // Deprecated: This query is deprecated in favor of the bank module's SupplyOf query.
  rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) {
    option deprecated                          = true;
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/supply/{id}";
  }

  // query for coins on a marker account
  rpc Escrow(QueryEscrowRequest) returns (QueryEscrowResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/escrow/{id}";
  }

  // query for access records on an account
  rpc Access(QueryAccessRequest) returns (QueryAccessResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/accesscontrol/{id}";
  }

  // query for access records on an account
  rpc DenomMetadata(QueryDenomMetadataRequest) returns (QueryDenomMetadataResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/getdenommetadata/{denom}";
  }

  // query for account data associated with a denom
  rpc AccountData(QueryAccountDataRequest) returns (QueryAccountDataResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/accountdata/{denom}";
  }

  // NetAssetValues returns net asset values for marker
  rpc NetAssetValues(QueryNetAssetValuesRequest) returns (QueryNetAssetValuesResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/marker/v1/netassetvalues/{id}";
  }
}

// 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];
}

// QueryAllMarkersRequest is the request type for the Query/AllMarkers method.
message QueryAllMarkersRequest {
  // Optional status to filter request
  MarkerStatus status = 1;
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryAllMarkersResponse is the response type for the Query/AllMarkers method.
message QueryAllMarkersResponse {
  repeated google.protobuf.Any markers = 1 [(cosmos_proto.accepts_interface) = "MarkerAccountI"];
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryMarkerRequest is the request type for the Query/Marker method.
message QueryMarkerRequest {
  // the address or denom of the marker
  string id = 1;
}
// QueryMarkerResponse is the response type for the Query/Marker method.
message QueryMarkerResponse {
  google.protobuf.Any marker = 1 [(cosmos_proto.accepts_interface) = "MarkerAccountI"];
}

// QueryHoldingRequest is the request type for the Query/MarkerHolders method.
message QueryHoldingRequest {
  // the address or denom of the marker
  string id = 1;
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
}
// QueryHoldingResponse is the response type for the Query/MarkerHolders method.
message QueryHoldingResponse {
  repeated Balance balances = 1 [(gogoproto.nullable) = false];
  // pagination defines an optional pagination for the request.
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QuerySupplyRequest is the request type for the Query/MarkerSupply method.
// Deprecated: This returns initial/target supply. Use the bank module's SupplyOf query for actual circulating supply.
message QuerySupplyRequest {
  option deprecated = true;
  // address or denom for the marker
  string id = 1;
}
// QuerySupplyResponse is the response type for the Query/MarkerSupply method.
// Deprecated: This returns initial/target supply. Use the bank module's SupplyOf query for actual circulating supply.
message QuerySupplyResponse {
  option deprecated = true;
  // amount is the supply of the marker.
  cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false];
}

// QueryEscrowRequest is the request type for the Query/MarkerEscrow method.
message QueryEscrowRequest {
  // address or denom for the marker
  string id = 1;
}
// QueryEscrowResponse is the response type for the Query/MarkerEscrow method.
message QueryEscrowResponse {
  repeated cosmos.base.v1beta1.Coin escrow = 1 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true,
    (amino.encoding)         = "legacy_coins"
  ];
}

// QueryAccessRequest is the request type for the Query/MarkerAccess method.
message QueryAccessRequest {
  // address or denom for the marker
  string id = 1;
}
// QueryAccessResponse is the response type for the Query/MarkerAccess method.
message QueryAccessResponse {
  repeated AccessGrant accounts = 1 [(gogoproto.nullable) = false];
}

// QueryDenomMetadataRequest is the request type for Query/DenomMetadata
message QueryDenomMetadataRequest {
  string denom = 1;
}
// QueryDenomMetadataResponse is the response type for the Query/DenomMetadata
message QueryDenomMetadataResponse {
  cosmos.bank.v1beta1.Metadata metadata = 1 [(gogoproto.nullable) = false];
}

// QueryAccountDataRequest is the request type for the Query/AccountData
message QueryAccountDataRequest {
  // The denomination to look up.
  string denom = 1;
}
// QueryAccountDataResponse is the response type for the Query/AccountData
message QueryAccountDataResponse {
  // The accountdata for the requested denom.
  string value = 1;
}

// Balance defines an account address and balance pair used in queries for accounts holding a marker
message Balance {
  option (gogoproto.equal)           = false;
  option (gogoproto.goproto_getters) = false;

  // address is the address of the balance holder.
  string address = 1;

  // coins defines the different coins this balance holds.
  repeated cosmos.base.v1beta1.Coin coins = 2 [
    (gogoproto.nullable)     = false,
    (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
    (amino.dont_omitempty)   = true,
    (amino.encoding)         = "legacy_coins"
  ];
}

// QueryNetAssetValuesRequest is the request type for the Query/NetAssetValues method.
message QueryNetAssetValuesRequest {
  // address or denom for the marker
  string id = 1;
}

// QueryNetAssetValuesRequest is the response type for the Query/NetAssetValues method.
message QueryNetAssetValuesResponse {
  // net asset values for marker denom
  repeated NetAssetValue net_asset_values = 1 [(gogoproto.nullable) = false];
}