Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: Handling exponential numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Sep 20, 2023
1 parent 3ae76eb commit 2f2c8e3
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:datadashwallet/common/config.dart';
import 'package:datadashwallet/common/utils/utils.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:datadashwallet/features/common/common.dart';
import 'package:datadashwallet/features/common/app_nav_bar/app_nav_bar_presenter.dart';
Expand Down Expand Up @@ -37,6 +38,8 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {

final Token token;

late final _transactionHistoryUseCase =
ref.read(transactionHistoryUseCaseProvider);
late final TokenContractUseCase _tokenContractUseCase =
ref.read(tokenContractUseCaseProvider);
late final _accountUseCase = ref.read(accountUseCaseProvider);
Expand Down Expand Up @@ -114,6 +117,11 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
double sumBalance = token.balance! - double.parse(amount);
estimatedGasFee = await _estimatedFee(recipientAddress);
sumBalance -= estimatedGasFee?.gasFee ?? 0.0;
final estimatedFee = estimatedGasFee == null
? '--'
: Validation.isExpoNumber(estimatedGasFee.gasFee.toString())
? '0.000'
: estimatedGasFee.gasFee.toString();

final result = await showTransactionDialog(context!,
amount: amount,
Expand All @@ -122,7 +130,7 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
newtork: state.network?.label ?? '--',
from: state.account!.address,
to: recipient,
estimatedFee: estimatedGasFee?.gasFee.toString(),
estimatedFee: estimatedFee,
onTap: (transactionType) => _nextTransactionStep(transactionType),
networkSymbol: state.network?.symbol ?? '--');
}
Expand Down

0 comments on commit 2f2c8e3

Please sign in to comment.