| 1 | import 'package:cw_core/amount/money.dart'; |
| 2 | import 'package:cw_core/pending_transaction.dart'; |
| 3 | import 'package:cw_zano/api/model/destination.dart'; |
| 4 | import 'package:cw_zano/api/model/transfer_result.dart'; |
| 5 | import 'package:cw_zano/zano_wallet.dart'; |
| 6 | |
| 7 | class PendingZanoTransaction with PendingTransaction { |
| 8 | PendingZanoTransaction({ |
| 9 | required this.zanoWallet, |
| 10 | required this.destinations, |
| 11 | required this.fee, |
| 12 | required this.comment, |
| 13 | required this.assetId, |
| 14 | required this.amount, |
| 15 | }); |
| 16 | |
| 17 | final ZanoWalletBase zanoWallet; |
| 18 | final List<Destination> destinations; |
| 19 | final String comment; |
| 20 | final String assetId; |
| 21 | |
| 22 | @override |
| 23 | final Money amount; |
| 24 | |
| 25 | @override |
| 26 | final Money fee; |
| 27 | |
| 28 | @override |
| 29 | String get id => transferResult?.txHash ?? ''; |
| 30 | |
| 31 | @override |
| 32 | String get hex => ''; |
| 33 | |
| 34 | @override |
| 35 | String get amountFormatted => amount.toString(); |
| 36 | |
| 37 | TransferResult? transferResult; |
| 38 | |
| 39 | @override |
| 40 | Future<void> commit() async { |
| 41 | transferResult = await zanoWallet.transfer(destinations, fee.amount, comment); |
| 42 | zanoWallet.fetchTransactions(); |
| 43 | } |
| 44 | |
| 45 | @override |
| 46 | Future<Map<String, String>> commitUR() => throw UnimplementedError(); |
| 47 | } |