Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/client/src/components/DevTools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import mudConfig from 'contracts/mud.config';
import { useEffect } from 'react';

import { useMUD } from '../contexts/MUDContext';

// Displays dev-tools connected to the burner wallet
export function DevTools(): null {
const { network } = useMUD();

useEffect(() => {
let unmount: (() => void) | undefined;

import('@latticexyz/dev-tools')
.then(({ mount }) =>
mount({
config: mudConfig,
publicClient: network.publicClient,
walletClient: network.walletClient,
latestBlock$: network.latestBlock$,
storedBlockLogs$: network.storedBlockLogs$,
worldAddress: network.worldContract.address,
worldAbi: network.worldContract.abi,
write$: network.write$,
recsWorld: network.world,
}),
)
.then(result => {
unmount = result;
});

return () => {
if (unmount) {
unmount();
}
};
}, [network]);

return null;
}
19 changes: 2 additions & 17 deletions packages/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import '@rainbow-me/rainbowkit/styles.css';

import { ChakraProvider } from '@chakra-ui/react';
import { Global } from '@emotion/react';
import mudConfig from 'contracts/mud.config';
import { createRoot } from 'react-dom/client';

import { App } from './App';
import { DevTools } from './components/DevTools';
import { MUDProvider } from './contexts/MUDContext';
import { Web3Provider } from './contexts/Web3Provider';
import { setup } from './lib/mud/setup';
Expand All @@ -30,24 +30,9 @@ setup().then(async result => {
<Web3Provider>
<MUDProvider setupResult={result}>
<App />
<DevTools />
</MUDProvider>
</Web3Provider>
</ChakraProvider>,
);

// https://vitejs.dev/guide/env-and-mode.html
if (import.meta.env.DEV) {
const { mount: mountDevTools } = await import('@latticexyz/dev-tools');
mountDevTools({
config: mudConfig,
publicClient: result.network.publicClient,
walletClient: result.network.walletClient,
latestBlock$: result.network.latestBlock$,
storedBlockLogs$: result.network.storedBlockLogs$,
worldAddress: result.network.worldContract.address,
worldAbi: result.network.worldContract.abi,
write$: result.network.write$,
recsWorld: result.network.world,
});
}
});
2 changes: 1 addition & 1 deletion packages/client/src/lib/mud/supportedChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const baseSepolia = {

const getSupportedChains = () => {
if (import.meta.env.DEV) {
return [mudFoundry];
return [baseSepolia, mudFoundry];
}

return [baseSepolia];
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/lib/web3/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const CHAIN_ID_TO_LABEL: { [key: number]: string } = {

const getSupportedChains = () => {
if (import.meta.env.DEV) {
return [anvil] as const;
return [anvil, baseSepolia] as const;
}

return [baseSepolia] as const;
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/pages/CharacterCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export const CharacterCreation = (): JSX.Element => {
await new Promise(resolve => setTimeout(resolve, 2000));

renderSuccess('Character created!');
navigate('/world');
} catch (e) {
renderError(e, 'Failed to create character.');
} finally {
setIsCreating(false);
navigate('/world');
}
},
[
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/worlds.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"address": "0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b"
},
"84532": {
"address": "0x203630cba12f27a6a995eb20baae9c3caaf63fdc",
"blockNumber": 10440031
"address": "0xea59f64d860d4be9918dc2c93bf8a5e84c875324",
"blockNumber": 10874436
}
}