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

Commit 587f0f2

Browse files
committed
Merge branch 'main' into feat/update-block-remove-liquidity
2 parents a02db28 + b4839ae commit 587f0f2

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

lib/modules/pool/actions/add-liquidity/form/useMaximumInputs.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ export function useMaximumInputs() {
2323

2424
// Depending on if the user is using WETH or ETH, we need to filter out the
2525
// native asset or wrapped native asset.
26-
const nativeAssetFilter = (balance: TokenAmount) =>
27-
wethIsEth
28-
? wNativeAsset && balance.address !== wNativeAsset.address
29-
: nativeAsset && balance.address !== nativeAsset.address
26+
const nativeAssetFilter = (balance: TokenAmount) => {
27+
return wethIsEth
28+
? balance.address !== wNativeAsset?.address
29+
: balance.address !== nativeAsset?.address
30+
}
3031

3132
const filteredBalances = useMemo(() => {
3233
return balances.filter(nativeAssetFilter)

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)