Skip to content

Commit

Permalink
fix: fix mud tool
Browse files Browse the repository at this point in the history
  • Loading branch information
TiyoSheng committed Nov 5, 2023
1 parent bd00e95 commit 439e93e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@latticexyz/world": "2.0.0-next.4",
"@openzeppelin/contracts": "^4.9.3",
"@types/node": "^18.15.11",
"@vitejs/plugin-react": "^4.1.1",
"antd": "^5.9.2",
"buffer": "^6.0.3",
"contracts": "workspace:*",
Expand Down
49 changes: 22 additions & 27 deletions packages/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,33 @@ import { world } from "@/mud/world";
import { MUDProvider } from "@/mud/MUDContext";
const { network } = await setup();

// Components expose a stream that triggers when the component is updated.

const rootElement = document.getElementById("root");
if (!rootElement) throw new Error("React root not found");
const root = ReactDOM.createRoot(rootElement);

setup().then(async (result) => {
root.render(
<MUDProvider value={result}>
<App />
</MUDProvider>
);
const { mount: mountDevTools } = await import("@latticexyz/dev-tools");
const comp = [];
network.world.components.forEach((c) => {
if (comp.findIndex((item) => item.id === c.id) === -1) {
comp.push(c);
}
});
network.world.components = comp;
mountDevTools({
config: mudConfig,
publicClient: network.publicClient,
walletClient: network.walletClient,
latestBlock$: network.latestBlock$,
blockStorageOperations$: network.blockStorageOperations$,
worldAddress: network.worldContract.address,
worldAbi: network.worldContract.abi,
write$: network.write$,
recsWorld: network.world,
});
});
if (!rootElement) throw new Error("React root not found");

const root = ReactDOM.createRoot(rootElement);

// https://vitejs.dev/guide/env-and-mode.html
const { mount: mountDevTools } = await import("@latticexyz/dev-tools");
const comp = [];
network.world.components.forEach((c) => {
if (comp.findIndex((item) => item.id === c.id) === -1) {
comp.push(c);
}
});
network.world.components = comp;
mountDevTools({
config: mudConfig,
publicClient: network.publicClient,
walletClient: network.walletClient,
latestBlock$: network.latestBlock$,
blockStorageOperations$: network.blockStorageOperations$,
worldAddress: network.worldContract.address,
worldAbi: network.worldContract.abi,
write$: network.write$,
recsWorld: network.world,
});
console.log("mounted");
2 changes: 2 additions & 0 deletions packages/client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineConfig } from "vite";
import path from 'path';
import react from "@vitejs/plugin-react";

export default defineConfig({
plugins: [react()],
server: {
port: 3000,
fs: {
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/worlds.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"blockNumber": 29407241
},
"31337": {
"address": "0x607c2d79E406a5DC2D1E01b6820dd5a72FbA58C7"
"address": "0x46d4674578a2daBbD0CEAB0500c6c7867999db34"
},
"421613": {
"address": "0x2Bc1034975c3df48D6f3026802f372677844b85d",
Expand Down

0 comments on commit 439e93e

Please sign in to comment.