diff --git a/cw_bitcoin/lib/electrum_fee_estimate.dart b/cw_bitcoin/lib/electrum_fee_estimate.dart index dc621d739..22e7c130f 100644 --- a/cw_bitcoin/lib/electrum_fee_estimate.dart +++ b/cw_bitcoin/lib/electrum_fee_estimate.dart @@ -8,13 +8,13 @@ class ElectrumFeeEstimate extends FeeEstimate { ElectrumWalletBase _wallet; - int get({TransactionPriority priority, int amount, int outputsCount}) { + int get({TransactionPriority? priority, int? amount, int? outputsCount}) { // Electrum doesn't require an async call to obtain the estimated fee. // We don't bother caching and just obtain it directly. return _wallet.calculateEstimatedFee(priority,amount, outputsCount: outputsCount); } - void update({TransactionPriority priority, int amount, int outputsCount}) {} + void update({TransactionPriority? priority, int? amount, int? outputsCount}) {} - void set({TransactionPriority priority, int outputsCount, int fee}) {} + void set({TransactionPriority? priority, int? outputsCount, int? fee}) {} } \ No newline at end of file diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index fcb6e5269..82c4e205f 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -68,12 +68,12 @@ abstract class ElectrumWalletBase extends WalletBase @@ -98,7 +98,7 @@ abstract class ElectrumWalletBase extends WalletBase get scriptHashes => walletAddresses.addresses .map((addr) => scriptHash(addr.address, networkType: networkType)) diff --git a/cw_core/lib/fee_estimate.dart b/cw_core/lib/fee_estimate.dart index 862040745..d577d2e09 100644 --- a/cw_core/lib/fee_estimate.dart +++ b/cw_core/lib/fee_estimate.dart @@ -2,9 +2,9 @@ import 'package:cw_core/transaction_priority.dart'; abstract class FeeEstimate { - void update({TransactionPriority priority, int outputsCount}); + void update({required TransactionPriority priority, int outputsCount = 1}); - int get({TransactionPriority priority, int amount, int outputsCount}); + int get({required TransactionPriority priority, required int amount, int outputsCount = 1}); - void set({TransactionPriority priority, int outputsCount, int fee}); + void set({required TransactionPriority priority, required int outputsCount, required int fee}); } \ No newline at end of file diff --git a/cw_haven/lib/api/wallet.dart b/cw_haven/lib/api/wallet.dart index db6163afe..3abb6e9c0 100644 --- a/cw_haven/lib/api/wallet.dart +++ b/cw_haven/lib/api/wallet.dart @@ -366,6 +366,6 @@ int _estimateTransactionFee(Map args) { return estimateTransactionFeeSync(outputsCount, priorityRaw); } -Future estimateTransactionFee({int priorityRaw, int outputsCount}) { +Future estimateTransactionFee({required int priorityRaw, required int outputsCount}) { return compute(_estimateTransactionFee, {'priorityRaw': priorityRaw, 'outputsCount': outputsCount}); } \ No newline at end of file diff --git a/cw_haven/lib/haven_fee_estimate.dart b/cw_haven/lib/haven_fee_estimate.dart index 826690887..80ed775a6 100644 --- a/cw_haven/lib/haven_fee_estimate.dart +++ b/cw_haven/lib/haven_fee_estimate.dart @@ -15,7 +15,7 @@ abstract class _HavenFeeEstimate extends FeeEstimate with Store { ObservableMap _estimatedFee; @override - void update({TransactionPriority priority, int outputsCount}) { + void update({required TransactionPriority priority, int outputsCount = 1}) { Future(() async { final fee = await haven_wallet.estimateTransactionFee(priorityRaw: priority.raw, outputsCount: outputsCount); set(priority: priority, fee: fee, outputsCount: outputsCount); @@ -23,12 +23,12 @@ abstract class _HavenFeeEstimate extends FeeEstimate with Store { } @override - int get({TransactionPriority priority, int amount, int outputsCount}) { + int get({required TransactionPriority priority, required int amount, int outputsCount = 1}) { return _estimatedFee[_key(priority, outputsCount)] ?? 0; } @override - void set({TransactionPriority priority, int outputsCount, int fee}) { + void set({required TransactionPriority priority, required int outputsCount, required int fee}) { _estimatedFee[_key(priority, outputsCount)] = fee; } diff --git a/cw_haven/lib/haven_wallet.dart b/cw_haven/lib/haven_wallet.dart index e6c18edce..646ac199f 100644 --- a/cw_haven/lib/haven_wallet.dart +++ b/cw_haven/lib/haven_wallet.dart @@ -42,6 +42,7 @@ abstract class HavenWalletBase extends WalletBase walletAddresses.account, @@ -52,7 +53,6 @@ abstract class HavenWalletBase extends WalletBase estimateTransactionFee({int priorityRaw, int outputsCount}) { - return compute(_estimateTransactionFee, {'priorityRaw': priorityRaw, 'outputsCount': outputsCount}); +Future estimateTransactionFee({required int priorityRaw, int? outputsCount}) { + return compute(_estimateTransactionFee, {'priorityRaw': priorityRaw, 'outputsCount': outputsCount ?? 1}); } \ No newline at end of file diff --git a/cw_monero/lib/monero_fee_estimate.dart b/cw_monero/lib/monero_fee_estimate.dart index c32ad3bf2..db9904958 100644 --- a/cw_monero/lib/monero_fee_estimate.dart +++ b/cw_monero/lib/monero_fee_estimate.dart @@ -15,7 +15,7 @@ abstract class _MoneroFeeEstimate extends FeeEstimate with Store { ObservableMap _estimatedFee; @override - void update({TransactionPriority priority, int outputsCount}) { + void update({required TransactionPriority priority, int outputsCount = 1}) { Future(() async { final fee = await monero_wallet.estimateTransactionFee(priorityRaw: priority.raw, outputsCount: outputsCount); set(priority: priority, fee: fee, outputsCount: outputsCount); @@ -23,12 +23,12 @@ abstract class _MoneroFeeEstimate extends FeeEstimate with Store { } @override - int get({TransactionPriority priority, int amount, int outputsCount}) { + int get({required TransactionPriority priority, required int amount, int outputsCount = 1}) { return _estimatedFee[_key(priority, outputsCount)] ?? 0; } @override - void set({TransactionPriority priority, int outputsCount, int fee}) { + void set({required TransactionPriority priority, required int outputsCount, required int fee}) { _estimatedFee[_key(priority, outputsCount)] = fee; } diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 89b257dd3..a32288d43 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -1,4 +1,6 @@ import 'dart:async'; +import 'package:cw_core/monero_balance.dart'; +import 'package:cw_core/monero_wallet_keys.dart'; import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/monero_amount_format.dart'; import 'package:cw_monero/monero_transaction_creation_exception.dart'; @@ -16,8 +18,6 @@ import 'package:cw_monero/api/transaction_history.dart' as transaction_history; import 'package:cw_monero/api/monero_output.dart'; import 'package:cw_monero/monero_transaction_creation_credentials.dart'; import 'package:cw_monero/pending_monero_transaction.dart'; -import 'package:cw_monero/monero_wallet_keys.dart'; -import 'package:cw_monero/monero_balance.dart'; import 'package:cw_monero/monero_fee_estimate.dart'; import 'package:cw_monero/monero_transaction_history.dart'; import 'package:cw_core/account.dart'; @@ -26,7 +26,6 @@ import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/node.dart'; -import 'package:cw_core/monero_transaction_priority.dart'; import 'package:cw_core/crypto_currency.dart'; part 'monero_wallet.g.dart'; @@ -47,6 +46,7 @@ abstract class MoneroWalletBase extends WalletBase walletAddresses.account, @@ -64,7 +64,6 @@ abstract class MoneroWalletBase extends WalletBase fetchParsedAddress(BuildContext context) async { diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index ff77ab892..93476c6e1 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -54,7 +54,9 @@ abstract class SendViewModelBase with Store { outputs.add(Output(_wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency)); _settingsStore.priority.observe((change) async { - _wallet.feeEstimate.update(priority: change.newValue, outputsCount: outputs.length); + if (change.newValue != null) { + _wallet.feeEstimate.update(priority: change.newValue!, outputsCount: outputs.length); + } }); estimateFee(); @@ -90,7 +92,7 @@ abstract class SendViewModelBase with Store { String get pendingTransactionFiatAmount { try { if (pendingTransaction != null) { - return _calculateFiatAmount(pendingTransaction.amountFormatted); + return _calculateFiatAmount(pendingTransaction!.amountFormatted); } else { return '0.00'; } @@ -103,7 +105,7 @@ abstract class SendViewModelBase with Store { String get pendingTransactionFeeFiatAmount { try { if (pendingTransaction != null) { - return _calculateFiatAmount(pendingTransaction.feeFormatted); + return _calculateFiatAmount(pendingTransaction!.feeFormatted); } else { return '0.00'; } @@ -292,7 +294,7 @@ abstract class SendViewModelBase with Store { currency.toLowerCase() == _wallet.currency.title.toLowerCase(); void estimateFee() { - _wallet.feeEstimate.update(priority: _settingsStore.priority[_wallet.type], outputsCount: outputs.length); + _wallet.feeEstimate.update(priority: _settingsStore.priority[_wallet.type]!, outputsCount: outputs.length); } @computed @@ -304,7 +306,7 @@ abstract class SendViewModelBase with Store { } final fee = _wallet.feeEstimate.get( - priority: _settingsStore.priority[_wallet.type], + priority: _settingsStore.priority[_wallet.type]!, amount: totalFormattedCryptoAmount, outputsCount: outputs.length, );