import '../../domain/entities/global_state.dart';

class GlobalStateModel extends GlobalState {
  const GlobalStateModel({
    required super.currentPrice,
    required super.priceChange24h,
    required super.totalDistributed,
    required super.totalBurned,
    required super.circulationPool,
    required super.networkContribution,
    required super.eraNumber,
    required super.remainingDistribution,
    required super.updatedAt,
  });

  factory GlobalStateModel.fromJson(Map<String, dynamic> json) {
    return GlobalStateModel(
      currentPrice: json['currentPrice']?.toString() ?? '0',
      priceChange24h: json['priceChange24h']?.toString() ?? '0',
      totalDistributed: json['totalDistributed']?.toString() ?? '0',
      totalBurned: json['totalBurned']?.toString() ?? '0',
      circulationPool: json['circulationPool']?.toString() ?? '0',
      networkContribution: json['networkContribution']?.toString() ?? '0',
      eraNumber: json['eraNumber'] ?? 1,
      remainingDistribution: json['remainingDistribution']?.toString() ?? '0',
      updatedAt: json['updatedAt'] != null
          ? DateTime.parse(json['updatedAt'])
          : DateTime.now(),
    );
  }
}
