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

import "gogoproto/gogo.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "google/api/annotations.proto";
import "provenance/metadata/v1/metadata.proto";
import "provenance/metadata/v1/scope.proto";
import "provenance/metadata/v1/specification.proto";
import "provenance/metadata/v1/objectstore.proto";
import "cosmos/query/v1/query.proto";

option go_package = "github.com/provenance-io/provenance/x/metadata/types";

option java_package        = "io.provenance.metadata.v1";
option java_multiple_files = true;

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

  // ---- Primary Data Queries -----

  // Scope searches for a scope.
  //
  // The scope id, if provided, must either be scope uuid, e.g. 91978ba2-5f35-459a-86a7-feca1b0512e0 or a scope address,
  // e.g. scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel. The session addr, if provided, must be a bech32 session address,
  // e.g. session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr. The record_addr, if provided, must be a
  // bech32 record address, e.g. record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3.
  //
  // * If only a scope_id is provided, that scope is returned.
  // * If only a session_addr is provided, the scope containing that session is returned.
  // * If only a record_addr is provided, the scope containing that record is returned.
  // * If more than one of scope_id, session_addr, and record_addr are provided, and they don't refer to the same scope,
  // a bad request is returned.
  //
  // Providing a session addr or record addr does not limit the sessions and records returned (if requested).
  // Those parameters are only used to find the scope.
  //
  // By default, sessions and records are not included.
  // Set include_sessions and/or include_records to true to include sessions and/or records.
  rpc Scope(ScopeRequest) returns (ScopeResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http)                   = {
      get: "/provenance/metadata/v1/scope/{scope_id}"
      additional_bindings: {get: "/provenance/metadata/v1/session/{session_addr}/scope"}
      additional_bindings: {get: "/provenance/metadata/v1/record/{record_addr}/scope"}
    };
  }

  // ScopesAll retrieves all scopes.
  rpc ScopesAll(ScopesAllRequest) returns (ScopesAllResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/scopes/all";
  }

  // Sessions searches for sessions.
  //
  // The scope_id can either be scope uuid, e.g. 91978ba2-5f35-459a-86a7-feca1b0512e0 or a scope address, e.g.
  // scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel. Similarly, the session_id can either be a uuid or session address, e.g.
  // session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr. The record_addr, if provided, must be a
  // bech32 record address, e.g. record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3.
  //
  // * If only a scope_id is provided, all sessions in that scope are returned.
  // * If only a session_id is provided, it must be an address, and that single session is returned.
  // * If the session_id is a uuid, then either a scope_id or record_addr must also be provided, and that single session
  // is returned.
  // * If only a record_addr is provided, the session containing that record will be returned.
  // * If a record_name is provided then either a scope_id, session_id as an address, or record_addr must also be
  // provided, and the session containing that record will be returned.
  //
  // A bad request is returned if:
  // * The session_id is a uuid and is provided without a scope_id or record_addr.
  // * A record_name is provided without any way to identify the scope (e.g. a scope_id, a session_id as an address, or
  // a record_addr).
  // * Two or more of scope_id, session_id as an address, and record_addr are provided and don't all refer to the same
  // scope.
  // * A record_addr (or scope_id and record_name) is provided with a session_id and that session does not contain such
  // a record.
  // * A record_addr and record_name are both provided, but reference different records.
  //
  // By default, the scope and records are not included.
  // Set include_scope and/or include_records to true to include the scope and/or records.
  rpc Sessions(SessionsRequest) returns (SessionsResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http)                   = {
      get: "/provenance/metadata/v1/session/{session_id}"
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/sessions"}
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/session/{session_id}"}
      additional_bindings: {get: "/provenance/metadata/v1/record/{record_addr}/session"}
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/record/{record_name}/session"}
    };
  }

  // SessionsAll retrieves all sessions.
  rpc SessionsAll(SessionsAllRequest) returns (SessionsAllResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/sessions/all";
  }

  // Records searches for records.
  //
  // The record_addr, if provided, must be a bech32 record address, e.g.
  // record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3. The scope-id can either be scope uuid, e.g.
  // 91978ba2-5f35-459a-86a7-feca1b0512e0 or a scope address, e.g. scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel. Similarly,
  // the session_id can either be a uuid or session address, e.g.
  // session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr. The name is the name of the record you're
  // interested in.
  //
  // * If only a record_addr is provided, that single record will be returned.
  // * If only a scope_id is provided, all records in that scope will be returned.
  // * If only a session_id (or scope_id/session_id), all records in that session will be returned.
  // * If a name is provided with a scope_id and/or session_id, that single record will be returned.
  //
  // A bad request is returned if:
  // * The session_id is a uuid and no scope_id is provided.
  // * There are two or more of record_addr, session_id, and scope_id, and they don't all refer to the same scope.
  // * A name is provided, but not a scope_id and/or a session_id.
  // * A name and record_addr are provided and the name doesn't match the record_addr.
  //
  // By default, the scope and sessions are not included.
  // Set include_scope and/or include_sessions to true to include the scope and/or sessions.
  rpc Records(RecordsRequest) returns (RecordsResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http)                   = {
      get: "/provenance/metadata/v1/record/{record_addr}"
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/records"}
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/record/{name}"}
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/session/{session_id}/records"}
      additional_bindings: {get: "/provenance/metadata/v1/scope/{scope_id}/session/{session_id}/record/{name}"}
      additional_bindings: {get: "/provenance/metadata/v1/session/{session_id}/records"}
      additional_bindings: {get: "/provenance/metadata/v1/session/{session_id}/record/{name}"}
    };
  }

  // RecordsAll retrieves all records.
  rpc RecordsAll(RecordsAllRequest) returns (RecordsAllResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/records/all";
  }

  // Ownership returns the scope identifiers that have the given address in the owners list.
  rpc Ownership(OwnershipRequest) returns (OwnershipResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/ownership/{address}";
  }

  // ValueOwnership returns the scope identifiers that list the given address as the value owner.
  rpc ValueOwnership(ValueOwnershipRequest) returns (ValueOwnershipResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/valueownership/{address}";
  }

  // ---- Specification Queries -----

  // ScopeSpecification returns a scope specification for the given specification id.
  //
  // The specification_id can either be a uuid, e.g. dc83ea70-eacd-40fe-9adf-1cf6148bf8a2 or a bech32 scope
  // specification address, e.g. scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m.
  //
  // By default, the contract and record specifications are not included.
  // Set include_contract_specs and/or include_record_specs to true to include contract and/or record specifications.
  rpc ScopeSpecification(ScopeSpecificationRequest) returns (ScopeSpecificationResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/scopespec/{specification_id}";
  }

  // ScopeSpecificationsAll retrieves all scope specifications.
  rpc ScopeSpecificationsAll(ScopeSpecificationsAllRequest) returns (ScopeSpecificationsAllResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/scopespecs/all";
  }

  // ContractSpecification returns a contract specification for the given specification id.
  //
  // The specification_id can either be a uuid, e.g. def6bc0a-c9dd-4874-948f-5206e6060a84, a bech32 contract
  // specification address, e.g. contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn, or a bech32 record specification
  // address, e.g. recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44. If it is a record specification
  // address, then the contract specification that contains that record specification is looked up.
  //
  // By default, the record specifications for this contract specification are not included.
  // Set include_record_specs to true to include them in the result.
  rpc ContractSpecification(ContractSpecificationRequest) returns (ContractSpecificationResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/contractspec/{specification_id}";
  }

  // ContractSpecificationsAll retrieves all contract specifications.
  rpc ContractSpecificationsAll(ContractSpecificationsAllRequest) returns (ContractSpecificationsAllResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/contractspecs/all";
  }

  // RecordSpecificationsForContractSpecification returns the record specifications for the given input.
  //
  // The specification_id can either be a uuid, e.g. def6bc0a-c9dd-4874-948f-5206e6060a84, a bech32 contract
  // specification address, e.g. contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn, or a bech32 record specification
  // address, e.g. recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44. If it is a record specification
  // address, then the contract specification that contains that record specification is used.
  rpc RecordSpecificationsForContractSpecification(RecordSpecificationsForContractSpecificationRequest)
      returns (RecordSpecificationsForContractSpecificationResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/contractspec/{specification_id}/recordspecs";
  }

  // RecordSpecification returns a record specification for the given input.
  rpc RecordSpecification(RecordSpecificationRequest) returns (RecordSpecificationResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http)                   = {
      get: "/provenance/metadata/v1/recordspec/{specification_id}"
      additional_bindings: {get: "/provenance/metadata/v1/contractspec/{specification_id}/recordspec/{name}"}
    };
  }

  // RecordSpecificationsAll retrieves all record specifications.
  rpc RecordSpecificationsAll(RecordSpecificationsAllRequest) returns (RecordSpecificationsAllResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/recordspecs/all";
  }

  // GetByAddr retrieves metadata given any address(es).
  rpc GetByAddr(GetByAddrRequest) returns (GetByAddrResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/addr/{addrs}";
  }

  // ---- Object Store Locator Queries -----

  // OSLocatorParams returns all parameters for the object store locator sub module.
  rpc OSLocatorParams(OSLocatorParamsRequest) returns (OSLocatorParamsResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/locator/params";
  }

  // OSLocator returns an ObjectStoreLocator by its owner's address.
  rpc OSLocator(OSLocatorRequest) returns (OSLocatorResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/locator/{owner}";
  }

  // OSLocatorsByURI returns all ObjectStoreLocator entries for a locator uri.
  rpc OSLocatorsByURI(OSLocatorsByURIRequest) returns (OSLocatorsByURIResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/locator/uri/{uri}";
  }

  // OSLocatorsByScope returns all ObjectStoreLocator entries for a for all signer's present in the specified scope.
  rpc OSLocatorsByScope(OSLocatorsByScopeRequest) returns (OSLocatorsByScopeResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/locator/scope/{scope_id}";
  }

  // OSAllLocators returns all ObjectStoreLocator entries.
  rpc OSAllLocators(OSAllLocatorsRequest) returns (OSAllLocatorsResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/locators/all";
  }

  // AccountData gets the account data associated with a metadata address.
  // Currently, only scope ids are supported.
  rpc AccountData(AccountDataRequest) returns (AccountDataResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/accountdata/{metadata_addr}";
  }

  // ScopeNetAssetValues returns net asset values for scope
  rpc ScopeNetAssetValues(QueryScopeNetAssetValuesRequest) returns (QueryScopeNetAssetValuesResponse) {
    option (cosmos.query.v1.module_query_safe) = true;
    option (google.api.http).get               = "/provenance/metadata/v1/netassetvalues/{id}";
  }
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {
  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

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

  // request is a copy of the request that generated these results.
  QueryParamsRequest request = 98;
}

// ScopeRequest is the request type for the Query/Scope RPC method.
message ScopeRequest {
  // scope_id can either be a uuid, e.g. 91978ba2-5f35-459a-86a7-feca1b0512e0 or a bech32 scope address, e.g.
  // scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel.
  string scope_id = 1;
  // session_addr is a bech32 session address, e.g.
  // session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr.
  string session_addr = 2;
  // record_addr is a bech32 record address, e.g. record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3.
  string record_addr = 3;

  // include_sessions is a flag for whether to include the sessions of the scope in the response.
  bool include_sessions = 10;
  // include_records is a flag for whether to include the records of the scope in the response.
  bool include_records = 11;
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// ScopeResponse is the response type for the Query/Scope RPC method.
message ScopeResponse {
  // scope is the wrapped scope result.
  ScopeWrapper scope = 1;
  // sessions is any number of wrapped sessions in this scope (if requested).
  repeated SessionWrapper sessions = 2;
  // records is any number of wrapped records in this scope (if requested).
  repeated RecordWrapper records = 3;

  // request is a copy of the request that generated these results.
  ScopeRequest request = 98;
}

// SessionWrapper contains a single scope and its uuid.
message ScopeWrapper {
  // scope is the on-chain scope message.
  Scope scope = 1;
  // scope_id_info contains information about the id/address of the scope.
  ScopeIdInfo scope_id_info = 2;
  // scope_spec_id_info contains information about the id/address of the scope specification.
  ScopeSpecIdInfo scope_spec_id_info = 3;
}

// ScopesAllRequest is the request type for the Query/ScopesAll RPC method.
message ScopesAllRequest {
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// ScopesAllResponse is the response type for the Query/ScopesAll RPC method.
message ScopesAllResponse {
  // scopes are the wrapped scopes.
  repeated ScopeWrapper scopes = 1;

  // request is a copy of the request that generated these results.
  ScopesAllRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// SessionsRequest is the request type for the Query/Sessions RPC method.
message SessionsRequest {
  // scope_id can either be a uuid, e.g. 91978ba2-5f35-459a-86a7-feca1b0512e0 or a bech32 scope address, e.g.
  // scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel.
  string scope_id = 1;
  // session_id can either be a uuid, e.g. 5803f8bc-6067-4eb5-951f-2121671c2ec0 or a bech32 session address, e.g.
  // session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr. This can only be a uuid if a scope_id is also
  // provided.
  string session_id = 2;
  // record_addr is a bech32 record address, e.g. record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3.
  string record_addr = 3;
  // record_name is the name of the record to find the session for in the provided scope.
  string record_name = 4;

  // include_scope is a flag for whether to include the scope containing these sessions in the response.
  bool include_scope = 10;
  // include_records is a flag for whether to include the records of these sessions in the response.
  bool include_records = 11;
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// SessionsResponse is the response type for the Query/Sessions RPC method.
message SessionsResponse {
  // scope is the wrapped scope that holds these sessions (if requested).
  ScopeWrapper scope = 1;
  // sessions is any number of wrapped session results.
  repeated SessionWrapper sessions = 2;
  // records is any number of wrapped records contained in these sessions (if requested).
  repeated RecordWrapper records = 3;

  // request is a copy of the request that generated these results.
  SessionsRequest request = 98;
}

// SessionWrapper contains a single session and some extra identifiers for it.
message SessionWrapper {
  // session is the on-chain session message.
  Session session = 1;
  // session_id_info contains information about the id/address of the session.
  SessionIdInfo session_id_info = 2;
  // contract_spec_id_info contains information about the id/address of the contract specification.
  ContractSpecIdInfo contract_spec_id_info = 3;
}

// SessionsAllRequest is the request type for the Query/SessionsAll RPC method.
message SessionsAllRequest {
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// SessionsAllResponse is the response type for the Query/SessionsAll RPC method.
message SessionsAllResponse {
  // sessions are the wrapped sessions.
  repeated SessionWrapper sessions = 1;

  // request is a copy of the request that generated these results.
  SessionsAllRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// RecordsRequest is the request type for the Query/Records RPC method.
message RecordsRequest {
  // record_addr is a bech32 record address, e.g. record1q2ge0zaztu65tx5x5llv5xc9ztsw42dq2jdvmdazuwzcaddhh8gmu3mcze3.
  string record_addr = 1;
  // scope_id can either be a uuid, e.g. 91978ba2-5f35-459a-86a7-feca1b0512e0 or a bech32 scope address, e.g.
  // scope1qzge0zaztu65tx5x5llv5xc9ztsqxlkwel.
  string scope_id = 2;
  // session_id can either be a uuid, e.g. 5803f8bc-6067-4eb5-951f-2121671c2ec0 or a bech32 session address, e.g.
  // session1qxge0zaztu65tx5x5llv5xc9zts9sqlch3sxwn44j50jzgt8rshvqyfrjcr. This can only be a uuid if a scope_id is also
  // provided.
  string session_id = 3;
  // name is the name of the record to look for
  string name = 4;

  // include_scope is a flag for whether to include the the scope containing these records in the response.
  bool include_scope = 10;
  // include_sessions is a flag for whether to include the sessions containing these records in the response.
  bool include_sessions = 11;
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// RecordsResponse is the response type for the Query/Records RPC method.
message RecordsResponse {
  // scope is the wrapped scope that holds these records (if requested).
  ScopeWrapper scope = 1;
  // sessions is any number of wrapped sessions that hold these records (if requested).
  repeated SessionWrapper sessions = 2;
  // records is any number of wrapped record results.
  repeated RecordWrapper records = 3;

  // request is a copy of the request that generated these results.
  RecordsRequest request = 98;
}

// RecordWrapper contains a single record and some extra identifiers for it.
message RecordWrapper {
  // record is the on-chain record message.
  Record record = 1;
  // record_id_info contains information about the id/address of the record.
  RecordIdInfo record_id_info = 2;
  // record_spec_id_info contains information about the id/address of the record specification.
  RecordSpecIdInfo record_spec_id_info = 3;
}

// RecordsAllRequest is the request type for the Query/RecordsAll RPC method.
message RecordsAllRequest {
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// RecordsAllResponse is the response type for the Query/RecordsAll RPC method.
message RecordsAllResponse {
  // records are the wrapped records.
  repeated RecordWrapper records = 1;

  // request is a copy of the request that generated these results.
  RecordsAllRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// OwnershipRequest is the request type for the Query/Ownership RPC method.
message OwnershipRequest {
  string address = 1;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// OwnershipResponse is the response type for the Query/Ownership RPC method.
message OwnershipResponse {
  // A list of scope ids (uuid) associated with the given address.
  repeated string scope_uuids = 1;

  // request is a copy of the request that generated these results.
  OwnershipRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// ValueOwnershipRequest is the request type for the Query/ValueOwnership RPC method.
message ValueOwnershipRequest {
  string address = 1;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// ValueOwnershipResponse is the response type for the Query/ValueOwnership RPC method.
message ValueOwnershipResponse {
  // A list of scope ids (uuid) associated with the given address.
  repeated string scope_uuids = 1;

  // request is a copy of the request that generated these results.
  ValueOwnershipRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// ScopeSpecificationRequest is the request type for the Query/ScopeSpecification RPC method.
message ScopeSpecificationRequest {
  // specification_id can either be a uuid, e.g. dc83ea70-eacd-40fe-9adf-1cf6148bf8a2 or a bech32 scope specification
  // address, e.g. scopespec1qnwg86nsatx5pl56muw0v9ytlz3qu3jx6m.
  string specification_id = 1;

  // include_contract_specs is a flag for whether to include the contract specifications of the scope specification in
  // the response.
  bool include_contract_specs = 10;
  // include_record_specs is a flag for whether to include the record specifications of the scope specification in the
  // response.
  bool include_record_specs = 11;
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// ScopeSpecificationResponse is the response type for the Query/ScopeSpecification RPC method.
message ScopeSpecificationResponse {
  // scope_specification is the wrapped scope specification.
  ScopeSpecificationWrapper scope_specification = 1;
  // contract_specs is any number of wrapped contract specifications in this scope specification (if requested).
  repeated ContractSpecificationWrapper contract_specs = 2;
  // record_specs is any number of wrapped record specifications in this scope specification (if requested).
  repeated RecordSpecificationWrapper record_specs = 3;

  // request is a copy of the request that generated these results.
  ScopeSpecificationRequest request = 98;
}

// ScopeSpecificationWrapper contains a single scope specification and some extra identifiers for it.
message ScopeSpecificationWrapper {
  // specification is the on-chain scope specification message.
  ScopeSpecification specification = 1;
  // scope_spec_id_info contains information about the id/address of the scope specification.
  ScopeSpecIdInfo scope_spec_id_info = 2;
}

// ScopeSpecificationsAllRequest is the request type for the Query/ScopeSpecificationsAll RPC method.
message ScopeSpecificationsAllRequest {
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// ScopeSpecificationsAllResponse is the response type for the Query/ScopeSpecificationsAll RPC method.
message ScopeSpecificationsAllResponse {
  // scope_specifications are the wrapped scope specifications.
  repeated ScopeSpecificationWrapper scope_specifications = 1;

  // request is a copy of the request that generated these results.
  ScopeSpecificationsAllRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// ContractSpecificationRequest is the request type for the Query/ContractSpecification RPC method.
message ContractSpecificationRequest {
  // specification_id can either be a uuid, e.g. def6bc0a-c9dd-4874-948f-5206e6060a84 or a bech32 contract specification
  // address, e.g. contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn.
  // It can also be a record specification address, e.g.
  // recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44.
  string specification_id = 1;

  // include_record_specs is a flag for whether to include the the record specifications of this contract specification
  // in the response.
  bool include_record_specs = 10;
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// ContractSpecificationResponse is the response type for the Query/ContractSpecification RPC method.
message ContractSpecificationResponse {
  // contract_specification is the wrapped contract specification.
  ContractSpecificationWrapper contract_specification = 1;
  // record_specifications is any number or wrapped record specifications associated with this contract_specification
  // (if requested).
  repeated RecordSpecificationWrapper record_specifications = 3;

  // request is a copy of the request that generated these results.
  ContractSpecificationRequest request = 98;
}

// ContractSpecificationWrapper contains a single contract specification and some extra identifiers for it.
message ContractSpecificationWrapper {
  // specification is the on-chain contract specification message.
  ContractSpecification specification = 1;
  // contract_spec_id_info contains information about the id/address of the contract specification.
  ContractSpecIdInfo contract_spec_id_info = 2;
}

// ContractSpecificationsAllRequest is the request type for the Query/ContractSpecificationsAll RPC method.
message ContractSpecificationsAllRequest {
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// ContractSpecificationsAllResponse is the response type for the Query/ContractSpecificationsAll RPC method.
message ContractSpecificationsAllResponse {
  // contract_specifications are the wrapped contract specifications.
  repeated ContractSpecificationWrapper contract_specifications = 1;

  // request is a copy of the request that generated these results.
  ContractSpecificationsAllRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// RecordSpecificationsForContractSpecificationRequest is the request type for the
// Query/RecordSpecificationsForContractSpecification RPC method.
message RecordSpecificationsForContractSpecificationRequest {
  // specification_id can either be a uuid, e.g. def6bc0a-c9dd-4874-948f-5206e6060a84 or a bech32 contract specification
  // address, e.g. contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn.
  // It can also be a record specification address, e.g.
  // recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44.
  string specification_id = 1;

  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// RecordSpecificationsForContractSpecificationResponse is the response type for the
// Query/RecordSpecificationsForContractSpecification RPC method.
message RecordSpecificationsForContractSpecificationResponse {
  // record_specifications is any number of wrapped record specifications associated with this contract_specification.
  repeated RecordSpecificationWrapper record_specifications = 1;
  // contract_specification_uuid is the uuid of this contract specification.
  string contract_specification_uuid = 2;
  // contract_specification_addr is the contract specification address as a bech32 encoded string.
  string contract_specification_addr = 3;

  // request is a copy of the request that generated these results.
  RecordSpecificationsForContractSpecificationRequest request = 98;
}

// RecordSpecificationRequest is the request type for the Query/RecordSpecification RPC method.
message RecordSpecificationRequest {
  // specification_id can either be a uuid, e.g. def6bc0a-c9dd-4874-948f-5206e6060a84 or a bech32 contract specification
  // address, e.g. contractspec1q000d0q2e8w5say53afqdesxp2zqzkr4fn.
  // It can also be a record specification address, e.g.
  // recspec1qh00d0q2e8w5say53afqdesxp2zw42dq2jdvmdazuwzcaddhh8gmuqhez44.
  string specification_id = 1;
  // name is the name of the record to look up.
  // It is required if the specification_id is a uuid or contract specification address.
  // It is ignored if the specification_id is a record specification address.
  string name = 2;

  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// RecordSpecificationResponse is the response type for the Query/RecordSpecification RPC method.
message RecordSpecificationResponse {
  // record_specification is the wrapped record specification.
  RecordSpecificationWrapper record_specification = 1;

  // request is a copy of the request that generated these results.
  RecordSpecificationRequest request = 98;
}

// RecordSpecificationWrapper contains a single record specification and some extra identifiers for it.
message RecordSpecificationWrapper {
  // specification is the on-chain record specification message.
  RecordSpecification specification = 1;
  // record_spec_id_info contains information about the id/address of the record specification.
  RecordSpecIdInfo record_spec_id_info = 2;
}

// RecordSpecificationsAllRequest is the request type for the Query/RecordSpecificationsAll RPC method.
message RecordSpecificationsAllRequest {
  // exclude_id_info is a flag for whether to exclude the id info from the response.
  bool exclude_id_info = 12;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// RecordSpecificationsAllResponse is the response type for the Query/RecordSpecificationsAll RPC method.
message RecordSpecificationsAllResponse {
  // record_specifications are the wrapped record specifications.
  repeated RecordSpecificationWrapper record_specifications = 1;

  // request is a copy of the request that generated these results.
  RecordSpecificationsAllRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// GetByAddrRequest is the request type for the Query/GetByAddr RPC method.
message GetByAddrRequest {
  // ids are the metadata addresses of the things to look up.
  repeated string addrs = 1;
}

// GetByAddrResponse is the response type for the Query/GetByAddr RPC method.
message GetByAddrResponse {
  // scopes contains any scopes that were requested and found.
  repeated Scope scopes = 1;
  // sessions contains any sessions that were requested and found.
  repeated Session sessions = 2;
  // records contains any records that were requested and found.
  repeated Record records = 3;
  // scope_specs contains any scope specifications that were requested and found.
  repeated ScopeSpecification scope_specs = 4;
  // contract_specs contains any contract specifications that were requested and found.
  repeated ContractSpecification contract_specs = 5;
  // record_specs contains any record specifications that were requested and found.
  repeated RecordSpecification record_specs = 6;
  // not_found contains any addrs requested but not found.
  repeated string not_found = 7;
}

// OSLocatorParamsRequest is the request type for the Query/OSLocatorParams RPC method.
message OSLocatorParamsRequest {
  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

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

  // request is a copy of the request that generated these results.
  OSLocatorParamsRequest request = 98;
}

// OSLocatorRequest is the request type for the Query/OSLocator RPC method.
message OSLocatorRequest {
  string owner = 1;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// OSLocatorResponse is the response type for the Query/OSLocator RPC method.
message OSLocatorResponse {
  ObjectStoreLocator locator = 1;

  // request is a copy of the request that generated these results.
  OSLocatorRequest request = 98;
}

// OSLocatorsByURIRequest is the request type for the Query/OSLocatorsByURI RPC method.
message OSLocatorsByURIRequest {
  string uri = 1;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// OSLocatorsByURIResponse is the response type for the Query/OSLocatorsByURI RPC method.
message OSLocatorsByURIResponse {
  repeated ObjectStoreLocator locators = 1 [(gogoproto.nullable) = false];

  // request is a copy of the request that generated these results.
  OSLocatorsByURIRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// OSLocatorsByScopeRequest is the request type for the Query/OSLocatorsByScope RPC method.
message OSLocatorsByScopeRequest {
  string scope_id = 1;

  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
}

// OSLocatorsByScopeResponse is the response type for the Query/OSLocatorsByScope RPC method.
message OSLocatorsByScopeResponse {
  repeated ObjectStoreLocator locators = 1 [(gogoproto.nullable) = false];

  // request is a copy of the request that generated these results.
  OSLocatorsByScopeRequest request = 98;
}

// OSAllLocatorsRequest is the request type for the Query/OSAllLocators RPC method.
message OSAllLocatorsRequest {
  // include_request is a flag for whether to include this request in your result.
  bool include_request = 98;
  // pagination defines optional pagination parameters for the request.
  cosmos.base.query.v1beta1.PageRequest pagination = 99;
}

// OSAllLocatorsResponse is the response type for the Query/OSAllLocators RPC method.
message OSAllLocatorsResponse {
  repeated ObjectStoreLocator locators = 1 [(gogoproto.nullable) = false];

  // request is a copy of the request that generated these results.
  OSAllLocatorsRequest request = 98;
  // pagination provides the pagination information of this response.
  cosmos.base.query.v1beta1.PageResponse pagination = 99;
}

// AccountDataRequest is the request type for the Query/AccountData RPC method.
message AccountDataRequest {
  // The metadata address to look up.
  // Currently, only scope ids are supported.
  bytes metadata_addr = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "MetadataAddress"];
}

// AccountDataResponse is the response type for the Query/AccountData RPC method.
message AccountDataResponse {
  // The accountdata for the requested metadata address.
  string value = 1;
}

// QueryNetAssetValuesRequest is the request type for the Query/NetAssetValues method.
message QueryScopeNetAssetValuesRequest {
  // scopeid metadata address
  string id = 1;
}

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