Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: handle BAL#402 (paused) error #1129

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/shared/components/errors/GenericError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { AlertProps, Text } from '@chakra-ui/react'
import { ErrorAlert } from './ErrorAlert'
import { isUserRejectedError, isViemHttpFetchError } from '../../utils/error-filters'
import { isPausedError, isUserRejectedError, isViemHttpFetchError } from '../../utils/error-filters'
import { ensureError } from '../../utils/errors'
import { BalAlertLink } from '../alerts/BalAlertLink'

Expand All @@ -28,6 +28,17 @@ export function GenericError({ error: _error, customErrorName, ...rest }: Props)
</ErrorAlert>
)
}
if (isPausedError(_error)) {
return (
<ErrorAlert title={customErrorName} {...rest}>
<Text variant="secondary" color="black">
The pool or one of the pool tokens is paused. Check{' '}
<BalAlertLink href="https://discord.balancer.fi/">our discord</BalAlertLink> for more
information.
</Text>
</ErrorAlert>
)
}
const errorMessage = error?.shortMessage || error.message

if (errorMessage === 'RPC Request failed.' || errorMessage === 'An unknown RPC error occurred.') {
Expand Down
19 changes: 12 additions & 7 deletions lib/shared/utils/error-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ export function isUserRejectedError(error: Error): boolean {
*/
export function isViemHttpFetchError(error?: Error | null): boolean {
if (!error) return false
if (
error.message.startsWith('HTTP request failed.') &&
error.message.includes('Failed to fetch')
) {
return true
}
return false
return (
error.message.startsWith('HTTP request failed.') && error.message.includes('Failed to fetch')
)
}

export function isPausedError(error?: Error | null): boolean {
if (!error) return false
return isPausedErrorMessage(error.message)
}

export function isPausedErrorMessage(errorMessage: string): boolean {
return errorMessage.includes('reverted with the following reason:\nBAL#402\n')
}
4 changes: 3 additions & 1 deletion lib/shared/utils/query-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Exception as SentryException,
} from '@sentry/types'
import { SentryError, ensureError } from './errors'
import { isUserRejectedError } from './error-filters'
import { isPausedErrorMessage, isUserRejectedError } from './error-filters'
import {
AddLiquidityParams,
stringifyHumanAmountsIn,
Expand Down Expand Up @@ -332,6 +332,8 @@ export function shouldIgnore(message: string, stackTrace = ''): boolean {
return true
}

if (isPausedErrorMessage(message)) return true

return false
}

Expand Down
Loading