-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(explorer): various fixes (#3195)
- Loading branch information
Showing
14 changed files
with
136 additions
and
112 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,5 @@ | ||
--- | ||
"@latticexyz/explorer": patch | ||
--- | ||
|
||
Refactored `observer` initialization to reuse bridge iframes with the same `url`. |
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,5 @@ | ||
--- | ||
"@latticexyz/explorer": patch | ||
--- | ||
|
||
Fixed favicon paths and fixed a few issues where we were incorrectly redirecting based on the chain name or ID. |
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,10 @@ | ||
--- | ||
"@latticexyz/explorer": patch | ||
--- | ||
|
||
Fixed an issue where the `observer` Viem client decorator required an empty object arg when no options are used. | ||
|
||
```diff | ||
-client.extend(observer({})); | ||
+client.extend(observer()); | ||
``` |
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
File renamed without changes.
File renamed without changes
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
4 changes: 2 additions & 2 deletions
4
packages/explorer/src/app/page.tsx → ...ages/explorer/src/app/(explorer)/page.tsx
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,12 +1,12 @@ | ||
import { redirect } from "next/navigation"; | ||
import { supportedChainsById, validateChainId } from "../common"; | ||
import { chainIdToName, validateChainId } from "../../common"; | ||
|
||
export const dynamic = "force-dynamic"; | ||
|
||
export default function IndexPage() { | ||
const chainId = Number(process.env.CHAIN_ID); | ||
validateChainId(chainId); | ||
|
||
const chainName = supportedChainsById[chainId]; | ||
const chainName = chainIdToName[chainId] ?? "anvil"; | ||
return redirect(`/${chainName}/worlds`); | ||
} |
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,21 +1,23 @@ | ||
import { anvil, garnet, redstone } from "viem/chains"; | ||
|
||
export const supportedChains = { anvil, garnet, redstone } as const; | ||
export const supportedChainsById = Object.fromEntries( | ||
Object.entries(supportedChains).map(([, chain]) => [chain.id, chain]), | ||
); | ||
export type supportedChains = typeof supportedChains; | ||
|
||
export type supportedChainName = keyof supportedChains; | ||
export type supportedChainId = supportedChains[supportedChainName]["id"]; | ||
|
||
export type SupportedChainIds = (typeof supportedChains)[keyof typeof supportedChains]["id"]; | ||
export type SupportedChainNames = keyof typeof supportedChains; | ||
export const chainIdToName = Object.fromEntries( | ||
Object.entries(supportedChains).map(([chainName, chain]) => [chain.id, chainName]), | ||
); | ||
|
||
export function validateChainId(chainId: number): asserts chainId is SupportedChainIds { | ||
if (!(chainId in supportedChainsById)) { | ||
throw new Error(`Invalid chain id. Supported chains are: ${Object.keys(supportedChainsById).join(", ")}.`); | ||
export function validateChainId(chainId: unknown): asserts chainId is supportedChainId { | ||
if (!(typeof chainId === "number" && chainId in chainIdToName)) { | ||
throw new Error(`Invalid chain ID. Supported chains are: ${Object.keys(chainIdToName).join(", ")}.`); | ||
} | ||
} | ||
|
||
export function validateChainName(name: string | string[] | undefined): asserts name is SupportedChainNames { | ||
if (Array.isArray(name) || typeof name !== "string" || !(name in supportedChains)) { | ||
throw new Error(`Invalid chain name. Supported chains are: ${Object.keys(supportedChainsById).join(", ")}.`); | ||
export function validateChainName(name: unknown): asserts name is supportedChainName { | ||
if (!(typeof name === "string" && name in supportedChains)) { | ||
throw new Error(`Invalid chain name. Supported chains are: ${Object.keys(supportedChains).join(", ")}.`); | ||
} | ||
} |
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