Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit b4839ae

Browse files
authored
fix: setup private RPC url for fraxtal and mode (#1144)
1 parent 430f456 commit b4839ae

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

lib/modules/web3/ChainConfig.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export const rpcOverrides: Record<GqlChain, string | undefined> = {
5353
[GqlChain.Polygon]: getPrivateRpcUrl(GqlChain.Polygon),
5454
[GqlChain.Zkevm]: getPrivateRpcUrl(GqlChain.Zkevm),
5555
[GqlChain.Sepolia]: getPrivateRpcUrl(GqlChain.Sepolia),
56-
[GqlChain.Mode]: undefined,
57-
[GqlChain.Fraxtal]: undefined,
56+
[GqlChain.Mode]: getPrivateRpcUrl(GqlChain.Mode),
57+
[GqlChain.Fraxtal]: getPrivateRpcUrl(GqlChain.Fraxtal),
5858
}
5959

6060
const customMainnet = { iconUrl: '/images/chains/MAINNET.svg', ...mainnet }

lib/shared/components/errors/GenericError.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import { AlertProps, Text } from '@chakra-ui/react'
44
import { ErrorAlert } from './ErrorAlert'
5-
import { isPausedError, isUserRejectedError, isViemHttpFetchError } from '../../utils/error-filters'
5+
import {
6+
isPausedError,
7+
isTooManyRequestsError,
8+
isUserRejectedError,
9+
isViemHttpFetchError,
10+
} from '../../utils/error-filters'
611
import { ensureError } from '../../utils/errors'
712
import { BalAlertLink } from '../alerts/BalAlertLink'
813

@@ -39,6 +44,17 @@ export function GenericError({ error: _error, customErrorName, ...rest }: Props)
3944
</ErrorAlert>
4045
)
4146
}
47+
if (isTooManyRequestsError(_error)) {
48+
return (
49+
<ErrorAlert title={customErrorName} {...rest}>
50+
<Text variant="secondary" color="black">
51+
Too many RPC requests. Please try again in some minutes. You can report the problem in{' '}
52+
<BalAlertLink href="https://discord.balancer.fi/">our discord</BalAlertLink> if the issue
53+
persists.
54+
</Text>
55+
</ErrorAlert>
56+
)
57+
}
4258
const errorMessage = error?.shortMessage || error.message
4359

4460
if (errorMessage === 'RPC Request failed.' || errorMessage === 'An unknown RPC error occurred.') {

lib/shared/utils/error-filters.ts

+13
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ export function isViemHttpFetchError(error?: Error | null): boolean {
1313
)
1414
}
1515

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

0 commit comments

Comments
 (0)