| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- /// 链上充值父币种 — GET uc/coin-network/recharge-parents
- class RechargeParentCoin {
- final String name;
- final String nameCn;
- final String unit;
- final int status;
- final int canRecharge;
- final int sort;
- const RechargeParentCoin({
- required this.name,
- required this.nameCn,
- required this.unit,
- this.status = 0,
- this.canRecharge = 0,
- this.sort = 0,
- });
- factory RechargeParentCoin.fromJson(Map<String, dynamic> json) {
- return RechargeParentCoin(
- name: json['name']?.toString() ?? '',
- nameCn: json['nameCn']?.toString() ?? '',
- unit: json['unit']?.toString() ?? '',
- status: int.tryParse(json['status']?.toString() ?? '') ?? 0,
- canRecharge: int.tryParse(json['canRecharge']?.toString() ?? '') ?? 0,
- sort: int.tryParse(json['sort']?.toString() ?? '') ?? 0,
- );
- }
- }
- /// 充值主网 — GET uc/coin-network/recharge-networks
- class RechargeNetworkItem {
- final int id;
- final String name;
- final String protocol;
- final int? status;
- final int sort;
- const RechargeNetworkItem({
- required this.id,
- required this.name,
- required this.protocol,
- this.status,
- this.sort = 0,
- });
- factory RechargeNetworkItem.fromJson(Map<String, dynamic> json) {
- return RechargeNetworkItem(
- id: int.tryParse(json['id']?.toString() ?? '') ?? 0,
- name: json['name']?.toString() ?? '',
- protocol: json['protocol']?.toString() ?? '',
- status: json['status'] != null
- ? int.tryParse(json['status']?.toString() ?? '')
- : null,
- sort: int.tryParse(json['sort']?.toString() ?? '') ?? 0,
- );
- }
- }
- /// 某主网下 coin_network_config 一行 — GET uc/coin-network/recharge-configs
- class RechargeConfigOption {
- final int networkConfigId;
- final String coinName;
- final String coinNameCn;
- final int networkId;
- final String networkName;
- final String protocol;
- final String contractAddress;
- final String rechargeAddress;
- final int sort;
- const RechargeConfigOption({
- required this.networkConfigId,
- required this.coinName,
- required this.coinNameCn,
- required this.networkId,
- required this.networkName,
- required this.protocol,
- required this.contractAddress,
- required this.rechargeAddress,
- this.sort = 0,
- });
- factory RechargeConfigOption.fromJson(Map<String, dynamic> json) {
- final network = json['network'];
- return RechargeConfigOption(
- networkConfigId:
- int.tryParse(json['networkConfigId']?.toString() ?? json['id']?.toString() ?? '') ??
- 0,
- coinName: json['coinName']?.toString() ?? '',
- coinNameCn: json['coinNameCn']?.toString() ?? '',
- networkId: int.tryParse(json['networkId']?.toString() ??
- (network is Map ? network['id']?.toString() : null) ??
- '') ??
- 0,
- networkName: json['networkName']?.toString() ??
- (network is Map ? network['name']?.toString() : null) ??
- '',
- protocol: json['protocol']?.toString() ??
- (network is Map ? network['protocol']?.toString() : null) ??
- '',
- contractAddress: json['contractAddress']?.toString() ?? '',
- rechargeAddress: json['rechargeAddress']?.toString() ?? '',
- sort: int.tryParse(json['sort']?.toString() ?? '') ?? 0,
- );
- }
- bool get hasTokenContract => contractAddress.trim().isNotEmpty;
- }
- /// 扁平化后的充值网络选项(供钱包/EVM 工具使用,与 Web `RechargeFlatNetworkOption` 一致)
- class RechargeFlatNetworkOption {
- final String coinName;
- final String coinNameCn;
- final int networkConfigId;
- final int networkId;
- final String networkName;
- final String protocol;
- final String contractAddress;
- final String rechargeAddress;
- final int sort;
- const RechargeFlatNetworkOption({
- required this.coinName,
- required this.coinNameCn,
- required this.networkConfigId,
- required this.networkId,
- required this.networkName,
- required this.protocol,
- required this.contractAddress,
- required this.rechargeAddress,
- this.sort = 0,
- });
- factory RechargeFlatNetworkOption.fromConfig(RechargeConfigOption cfg) {
- return RechargeFlatNetworkOption(
- coinName: cfg.coinName,
- coinNameCn: cfg.coinNameCn,
- networkConfigId: cfg.networkConfigId,
- networkId: cfg.networkId,
- networkName: cfg.networkName,
- protocol: cfg.protocol,
- contractAddress: cfg.contractAddress,
- rechargeAddress: cfg.rechargeAddress,
- sort: cfg.sort,
- );
- }
- bool get hasTokenContract => contractAddress.trim().isNotEmpty;
- }
- /// 充值订单详情
- class RechargeOrderDetail {
- final int id;
- final String orderNo;
- final String coinName;
- final String networkName;
- final String rechargeAddress;
- final String amount;
- final String? txHash;
- final int status;
- final String createTime;
- const RechargeOrderDetail({
- this.id = 0,
- this.orderNo = '',
- this.coinName = '',
- this.networkName = '',
- this.rechargeAddress = '',
- this.amount = '0',
- this.txHash,
- this.status = 0,
- this.createTime = '',
- });
- factory RechargeOrderDetail.fromJson(Map<String, dynamic> json) {
- final th = json['txHash'];
- return RechargeOrderDetail(
- id: int.tryParse(json['id']?.toString() ?? '') ?? 0,
- orderNo: json['orderNo']?.toString() ?? '',
- coinName: json['coinName']?.toString() ?? '',
- networkName: json['networkName']?.toString() ?? '',
- rechargeAddress: json['rechargeAddress']?.toString() ?? '',
- amount: json['amount']?.toString() ?? '0',
- txHash: th != null && th.toString().isNotEmpty ? th.toString() : null,
- status: int.tryParse(json['status']?.toString() ?? '') ?? 0,
- createTime: json['createTime']?.toString() ?? '',
- );
- }
- bool get isPendingPayment => status == 0;
- }
|