syntax = "proto3";
package forge_abi;

enum StatusCode {
  ok = 0;

  // common code
  // 1 - 15
  invalid_nonce = 1;
  invalid_signature = 2;
  invalid_sender_state = 3;
  invalid_receiver_state = 4;
  insufficient_data = 5;
  insufficient_fund = 6;
  invalid_owner = 7;
  invalid_tx = 8;
  unsupported_tx = 9;
  expired_tx = 10;

  // 16 - 2047 various errors
  invalid_moniker = 16;
  invalid_passphrase = 17;

  invalid_multisig = 20;
  invalid_wallet = 21;
  invalid_chain_id = 22;

  consensus_rpc_error = 24;
  storage_rpc_error = 25;
  noent = 26;
  account_migrated = 27;

  unsupported_stake = 30;
  insufficient_stake = 31;
  invalid_stake_state = 32;
  expired_wallet_token = 33;
  banned_unstake = 34;
  invalid_asset = 35;
  invalid_tx_size = 36;
  invalid_signer_state = 37;
  invalid_forge_state = 38;
  expired_asset = 39;
  untransferrable_asset = 40;
  readonly_asset = 41;
  consumed_asset = 42;

  forbidden = 403;
  internal = 500;

  // user defined status code shall start from 600
}

// event happened on Forge powered chain
enum TopicType {
  // most commonly used event
  transfer = 0;

  // 1-15 fequently used event
  exchange = 1;
  declare = 2;
  create_asset = 3;
  update_asset = 4;
  stake = 5;
  account_migrate = 6;

  // 7-15 reserved for future frequent forge tx

  // 16-2047 infrequently used event
  begin_block = 16;
  end_block = 17;

  consensus_upgrade = 21;
  declare_file = 22;
  sys_upgrade = 23;
  application = 24;
  consume_asset = 25;

  // 24-128 reserved for future infrequent forge tx

  account_state = 129;
  asset_state = 130;
  forge_state = 131;
  stake_state = 132;

  // user defined event type shall start from 256.
}

enum KeyType {
  ed25519 = 0;
  secp256k1 = 1;
}

enum HashType {
  keccak = 0;
  sha3 = 1;

  // 2-5 reserved

  keccak_384 = 6;
  sha3_384 = 7;

  // 9-12 reserved

  keccak_512 = 13;
  sha3_512 = 14;
}

enum EncodingType {
  base16 = 0;
  base58 = 1;
}

enum RoleType {
  role_account = 0;
  role_node = 1;
  role_device = 2;
  role_application = 3;
  role_smart_contract = 4;
  role_bot = 5;
  role_asset = 6;
  role_stake = 7;
  role_validator = 8;
}

enum UpgradeType {
  // configuration
  config_app = 0;
  config_forge = 1;
  config_dfs = 2;
  config_consensus = 3;
  config_p2p = 4;

  // executable
  exe_app = 10;
  exe_forge = 11;
  exe_dfs = 12;
  exe_consensus = 13;
  exe_p2p = 14;
}

enum UpgradeAction {
  verify = 0;
  backup = 1;
  replace = 2;

  // restart different part of the system
  restart_app = 10;
  restart_dfs = 11;
  restart_consensus = 12;
  restart_p2p = 13;
  // restart forge will indirectly restart all component in a graceful manner
  restart_forge = 14;

  // depend on deployment, the monitor app (e.g. systemd) shall bring the
  // process back
  rollback_if_fail = 30;
  restart_all_if_fail = 31;
  crash_if_fail = 33;

  // drop different intermediate files
  drop_address_book = 50;
}

enum StateType {
  state_account = 0;
  state_asset = 1;
  state_channel = 2;
  state_forge = 3;
  state_stake = 4;
}

enum StakeType {
  stake_node = 0;
  stake_user = 1;
  stake_asset = 2;
  stake_chain = 3;
}
