experiment with view model code

This commit is contained in:
Czarek Nakamoto 2024-10-20 18:58:49 +02:00
parent eb52baff41
commit 8597ab7652
No known key found for this signature in database
GPG key ID: 04FB77CB56AB1DF4

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/contact.dart';
import 'package:cake_wallet/entities/priority_for_wallet_type.dart';
import 'package:cake_wallet/entities/transaction_description.dart';
@ -16,6 +17,7 @@ import 'package:cake_wallet/tron/tron.dart';
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
import 'package:cake_wallet/wownero/wownero.dart';
import 'package:cw_core/exceptions.dart';
import 'package:cw_core/transaction_info.dart';
@ -501,6 +503,17 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
throw Exception('Priority is null for wallet type: ${wallet.type}');
}
if (hasCoinControl) {
final vm = getIt.get<UnspentCoinsListViewModel>(param1: coinTypeToSpendFrom);
bool isCoinSelected = false;
for (var coin in vm.items) {
isCoinSelected = isCoinSelected || (coin.isSending && !coin.isFrozen);
}
if (!isCoinSelected) {
throw Exception("No coin selected in coin control, you need to select a coin in order to spend");
}
}
switch (wallet.type) {
case WalletType.bitcoin:
case WalletType.litecoin: