From 8a9ac356fc49d78d3110b5243dec6226070e98e2 Mon Sep 17 00:00:00 2001 From: redDwarf03 Date: Mon, 27 May 2024 11:56:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20wrong=20error=20message=20?= =?UTF-8?q?when=20user=20tries=20to=20swap=20the=20same=20tokens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/views/swap/bloc/provider.dart | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/ui/views/swap/bloc/provider.dart b/lib/ui/views/swap/bloc/provider.dart index 47304dab..d67b2846 100644 --- a/lib/ui/views/swap/bloc/provider.dart +++ b/lib/ui/views/swap/bloc/provider.dart @@ -78,7 +78,11 @@ class SwapFormNotifier extends AutoDisposeNotifier { setFailure( const aedappfm.Failure.other(cause: "You can't swap the same tokens"), ); - state = state.copyWith(ratio: 0, pool: null); + state = state.copyWith( + ratio: 0, + pool: null, + calculationInProgress: false, + ); return; } @@ -261,6 +265,15 @@ class SwapFormNotifier extends AutoDisposeNotifier { cancel: false, ); + if (state.tokenToSwap != null && + state.tokenSwapped != null && + state.tokenToSwap!.address == state.tokenSwapped!.address) { + setFailure( + const aedappfm.Failure.other(cause: "You can't swap the same tokens"), + ); + return; + } + if (state.tokenFormSelected == 1) { if (state.tokenToSwapAmount == 0) { return; @@ -422,7 +435,11 @@ class SwapFormNotifier extends AutoDisposeNotifier { setFailure( const aedappfm.Failure.other(cause: "You can't swap the same tokens"), ); - state = state.copyWith(ratio: 0, pool: null); + state = state.copyWith( + ratio: 0, + pool: null, + calculationInProgress: false, + ); return; }