don't check balance on exchange from wallet

This commit is contained in:
julian 2022-09-09 08:39:25 -06:00
parent c18d456493
commit 95d86d8f0f

View file

@ -29,7 +29,6 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/cfcolors.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.dart';
import 'package:stackwallet/utilities/format.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart';
@ -1272,55 +1271,55 @@ class _WalletInitiatedExchangeViewState
.read(estimatedRateExchangeFormProvider) .read(estimatedRateExchangeFormProvider)
.fromAmountString); .fromAmountString);
if (ft.toLowerCase() == // if (ft.toLowerCase() ==
coin.ticker.toLowerCase()) { // coin.ticker.toLowerCase()) {
bool shouldPop = false; // bool shouldPop = false;
bool wasPopped = false; // bool wasPopped = false;
unawaited(showDialog<void>( // unawaited(showDialog<void>(
context: context, // context: context,
builder: (_) => WillPopScope( // builder: (_) => WillPopScope(
onWillPop: () async { // onWillPop: () async {
if (shouldPop) { // if (shouldPop) {
wasPopped = true; // wasPopped = true;
} // }
return shouldPop; // return shouldPop;
}, // },
child: const CustomLoadingOverlay( // child: const CustomLoadingOverlay(
message: "Checking available balance", // message: "Checking available balance",
eventBus: null, // eventBus: null,
), // ),
), // ),
)); // ));
//
final availableBalance = // final availableBalance =
await manager.availableBalance; // await manager.availableBalance;
//
final feeObject = await manager.fees; // final feeObject = await manager.fees;
//
final fee = await manager.estimateFeeFor( // final fee = await manager.estimateFeeFor(
Format.decimalAmountToSatoshis( // Format.decimalAmountToSatoshis(
sendAmount), // sendAmount),
feeObject.medium); // feeObject.medium);
//
shouldPop = true; // shouldPop = true;
if (!wasPopped && mounted) { // if (!wasPopped && mounted) {
Navigator.of(context).pop(); // Navigator.of(context).pop();
} // }
//
if (availableBalance < // if (availableBalance <
sendAmount + // sendAmount +
Format.satoshisToAmount(fee)) { // Format.satoshisToAmount(fee)) {
unawaited(showDialog<void>( // unawaited(showDialog<void>(
context: context, // context: context,
builder: (_) => StackOkDialog( // builder: (_) => StackOkDialog(
title: "Insufficient balance", // title: "Insufficient balance",
message: // message:
"Current ${coin.prettyName} wallet does not have enough ${coin.ticker} for this trade", // "Current ${coin.prettyName} wallet does not have enough ${coin.ticker} for this trade",
), // ),
)); // ));
return; // return;
} // }
} // }
if (isEstimated) { if (isEstimated) {
final fromTicker = ref final fromTicker = ref