Skip to content

Commit

Permalink
fix live spectate
Browse files Browse the repository at this point in the history
  • Loading branch information
Await-0x committed Feb 21, 2025
1 parent d8a6ae9 commit 360fe33
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@cartridge/connector": "0.6.0",
"@cartridge/controller": "0.6.0",
"@dojoengine/core": "^1.0.0",
"@dojoengine/torii-client": "^1.0.11",
"@dojoengine/torii-client": "^1.1.3",
"@dojoengine/utils": "^1.0.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
Expand Down
18 changes: 9 additions & 9 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion client/src/contexts/dojoContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const DojoProvider = ({ children }) => {
<DojoContext.Provider
value={{
address: address,
provider: dojoprovider,
connecting: isConnecting,
network: chain.network,
userName,
Expand Down
16 changes: 7 additions & 9 deletions client/src/contexts/replayContext.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { createClient } from "@dojoengine/torii-client";
import { useAccount, useConnect } from '@starknet-react/core';
import { useSnackbar } from 'notistack';
import React, { createContext, useContext, useEffect, useState } from 'react';
import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';
import { RpcProvider } from "starknet";
import { dojoConfig } from "../../dojo.config";
import { getGameTxs, getSettings } from '../api/indexer';
import { CARD_DETAILS, formatBoard } from '../helpers/cards';
import { LAST_NODE_LEVEL } from "../helpers/constants";
import { translateEvent } from '../helpers/events';
import { generateMapNodes } from '../helpers/map';
import { BattleContext } from './battleContext';
import { DraftContext } from './draftContext';
import { GAME_STATES, GameContext } from './gameContext';
import { dojoConfig } from "../../dojo.config";
import { useCallback } from "react";
import { LAST_NODE_LEVEL } from "../helpers/constants";

// Create a context
const ReplayContext = createContext();
Expand All @@ -23,11 +22,9 @@ export const ReplayProvider = ({ children }) => {
const battle = useContext(BattleContext)

const { enqueueSnackbar } = useSnackbar()
const { account } = useAccount()
const { connect, connectors } = useConnect();
const [toriiClient, setToriiClient] = useState(null)

let cartridgeConnector = connectors.find(conn => conn.id === "controller")
let provider = new RpcProvider({ nodeUrl: dojoConfig.rpcUrl });

const [txHashes, setTxHashes] = useState([]);
const [step, setStep] = useState(0)
Expand All @@ -53,7 +50,7 @@ export const ReplayProvider = ({ children }) => {
return
}

const receipt = await dojo.provider.waitForTransaction(txHash || txHashes[step], { retryInterval: 100 })
const receipt = await provider.waitForTransaction(txHash || txHashes[step], { retryInterval: 100 })
if (!receipt) {
enqueueSnackbar('Failed to load replay', { variant: 'error', anchorOrigin: { vertical: 'bottom', horizontal: 'right' } })
endReplay()
Expand Down Expand Up @@ -204,6 +201,7 @@ export const ReplayProvider = ({ children }) => {
[],
false,
(_, data) => {
console.log('data', data)
if (Boolean(data[`${dojoConfig.namespace}-GameActionEvent`])) {
let gameId = data[`${dojoConfig.namespace}-GameActionEvent`]["game_id"].value

Expand Down

0 comments on commit 360fe33

Please sign in to comment.