Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aymericdelab committed Jan 22, 2025
1 parent d67cca7 commit ca8ce55
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 282 deletions.
6 changes: 0 additions & 6 deletions client/apps/game/src/dojo/sync.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { AppStore } from "@/hooks/store/use-ui-store";
import { LoadingStateKey } from "@/hooks/store/use-world-loading";
import { ETERNUM_CONFIG } from "@/utils/config";
import {
BUILDING_CATEGORY_POPULATION_CONFIG_ID,
configManager,
HYPERSTRUCTURE_CONFIG_ID,
SetupResult,
WORLD_CONFIG_ID,
Expand Down Expand Up @@ -212,10 +210,6 @@ export const initialSync = async (setup: SetupResult, state: AppStore) => {
setLoading(LoadingStateKey.SingleKey, false);
});

const eternumConfig = await ETERNUM_CONFIG();
console.log({ eternumConfig });
configManager.setDojo(setup.components, eternumConfig);

setLoading(LoadingStateKey.Events, true);

await getEvents(
Expand Down
6 changes: 5 additions & 1 deletion client/apps/game/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="vite-plugin-pwa/client" />

import { setup } from "@bibliothecadao/eternum";
import { configManager, setup } from "@bibliothecadao/eternum";
import { inject } from "@vercel/analytics";
import { Buffer } from "buffer";
import React from "react";
Expand All @@ -20,6 +20,7 @@ import GameRenderer from "./three/game-renderer";
import { PWAUpdatePopup } from "./ui/components/pwa-update-popup";
import { LoadingScreen } from "./ui/modules/loading-screen";
import { getRandomBackgroundImage } from "./ui/utils/utils";
import { ETERNUM_CONFIG } from "./utils/config";

declare global {
interface Window {
Expand Down Expand Up @@ -71,6 +72,9 @@ async function init() {
{ vrfProviderAddress: env.VITE_PUBLIC_VRF_PROVIDER_ADDRESS, useBurner: env.VITE_PUBLIC_CHAIN === "local" },
);

const eternumConfig = await ETERNUM_CONFIG();
configManager.setDojo(setupResult.components, eternumConfig);

await initialSync(setupResult, state);

const graphic = new GameRenderer(setupResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import { useDojo } from "@bibliothecadao/react";
import React from "react";

// const eternumConfig = await ETERNUM_CONFIG();
const STRUCTURE_IMAGE_PREFIX = "/images/buildings/thumb/";
export const STRUCTURE_IMAGE_PATHS = {
[StructureType.Bank]: STRUCTURE_IMAGE_PREFIX + "mine.png",
Expand Down
195 changes: 0 additions & 195 deletions client/apps/landing/src/dojo/createSystemCalls.ts

This file was deleted.

24 changes: 0 additions & 24 deletions client/apps/landing/src/dojo/setup.ts

This file was deleted.

48 changes: 0 additions & 48 deletions client/apps/landing/src/dojo/setupNetwork.ts

This file was deleted.

3 changes: 0 additions & 3 deletions client/apps/landing/src/dojo/world.ts

This file was deleted.

15 changes: 13 additions & 2 deletions client/apps/landing/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import "./index.css";
// Import the generated route tree
//import { ArkProvider } from '@ark-project/react';

import { ClientConfigManager, setup } from "@bibliothecadao/eternum";
import { NuqsAdapter } from "nuqs/adapters/react";
import { dojoConfig } from "../dojoConfig";
import { StarknetProvider } from "./components/providers/starknet-provider";
import { ThemeProvider } from "./components/providers/theme-provider";
import { TypeH1 } from "./components/typography/type-h1";
import { setup } from "./dojo/setup";
import { DojoProvider } from "./hooks/context/DojoContext";
import { DojoEventListener } from "./hooks/subscriptions.tsx/dojo-event-listener";
import { routeTree } from "./routeTree.gen";
import { ETERNUM_CONFIG } from "./utils/config";
// Create a new router instance
const router = createRouter({ routeTree });

Expand All @@ -25,6 +26,16 @@ declare module "@tanstack/react-router" {
}
}

const initializeApp = async () => {
const setupResult = await setup(dojoConfig, {
vrfProviderAddress: import.meta.env.VITE_PUBLIC_VRF_PROVIDER_ADDRESS,
useBurner: import.meta.env.VITE_PUBLIC_CHAIN === "local",
});
const eternumConfig = await ETERNUM_CONFIG();
ClientConfigManager.instance().setDojo(setupResult.components, eternumConfig);
return setupResult;
};

// Render the app
const rootElement = document.getElementById("root")!;
if (!rootElement.innerHTML) {
Expand All @@ -40,7 +51,7 @@ if (!rootElement.innerHTML) {
</div>,
);

const setupResult = await setup(dojoConfig);
const setupResult = await initializeApp();

root.render(
<StrictMode>
Expand Down
Loading

0 comments on commit ca8ce55

Please sign in to comment.