2024-03-16 10:55:03 +00:00
|
|
|
import 'package:cw_core/pending_transaction.dart';
|
2023-12-16 08:49:23 +00:00
|
|
|
import 'package:cw_zano/api/model/destination.dart';
|
|
|
|
import 'package:cw_zano/api/model/transfer_result.dart';
|
2024-03-16 10:55:03 +00:00
|
|
|
import 'package:cw_zano/zano_formatter.dart';
|
2023-12-16 08:49:23 +00:00
|
|
|
import 'package:cw_zano/zano_wallet.dart';
|
2023-10-02 14:17:35 +00:00
|
|
|
|
|
|
|
class PendingZanoTransaction with PendingTransaction {
|
2024-03-08 10:50:34 +00:00
|
|
|
PendingZanoTransaction({
|
|
|
|
required this.zanoWallet,
|
|
|
|
required this.destinations,
|
|
|
|
required this.fee,
|
|
|
|
required this.comment,
|
2024-03-16 10:55:03 +00:00
|
|
|
required this.assetId,
|
|
|
|
required this.ticker,
|
2024-03-18 12:15:54 +00:00
|
|
|
this.decimalPoint = ZanoFormatter.defaultDecimalPoint,
|
2024-03-16 10:55:03 +00:00
|
|
|
required this.amount,
|
2024-03-08 10:50:34 +00:00
|
|
|
});
|
2023-10-02 14:17:35 +00:00
|
|
|
|
2023-12-16 12:19:11 +00:00
|
|
|
final ZanoWalletBase zanoWallet;
|
2024-03-08 10:50:34 +00:00
|
|
|
final List<Destination> destinations;
|
2024-03-16 10:55:03 +00:00
|
|
|
final BigInt fee;
|
2023-12-16 08:49:23 +00:00
|
|
|
final String comment;
|
2024-03-16 10:55:03 +00:00
|
|
|
final String assetId;
|
|
|
|
final String ticker;
|
|
|
|
final int decimalPoint;
|
|
|
|
final BigInt amount;
|
2023-12-16 08:49:23 +00:00
|
|
|
|
2023-10-02 14:17:35 +00:00
|
|
|
@override
|
2024-03-08 10:50:34 +00:00
|
|
|
String get id => transferResult?.txHash ?? '';
|
2023-10-02 14:17:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String get hex => '';
|
|
|
|
|
|
|
|
@override
|
2024-03-16 10:55:03 +00:00
|
|
|
String get amountFormatted => '${ZanoFormatter.bigIntAmountToString(amount, decimalPoint)} $ticker';
|
2023-10-02 14:17:35 +00:00
|
|
|
|
|
|
|
@override
|
2024-03-16 10:55:03 +00:00
|
|
|
String get feeFormatted => '${ZanoFormatter.bigIntAmountToString(fee)} ZANO';
|
2023-12-16 08:49:23 +00:00
|
|
|
|
|
|
|
TransferResult? transferResult;
|
2023-10-02 14:17:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> commit() async {
|
2024-04-03 15:14:53 +00:00
|
|
|
await zanoWallet.transfer(destinations, fee, comment);
|
|
|
|
await zanoWallet.fetchTransactions();
|
2023-10-02 14:17:35 +00:00
|
|
|
}
|
|
|
|
}
|