syntax = "proto3";

package freeexile.trade;

// FreeExile Original Barter Economy: Primal Spiritual Stones & Runes (Linh Thạch & Thần Bí Phù)
enum PrimalStoneType {
  STONE_KHAI_LINH = 0;       // Awakening Pearl: Normal -> Magic (Phàm phẩm -> Linh phẩm)
  STONE_TINH_LUYEN = 1;      // Refinement Rune: Alteration of existing magical affixes
  STONE_TAO_HOA = 2;         // Creation Stone: Normal -> Rare (Phàm phẩm -> Cực phẩm)
  STONE_HON_NGUYEN = 3;      // Primal Chaos Stone: Re-rolls all affixes on Rare (Standard Currency Benchmark)
  STONE_THIEN_TUONG = 4;     // Celestial Sovereign Talisman: Adds a high-tier affix to Rare
  STONE_THIEN_MENH = 5;      // Destiny Rune: Re-rolls min-max ranges of existing affixes (High-Tier Benchmark)
  STONE_THAI_HU_KINH = 6;    // Mirror of Void Essence: Creates an identical mirrored copy of a non-unique artifact
}

message CurrencyStack {
  PrimalStoneType stone_type = 1;
  uint32 amount = 2;
}

message ItemRecord {
  string item_uuid = 1;        // Global unique UUID v7 + Cryptographic Salt
  string item_name = 2;
  uint32 item_level = 3;
  uint32 rarity = 4;           // 0=Phàm phẩm (Common), 1=Linh phẩm (Magic), 2=Cực phẩm (Rare), 3=Thần thoại (Unique)
  repeated string explicit_affixes = 5;
  repeated string implicit_affixes = 6;
}

message VaultListing {
  string listing_id = 1;
  string seller_account_id = 2;
  ItemRecord item = 3;
  CurrencyStack asking_price = 4;
  uint64 listed_timestamp = 5;
  bool is_active = 6;
}

message InstantBuyoutRequest {
  string listing_id = 1;
  string buyer_account_id = 2;
  CurrencyStack offered_payment = 3;
  uint64 request_timestamp = 4;
  string idempotency_key = 5;
}

message TradeReceipt {
  string transaction_id = 1;
  string listing_id = 2;
  string seller_account_id = 3;
  string buyer_account_id = 4;
  string item_uuid = 5;
  CurrencyStack paid_amount = 6;
  uint64 confirmed_timestamp = 7;
  bool success = 8;
  string error_message = 9;
}
