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) {