From a088d16bd18d4e1d18f276a63edfc208eece39e9 Mon Sep 17 00:00:00 2001 From: Karolis Ramanauskas Date: Sun, 13 Oct 2024 13:29:52 +0300 Subject: [PATCH] feat(explorer): rhodolite support (#3256) Co-authored-by: alvrs --- .../app/(explorer)/[chainName]/worlds/page.tsx | 2 +- .../utils/blockExplorerTransactionUrl.ts | 2 +- packages/explorer/src/chains/rhodolite.ts | 17 +++++++++++++++++ packages/explorer/src/common.ts | 3 ++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 packages/explorer/src/chains/rhodolite.ts diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/page.tsx b/packages/explorer/src/app/(explorer)/[chainName]/worlds/page.tsx index 9656b5459a..a8ab09a6aa 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/page.tsx +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/page.tsx @@ -27,7 +27,7 @@ async function fetchWorlds(chainName: string): Promise { const baseUrl = `${protocol}://${host}`; worldsApiUrl = `${baseUrl}/api/sqlite-indexer/worlds`; } else { - const blockExplorerUrl = chain.blockExplorers?.default.url; + const blockExplorerUrl = "blockExplorers" in chain && chain.blockExplorers?.default.url; if (blockExplorerUrl) { worldsApiUrl = `${blockExplorerUrl}/api/v2/mud/worlds`; } diff --git a/packages/explorer/src/app/(explorer)/utils/blockExplorerTransactionUrl.ts b/packages/explorer/src/app/(explorer)/utils/blockExplorerTransactionUrl.ts index a7e8ee8b36..aa8a43a0b0 100644 --- a/packages/explorer/src/app/(explorer)/utils/blockExplorerTransactionUrl.ts +++ b/packages/explorer/src/app/(explorer)/utils/blockExplorerTransactionUrl.ts @@ -13,7 +13,7 @@ export function blockExplorerTransactionUrl({ const chainName = chainIdToName[chainId]; const chain = supportedChains[chainName]; - const explorerUrl = chain.blockExplorers?.default.url; + const explorerUrl = "blockExplorers" in chain && chain.blockExplorers?.default.url; if (!explorerUrl) return undefined; return `${explorerUrl}/tx/${hash}`; } diff --git a/packages/explorer/src/chains/rhodolite.ts b/packages/explorer/src/chains/rhodolite.ts new file mode 100644 index 0000000000..d973da34cf --- /dev/null +++ b/packages/explorer/src/chains/rhodolite.ts @@ -0,0 +1,17 @@ +import { MUDChain } from "@latticexyz/common/chains"; + +export const rhodolite = { + id: 17420, + name: "Rhodolite", + nativeCurrency: { + decimals: 18, + name: "Ether", + symbol: "ETH", + }, + rpcUrls: { + default: { + http: ["https://rpc.rhodolitechain.com"], + }, + }, + indexerUrl: "https://indexer.mud.rhodolitechain.com", +} satisfies MUDChain; diff --git a/packages/explorer/src/common.ts b/packages/explorer/src/common.ts index 1d3869d88a..bd7af3a874 100644 --- a/packages/explorer/src/common.ts +++ b/packages/explorer/src/common.ts @@ -1,9 +1,10 @@ import { anvil } from "viem/chains"; import { garnet, redstone } from "@latticexyz/common/chains"; +import { rhodolite } from "./chains/rhodolite"; export const internalNamespaces = ["world", "store", "metadata", "puppet", "erc20-puppet", "erc721-puppet"]; -export const supportedChains = { anvil, garnet, redstone } as const; +export const supportedChains = { anvil, garnet, redstone, rhodolite } as const; export type supportedChains = typeof supportedChains; export type supportedChainName = keyof supportedChains;