Skip to content

Commit

Permalink
add redstone support
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis committed Sep 3, 2024
1 parent 9b41bdf commit 3495685
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/explorer/src/app/(explorer)/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { injected, metaMask, safe } from "wagmi/connectors";
import { ReactNode } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { createConfig, http } from "@wagmi/core";
import { localhost } from "@wagmi/core/chains";
import { localhost, redstone } from "@wagmi/core/chains";
import { AppStoreProvider } from "../../store";

const queryClient = new QueryClient();

export const wagmiConfig = createConfig({
chains: [localhost],
chains: [localhost, redstone],
connectors: [
injected(),
metaMask({
Expand All @@ -23,6 +23,7 @@ export const wagmiConfig = createConfig({
],
transports: {
[localhost.id]: http(),
[redstone.id]: http(),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function useContractMutation({ abi, operationType }: UseContractMutationP
address: worldAddress as Hex,
functionName: abi.name,
args: inputs,
chainId: process.env.CHAIN_ID,
});

return { result };
Expand All @@ -40,6 +41,7 @@ export function useContractMutation({ abi, operationType }: UseContractMutationP
functionName: abi.name,
args: inputs,
...(value && { value: BigInt(value) }),
chainId: process.env.CHAIN_ID,
});

const receipt = await waitForTransactionReceipt(wagmiConfig, {
Expand Down
8 changes: 4 additions & 4 deletions packages/explorer/src/app/api/world/route.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { AbiFunction, Address, Hex, createWalletClient, http, parseAbi } from "viem";
import { getBlockNumber, getLogs } from "viem/actions";
import { getRpcUrl } from "@latticexyz/common/foundry";
import { redstone } from "viem/chains";
import { helloStoreEvent } from "@latticexyz/store";
import { helloWorldEvent } from "@latticexyz/world";
import { getWorldAbi } from "@latticexyz/world/internal";

export const dynamic = "force-dynamic";

async function getClient() {
const profile = process.env.FOUNDRY_PROFILE;
const rpc = await getRpcUrl(profile);
const client = createWalletClient({
transport: http(rpc),
chain: redstone,
transport: http(),
});

return client;
Expand Down Expand Up @@ -51,6 +50,7 @@ export async function GET(req: Request) {
fromBlock,
toBlock,
});

const abi = worldAbiResponse
.filter((entry): entry is AbiFunction => entry.type === "function")
.sort((a, b) => a.name.localeCompare(b.name));
Expand Down

0 comments on commit 3495685

Please sign in to comment.