fix: Fix issue resulting in tron and solana not displaying estimated fees, also modify estimated fees to display directly instead of formatted display (e.g 0.00005237ETH instead of 5.237e-5 ETH) (#2640)
David Adegoke committed
Nov 7, 2025 at 16:29 UTC
be170b0d3f4a79be7c0e78927dea093d37fa4421
1 file changed
+33
-27
lib/view_model/send/output.dart
+33
-27
@@ -14,6 +14,7 @@ import 'package:cake_wallet/wownero/wownero.dart';
14
import 'package:cake_wallet/zano/zano.dart';
15
import 'package:cw_core/balance.dart';
16
import 'package:cw_core/crypto_currency.dart';
17
+import 'package:cw_core/format_fixed.dart';
18
import 'package:cw_core/transaction_history.dart';
19
import 'package:cw_core/transaction_info.dart';
20
import 'package:cw_core/utils/print_verbose.dart';
@@ -50,7 +51,7 @@ abstract class OutputBase with Store {
51
address = '',
52
note = '',
53
extractedAddress = '',
53
- estimatedFee = 0.0,
54
+ estimatedFee = '0.0',
55
parsedAddress = ParsedAddress(addresses: []) {
56
_setCryptoNumMaximumFractionDigits();
57
autorun((_) {
@@ -157,7 +158,7 @@ abstract class OutputBase with Store {
158
}
159
160
@observable
160
- double estimatedFee;
161
+ String estimatedFee;
162
163
@action
164
Future<void> calculateEstimatedFee() async {
@@ -166,14 +167,17 @@ abstract class OutputBase with Store {
167
await _wallet.updateEstimatedFeesParams(_settingsStore.priority[_wallet.type]!);
168
}
169
169
- int? fee = _wallet.calculateEstimatedFee(
170
- _settingsStore.priority[_wallet.type]!,
171
- formattedCryptoAmount,
172
- );
170
+ int fee = 0;
171
+ if (_settingsStore.priority[_wallet.type] != null) {
172
+ fee = _wallet.calculateEstimatedFee(
173
+ _settingsStore.priority[_wallet.type]!,
174
+ formattedCryptoAmount,
175
+ );
176
+ }
177
178
switch (_wallet.type) {
179
case WalletType.monero:
176
- estimatedFee = monero!.formatterMoneroAmountToDouble(amount: fee);
180
+ estimatedFee = monero!.formatterMoneroAmountToDouble(amount: fee).toString();
181
break;
182
case WalletType.bitcoin:
183
if (_settingsStore.priority[_wallet.type] ==
@@ -182,33 +186,33 @@ abstract class OutputBase with Store {
186
_wallet, _settingsStore.customBitcoinFeeRate, formattedCryptoAmount);
187
}
188
185
- estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
189
+ estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee).toString();
190
break;
191
case WalletType.litecoin:
192
case WalletType.bitcoinCash:
193
case WalletType.dogecoin:
190
- estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee);
194
+ estimatedFee = bitcoin!.formatterBitcoinAmountToDouble(amount: fee).toString();
195
break;
196
case WalletType.solana:
193
- estimatedFee = solana!.getEstimateFees(_wallet) ?? 0.0;
197
+ estimatedFee = solana!.getEstimateFees(_wallet).toString();
198
break;
199
case WalletType.wownero:
196
- estimatedFee = wownero!.formatterWowneroAmountToDouble(amount: fee);
200
+ estimatedFee = wownero!.formatterWowneroAmountToDouble(amount: fee).toString();
201
break;
202
case WalletType.zano:
199
- estimatedFee = zano!.formatterIntAmountToDouble(
200
- amount: fee, currency: cryptoCurrencyHandler(), forFee: true);
203
+ estimatedFee = zano!
204
+ .formatterIntAmountToDouble(
205
+ amount: fee, currency: cryptoCurrencyHandler(), forFee: true)
206
+ .toString();
207
break;
208
case WalletType.decred:
203
- estimatedFee = decred!.formatterDecredAmountToDouble(amount: fee);
209
+ estimatedFee = decred!.formatterDecredAmountToDouble(amount: fee).toString();
210
break;
211
case WalletType.tron:
212
if (cryptoCurrencyHandler() == CryptoCurrency.trx) {
207
- final nativeEstimatedFee = tron!.getTronNativeEstimatedFee(_wallet) ?? '0';
208
- estimatedFee = double.parse(nativeEstimatedFee);
213
+ estimatedFee = tron!.getTronNativeEstimatedFee(_wallet).toString();
214
} else {
210
- final trc20EstimatedFee = tron!.getTronTRC20EstimatedFee(_wallet) ?? '0';
211
- estimatedFee = double.parse(trc20EstimatedFee);
215
+ estimatedFee = tron!.getTronTRC20EstimatedFee(_wallet).toString();
216
}
217
break;
218
@@ -218,32 +222,33 @@ abstract class OutputBase with Store {
222
? ethereum!.getEthereumNativeEstimatedFee(_wallet)
223
: ethereum!.getEthereumERC20EstimatedFee(_wallet);
224
221
- estimatedFee = ethereum!
222
- .formatterEthereumAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
225
+ estimatedFee = formatFixed(BigInt.parse(fee ?? '0.0'), 18, fractionalDigits: 12);
226
break;
227
+
228
case WalletType.polygon:
229
String? fee = cryptoCurrencyHandler() == CryptoCurrency.maticpoly
230
? polygon!.getPolygonNativeEstimatedFee(_wallet)
231
: polygon!.getPolygonERC20EstimatedFee(_wallet);
232
229
- estimatedFee = polygon!
230
- .formatterPolygonAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
233
+ estimatedFee = formatFixed(BigInt.parse(fee ?? '0.0'), 18, fractionalDigits: 12);
234
break;
235
+
236
case WalletType.base:
237
String? fee = cryptoCurrencyHandler() == CryptoCurrency.baseEth
238
? base!.getBaseNativeEstimatedFee(_wallet)
239
: base!.getBaseERC20EstimatedFee(_wallet);
236
- estimatedFee =
237
- base!.formatterBaseAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
240
+
241
+ estimatedFee = formatFixed(BigInt.parse(fee ?? '0.0'), 18, fractionalDigits: 12);
242
break;
243
+
244
case WalletType.arbitrum:
245
String? fee = cryptoCurrencyHandler() == CryptoCurrency.arbEth
246
? arbitrum!.getArbitrumNativeEstimatedFee(_wallet)
247
: arbitrum!.getArbitrumERC20EstimatedFee(_wallet);
248
244
- estimatedFee = arbitrum!
245
- .formatterArbitrumAmountToDouble(amount: BigInt.from(double.parse(fee ?? '0.0')));
249
+ estimatedFee = formatFixed(BigInt.parse(fee ?? '0.0'), 18, fractionalDigits: 12);
250
break;
251
+
252
/// end EVMs
253
254
case WalletType.haven:
@@ -270,7 +275,8 @@ abstract class OutputBase with Store {
275
? _wallet.currency
276
: cryptoCurrencyHandler();
277
final fiat = calculateFiatAmountRaw(
273
- price: _fiatConversationStore.prices[currency]!, cryptoAmount: estimatedFee);
278
+ price: _fiatConversationStore.prices[currency]!,
279
+ cryptoAmount: double.parse(estimatedFee));
280
return fiat;
281
} catch (_) {
282
return '0.00';