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

fix: setup private RPC urls for fraxtal and mode #1144

Merged
merged 1 commit into from
Oct 3, 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
4 changes: 2 additions & 2 deletions lib/modules/web3/ChainConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const rpcOverrides: Record<GqlChain, string | undefined> = {
[GqlChain.Polygon]: getPrivateRpcUrl(GqlChain.Polygon),
[GqlChain.Zkevm]: getPrivateRpcUrl(GqlChain.Zkevm),
[GqlChain.Sepolia]: getPrivateRpcUrl(GqlChain.Sepolia),
[GqlChain.Mode]: undefined,
[GqlChain.Fraxtal]: undefined,
[GqlChain.Mode]: getPrivateRpcUrl(GqlChain.Mode),
[GqlChain.Fraxtal]: getPrivateRpcUrl(GqlChain.Fraxtal),
}

const customMainnet = { iconUrl: '/images/chains/MAINNET.svg', ...mainnet }
Expand Down
18 changes: 17 additions & 1 deletion lib/shared/components/errors/GenericError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

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

Expand Down Expand Up @@ -39,6 +44,17 @@ export function GenericError({ error: _error, customErrorName, ...rest }: Props)
</ErrorAlert>
)
}
if (isTooManyRequestsError(_error)) {
return (
<ErrorAlert title={customErrorName} {...rest}>
<Text variant="secondary" color="black">
Too many RPC requests. Please try again in some minutes. 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
13 changes: 13 additions & 0 deletions lib/shared/utils/error-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ export function isViemHttpFetchError(error?: Error | null): boolean {
)
}

/*
Detects 429 Too Many Requests errors thrown by wagmi/viem
We should not have many of them as we are using a private RPC provider but they still could happen when:
- the provider's rate limiting is not working as expected
- the provider is down and we are using a public fallback
- others
*/
export function isTooManyRequestsError(error?: Error | null): boolean {
console.log(error?.message)
if (!error) return false
return error.message.startsWith('HTTP request failed.') && error.message.includes('Status: 429')
}

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