diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c30feedda..6a19fa501 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - name: Download Dojo release artifact run: | - curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/v0.2.2/dojo_v0.2.2_linux_amd64.tar.gz + curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/v0.2.3/dojo_v0.2.3_linux_amd64.tar.gz tar -xzf dojo-linux-x86_64.tar.gz sudo mv sozo /usr/local/bin/ diff --git a/client/src/components/cityview/realm/labor/LaborBuild.tsx b/client/src/components/cityview/realm/labor/LaborBuild.tsx index 411388334..49805dc6d 100644 --- a/client/src/components/cityview/realm/labor/LaborBuild.tsx +++ b/client/src/components/cityview/realm/labor/LaborBuild.tsx @@ -129,6 +129,7 @@ export const LaborBuildPopup = ({ resourceId, setBuildLoadingStates, onClose }: optimisticBuildLabor( nextBlockTimestamp || 0, costResources, + laborAuctionAverageCoefficient, buildLabor, )({ signer: account, diff --git a/client/src/dojo/createOptimisticSystemCalls.ts b/client/src/dojo/createOptimisticSystemCalls.ts index 3d41f2d38..a660c7417 100644 --- a/client/src/dojo/createOptimisticSystemCalls.ts +++ b/client/src/dojo/createOptimisticSystemCalls.ts @@ -203,6 +203,7 @@ export function createOptimisticSystemCalls({ function optimisticBuildLabor( ts: number, costResources: LaborCostInterface[], + laborAuctionAverageCoefficient: number, systemCall: (args: BuildLaborProps) => Promise, ) { return async function (this: any, args: BuildLaborProps) { @@ -217,7 +218,8 @@ export function createOptimisticSystemCalls({ balance: 0, }; let balance = - currentResource.balance - (laborUnits as number) * (multiplier as number) * costResources[i].amount; + currentResource.balance - + (laborUnits as number) * (multiplier as number) * costResources[i].amount * laborAuctionAverageCoefficient; Resource.addOverride(overrideId, { entity: costId, value: { diff --git a/client/src/hooks/store/useBlockchainStore.tsx b/client/src/hooks/store/useBlockchainStore.tsx index 350955193..1932fffb2 100644 --- a/client/src/hooks/store/useBlockchainStore.tsx +++ b/client/src/hooks/store/useBlockchainStore.tsx @@ -29,7 +29,7 @@ export const useFetchBlockchainData = () => { fetchBlockchainTimestamp(); // Initial fetch - const intervalId = setInterval(fetchBlockchainTimestamp, 5000); // Fetch every 5 seconds + const intervalId = setInterval(fetchBlockchainTimestamp, 10000); // Fetch every 10 seconds return () => { clearInterval(intervalId); // Clear interval on component unmount @@ -58,20 +58,11 @@ const fetchBlockTimestamp = async (): Promise => { const data = await response.json(); return data.result; } else { - const reponse = await fetch(import.meta.env.VITE_KATANA_URL!, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - jsonrpc: "2.0", - method: "starknet_getBlockWithTxs", - params: { blockId: "latest" }, - id: 1, - }), - }); - const data = await reponse.json(); - return data.result.timestamp; + // NOTE: if we are using Katana in dev, we should use next block timestmamp because + // it allows us to advance time. But current issue with next_block_timestamp is that + // it does not get updated in katana until someone mints a new block. Since in prod we should + // not be able to use advance time, we should use current block timestamp + return Date.now() / 1000; } } catch (error) { console.error("Error fetching block timestamp:", error); diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index d62b6e275..d6cc28a75 100755 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -7,7 +7,7 @@ version = "0.1.0" sierra-replace-ids = true [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", rev = "47c0cbcfa4ebd4d4b504ec959fdbcfd3e4271e8a" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.2.3" } alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "e1aa42853815f04ff00e4ed3507cfd74d7b0c644" } cubit = { git = "https://github.com/influenceth/cubit" } # TODO: use dojo_defi when works with latest nightly