Skip to content

Commit b1c1edf

Browse files
committed
fix: pr comment
1 parent 2630ed1 commit b1c1edf

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/components/transactions/Swap/errors/SwapErrors.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Dispatch, useEffect } from 'react';
22
import { useAppDataContext } from 'src/hooks/app-data-provider/useAppDataProvider';
33
import { useZeroLTVBlockingWithdraw } from 'src/hooks/useZeroLTVBlockingWithdraw';
4-
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
54

65
import { useModalContext } from '../../../../hooks/useModal';
76
import { TrackAnalyticsHandlers } from '../analytics/useTrackAnalytics';
@@ -42,7 +41,6 @@ export const SwapErrors = ({
4241
trackingHandlers: TrackAnalyticsHandlers;
4342
}) => {
4443
const { txError } = useModalContext();
45-
const { readOnlyMode } = useWeb3Context();
4644
const assetsBlockingWithdraw = useZeroLTVBlockingWithdraw();
4745
const { user: extendedUser } = useAppDataContext();
4846

@@ -151,15 +149,6 @@ export const SwapErrors = ({
151149
return null;
152150
}
153151

154-
if (readOnlyMode) {
155-
return (
156-
<GenericError
157-
sx={{ mb: !state.isSwapFlowSelected ? 0 : 4 }}
158-
message="This transaction is not possible in watch wallet mode. Please leave watch wallet mode and connect a wallet."
159-
/>
160-
);
161-
}
162-
163152
if (hasUserDenied(state.error)) {
164153
return <UserDenied state={state} setState={setState} key={`user-denied`} />;
165154
}

src/components/transactions/Swap/errors/shared/ProviderError.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SxProps, Typography } from '@mui/material';
22
import { Warning } from 'src/components/primitives/Warning';
3+
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
34

45
import { SwapError, SwapProvider, SwapState } from '../../types';
56
import { convertCowProtocolErrorMessage } from '../cow/quote.helpers';
@@ -15,6 +16,7 @@ interface QuoteErrorProps {
1516
}
1617

1718
export const ProviderError = ({ error, sx, provider, state }: QuoteErrorProps) => {
19+
const { readOnlyMode } = useWeb3Context();
1820
let customErrorMessage;
1921

2022
switch (provider) {
@@ -30,6 +32,12 @@ export const ProviderError = ({ error, sx, provider, state }: QuoteErrorProps) =
3032
}
3133

3234
if (!customErrorMessage) {
35+
if (readOnlyMode) {
36+
return (
37+
<GenericError message="This transaction is not possible in watch wallet mode. Please leave watch wallet mode and connect a wallet." />
38+
);
39+
}
40+
3341
const errorToCopy = errorToConsoleString(state, error);
3442
return (
3543
<GenericError

0 commit comments

Comments
 (0)