-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from lidofinance/fix/rpc-config
Fix: rework rpc config
- Loading branch information
Showing
22 changed files
with
3,013 additions
and
2,303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# https://eth-{NETWORK}.alchemyapi.io/v2/{ALCHEMY_API_KEY} | ||
ALCHEMY_API_KEY=-_tSz4KA-fGCEBIdfYfP2etFFXzdKN74 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
import { ReactNode } from 'react'; | ||
import React from 'react'; | ||
import { WagmiConfig, createClient, configureChains, Chain } from 'wagmi'; | ||
import { goerli, mainnet } from 'wagmi/chains'; | ||
import { ProviderWeb3, useWeb3 } from 'reef-knot/web3-react'; | ||
import { ProviderSDK } from '@lido-sdk/react'; | ||
import { rpc } from '../util/rpc'; | ||
import { ProviderWeb3 } from 'reef-knot/web3-react'; | ||
import { getConnectors } from 'reef-knot/core-react'; | ||
import { getStaticRpcBatchProvider } from '@lido-sdk/providers'; | ||
import { getRPCPath } from '../util/contractTestingUtils'; | ||
import { rpcUrlsString } from '../util/rpc'; | ||
import { WC_PROJECT_ID } from '../util/walletconnectProjectId'; | ||
|
||
const SDKProvider: React.FC = ({ children }) => { | ||
const web3 = useWeb3(); | ||
return ( | ||
<ProviderSDK | ||
chainId={goerli.id} | ||
supportedChainIds={[goerli.id, mainnet.id]} | ||
providerWeb3={web3.library} | ||
account={web3.account ?? undefined} | ||
> | ||
{children} | ||
</ProviderSDK> | ||
); | ||
}; | ||
const supportedChains = [goerli, mainnet]; | ||
const supportedChainsIds = supportedChains.map((chain) => chain.id); | ||
const defaultChainId = goerli.id; | ||
|
||
const jsonRcpBatchProvider = (chain: Chain) => ({ | ||
provider: () => | ||
getStaticRpcBatchProvider(chain.id, getRPCPath(chain.id), undefined, 12000), | ||
chain, | ||
}); | ||
|
||
const { chains, provider, webSocketProvider } = configureChains( | ||
supportedChains, | ||
[jsonRcpBatchProvider], | ||
); | ||
|
||
const connectors = getConnectors({ | ||
rpc: rpcUrlsString, | ||
walletconnectProjectId: WC_PROJECT_ID, | ||
chains, | ||
defaultChain: goerli, | ||
}); | ||
|
||
const client = createClient({ | ||
connectors, | ||
autoConnect: true, | ||
provider, | ||
webSocketProvider, | ||
}); | ||
|
||
const ProviderWeb3WithProps = (props: { children: ReactNode }) => { | ||
const ProviderWeb3WithProps: React.FC = ({ children }) => { | ||
return ( | ||
<ProviderWeb3 | ||
defaultChainId={goerli.id} | ||
supportedChainIds={[goerli.id, mainnet.id]} | ||
rpc={rpc} | ||
walletconnectProjectId={WC_PROJECT_ID} | ||
> | ||
<SDKProvider>{props.children}</SDKProvider> | ||
</ProviderWeb3> | ||
<WagmiConfig client={client}> | ||
<ProviderWeb3 | ||
defaultChainId={defaultChainId} | ||
supportedChainIds={supportedChainsIds} | ||
rpc={rpcUrlsString} | ||
walletconnectProjectId={WC_PROJECT_ID} | ||
> | ||
{children} | ||
</ProviderWeb3> | ||
</WagmiConfig> | ||
); | ||
}; | ||
export default ProviderWeb3WithProps; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.