Skip to content

Commit

Permalink
fix(explorer): various fixes (#3298)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Oct 16, 2024
1 parent 22ec353 commit e0c4b4c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { store as worldStore } from "../store";

export function TransactionsWatcher() {
const { id: chainId } = useChain();
const { worldAddress } = useParams();
const { worldAddress } = useParams<{ worldAddress: string }>();
const wagmiConfig = useConfig();
const { data: worldAbiData } = useWorldAbiQuery();
const abi = worldAbiData?.abi;
Expand Down Expand Up @@ -98,7 +98,7 @@ export function TransactionsWatcher() {
useEffect(() => {
for (const write of Object.values(observerWrites)) {
const hash = write.hash;
if (hash && write.address === worldAddress) {
if (hash && write.address.toLowerCase() === worldAddress.toLowerCase()) {
const transaction = transactions.find((transaction) => transaction.hash === hash);
if (!transaction) {
handleTransaction(hash, BigInt(write.time) / 1000n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export type ObservedTransaction = {
};

export function useObservedTransactions() {
const { worldAddress } = useParams();
const { worldAddress } = useParams<{ worldAddress: string }>();
const transactions = useStore(worldStore, (state) => state.transactions);
const observerWrites = useStore(observerStore, (state) => state.writes);

const mergedTransactions = useMemo((): ObservedTransaction[] => {
const mergedMap = new Map<string | undefined, ObservedTransaction>();

for (const write of Object.values(observerWrites)) {
if (write.address !== worldAddress) continue;
if (write.address.toLowerCase() !== worldAddress.toLowerCase()) continue;

const parsedAbiItem = parseAbiItem(`function ${write.functionSignature}`) as AbiFunction;
const writeResult = write.events.find((event): event is Message<"write:result"> => event.type === "write:result");
Expand Down
17 changes: 0 additions & 17 deletions packages/explorer/src/chains/rhodolite.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/explorer/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { anvil } from "viem/chains";
import { garnet, redstone } from "@latticexyz/common/chains";
import { rhodolite } from "./chains/rhodolite";
import { garnet, redstone, rhodolite } from "@latticexyz/common/chains";

export const internalNamespaces = ["world", "store", "metadata", "puppet", "erc20-puppet", "erc721-puppet"];

export const supportedChains = { anvil, garnet, redstone, rhodolite } as const;
export const supportedChains = { anvil, rhodolite, garnet, redstone } as const;
export type supportedChains = typeof supportedChains;

export type supportedChainName = keyof supportedChains;
Expand Down
3 changes: 2 additions & 1 deletion packages/explorer/src/observer/relay.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";

import debug from "debug";
import { isBridgeEnvelope } from "./bridge";
import { relayChannelName } from "./common";
import { debug } from "./debug";

export function createRelay(): () => void {
debug("creating relay");
const channel = new BroadcastChannel(relayChannelName);
function relay(event: MessageEvent) {
if (isBridgeEnvelope(event.data)) {
Expand Down

0 comments on commit e0c4b4c

Please sign in to comment.