Skip to content

Commit

Permalink
fix: pollingInterval for sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
alx-khramov committed Mar 5, 2024
1 parent c86d772 commit 96f0c34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions providers/sdk-legacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ export const SDKLegacyProvider = (props: {
defaultChainId: number;
supportedChains: Chain[];
rpc: Record<number, string>;
pollingInterval?: number;
}) => {
const { children, defaultChainId, rpc, supportedChains } = props;
const {
children,
defaultChainId,
rpc,
supportedChains,
pollingInterval = POLLING_INTERVAL,
} = props;
const { chainId = defaultChainId, account } = useWeb3();
const { connector, isConnected } = useAccount();

Expand All @@ -32,26 +39,26 @@ export const SDKLegacyProvider = (props: {
if (!providerWeb3 && connector && isConnected) {
const provider = await connector.getProvider();
const wrappedProvider = new Web3Provider(provider);
wrappedProvider.pollingInterval = POLLING_INTERVAL;
wrappedProvider.pollingInterval = pollingInterval;
setProviderWeb3(wrappedProvider);
}
})();
}, [connector, isConnected, providerWeb3]);
}, [connector, isConnected, pollingInterval, providerWeb3]);

const supportedChainIds = supportedChains.map((chain) => chain.id);

const providerRpc = getStaticRpcBatchProvider(
chainId,
rpc[chainId],
0,
POLLING_INTERVAL,
pollingInterval,
);

const providerMainnetRpc = getStaticRpcBatchProvider(
mainnet.id,
rpc[mainnet.id],
0,
POLLING_INTERVAL,
pollingInterval,
);

return (
Expand Down
1 change: 1 addition & 0 deletions providers/web3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const Web3Provider: FC<PropsWithChildren> = ({ children }) => {
defaultChainId={defaultChain.id}
supportedChains={supportedChains}
rpc={backendRPC}
pollingInterval={1200}
>
{children}
</SDKLegacyProvider>
Expand Down

0 comments on commit 96f0c34

Please sign in to comment.