Merge pull request #673 from cake-tech/set-default-values-for-transaction-priority

Validate bitcoin saved transaction priority
This commit is contained in:
Omar Hatem 2022-12-15 14:22:50 +02:00 committed by GitHub
commit 3d3c22c259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 17 deletions

View file

@ -21,22 +21,6 @@ class MoneroTransactionPriority extends TransactionPriority {
static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4);
static const standard = slow;
static List<MoneroTransactionPriority> forWalletType(WalletType type) {
switch (type) {
case WalletType.monero:
return MoneroTransactionPriority.all;
case WalletType.bitcoin:
return [
MoneroTransactionPriority.slow,
MoneroTransactionPriority.automatic,
MoneroTransactionPriority.fast
];
default:
return [];
}
}
static MoneroTransactionPriority deserialize({required int raw}) {
switch (raw) {
case 0:

View file

@ -139,6 +139,10 @@ Future defaultSettingsMigration(
await addOnionNode(nodes);
break;
case 19:
await validateBitcoinSavedTransactionPriority(sharedPreferences);
break;
default:
break;
}
@ -154,6 +158,18 @@ Future defaultSettingsMigration(
PreferencesKey.currentDefaultSettingsMigrationVersion, version);
}
Future<void> validateBitcoinSavedTransactionPriority(SharedPreferences sharedPreferences) async {
if (bitcoin == null) {
return;
}
final int? savedBitcoinPriority =
sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority);
if (!bitcoin!.getTransactionPriorities().any((element) => element.raw == savedBitcoinPriority)) {
await sharedPreferences.setInt(
PreferencesKey.bitcoinTransactionPriority, bitcoin!.getMediumTransactionPriority().serialize());
}
}
Future<void> addOnionNode(Box<Node> nodes) async {
final onionNodeUri = "cakexmrl7bonq7ovjka5kuwuyd3f7qnkz6z6s6dmsy3uckwra7bvggyd.onion:18081";

View file

@ -129,7 +129,7 @@ Future<void> main() async {
exchangeTemplates: exchangeTemplates,
transactionDescriptions: transactionDescriptions,
secureStorage: secureStorage,
initialMigrationVersion: 18);
initialMigrationVersion: 19);
runApp(App());
} catch (e, stacktrace) {
runApp(MaterialApp(