Skip to content

Commit

Permalink
🐛 Fix wrong error message when user tries to swap the same tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed May 27, 2024
1 parent 2941661 commit 8a9ac35
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/ui/views/swap/bloc/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ class SwapFormNotifier extends AutoDisposeNotifier<SwapFormState> {
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;
}

Expand Down Expand Up @@ -261,6 +265,15 @@ class SwapFormNotifier extends AutoDisposeNotifier<SwapFormState> {
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;
Expand Down Expand Up @@ -422,7 +435,11 @@ class SwapFormNotifier extends AutoDisposeNotifier<SwapFormState> {
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;
}

Expand Down

0 comments on commit 8a9ac35

Please sign in to comment.