Skip to content

Commit

Permalink
deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Mar 29, 2024
1 parent 5516eb5 commit a0b0070
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/config/game.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ fn initialize_game_config(world: IWorldDispatcher) {
world,
GameConfig {
key: GAME_CONFIG_KEY,
cash: 1421, // 690
cash: 1000, // 690
health: 100, // 100,
max_turns: 42,
max_turns: 30,
max_wanted_shopping: 5,
max_rounds: 3,
}
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/layout/ConnectionError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Button, Flex, Text, VStack } from "@chakra-ui/react";
import { useRouter } from "next/router";
import { ChainSelector } from "../wallet";

const ConnectionError = ({ errors }: { errors: string[] }) => {
const ConnectionError = ({ errors }: { errors: (string | undefined)[] }) => {
const router = useRouter();

return (
Expand All @@ -11,9 +11,9 @@ const ConnectionError = ({ errors }: { errors: string[] }) => {
<VStack fontSize="16px">
<VStack fontSize="16px">
<Text>Unable to connect</Text>
{errors.map((e) => {
{errors.map((e,key) => {
if (e) {
return <Text>{e}</Text>;
return <Text key={key}>{e}</Text>;
}
})}
</VStack>
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/pages/admin/DrugTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useDojoContext } from "@/dojo/hooks";
import { observer } from "mobx-react-lite";
import DataTable from "react-data-table-component";
import { customTableStyles, getTableColumns } from "./tables";
import { getTableColumns } from "./tables";

const columns = getTableColumns(["drug", "drug_id", "name", "base", "step", "weight"]);

export const DrugTable = observer(() => {
const {
configStore: { config },
} = useDojoContext();
return <DataTable customStyles={customTableStyles} columns={columns} data={config?.drug} />;
return <DataTable columns={columns} data={config?.drug || []} />;
});
9 changes: 4 additions & 5 deletions web/src/components/pages/admin/GameLayoutTable.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { useDojoContext } from "@/dojo/hooks";
import { observer } from "mobx-react-lite";
import DataTable from "react-data-table-component";
import { customTableStyles } from "./tables";

// bigint not supported ...
// const columns = getTableColumns(["name", "idx", "bits"]);

const columns = [
{
name: "name",
selector: (row) => row["name"],
selector: (row: any) => row["name"],
},
{
name: "idx",
selector: (row) => Number(row["idx"]),
selector: (row: any) => Number(row["idx"]),
},
{
name: "bits",
selector: (row) => Number(row["bits"]),
selector: (row: any) => Number(row["bits"]),
},
]

export const GameLayoutTable = observer(() => {
const {
configStore: { config },
} = useDojoContext();
return <DataTable customStyles={customTableStyles} columns={columns} data={config?.config.layouts.game_store} />;
return <DataTable columns={columns} data={config?.config.layouts.game_store || []} />;
});
4 changes: 2 additions & 2 deletions web/src/components/pages/admin/HustlerItemBaseTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useDojoContext } from "@/dojo/hooks";
import { observer } from "mobx-react-lite";
import DataTable from "react-data-table-component";
import { customTableStyles, getTableColumns } from "./tables";
import { getTableColumns } from "./tables";

const columns = getTableColumns(["slot", "id", "slot_id", "name", "initial_tier"]);

export const HustlerItemBaseTable = observer(() => {
const {
configStore: { config },
} = useDojoContext();
return <DataTable customStyles={customTableStyles} columns={columns} data={config?.items} />;
return <DataTable columns={columns} data={config?.items || []} />;
});
4 changes: 2 additions & 2 deletions web/src/components/pages/admin/HustlerItemTiersTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useDojoContext } from "@/dojo/hooks";
import { observer } from "mobx-react-lite";
import DataTable from "react-data-table-component";
import { customTableStyles, getTableColumns } from "./tables";
import { getTableColumns } from "./tables";

const columns = getTableColumns(["slot", "tier", "slot_id", "cost", "stat"]);

export const HustlerItemTiersTable = observer(() => {
const {
configStore: { config },
} = useDojoContext();
return <DataTable customStyles={customTableStyles} columns={columns} data={config?.tiers} />;
return <DataTable columns={columns} data={config?.tiers || []} />;
});
12 changes: 5 additions & 7 deletions web/src/components/pages/admin/PlayerLayoutTable.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { useDojoContext } from "@/dojo/hooks";
import { observer } from "mobx-react-lite";
import DataTable from "react-data-table-component";
import { customTableStyles } from "./tables";


// bigint not supported ...
// const columns = getTableColumns(["name", "idx", "bits"]);

const columns = [
{
name: "name",
selector: (row) => row["name"],
selector: (row: any) => row["name"],
},
{
name: "idx",
selector: (row) => Number(row["idx"]),
selector: (row: any) => Number(row["idx"]),
},
{
name: "bits",
selector: (row) => Number(row["bits"]),
selector: (row: any) => Number(row["bits"]),
},
]
];

export const PlayerLayoutTable = observer(() => {
const {
configStore: { config },
} = useDojoContext();
return <DataTable customStyles={customTableStyles} columns={columns} data={config?.config.layouts.player} />;
return <DataTable columns={columns} data={config?.config.layouts.player || []} />;
});
2 changes: 1 addition & 1 deletion web/src/components/pages/admin/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function getTableColumns(fields: string[]) {
return fields.map((field) => {
return {
name: field,
selector: (row) => row[field],
selector: (row: any) => row[field],
};
});
}
2 changes: 1 addition & 1 deletion web/src/components/wallet/ChainSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDisconnect } from "@starknet-react/core";

type ChainSelectorProps = {
canChange: boolean;
onChange: VoidFunction;
onChange?: VoidFunction;
};

export const ChainSelector = ({ canChange = false, onChange = () => {} }: ChainSelectorProps) => {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/wallet/Predeployed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PredeployedManagerUi } from "./ui/PredeployedManagerUi";

export const Predeployed = () => {
const { predeployedManager } = useDojoContext();
const { connector, isConnected } = useConnect();
const { connector } = useConnect();
const { account } = useAccount();

if (!predeployedManager) return null;
Expand Down
17 changes: 10 additions & 7 deletions web/src/dojo/context/DojoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { QueryClientProvider } from "react-query";
import { Account, AccountInterface } from "starknet";
import { DojoChainsResult, useDojoChains } from "../hooks/useDojoChains";
import { DojoClientsResult, useDojoClients } from "../hooks/useDojoClients";
import { DojoContextConfig } from "../setup/config";
import { DojoContextConfig, SupportedChainIds } from "../setup/config";
import { ConfigStoreClass } from "../stores/config";
import { GameStoreClass } from "../stores/game";

Expand All @@ -36,7 +36,11 @@ export const DojoContextProvider = observer(
const currentValue = useContext(DojoContext);
if (currentValue) throw new Error("DojoProvider can only be used once");

const [configStoreState, setConfigStoreState] = useState({
const [configStoreState, setConfigStoreState] = useState<{
isInitialized: boolean;
isError: boolean;
error: string | undefined;
}>({
isInitialized: false,
isError: false,
error: undefined,
Expand All @@ -47,6 +51,7 @@ export const DojoContextProvider = observer(

const lastSelectedChainId =
typeof window !== "undefined" ? window?.localStorage?.getItem("lastSelectedChainId") : undefined;

const intialChain =
lastSelectedChainId && dojoContextConfig[lastSelectedChainId as SupportedChainIds]
? dojoContextConfig[lastSelectedChainId as SupportedChainIds]
Expand All @@ -65,7 +70,6 @@ export const DojoContextProvider = observer(

const burnerManager = useMemo(() => {
if (!masterAccount) return undefined;
// console.log("new BurnerManager");

return new BurnerManager({
masterAccount: masterAccount!,
Expand All @@ -76,7 +80,6 @@ export const DojoContextProvider = observer(

const predeployedManager = useMemo(() => {
if (!selectedChain.predeployedAccounts || selectedChain.predeployedAccounts.length === 0) return undefined;
// console.log("new BurnerManager");

return new PredeployedManager({
rpcProvider: rpcProvider,
Expand All @@ -89,7 +92,7 @@ export const DojoContextProvider = observer(
isError: burnerSWOIsError,
error: burnerSWOError,
} = useBurnerWindowObject(burnerManager);

const {
isInitialized: predeployedSWOIsInitialized,
isError: predeployedSWOIsError,
Expand All @@ -114,7 +117,7 @@ export const DojoContextProvider = observer(

useEffect(() => {
const initAsync = async () => {
if(!configStore) return
if (!configStore) return;
try {
await configStore.init();
setConfigStoreState({
Expand All @@ -139,7 +142,7 @@ export const DojoContextProvider = observer(

// console.log("isInitialized", isInitialized);
// console.log("hasError", hasError);

// is initializing
if (!hasError && !isInitialized)
return (
Expand Down
13 changes: 7 additions & 6 deletions web/src/dojo/hooks/useSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ export interface SystemsInterface {
endGame: (gameId: string, actions: Array<PendingCall>) => Promise<SystemExecuteResult>;
decide: (gameId: string, action: EncountersAction) => Promise<SystemExecuteResult>;
claim: (season: number) => Promise<SystemExecuteResult>;
//
//
setPaused: (paused: boolean) => Promise<SystemExecuteResult>;
claimTreasury: () => Promise<SystemExecuteResult>;
setPaperFee: (fee: number) => Promise<SystemExecuteResult>;
setTreasuryFeePct: (fee: number) => Promise<SystemExecuteResult>;
//
//
failingTx: () => Promise<SystemExecuteResult>;
feedLeaderboard: (count: number) => Promise<SystemExecuteResult>;
feedLeaderboard: (count: number) => Promise<SystemExecuteResult>;

isPending: boolean;
error?: string;
Expand Down Expand Up @@ -361,7 +362,7 @@ export const useSystems = (): SystemsInterface => {
{
contractName: "rollyourown::systems::ryo::ryo",
functionName: "set_paused",
callData: [paused],
callData: [paused ? 0 : 1],
}
);

Expand Down Expand Up @@ -413,9 +414,9 @@ export const useSystems = (): SystemsInterface => {
);








//
//
Expand Down
9 changes: 8 additions & 1 deletion web/src/dojo/setup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ const katanaSlot420: DojoChainConfig = {
masterPrivateKey: "0x2e8ac99614186737cefc47effe03134f5a19c6dc2443c16510d3384769f9c78",
accountClassHash: "0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c",
manifest,
predeployedAccounts: []
predeployedAccounts: [
{
name: "Deployer",
address: "0x754d8bc62099e306ab40deb98accc3e717eb1a7b8838060c6312c6e8f8ee1d7",
privateKey: "0x2f9a2435c3195dfa3c2f8290de5347e0da48193fd6d6d80320f0201a0964b8c",
active: false
},
]
}

const katanaSlot421: DojoChainConfig = {
Expand Down
10 changes: 0 additions & 10 deletions web/src/pages/_error.tsx

This file was deleted.

0 comments on commit a0b0070

Please sign in to comment.