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: fallback for testnets #535

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: 8 additions & 5 deletions modules/web3/web3-provider/sdk-legacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ProviderSDK } from '@lido-sdk/react';
import { useLidoSDK } from './lido-sdk';
import { config } from 'config';
import { isSDKSupportedL2Chain } from 'consts/chains';
import { useMainnetStaticRpcProvider } from 'shared/hooks/use-mainnet-static-rpc-provider';

// Stabilizes network detection to prevent repeated chainId calls
class EthersToViemProvider extends Web3Provider {
Expand Down Expand Up @@ -61,12 +62,14 @@ export const SDKLegacyProvider = ({ children }: PropsWithChildren) => {
);
}, [onlyL1chainId, onlyL1publicClient]);

// Fallback for when mainnet is not present in supported chains
const staticMainnetProvider = useMainnetStaticRpcProvider();

const providerMainnetRpc = useMemo(() => {
return (
publicMainnetClient &&
new EthersToViemProvider(publicMainnetClient.transport, 1)
);
}, [publicMainnetClient]);
return publicMainnetClient
? new EthersToViemProvider(publicMainnetClient.transport, 1)
: staticMainnetProvider;
}, [publicMainnetClient, staticMainnetProvider]);

return (
// @ts-expect-error Property children does not exist on type
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
"react-hook-form": "^7.45.2",
"react-is": "^18.2.0",
"react-transition-group": "^4.4.2",
"reef-knot": "5.7.4",
"reef-knot": "5.7.5",
"styled-components": "^5.3.5",
"swr": "^1.3.0",
"tiny-async-pool": "^1.2.0",
"tiny-invariant": "^1.1.0",
"uuid": "^8.3.2",
"viem": "2.21.25",
"wagmi": "2.12.17"
"viem": "2.21.40",
"wagmi": "2.12.25"
},
"devDependencies": {
"@commitlint/cli": "^17.4.4",
Expand Down
Loading
Loading