diff --git a/lib/di.dart b/lib/di.dart index c10b8de5f..7ce2ff6d9 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -494,6 +494,7 @@ Future setup( getIt.get(), getIt.get().settingsStore, getIt.get(), + getIt.get(), )); getIt.registerFactory(() => ExchangeTradeViewModel( diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index e9c6b4234..744848156 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -111,6 +111,10 @@ class ExchangePage extends BasePage { WidgetsBinding.instance .addPostFrameCallback((_) => _setReactions(context, exchangeViewModel)); + if (exchangeViewModel.isLowFee) { + _showFeeAlert(context); + } + return KeyboardActions( disableScroll: true, config: KeyboardActionsConfig( @@ -794,5 +798,23 @@ class ExchangePage extends BasePage { return address; } + void _showFeeAlert(BuildContext context) async { + await Future.delayed(Duration(seconds: 1)); + final confirmed = await showPopUp( + context: context, + builder: (dialogContext) { + return AlertWithTwoActions( + alertTitle: S.of(context).low_fee, + alertContent: S.of(context).low_fee_alert, + leftButtonText: S.of(context).ignor, + rightButtonText: S.of(context).use_suggested, + actionLeftButton: () => Navigator.of(context).pop(false), + actionRightButton: () => Navigator.of(context).pop(true)); + }) ?? false; + if (confirmed) { + exchangeViewModel.setDefaultTransactionPriority(); + } + } + void disposeBestRateSync() => exchangeViewModel.bestRateSync?.cancel(); } diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 9af319e95..9ff690b70 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -6,6 +6,10 @@ import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart'; import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart'; import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart'; +import 'package:cake_wallet/view_model/settings/settings_view_model.dart'; +import 'package:cw_bitcoin/bitcoin_transaction_priority.dart'; +import 'package:cw_core/monero_transaction_priority.dart'; +import 'package:cw_core/transaction_priority.dart'; import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/crypto_currency.dart'; @@ -40,7 +44,7 @@ class ExchangeViewModel = ExchangeViewModelBase with _$ExchangeViewModel; abstract class ExchangeViewModelBase with Store { ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore, - this.tradesStore, this._settingsStore, this.sharedPreferences) + this.tradesStore, this._settingsStore, this.sharedPreferences, this._settingsViewModel) : _cryptoNumberFormat = NumberFormat(), isReverse = false, isFixedRateMode = false, @@ -192,6 +196,20 @@ abstract class ExchangeViewModelBase with Store { bool get isMoneroWallet => wallet.type == WalletType.monero; + bool get isLowFee { + switch (wallet.type) { + case WalletType.monero: + case WalletType.haven: + return _settingsViewModel.transactionPriority == MoneroTransactionPriority.slow; + case WalletType.bitcoin: + return _settingsViewModel.transactionPriority == BitcoinTransactionPriority.slow; + case WalletType.litecoin: + return _settingsViewModel.transactionPriority == LitecoinTransactionPriority.slow; + default: + return false; + } + } + List receiveCurrencies; List depositCurrencies; @@ -204,6 +222,8 @@ abstract class ExchangeViewModelBase with Store { final SettingsStore _settingsStore; + final SettingsViewModel _settingsViewModel; + double _bestRate = 0.0; late Timer bestRateSync; @@ -611,4 +631,22 @@ abstract class ExchangeViewModelBase with Store { selectedProviders .where((provider) => providersForCurrentPair().contains(provider))); } + + @action + void setDefaultTransactionPriority() { + switch (wallet.type) { + case WalletType.monero: + case WalletType.haven: + _settingsStore.priority[wallet.type] = MoneroTransactionPriority.automatic; + break; + case WalletType.bitcoin: + _settingsStore.priority[wallet.type] = BitcoinTransactionPriority.medium; + break; + case WalletType.litecoin: + _settingsStore.priority[wallet.type] = LitecoinTransactionPriority.medium; + break; + default: + break; + } + } } diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 7fb18e39b..a580ab90a 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -646,6 +646,10 @@ "remaining": "Rest", "delete_wallet": "Geldbörse löschen", "delete_wallet_confirm_message" : "Sind Sie sicher, dass Sie das ${wallet_name} Wallet löschen möchten?", + "low_fee": "Niedrige Gebühr", + "low_fee_alert": "Sie verwenden derzeit eine niedrige Netzwerkgebührenpriorität. Dies kann zu langen Wartezeiten, unterschiedlichen Kursen oder stornierten Trades führen. Wir empfehlen, für ein besseres Erlebnis eine höhere Gebühr festzulegen.", + "ignor": "Ignorieren", + "use_suggested": "Vorgeschlagen verwenden", "do_not_share_warning_text" : "Teilen Sie diese nicht mit anderen, einschließlich des Supports.\n\nSie werden Ihr Geld stehlen!", "help": "hilfe" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index bc93e5b45..877d09231 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -646,6 +646,10 @@ "remaining": "remaining", "delete_wallet": "Delete wallet", "delete_wallet_confirm_message" : "Are you sure that you want to delete ${wallet_name} wallet?", + "low_fee": "Low fee", + "low_fee_alert": "You currently are using a low network fee priority. This could cause long waits, different rates, or canceled trades. We recommend setting a higher fee for a better experience.", + "ignor": "Ignore", + "use_suggested": "Use Suggested", "do_not_share_warning_text" : "Do not share these with anyone else, including support.\n\nThey will steal your money!", "help": "help" } diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index d2201ed10..505f3ffa8 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -646,6 +646,10 @@ "remaining": "restante", "delete_wallet": "Eliminar billetera", "delete_wallet_confirm_message" : "¿Está seguro de que desea eliminar la billetera ${wallet_name}?", + "low_fee": "Tarifa baja", + "low_fee_alert": "Actualmente está utilizando una prioridad de tarifa de red baja. Esto podría causar largas esperas, tarifas diferentes o transacciones canceladas. Recomendamos establecer una tarifa más alta para una mejor experiencia.", + "ignor": "Pasar por alto", + "use_suggested": "Usar sugerido", "do_not_share_warning_text" : "No comparta estos con nadie más, incluido el soporte.\n\n¡Te robarán tu dinero!", "help": "ayuda" } diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 0eb4cccea..941016c0b 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -644,6 +644,10 @@ "remaining": "restant", "delete_wallet": "Supprimer le portefeuille", "delete_wallet_confirm_message" : "Êtes-vous sûr de vouloir supprimer le portefeuille ${wallet_name}?", + "low_fee": "Frais modiques", + "low_fee_alert": "Vous utilisez actuellement une priorité de frais de réseau peu élevés. Cela pourrait entraîner de longues attentes, des taux différents ou des transactions annulées. Nous vous recommandons de fixer des frais plus élevés pour une meilleure expérience.", + "ignor": "Ignorer", + "use_suggested": "Utilisation suggérée", "do_not_share_warning_text" : "Ne les partagez avec personne d'autre, y compris avec l'assistance.\n\nIls vont voler votre argent!", "help": "aider" } diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index df0c7cb63..7faa06f7f 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -646,6 +646,10 @@ "remaining": "शेष", "delete_wallet": "वॉलेट हटाएं", "delete_wallet_confirm_message" : "क्या आप वाकई ${wallet_name} वॉलेट हटाना चाहते हैं?", + "low_fee": "कम शुल्क", + "low_fee_alert": "आप वर्तमान में कम नेटवर्क शुल्क प्राथमिकता का उपयोग कर रहे हैं। यह लंबे इंतजार, अलग-अलग दरों या रद्द किए गए ट्रेडों का कारण बन सकता है। हम बेहतर अनुभव के लिए अधिक शुल्क निर्धारित करने की सलाह देते हैं।", + "ignor": "नज़रअंदाज़ करना", + "use_suggested": "सुझाए गए का प्रयोग करें", "do_not_share_warning_text" : "इन्हें समर्थन सहित किसी और के साथ साझा न करें।\n\nवे आपका पैसा चुरा लेंगे!", "help": "मदद करना" } diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 27c5aaaa0..4fa77948a 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -646,6 +646,10 @@ "remaining": "preostalo", "delete_wallet": "Izbriši novčanik", "delete_wallet_confirm_message" : "Jeste li sigurni da želite izbrisati ${wallet_name} novčanik?", + "low_fee": "Niska naknada", + "low_fee_alert": "Trenutačno koristite niski prioritet mrežne naknade. To bi moglo uzrokovati duga čekanja, različite tečajeve ili otkazane trgovine. Preporučujemo postavljanje veće naknade za bolje iskustvo.", + "ignor": "Zanemariti", + "use_suggested": "Koristite predloženo", "do_not_share_warning_text" : "Nemojte ih dijeliti ni s kim, uključujući podršku.\n\nUkrast će vam novac!", "help": "pomozite" } diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index f4b06f9c7..9a42a588b 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -646,6 +646,10 @@ "remaining": "rimanente", "delete_wallet": "Elimina portafoglio", "delete_wallet_confirm_message" : "Sei sicuro di voler eliminare il portafoglio ${wallet_name}?", + "low_fee": "Tariffa bassa", + "low_fee_alert": "Attualmente stai utilizzando una priorità a tariffa di rete bassa. Ciò potrebbe causare lunghe attese, tariffe diverse o operazioni annullate. Ti consigliamo di impostare una tariffa più alta per un'esperienza migliore.", + "ignor": "Ignorare", + "use_suggested": "Usa suggerito", "do_not_share_warning_text" : "Non condividerli con nessun altro, incluso il supporto.\n\nTi ruberanno i soldi!", "help": "aiuto" } diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 2b43999fe..c1d0de4e3 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -646,6 +646,10 @@ "remaining": "残り", "delete_wallet": "ウォレットを削除", "delete_wallet_confirm_message" : "${wallet_name} ウォレットを削除してもよろしいですか?", + "low_fee": "低料金", + "low_fee_alert": "現在、低ネットワーク料金優先度を使用しています。これにより、長い待ち時間、異なるレート、またはキャンセルされた取引が発生する可能性があります。より良い体験のために、より高い料金を設定することをお勧めします。", + "ignor": "無視", + "use_suggested": "推奨を使用", "do_not_share_warning_text" : "サポートを含め、これらを他の誰とも共有しないでください。\n\n彼らはあなたのお金を盗みます!", "help": "ヘルプ" } diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 91cef97d4..127aa949e 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -646,6 +646,10 @@ "remaining": "남은", "delete_wallet": "지갑 삭제", "delete_wallet_confirm_message" : "${wallet_name} 지갑을 삭제하시겠습니까?", + "low_fee": "낮은 수수료", + "low_fee_alert": "현재 낮은 네트워크 요금 우선 순위를 사용하고 있습니다. 이로 인해 긴 대기 시간, 다른 요금 또는 취소된 거래가 발생할 수 있습니다. 더 나은 경험을 위해 더 높은 요금을 설정하는 것이 좋습니다.", + "ignor": "무시하다", + "use_suggested": "추천 사용", "do_not_share_warning_text" : "지원을 포함하여 다른 사람과 이러한 정보를 공유하지 마십시오.\n\n그들은 당신의 돈을 훔칠 것입니다!", "help": "돕다" } diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 84b34cba5..bc53337a8 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -646,6 +646,10 @@ "remaining": "resterende", "delete_wallet": "Portemonnee verwijderen", "delete_wallet_confirm_message" : "Weet u zeker dat u de portemonnee van ${wallet_name} wilt verwijderen?", + "low_fee": "Lage vergoeding", + "low_fee_alert": "U gebruikt momenteel een lage prioriteit voor netwerkkosten. Dit kan lange wachttijden, andere tarieven of geannuleerde transacties veroorzaken. We raden aan een hogere vergoeding in te stellen voor een betere ervaring.", + "ignor": "Negeren", + "use_suggested": "Gebruik aanbevolen", "do_not_share_warning_text" : "Deel deze met niemand anders, ook niet met support.\n\nZe zullen je geld stelen!", "help": "helpen" } diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 245d48d3e..454fe9717 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -646,6 +646,10 @@ "remaining": "pozostałe", "delete_wallet": "Usuń portfel", "delete_wallet_confirm_message" : "Czy na pewno chcesz usunąć portfel ${wallet_name}?", + "low_fee": "Niska opłata", + "low_fee_alert": "Obecnie korzystasz z niskiego priorytetu opłaty sieciowej. Może to spowodować długie oczekiwanie, różne stawki lub anulowane transakcje. Zalecamy ustawienie wyższej opłaty, aby zapewnić lepsze wrażenia.", + "ignor": "Ignorować", + "use_suggested": "Użyj sugerowane", "do_not_share_warning_text" : "Nie udostępniaj ich nikomu innemu, w tym wsparcia.\n\nUkradną twoje pieniądze!", "help": "pomoc" } diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index e6b09a323..04a0a3ff2 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -646,6 +646,10 @@ "remaining": "restante", "delete_wallet": "Excluir carteira", "delete_wallet_confirm_message" : "Tem certeza de que deseja excluir a carteira ${wallet_name}?", + "low_fee": "Taxa baixa", + "low_fee_alert": "No momento, você está usando uma prioridade de taxa de rede baixa. Isso pode causar longas esperas, taxas diferentes ou negociações canceladas. Recomendamos definir uma taxa mais alta para uma melhor experiência.", + "ignor": "Ignorar", + "use_suggested": "Uso sugerido", "do_not_share_warning_text" : "Não os compartilhe com mais ninguém, incluindo suporte.\n\nEles vão roubar seu dinheiro!", "help": "ajuda" } diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index c3c832b36..632b0990c 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -646,6 +646,10 @@ "remaining": "осталось", "delete_wallet": "Удалить кошелек", "delete_wallet_confirm_message" : "Вы уверены, что хотите удалить кошелек ${wallet_name}?", + "low_fee": "Низкая комиссия", + "low_fee_alert": "В настоящее время вы используете низкий приоритет платы за сеть. Это может привести к длительному ожиданию, изменению ставок или отмене сделок. Мы рекомендуем установить более высокую плату для лучшего опыта.", + "ignor": "Игнорировать", + "use_suggested": "Использовать предложенный", "do_not_share_warning_text" : "Не делитесь ими с кем-либо еще, в том числе со службой поддержки.\n\nОни украдут ваши деньги!", "help": "помощь" } diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index 424f2567e..5e0f0d18a 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -645,6 +645,10 @@ "remaining": "залишилося", "delete_wallet": "Видалити гаманець", "delete_wallet_confirm_message" : "Ви впевнені, що хочете видалити гаманець ${wallet_name}?", + "low_fee": "Низька плата", + "low_fee_alert": "Зараз ви використовуєте низький пріоритет плати за мережу. Це може спричинити тривале очікування, інший курс або скасування угод. Ми рекомендуємо встановити вищу плату для кращого досвіду.", + "ignor": "Ігнорувати", + "use_suggested": "Використати запропоноване", "do_not_share_warning_text" : "Не повідомляйте їх нікому, включно зі службою підтримки.\n\nВони вкрадуть ваші гроші!", "help": "допомога" } diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 5aba482a4..c46d07d59 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -644,6 +644,10 @@ "remaining": "剩余", "delete_wallet": "删除钱包", "delete_wallet_confirm_message" : "您确定要删除 ${wallet_name} 钱包吗?", + "low_fee": "费用低", + "low_fee_alert": "您当前正在使用低网络费用优先级。这可能会导致长时间等待、不同的费率或取消交易。我们建议设置更高的费用以获得更好的体验。", + "ignor": "忽视", + "use_suggested": "使用建议", "do_not_share_warning_text" : "不要與其他任何人分享這些內容,包括支持。\n\n他們會偷你的錢!", "help": "帮助" }