Add adapters for some of bitcoin, litecoin and monero transactions priorities. Replace direct calls of transaction priorities for exchange_view_model. (#593)

This commit is contained in:
mkyq 2022-11-03 19:13:13 -04:00 committed by GitHub
parent 8683b0f435
commit 3ec414ae66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 8 deletions

View file

@ -140,4 +140,20 @@ class CWBitcoin extends Bitcoin {
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) { WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource) {
return LitecoinWalletService(walletInfoSource, unspentCoinSource); return LitecoinWalletService(walletInfoSource, unspentCoinSource);
} }
@override
TransactionPriority getBitcoinTransactionPriorityMedium()
=> BitcoinTransactionPriority.medium;
@override
TransactionPriority getLitecoinTransactionPriorityMedium()
=> LitecoinTransactionPriority.medium;
@override
TransactionPriority getBitcoinTransactionPrioritySlow()
=> BitcoinTransactionPriority.slow;
@override
TransactionPriority getLitecoinTransactionPrioritySlow()
=> LitecoinTransactionPriority.slow;
} }

View file

@ -170,6 +170,14 @@ class CWMonero extends Monero {
return MoneroTransactionPriority.automatic; return MoneroTransactionPriority.automatic;
} }
@override
TransactionPriority getMoneroTransactionPrioritySlow()
=> MoneroTransactionPriority.slow;
@override
TransactionPriority getMoneroTransactionPriorityAutomatic()
=> MoneroTransactionPriority.automatic;
@override @override
TransactionPriority deserializeMoneroTransactionPriority({required int raw}) { TransactionPriority deserializeMoneroTransactionPriority({required int raw}) {
return MoneroTransactionPriority.deserialize(raw: raw); return MoneroTransactionPriority.deserialize(raw: raw);

View file

@ -7,8 +7,6 @@ import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart'
import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart'; import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart'; import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart';
import 'package:cake_wallet/view_model/settings/settings_view_model.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:cw_core/transaction_priority.dart';
import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart'; import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart';
import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_base.dart';
@ -16,6 +14,7 @@ import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/sync_status.dart'; import 'package:cw_core/sync_status.dart';
import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/exchange/exchange_provider.dart'; import 'package:cake_wallet/exchange/exchange_provider.dart';
import 'package:cake_wallet/exchange/limits.dart'; import 'package:cake_wallet/exchange/limits.dart';
import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/exchange/trade.dart';
@ -200,11 +199,11 @@ abstract class ExchangeViewModelBase with Store {
switch (wallet.type) { switch (wallet.type) {
case WalletType.monero: case WalletType.monero:
case WalletType.haven: case WalletType.haven:
return _settingsViewModel.transactionPriority == MoneroTransactionPriority.slow; return _settingsViewModel.transactionPriority == monero!.getMoneroTransactionPrioritySlow();
case WalletType.bitcoin: case WalletType.bitcoin:
return _settingsViewModel.transactionPriority == BitcoinTransactionPriority.slow; return _settingsViewModel.transactionPriority == bitcoin!.getBitcoinTransactionPrioritySlow();
case WalletType.litecoin: case WalletType.litecoin:
return _settingsViewModel.transactionPriority == LitecoinTransactionPriority.slow; return _settingsViewModel.transactionPriority == bitcoin!.getLitecoinTransactionPrioritySlow();
default: default:
return false; return false;
} }
@ -637,13 +636,13 @@ abstract class ExchangeViewModelBase with Store {
switch (wallet.type) { switch (wallet.type) {
case WalletType.monero: case WalletType.monero:
case WalletType.haven: case WalletType.haven:
_settingsStore.priority[wallet.type] = MoneroTransactionPriority.automatic; _settingsStore.priority[wallet.type] = monero!.getMoneroTransactionPriorityAutomatic();
break; break;
case WalletType.bitcoin: case WalletType.bitcoin:
_settingsStore.priority[wallet.type] = BitcoinTransactionPriority.medium; _settingsStore.priority[wallet.type] = bitcoin!.getBitcoinTransactionPriorityMedium();
break; break;
case WalletType.litecoin: case WalletType.litecoin:
_settingsStore.priority[wallet.type] = LitecoinTransactionPriority.medium; _settingsStore.priority[wallet.type] = bitcoin!.getLitecoinTransactionPriorityMedium();
break; break;
default: default:
break; break;

View file

@ -92,6 +92,10 @@ abstract class Bitcoin {
void updateUnspents(Object wallet); void updateUnspents(Object wallet);
WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource); WalletService createBitcoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource); WalletService createLitecoinWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
TransactionPriority getBitcoinTransactionPriorityMedium();
TransactionPriority getLitecoinTransactionPriorityMedium();
TransactionPriority getBitcoinTransactionPrioritySlow();
TransactionPriority getLitecoinTransactionPrioritySlow();
} }
"""; """;
@ -218,6 +222,8 @@ abstract class Monero {
int getHeigthByDate({required DateTime date}); int getHeigthByDate({required DateTime date});
TransactionPriority getDefaultTransactionPriority(); TransactionPriority getDefaultTransactionPriority();
TransactionPriority getMoneroTransactionPrioritySlow();
TransactionPriority getMoneroTransactionPriorityAutomatic();
TransactionPriority deserializeMoneroTransactionPriority({required int raw}); TransactionPriority deserializeMoneroTransactionPriority({required int raw});
List<TransactionPriority> getTransactionPriorities(); List<TransactionPriority> getTransactionPriorities();
List<String> getMoneroWordList(String language); List<String> getMoneroWordList(String language);