diff --git a/cw_bitcoin_cash/lib/src/bitcoin_cash_transaction_priority.dart b/cw_bitcoin_cash/lib/src/bitcoin_cash_transaction_priority.dart index 971480270..a3a1c4729 100644 --- a/cw_bitcoin_cash/lib/src/bitcoin_cash_transaction_priority.dart +++ b/cw_bitcoin_cash/lib/src/bitcoin_cash_transaction_priority.dart @@ -1,9 +1,52 @@ import 'package:cw_core/transaction_priority.dart'; -class BitcoinCashTransactionPriority extends TransactionPriority{ - BitcoinCashTransactionPriority({required super.title, required super.raw}); +class BitcoinCashTransactionPriority extends TransactionPriority { + const BitcoinCashTransactionPriority({required String title, required int raw}) + : super(title: title, raw: raw); - static BitcoinCashTransactionPriority deserialize ({required int raw}) { - throw UnimplementedError('BitcoinCashTransactionPriority.deserialize() is not implemented'); + static const List all = [fast, medium, slow]; + static const BitcoinCashTransactionPriority slow = + BitcoinCashTransactionPriority(title: 'Slow', raw: 0); + static const BitcoinCashTransactionPriority medium = + BitcoinCashTransactionPriority(title: 'Medium', raw: 1); + static const BitcoinCashTransactionPriority fast = + BitcoinCashTransactionPriority(title: 'Fast', raw: 2); + + static BitcoinCashTransactionPriority deserialize({required int raw}) { + switch (raw) { + case 0: + return slow; + case 1: + return medium; + case 2: + return fast; + default: + throw Exception('Unexpected token: $raw for BitcoinTransactionPriority deserialize'); + } } -} \ No newline at end of file + + String get units => 'sat'; + + @override + String toString() { + var label = ''; + + switch (this) { + case BitcoinCashTransactionPriority.slow: + label = 'Slow ~24hrs'; // '${S.current.transaction_priority_slow} ~24hrs'; + break; + case BitcoinCashTransactionPriority.medium: + label = 'Medium'; // S.current.transaction_priority_medium; + break; + case BitcoinCashTransactionPriority.fast: + label = 'Fast'; // S.current.transaction_priority_fast; + break; + default: + break; + } + + return label; + } + + String labelWithRate(int rate) => '${toString()} ($rate ${units}/byte)'; +} diff --git a/lib/bitcoin_cash/cw_bitcoin_cash.dart b/lib/bitcoin_cash/cw_bitcoin_cash.dart index 8d9b014ef..50643a492 100644 --- a/lib/bitcoin_cash/cw_bitcoin_cash.dart +++ b/lib/bitcoin_cash/cw_bitcoin_cash.dart @@ -31,6 +31,8 @@ class CWBitcoinCash extends BitcoinCash { BitcoinCashTransactionPriority.deserialize(raw: raw); @override - TransactionPriority getDefaultTransactionPriority() => - throw UnimplementedError('getDefaultTransactionPriority'); + TransactionPriority getDefaultTransactionPriority() => BitcoinCashTransactionPriority.medium; + + @override + List getTransactionPriorities() => BitcoinCashTransactionPriority.all; } diff --git a/lib/entities/priority_for_wallet_type.dart b/lib/entities/priority_for_wallet_type.dart index eb9417763..65aefc930 100644 --- a/lib/entities/priority_for_wallet_type.dart +++ b/lib/entities/priority_for_wallet_type.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart'; +import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/haven/haven.dart'; import 'package:cake_wallet/monero/monero.dart'; @@ -17,6 +18,8 @@ List priorityForWalletType(WalletType type) { return haven!.getTransactionPriorities(); case WalletType.ethereum: return ethereum!.getTransactionPriorities(); + case WalletType.bitcoinCash: + return bitcoinCash!.getTransactionPriorities(); default: return []; } diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index 177293e8c..aecec7af5 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -51,7 +51,6 @@ class WalletListBodyState extends State { } final path = walletTypeToCryptoCurrency(type).iconPath ?? nonWalletTypeIconPath; - print('path: $path type: $type'); return Image.asset(path, height: 24, width: 24); } diff --git a/tool/configure.dart b/tool/configure.dart index 11f70430d..88d7d6e8c 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -594,6 +594,8 @@ abstract class BitcoinCash { TransactionPriority deserializeBitcoinCashTransactionPriority(int raw); TransactionPriority getDefaultTransactionPriority(); + + List getTransactionPriorities(); } """;