diff --git a/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts b/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts index 77b0ecdab70..480ae88fa0a 100644 --- a/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts +++ b/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts @@ -1,17 +1,10 @@ -import { SetupContractConfig, getBurnerWallet } from "@latticexyz/std-client"; +import { getBurnerWallet } from "@latticexyz/std-client"; import worldsJson from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -import type { Chain } from "viem/chains"; const worlds = worldsJson as Partial>; -type NetworkConfig = SetupContractConfig & { - privateKey: string; - faucetServiceUrl?: string; - chain: Chain; -}; - -export async function getNetworkConfig(): Promise { +export async function getNetworkConfig() { const params = new URLSearchParams(window.location.search); const chainId = Number(params.get("chainId") || params.get("chainid") || import.meta.env.VITE_CHAIN_ID || 31337); const chainIndex = supportedChains.findIndex((c) => c.id === chainId); @@ -31,22 +24,11 @@ export async function getNetworkConfig(): Promise { : world?.blockNumber ?? -1; // -1 will attempt to find the block number from RPC return { - clock: { - period: 1000, - initialTime: 0, - syncInterval: 5000, - }, - provider: { - chainId, - jsonRpcUrl: params.get("rpc") ?? chain.rpcUrls.default.http[0], - wsRpcUrl: params.get("wsRpc") ?? chain.rpcUrls.default.webSocket?.[0], - }, privateKey: getBurnerWallet().value, chainId, chain, faucetServiceUrl: params.get("faucet") ?? chain.faucetUrl, worldAddress, initialBlockNumber, - disableCache: params.get("cache") === "false", }; } diff --git a/templates/vanilla/packages/client/src/mud/setupNetwork.ts b/templates/vanilla/packages/client/src/mud/setupNetwork.ts index b74f6f9669d..4668426380f 100644 --- a/templates/vanilla/packages/client/src/mud/setupNetwork.ts +++ b/templates/vanilla/packages/client/src/mud/setupNetwork.ts @@ -1,4 +1,5 @@ -import { getBurnerWallet } from "@latticexyz/std-client"; +import { createPublicClient, fallback, webSocket, http, createWalletClient, getContract, Hex, parseEther } from "viem"; +import { privateKeyToAccount } from "viem/accounts"; import { createFaucetService } from "@latticexyz/network"; import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; import { getNetworkConfig } from "./getNetworkConfig"; @@ -6,8 +7,6 @@ import { defineContractComponents } from "./contractComponents"; import { world } from "./world"; import { IWorld__factory } from "contracts/types/ethers-contracts/factories/IWorld__factory"; import storeConfig from "contracts/mud.config"; -import { createPublicClient, fallback, webSocket, http, createWalletClient, getContract, Hex, parseEther } from "viem"; -import { privateKeyToAccount } from "viem/accounts"; export type SetupNetworkResult = Awaited>; @@ -27,9 +26,10 @@ export async function setupNetwork() { address: networkConfig.worldAddress as Hex, publicClient, components: contractComponents, + startBlock: BigInt(networkConfig.initialBlockNumber), }); - const burnerAccount = privateKeyToAccount(getBurnerWallet().value); + const burnerAccount = privateKeyToAccount(networkConfig.privateKey as Hex); const burnerWalletClient = createWalletClient({ account: burnerAccount, chain: networkConfig.chain,