From d3049a2e0a27352361f4461f6d8a30a551c83f33 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Mon, 11 Sep 2023 03:44:03 -0700 Subject: [PATCH] feat(create-mud): add worlds.json types (#1430) --- e2e/packages/client-vanilla/src/mud/getNetworkConfig.ts | 4 +--- e2e/packages/contracts/worlds.json.d.ts | 2 ++ .../packages/client-phaser/src/mud/getNetworkConfig.ts | 4 +--- .../minimal/packages/client-react/src/mud/getNetworkConfig.ts | 4 +--- .../packages/client-vanilla/src/mud/getNetworkConfig.ts | 4 +--- examples/minimal/packages/contracts/worlds.json | 2 +- examples/minimal/packages/contracts/worlds.json.d.ts | 2 ++ templates/phaser/packages/client/src/mud/getNetworkConfig.ts | 4 +--- templates/phaser/packages/contracts/worlds.json.d.ts | 2 ++ templates/react/packages/client/src/mud/getNetworkConfig.ts | 4 +--- templates/react/packages/contracts/worlds.json.d.ts | 2 ++ templates/threejs/packages/client/src/mud/getNetworkConfig.ts | 4 +--- templates/threejs/packages/contracts/worlds.json.d.ts | 2 ++ templates/vanilla/packages/client/src/mud/getNetworkConfig.ts | 4 +--- templates/vanilla/packages/contracts/worlds.json.d.ts | 2 ++ 15 files changed, 21 insertions(+), 25 deletions(-) create mode 100644 e2e/packages/contracts/worlds.json.d.ts create mode 100644 examples/minimal/packages/contracts/worlds.json.d.ts create mode 100644 templates/phaser/packages/contracts/worlds.json.d.ts create mode 100644 templates/react/packages/contracts/worlds.json.d.ts create mode 100644 templates/threejs/packages/contracts/worlds.json.d.ts create mode 100644 templates/vanilla/packages/contracts/worlds.json.d.ts diff --git a/e2e/packages/client-vanilla/src/mud/getNetworkConfig.ts b/e2e/packages/client-vanilla/src/mud/getNetworkConfig.ts index 2dd56bf204..b5f06918e9 100644 --- a/e2e/packages/client-vanilla/src/mud/getNetworkConfig.ts +++ b/e2e/packages/client-vanilla/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/e2e/packages/contracts/worlds.json.d.ts b/e2e/packages/contracts/worlds.json.d.ts new file mode 100644 index 0000000000..90ffc786f4 --- /dev/null +++ b/e2e/packages/contracts/worlds.json.d.ts @@ -0,0 +1,2 @@ +declare const worlds: Partial>; +export default worlds; diff --git a/examples/minimal/packages/client-phaser/src/mud/getNetworkConfig.ts b/examples/minimal/packages/client-phaser/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/examples/minimal/packages/client-phaser/src/mud/getNetworkConfig.ts +++ b/examples/minimal/packages/client-phaser/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/examples/minimal/packages/client-react/src/mud/getNetworkConfig.ts b/examples/minimal/packages/client-react/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/examples/minimal/packages/client-react/src/mud/getNetworkConfig.ts +++ b/examples/minimal/packages/client-react/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/examples/minimal/packages/client-vanilla/src/mud/getNetworkConfig.ts b/examples/minimal/packages/client-vanilla/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/examples/minimal/packages/client-vanilla/src/mud/getNetworkConfig.ts +++ b/examples/minimal/packages/client-vanilla/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/examples/minimal/packages/contracts/worlds.json b/examples/minimal/packages/contracts/worlds.json index a0e86cef0d..4a742a204d 100644 --- a/examples/minimal/packages/contracts/worlds.json +++ b/examples/minimal/packages/contracts/worlds.json @@ -4,6 +4,6 @@ "blockNumber": 21817970 }, "31337": { - "address": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E" + "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3" } } \ No newline at end of file diff --git a/examples/minimal/packages/contracts/worlds.json.d.ts b/examples/minimal/packages/contracts/worlds.json.d.ts new file mode 100644 index 0000000000..90ffc786f4 --- /dev/null +++ b/examples/minimal/packages/contracts/worlds.json.d.ts @@ -0,0 +1,2 @@ +declare const worlds: Partial>; +export default worlds; diff --git a/templates/phaser/packages/client/src/mud/getNetworkConfig.ts b/templates/phaser/packages/client/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/templates/phaser/packages/client/src/mud/getNetworkConfig.ts +++ b/templates/phaser/packages/client/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/templates/phaser/packages/contracts/worlds.json.d.ts b/templates/phaser/packages/contracts/worlds.json.d.ts new file mode 100644 index 0000000000..90ffc786f4 --- /dev/null +++ b/templates/phaser/packages/contracts/worlds.json.d.ts @@ -0,0 +1,2 @@ +declare const worlds: Partial>; +export default worlds; diff --git a/templates/react/packages/client/src/mud/getNetworkConfig.ts b/templates/react/packages/client/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/templates/react/packages/client/src/mud/getNetworkConfig.ts +++ b/templates/react/packages/client/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/templates/react/packages/contracts/worlds.json.d.ts b/templates/react/packages/contracts/worlds.json.d.ts new file mode 100644 index 0000000000..90ffc786f4 --- /dev/null +++ b/templates/react/packages/contracts/worlds.json.d.ts @@ -0,0 +1,2 @@ +declare const worlds: Partial>; +export default worlds; diff --git a/templates/threejs/packages/client/src/mud/getNetworkConfig.ts b/templates/threejs/packages/client/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/templates/threejs/packages/client/src/mud/getNetworkConfig.ts +++ b/templates/threejs/packages/client/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/templates/threejs/packages/contracts/worlds.json.d.ts b/templates/threejs/packages/contracts/worlds.json.d.ts new file mode 100644 index 0000000000..90ffc786f4 --- /dev/null +++ b/templates/threejs/packages/contracts/worlds.json.d.ts @@ -0,0 +1,2 @@ +declare const worlds: Partial>; +export default worlds; diff --git a/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts b/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts index e6ed032bfa..47d5880408 100644 --- a/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts +++ b/templates/vanilla/packages/client/src/mud/getNetworkConfig.ts @@ -1,9 +1,7 @@ import { getBurnerPrivateKey } from "@latticexyz/common"; -import worldsJson from "contracts/worlds.json"; +import worlds from "contracts/worlds.json"; import { supportedChains } from "./supportedChains"; -const worlds = worldsJson as Partial>; - 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); diff --git a/templates/vanilla/packages/contracts/worlds.json.d.ts b/templates/vanilla/packages/contracts/worlds.json.d.ts new file mode 100644 index 0000000000..90ffc786f4 --- /dev/null +++ b/templates/vanilla/packages/contracts/worlds.json.d.ts @@ -0,0 +1,2 @@ +declare const worlds: Partial>; +export default worlds;