From f85ec0631b083ce54dc7874d5cb24150331dfc09 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Tue, 26 Nov 2024 07:51:18 -0500 Subject: [PATCH] move view model into di.dart --- lib/di.dart | 1 + lib/view_model/send/send_view_model.dart | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index facdec912..be014f665 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -746,6 +746,7 @@ Future setup({ _transactionDescriptionBox, getIt.get().wallet!.isHardwareWallet ? getIt.get() : null, coinTypeToSpendFrom: coinTypeToSpendFrom ?? UnspentCoinType.any, + getIt.get(param1: coinTypeToSpendFrom), ), ); diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index dc215d3fe..69a500c9b 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -65,6 +65,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor wallet.type == WalletType.tron; } + UnspentCoinsListViewModel unspentCoinsListViewModel; + SendViewModelBase( AppStore appStore, this.sendTemplateViewModel, @@ -72,7 +74,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor this.balanceViewModel, this.contactListViewModel, this.transactionDescriptionBox, - this.ledgerViewModel, { + this.ledgerViewModel, + this.unspentCoinsListViewModel, { this.coinTypeToSpendFrom = UnspentCoinType.any, }) : state = InitialExecutionState(), currencies = appStore.wallet!.balance.keys.toList(), @@ -532,9 +535,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor } if (hasCoinControl) { - final vm = getIt.get(param1: coinTypeToSpendFrom); bool isCoinSelected = false; - for (var coin in vm.items) { + for (var coin in unspentCoinsListViewModel.items) { isCoinSelected = isCoinSelected || (coin.isSending && !coin.isFrozen); } if (!isCoinSelected) {