deposit_wallet.dart 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'package:decimal/decimal.dart';
  2. /// 充值钱包(含充值地址) - POST uc/asset/wallet/address
  3. class DepositWallet {
  4. final String id;
  5. final Decimal balance;
  6. final String address;
  7. final WalletCoin? coin;
  8. DepositWallet({
  9. required this.id,
  10. required this.balance,
  11. required this.address,
  12. this.coin,
  13. });
  14. factory DepositWallet.fromJson(Map<String, dynamic> json) {
  15. return DepositWallet(
  16. id: json['id']?.toString() ?? '',
  17. balance: Decimal.tryParse(json['balance']?.toString() ?? '0') ?? Decimal.zero,
  18. address: json['address']?.toString() ?? '',
  19. coin: json['coin'] != null
  20. ? WalletCoin.fromJson(json['coin'] as Map<String, dynamic>)
  21. : null,
  22. );
  23. }
  24. }
  25. /// 币种信息
  26. class WalletCoin {
  27. /// 币种全称(JSON: name)
  28. final String fullName;
  29. /// 币种代号(JSON: unit)— 用于区分网络(TUSDT/EUSDT/USDT-BEP20)
  30. final String code;
  31. /// 中文名称(JSON: nameCn)— 显示名(USDT-TRC20)
  32. final String name;
  33. /// 是否支持充值 "0"/"1"
  34. final String canRecharge;
  35. /// 是否支持提现 "0"/"1"
  36. final String canWithdraw;
  37. /// 最小充值额
  38. final Decimal minRechargeAmount;
  39. /// 最大充值额
  40. final Decimal maxRechargeAmount;
  41. /// 最小提现额
  42. final Decimal minWithdrawAmount;
  43. /// 最大提现额
  44. final Decimal maxWithdrawAmount;
  45. /// 最小手续费
  46. final Decimal minTxFee;
  47. /// 最大手续费
  48. final Decimal maxTxFee;
  49. /// 提现手续费(JSON: withdrawFeeValue)
  50. final Decimal fee;
  51. WalletCoin({
  52. this.fullName = '',
  53. this.code = '',
  54. this.name = '',
  55. this.canRecharge = '0',
  56. this.canWithdraw = '0',
  57. Decimal? minRechargeAmount,
  58. Decimal? maxRechargeAmount,
  59. Decimal? minWithdrawAmount,
  60. Decimal? maxWithdrawAmount,
  61. Decimal? minTxFee,
  62. Decimal? maxTxFee,
  63. Decimal? fee,
  64. }) : minRechargeAmount = minRechargeAmount ?? Decimal.zero,
  65. maxRechargeAmount = maxRechargeAmount ?? Decimal.zero,
  66. minWithdrawAmount = minWithdrawAmount ?? Decimal.zero,
  67. maxWithdrawAmount = maxWithdrawAmount ?? Decimal.zero,
  68. minTxFee = minTxFee ?? Decimal.zero,
  69. maxTxFee = maxTxFee ?? Decimal.zero,
  70. fee = fee ?? Decimal.zero;
  71. /// 是否支持充值
  72. bool get isRechargeEnabled => canRecharge == '1';
  73. /// 是否支持提现
  74. bool get isWithdrawEnabled => canWithdraw == '1';
  75. /// 网络类型显示名
  76. String get networkName {
  77. if (code == 'TUSDT') return 'TRC20';
  78. if (code == 'EUSDT') return 'ERC20';
  79. if (code.contains('BEP20')) return 'BEP20';
  80. return code;
  81. }
  82. factory WalletCoin.fromJson(Map<String, dynamic> json) {
  83. return WalletCoin(
  84. fullName: json['name']?.toString() ?? '',
  85. code: json['unit']?.toString() ?? '',
  86. name: json['nameCn']?.toString() ?? '',
  87. canRecharge: json['canRecharge']?.toString() ?? '0',
  88. canWithdraw: json['canWithdraw']?.toString() ?? '0',
  89. minRechargeAmount: Decimal.tryParse(json['minRechargeAmount']?.toString() ?? ''),
  90. maxRechargeAmount: Decimal.tryParse(json['maxRechargeAmount']?.toString() ?? ''),
  91. minWithdrawAmount: Decimal.tryParse(json['minWithdrawAmount']?.toString() ?? ''),
  92. maxWithdrawAmount: Decimal.tryParse(json['maxWithdrawAmount']?.toString() ?? ''),
  93. minTxFee: Decimal.tryParse(json['minTxFee']?.toString() ?? ''),
  94. maxTxFee: Decimal.tryParse(json['maxTxFee']?.toString() ?? ''),
  95. fee: Decimal.tryParse(json['withdrawFeeValue']?.toString() ?? ''),
  96. );
  97. }
  98. }