Skip to content

Commit

Permalink
Clear current STX error (#21848) (#21858)
Browse files Browse the repository at this point in the history
## **Description**

There were no merge conflicts when cherry picking this commit.
  • Loading branch information
dan437 authored Nov 21, 2023
1 parent 88b9d05 commit 0130693
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ui/ducks/swaps/swaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ const slice = createSlice({
state.customGas.fallBackPrice = action.payload;
},
setCurrentSmartTransactionsError: (state, action) => {
const errorType = Object.values(StxErrorTypes).includes(action.payload)
const isValidCurrentStxError =
Object.values(StxErrorTypes).includes(action.payload) ||
action.payload === undefined;
const errorType = isValidCurrentStxError
? action.payload
: StxErrorTypes.unavailable;
state.currentSmartTransactionsError = errorType;
Expand Down Expand Up @@ -596,6 +599,7 @@ export const fetchSwapsLivenessAndFeatureFlags = () => {
const swapsFeatureFlags = await fetchSwapsFeatureFlags();
await dispatch(setSwapsFeatureFlags(swapsFeatureFlags));
if (ALLOWED_SMART_TRANSACTIONS_CHAIN_IDS.includes(chainId)) {
await dispatch(setCurrentSmartTransactionsError(undefined));
await dispatch(fetchSmartTransactionsLiveness());
const transactions = await getTransactions({
searchCriteria: {
Expand Down
8 changes: 4 additions & 4 deletions ui/ducks/swaps/swaps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('Ducks - Swaps', () => {
createGetState(),
);
expect(featureFlagApiNock.isDone()).toBe(true);
expect(mockDispatch).toHaveBeenCalledTimes(4);
expect(mockDispatch).toHaveBeenCalledTimes(5);
expect(setSwapsLiveness).toHaveBeenCalledWith(expectedSwapsLiveness);
expect(setSwapsFeatureFlags).toHaveBeenCalledWith(featureFlagsResponse);
expect(swapsLiveness).toMatchObject(expectedSwapsLiveness);
Expand All @@ -105,7 +105,7 @@ describe('Ducks - Swaps', () => {
createGetState(),
);
expect(featureFlagApiNock.isDone()).toBe(true);
expect(mockDispatch).toHaveBeenCalledTimes(4);
expect(mockDispatch).toHaveBeenCalledTimes(5);
expect(setSwapsLiveness).toHaveBeenCalledWith(expectedSwapsLiveness);
expect(setSwapsFeatureFlags).toHaveBeenCalledWith(featureFlagsResponse);
expect(swapsLiveness).toMatchObject(expectedSwapsLiveness);
Expand All @@ -127,7 +127,7 @@ describe('Ducks - Swaps', () => {
createGetState(),
);
expect(featureFlagApiNock.isDone()).toBe(true);
expect(mockDispatch).toHaveBeenCalledTimes(4);
expect(mockDispatch).toHaveBeenCalledTimes(5);
expect(setSwapsLiveness).toHaveBeenCalledWith(expectedSwapsLiveness);
expect(setSwapsFeatureFlags).toHaveBeenCalledWith(featureFlagsResponse);
expect(swapsLiveness).toMatchObject(expectedSwapsLiveness);
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('Ducks - Swaps', () => {
createGetState(),
);
expect(featureFlagApiNock2.isDone()).toBe(false); // Second API call wasn't made, cache was used instead.
expect(mockDispatch).toHaveBeenCalledTimes(8);
expect(mockDispatch).toHaveBeenCalledTimes(10);
expect(setSwapsLiveness).toHaveBeenCalledWith(expectedSwapsLiveness);
expect(setSwapsFeatureFlags).toHaveBeenCalledWith(featureFlagsResponse);
expect(swapsLiveness).toMatchObject(expectedSwapsLiveness);
Expand Down

0 comments on commit 0130693

Please sign in to comment.