Skip to content

Commit

Permalink
Merge pull request #200 from archethic-foundation/181-wrong-error-mes…
Browse files Browse the repository at this point in the history
…sage

🐛 Fix wrong error message when user tries to swap the same tokens
  • Loading branch information
redDwarf03 authored May 27, 2024
2 parents 2941661 + 8a9ac35 commit 7413ad5
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 7413ad5

Please sign in to comment.