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: add not enough gas error to generic error #1150

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
12 changes: 12 additions & 0 deletions lib/shared/components/errors/GenericError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { AlertProps, Text } from '@chakra-ui/react'
import { ErrorAlert } from './ErrorAlert'
import {
isNotEnoughGasError,
isPausedError,
isTooManyRequestsError,
isUserRejectedError,
Expand Down Expand Up @@ -55,6 +56,17 @@ export function GenericError({ error: _error, customErrorName, ...rest }: Props)
</ErrorAlert>
)
}
if (isNotEnoughGasError(_error)) {
return (
<ErrorAlert title={customErrorName} {...rest}>
<Text variant="secondary" color="black">
It looks like you don&apos;t have enough gas for this transaction. You can report the
problem in <BalAlertLink href="https://discord.balancer.fi/">our discord</BalAlertLink> if
the issue persists.
</Text>
</ErrorAlert>
)
}
const errorMessage = error?.shortMessage || error.message

if (errorMessage === 'RPC Request failed.' || errorMessage === 'An unknown RPC error occurred.') {
Expand Down
5 changes: 5 additions & 0 deletions lib/shared/utils/error-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export function isTooManyRequestsError(error?: Error | null): boolean {
return error.message.startsWith('HTTP request failed.') && error.message.includes('Status: 429')
}

export function isNotEnoughGasError(error?: Error | null): boolean {
if (!error) return false
return error.message.startsWith('Execution reverted with reason: TRANSFER_FROM_FAILED.')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRANSFER_FROM_FAILED could also have other causes so I will try to improve this later.
Saving the PR as draft for now

}

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