CW-687 Coin control fixes (#2058)

* fix coin control

* don't reselect frozen coins
This commit is contained in:
Matthew Fosse 2025-03-03 17:38:00 -08:00 committed by GitHub
parent de40b2f9aa
commit 0c14c0b1f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 9 deletions

View file

@ -102,7 +102,9 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
outputs
.add(Output(wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency));
unspentCoinsListViewModel.initialSetup();
unspentCoinsListViewModel.initialSetup().then((_) {
unspentCoinsListViewModel.resetUnspentCoinsInfoSelections();
});
}
@observable
@ -728,11 +730,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
return S.current.insufficient_funds_for_tx;
}
return
'''${S.current.insufficient_funds_for_tx} \n\n'''
'''${S.current.balance}: ${parsedErrorMessageResult.balanceEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.balanceUsd} ${fiatFromSettings.name})\n\n'''
'''${S.current.transaction_cost}: ${parsedErrorMessageResult.txCostEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.txCostUsd} ${fiatFromSettings.name})\n\n'''
'''${S.current.overshot}: ${parsedErrorMessageResult.overshotEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.overshotUsd} ${fiatFromSettings.name})''';
return '''${S.current.insufficient_funds_for_tx} \n\n'''
'''${S.current.balance}: ${parsedErrorMessageResult.balanceEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.balanceUsd} ${fiatFromSettings.name})\n\n'''
'''${S.current.transaction_cost}: ${parsedErrorMessageResult.txCostEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.txCostUsd} ${fiatFromSettings.name})\n\n'''
'''${S.current.overshot}: ${parsedErrorMessageResult.overshotEth} ${walletType == WalletType.polygon ? "POL" : "ETH"} (${parsedErrorMessageResult.overshotUsd} ${fiatFromSettings.name})''';
}
return errorMessage;

View file

@ -68,7 +68,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
bool get hasAdjustableFieldChanged => items.any(_hasAdjustableFieldChanged);
Future<void> saveUnspentCoinInfo(UnspentCoinsItem item) async {
try {
final existingInfo = _unspentCoinsInfo.values
@ -79,7 +78,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
existingInfo.isSending = item.isSending;
existingInfo.note = item.note;
await existingInfo.save();
_updateUnspentCoinsInfo();
} catch (e) {
@ -167,6 +165,17 @@ abstract class UnspentCoinsListViewModelBase with Store {
items.addAll(unspents);
}
@action
void resetUnspentCoinsInfoSelections() {
// reset all unspent coins selections to true except frozen ones
for (final item in items) {
if (!item.isFrozen) {
item.isSending = true;
saveUnspentCoinInfo(item);
}
}
}
@action
void toggleSelectAll(bool value) {
for (final item in items) {