syntax = "proto3";
package forge_abi;

import "type.proto";

// indexed type definition

message PageOrder {
  string field = 1;
  string type = 2;
}

message PageInput {
  string cursor = 1;
  uint32 size = 2;
  repeated PageOrder order = 3;
}

message TypeFilter {
  repeated string types = 1;
}

message TimeFilter {
  string start_date_time = 1;
  string end_date_time = 2;
}

enum Direction {
  mutual = 0;
  one_way = 1;
  union = 2;
}

message AddressFilter {
  string sender = 1;
  string receiver = 2;
  Direction direction = 3;
}

message PageInfo {
  string cursor = 1;
  bool next = 2;
  uint32 total = 3;
}

message IndexedTransaction {
  string hash = 1;
  string sender = 2;
  string receiver = 3;
  string time = 4;
  string type = 5;
  Transaction tx = 6;
  oneof value {
    IndexedConsumeAsset consume_asset = 7;
    IndexedCreateAsset create_asset = 8;
    IndexedExchange exchange = 9;
    IndexedTransfer transfer =  10;
    IndexedUpdateAsset update_asset = 11;
  }
}

message IndexedAccountState {
  string address = 1;
  BigUint balance = 2;
  uint64 num_assets = 3;
  uint64 num_txs = 4;
  uint64 nonce = 5;
  string genesis_time = 6;
  string renaissance_time = 7;
  string moniker = 8;
  string migrated_from = 9;
  string migrated_to = 10;
  BigUint total_received_stakes = 11;
  BigUint total_stakes = 12;
  BigUint total_unstakes = 13;
  repeated uint64 recent_num_txs = 14;
}

message IndexedAssetState {
  string address = 1;
  string owner = 2;
  string genesis_time = 3;
  string renaissance_time = 4;
  string moniker = 5;
  bool readonly = 6;
}

message IndexedStakeState {
  string address = 1;
  BigUint balance = 2;
  string sender = 3;
  string receiver = 4;
  string genesis_time = 5;
  string renaissance_time = 6;
  string message = 7;
  uint32 type = 8;
}

message IndexedConsumeAsset {
  string asset = 1;
}

message IndexedCreateAsset {
  string asset = 1;
}

message IndexedExchange {
  repeated string sender_assets = 1;
  repeated string receiver_assets = 2;
}

message IndexedTransfer {
  repeated string assets = 1;
}

message IndexedUpdateAsset {
  string asset = 1;
}

message HeightFilter {
  uint64 from_height = 1;
  uint64 to_height = 2;
}

message NumTxsFilter {
  uint64 min_num_txs = 1;
  uint64 max_num_txs = 2;
}

message NumInvalidTxsFilter {
  uint64 min_num_invalid_txs = 1;
  uint64 max_num_invalid_txs = 2;
}

message IndexedBlock {
  uint64 height = 1;
  string time = 2;
  string proposer = 3;
  uint64 num_txs = 4;
  uint64 num_invalid_txs = 5;
}

message HealthStatus {
  ConsensusStatus consensus = 1;
  NetworkStatus network = 2;
  StorageStatus storage = 3;
  ForgeStatus forge = 4;
}

message ConsensusStatus{
  bool health = 1;
  bool synced = 2;
  uint64 block_height = 3;
}

message NetworkStatus{
  bool health = 1;
  uint32 num_peers = 2;
}

message StorageStatus{
  bool health = 1;
  string indexer_server = 2;
  string state_db = 3;
  DiskSpaceStatus disk_space = 4;
}

message DiskSpaceStatus {
  string forge_usage = 1;
  string total = 2;
}

message ForgeStatus{
  bool health = 1;
  string abi_server = 2;
  string forge_web = 3;
  AbciServerStatus abci_server = 4;
}

message AbciServerStatus{
  string abci_consensus = 1;
  string abci_info = 2;
}
