CAKE-299 | fixed bug for estimatedFee getter in the send_view_model.dart
OleksandrSobol committed
Mar 26, 2021 at 20:16 UTC
3839850f042973b58c173f4a5c551da7df1160c0
1 file changed
+28
-23
lib/view_model/send/send_view_model.dart
+28
-23
@@ -79,33 +79,38 @@ abstract class SendViewModelBase with Store {
79
double get estimatedFee {
80
int amount;
81
82
- if (cryptoAmount?.isNotEmpty ?? false) {
83
- int _amount = 0;
84
- switch (walletType) {
85
- case WalletType.monero:
86
- _amount = moneroParseAmount(amount: cryptoAmount);
87
- break;
88
- case WalletType.bitcoin:
89
- _amount = stringDoubleToBitcoinAmount(cryptoAmount);
90
- break;
91
- default:
92
- break;
93
- }
94
-
95
- if (_amount > 0) {
96
- amount = _amount;
82
+ try {
83
+ if (cryptoAmount?.isNotEmpty ?? false) {
84
+ final _cryptoAmount = cryptoAmount.replaceAll(',', '.');
85
+ int _amount = 0;
86
+ switch (walletType) {
87
+ case WalletType.monero:
88
+ _amount = moneroParseAmount(amount: _cryptoAmount);
89
+ break;
90
+ case WalletType.bitcoin:
91
+ _amount = stringDoubleToBitcoinAmount(_cryptoAmount);
92
+ break;
93
+ default:
94
+ break;
95
+ }
96
+
97
+ if (_amount > 0) {
98
+ amount = _amount;
99
+ }
100
}
98
- }
101
100
- final fee = _wallet.calculateEstimatedFee(
101
- _settingsStore.priority[_wallet.type], amount);
102
+ final fee = _wallet.calculateEstimatedFee(
103
+ _settingsStore.priority[_wallet.type], amount);
104
103
- if (_wallet is BitcoinWallet) {
104
- return bitcoinAmountToDouble(amount: fee);
105
- }
105
+ if (_wallet is BitcoinWallet) {
106
+ return bitcoinAmountToDouble(amount: fee);
107
+ }
108
107
- if (_wallet is MoneroWallet) {
108
- return moneroAmountToDouble(amount: fee);
109
+ if (_wallet is MoneroWallet) {
110
+ return moneroAmountToDouble(amount: fee);
111
+ }
112
+ } catch (e) {
113
+ print(e.toString());
114
}
115
116
return 0;