Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CW-687 Coin control fixes #2058

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/view_model/send/send_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -809,4 +810,4 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor

return false;
}
}
}
13 changes: 11 additions & 2 deletions lib/view_model/unspent_coins/unspent_coins_list_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -79,7 +78,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
existingInfo.isSending = item.isSending;
existingInfo.note = item.note;


await existingInfo.save();
_updateUnspentCoinsInfo();
} catch (e) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading