From 539787c27b6d10d00aa9292998c03c222e5afa4d Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Mon, 11 Nov 2024 11:06:27 +0700 Subject: [PATCH] update explorer transports/poll interval --- .../[chainName]/worlds/[worldAddress]/Providers.tsx | 9 +++++++-- .../worlds/[worldAddress]/explore/EditableTableCell.tsx | 5 +---- .../[worldAddress]/interact/useContractMutation.ts | 5 +---- .../[worldAddress]/observe/TransactionsWatcher.tsx | 2 -- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/Providers.tsx b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/Providers.tsx index 614b38186c..43357d18a9 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/Providers.tsx +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/Providers.tsx @@ -1,6 +1,6 @@ "use client"; -import { WagmiProvider, createConfig, http } from "wagmi"; +import { WagmiProvider, createConfig, fallback, http, webSocket } from "wagmi"; import { injected, metaMask, safe } from "wagmi/connectors"; import { ReactNode, useMemo } from "react"; import { RainbowKitProvider, darkTheme } from "@rainbow-me/rainbowkit"; @@ -27,9 +27,14 @@ export function Providers({ children }: { children: ReactNode }) { ...getDefaultAnvilConnectors(chain.id), ], transports: { - [chain.id]: http(), + [chain.id]: chain.rpcUrls.default.webSocket + ? fallback([webSocket(chain.rpcUrls.default.webSocket[0]), http(chain.rpcUrls.default.http[0])]) + : http(chain.rpcUrls.default.http[0]), }, ssr: true, + pollingInterval: { + [chain.id]: chain.id === 31337 ? 100 : 500, + }, }); }, [chain]); diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/EditableTableCell.tsx b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/EditableTableCell.tsx index 7d1e8a8cf0..655ba04ffe 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/EditableTableCell.tsx +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/explore/EditableTableCell.tsx @@ -53,10 +53,7 @@ export function EditableTableCell({ name, table, keyTuple, value: defaultValue } chainId, }); - const receipt = await waitForTransactionReceipt(wagmiConfig, { - hash: txHash, - pollingInterval: 100, - }); + const receipt = await waitForTransactionReceipt(wagmiConfig, { hash: txHash }); return { txHash, receipt }; }, diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/useContractMutation.ts b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/useContractMutation.ts index 3289e8cd6b..9411e055f1 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/useContractMutation.ts +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/useContractMutation.ts @@ -42,10 +42,7 @@ export function useContractMutation({ worldAbi, functionAbi, operationType }: Us chainId, }); - const receipt = await waitForTransactionReceipt(wagmiConfig, { - hash: txHash, - pollingInterval: 100, - }); + const receipt = await waitForTransactionReceipt(wagmiConfig, { hash: txHash }); return { txHash, receipt }; } diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/observe/TransactionsWatcher.tsx b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/observe/TransactionsWatcher.tsx index 8f5db0f8b9..a4d31bfe5c 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/observe/TransactionsWatcher.tsx +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/observe/TransactionsWatcher.tsx @@ -11,7 +11,6 @@ import { parseEventLogs, } from "viem"; import { UserOperation, entryPoint07Abi, entryPoint07Address } from "viem/account-abstraction"; -import { anvil } from "viem/chains"; import { useConfig, useWatchBlocks } from "wagmi"; import { getTransaction, simulateContract, waitForTransactionReceipt } from "wagmi/actions"; import { useStore } from "zustand"; @@ -226,7 +225,6 @@ export function TransactionsWatcher() { } }, chainId, - pollingInterval: chainId === anvil.id ? 10 : 500, }); return null;