import 'package:pshared/models/currency.dart';
import 'package:pshared/models/describable.dart';
import 'package:pshared/models/payment/chain_network.dart';


class Wallet implements Describable {
  final String id;
  final String walletUserID; // ID or number that we show the user
  final double balance;
  final Currency currency;
  final bool isHidden;
  final DateTime calculatedAt;
  final String? depositAddress;
  final ChainNetwork? network;
  final String? tokenSymbol;
  final String? contractAddress;
  final Describable describable;

  @override
  String get name => describable.name;

  @override
  String? get description => describable.description;

  Wallet({
    required this.id,
    required this.walletUserID,
    required this.balance,
    required this.currency,
    required this.calculatedAt,
    required this.describable,
    this.isHidden = true,
    this.depositAddress,
    this.network,
    this.tokenSymbol,
    this.contractAddress,
  });

  Wallet copyWith({
    String? id,
    double? balance,
    Currency? currency,
    String? walletUserID,
    bool? isHidden,
    String? depositAddress,
    ChainNetwork? network,
    String? tokenSymbol,
    String? contractAddress,
    Describable? describable,
    String? name,
    String? Function()? description,
  }) => Wallet(
    id: id ?? this.id,
    balance: balance ?? this.balance,
    currency: currency ?? this.currency,
    walletUserID: walletUserID ?? this.walletUserID,
    isHidden: isHidden ?? this.isHidden,
    calculatedAt: calculatedAt,
    depositAddress: depositAddress ?? this.depositAddress,
    network: network ?? this.network,
    tokenSymbol: tokenSymbol ?? this.tokenSymbol,
    contractAddress: contractAddress ?? this.contractAddress,
    describable: describable 
      ?? (name != null || description != null 
        ? this.describable.copyWith(name: name, description: description) 
        : this.describable),
  );
}
