Skip to content

Commit

Permalink
[client] show battle info on hover
Browse files Browse the repository at this point in the history
Fixes #1865
  • Loading branch information
aymericdelab committed Oct 22, 2024
2 parents eea0d82 + 8165175 commit a0506a2
Show file tree
Hide file tree
Showing 33 changed files with 579 additions and 738 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ jobs:
realm_test,
guild_test,
transport_test,
test_ownership_systems,
]
fail-fast: false
steps:
- name: Download Dojo release artifact
run: |
curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/v1.0.0-alpha.16/dojo_v1.0.0-alpha.16_linux_amd64.tar.gz
curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/v1.0.0-alpha.17/dojo_v1.0.0-alpha.17_linux_amd64.tar.gz
tar -xzf dojo-linux-x86_64.tar.gz
sudo mv sozo /usr/local/bin/
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.7.0
dojo 1.0.0-alpha.16
dojo 1.0.0-alpha.17
2 changes: 1 addition & 1 deletion client/.env.preview
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_PUBLIC_MASTER_ADDRESS="0x1a3e37c77be7de91a9177c6b57956faa6da25607e567b10a25cf64fea5e533b"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0x4ab5a607d92f0870cfd82ef9cecb2fe903830441180fd432b831a8863c08097"
VITE_PUBLIC_WORLD_ADDRESS="0x320b2713e324fe3125bbc42d85ff69cb3c0908b436fa38a35746dbc45deeb11"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"
VITE_EVENT_KEY="0x1a2f334228cee715f1f0f54053bb6b5eac54fa336e0bc1aacf7516decb0471d"
VITE_PUBLIC_TORII="https://api.cartridge.gg/x/eternum-42/torii"
VITE_PUBLIC_NODE_URL="https://api.cartridge.gg/x/eternum-42/katana/"
Expand Down
2 changes: 1 addition & 1 deletion client/.env.production
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_PUBLIC_MASTER_ADDRESS="0x779c2c098f066ddde5850ec8426511e46e6499adf0b5c77e8961917413b57db"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0x189765c7b9daa2efdd3025d3236a929ce5e510834b8cba4f002a0d5c1accb5a"
VITE_PUBLIC_WORLD_ADDRESS="0x320b2713e324fe3125bbc42d85ff69cb3c0908b436fa38a35746dbc45deeb11"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"
VITE_EVENT_KEY="0x1a2f334228cee715f1f0f54053bb6b5eac54fa336e0bc1aacf7516decb0471d"
VITE_PUBLIC_TORII="https://api.cartridge.gg/x/eternum-42/torii"
VITE_PUBLIC_NODE_URL="https://api.cartridge.gg/x/eternum-42/katana/"
Expand Down
12 changes: 8 additions & 4 deletions client/.env.sample
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VITE_PUBLIC_MASTER_ADDRESS="0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
VITE_PUBLIC_WORLD_ADDRESS="0x177a3f3d912cf4b55f0f74eccf3b7def7c6144efeba033e9f21d9cdb0230c64"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c"
VITE_PUBLIC_MASTER_ADDRESS="0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912"
VITE_PUBLIC_WORLD_ADDRESS="0x320b2713e324fe3125bbc42d85ff69cb3c0908b436fa38a35746dbc45deeb11"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"
VITE_NETWORK_FEE_TOKEN="0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
VITE_EVENT_KEY="0x1a2f334228cee715f1f0f54053bb6b5eac54fa336e0bc1aacf7516decb0471d"
VITE_PUBLIC_TORII="http://localhost:8080"
Expand All @@ -12,5 +12,9 @@ VITE_PUBLIC_DEV=false
VITE_PUBLIC_SHOW_FPS=true
VITE_PUBLIC_GRAPHICS_DEV=false

VITE_SEASON_PASS_ADDRESS="0x18cd31a545b13597adeafa40979a7456aae9d12bd0b9a9879089ed051402c6c"
VITE_REALMS_ADDRESS="0x57e1cb22f5688a833ceff37d8569297877dd8fc1896e36f1a0c8b2d30b7de85"
VITE_LORDS_ADDRESS="0x5839f41cadbe12678b2e7b67bd6daa5bd54b7b19bdc835c87fe4662dbf7a93c"

# You will have to change this to your local torii. It will be in the printout.
VITE_PUBLIC_TORII_RELAY="/ip4/0.0.0.0/udp/9091/webrtc-direct/certhash/uEiAN3-ttwg-yphp9ZgqhSCGNsWLXIo0eHEsrLRUzp4SpKg"
2 changes: 1 addition & 1 deletion client/dojoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const dojoConfig = createDojoConfig({
masterAddress: VITE_PUBLIC_MASTER_ADDRESS,
masterPrivateKey: VITE_PUBLIC_MASTER_PRIVATE_KEY,
accountClassHash:
VITE_PUBLIC_ACCOUNT_CLASS_HASH || "0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c",
VITE_PUBLIC_ACCOUNT_CLASS_HASH || "0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2",
feeTokenAddress: VITE_PUBLIC_FEE_TOKEN_ADDRESS || "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
manifest,
});
14 changes: 7 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
"coverage": "vitest run --coverage"
},
"peerDependencies": {
"starknet": "6.7.0"
"starknet": "6.11.0"
},
"dependencies": {
"@bibliothecadao/eternum": "workspace:^",
"@dojoengine/core": "1.0.0-alpha.14",
"@dojoengine/create-burner": "1.0.0-alpha.14",
"@dojoengine/react": "1.0.0-alpha.14",
"@dojoengine/core": "1.0.0-alpha.22",
"@dojoengine/create-burner": "1.0.0-alpha.22",
"@dojoengine/react": "1.0.0-alpha.22",
"@dojoengine/recs": "^2.0.13",
"@dojoengine/state": "1.0.0-alpha.14",
"@dojoengine/torii-client": "1.0.0-alpha.14",
"@dojoengine/utils": "1.0.0-alpha.14",
"@dojoengine/state": "1.0.0-alpha.22",
"@dojoengine/torii-client": "1.0.0-alpha.22",
"@dojoengine/utils": "1.0.0-alpha.22",
"@headlessui/react": "^1.7.18",
"@latticexyz/utils": "^2.0.0-next.12",
"@radix-ui/react-select": "^2.0.0",
Expand Down
3 changes: 1 addition & 2 deletions client/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export async function setup({ ...config }: DojoConfig) {
const systemCalls = createSystemCalls(network);

// fetch all existing entities from torii
const sync = await getSyncEntities(network.toriiClient, network.contractComponents as any, [], 1000);

const sync = await getSyncEntities(network.toriiClient, network.contractComponents as any, undefined, [], 1000);
const eventSync = getSyncEvents(network.toriiClient, network.contractComponents.events as any, undefined, []);

configManager.setDojo(components);
Expand Down
34 changes: 13 additions & 21 deletions client/src/hooks/store/useBlockchainStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,22 @@ export const useFetchBlockchainData = () => {
const setCurrentDefaultTick = useUIStore((state) => state.setCurrentDefaultTick);
const setCurrentArmiesTick = useUIStore((state) => state.setCurrentArmiesTick);

const tickConfigArmies = getComponentValue(
TickConfig,
getEntityIdFromKeys([WORLD_CONFIG_ID, BigInt(TickIds.Armies)]),
);
const tickConfigDefault = getComponentValue(
TickConfig,
getEntityIdFromKeys([WORLD_CONFIG_ID, BigInt(TickIds.Default)]),
);

useEffect(() => {
const tickConfigArmies = getComponentValue(
TickConfig,
getEntityIdFromKeys([WORLD_CONFIG_ID, BigInt(TickIds.Armies)]),
);
const tickConfigDefault = getComponentValue(
TickConfig,
getEntityIdFromKeys([WORLD_CONFIG_ID, BigInt(TickIds.Default)]),
);

console.log(tickConfigArmies, tickConfigDefault);

const fetchBlockchainTimestamp = async () => {
// Perform the necessary logic to fetch the blockchain timestamp
const timestamp = await fetchBlockTimestamp(); // Example: getBlockchainTimestamp is a placeholder for your blockchain timestamp retrieval logic
const timestamp = Math.floor(Date.now() / 1000);

// Update the state with the fetched timestamp
if (timestamp) {
// Check if fetched timestamp is different from current state
setNextBlockTimestamp(timestamp);
setCurrentDefaultTick(Math.floor(timestamp / Number(tickConfigDefault!.tick_interval_in_seconds)));
setCurrentArmiesTick(Math.floor(timestamp / Number(tickConfigArmies!.tick_interval_in_seconds)));
Expand All @@ -59,15 +58,8 @@ export const useFetchBlockchainData = () => {

fetchBlockchainTimestamp(); // Initial fetch

const intervalId = setInterval(fetchBlockchainTimestamp, 10000); // Fetch every 10 seconds

return () => {
clearInterval(intervalId); // Clear interval on component unmount
clearInterval(setInterval(fetchBlockchainTimestamp, 10000));
};
}, []);
};

const fetchBlockTimestamp = async (): Promise<number | undefined> => {
const currentTimestamp = Math.floor(Date.now() / 1000);
return currentTimestamp;
};
5 changes: 1 addition & 4 deletions client/src/ui/modules/military/Military.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import { useQuery } from "@/hooks/helpers/useQuery";
import { EntityArmyList } from "@/ui/components/military/ArmyList";
import { EntitiesArmyTable } from "@/ui/components/military/EntitiesArmyTable";
import { ID } from "@bibliothecadao/eternum";
import { useMemo } from "react";

export const Military = ({ entityId, className }: { entityId: ID | undefined; className?: string }) => {
const { isMapView } = useQuery();

const { playerStructures } = useEntities();

const selectedStructure = useMemo(() => {
return playerStructures().find((structure) => structure.entity_id === entityId);
}, [playerStructures, entityId]);
const selectedStructure = playerStructures().find((structure) => structure.entity_id === entityId);

return (
<div className={`relative ${className}`}>
Expand Down
4 changes: 2 additions & 2 deletions config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"peerDependencies": {
"typescript": "^5.0.0",
"@bibliothecadao/eternum": "workspace:^",
"@dojoengine/core": "1.0.0-alpha.14",
"starknet": "6.7.0"
"@dojoengine/core": "1.0.0-alpha.21",
"starknet": "6.11.0"
}
}
2 changes: 1 addition & 1 deletion contracts/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.7.0
dojo 1.0.0-alpha.16
dojo 1.0.0-alpha.17
2 changes: 1 addition & 1 deletion contracts/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ source = "git+https://github.com/dojoengine/cubit?branch=cairo_2.7#53020b6320a10
[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.16#3b3a78cd8239ca2ee524c49c83f36db4d79cb4bc"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.17#3b3a78cd8239ca2ee524c49c83f36db4d79cb4bc"

[[package]]
name = "eternum"
Expand Down
2 changes: 1 addition & 1 deletion contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "1.0.0"
sierra-replace-ids = true

[dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.16" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "e1b080577aaa6889116fc8be5dde72b2fd21e397" }
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "e1b080577aaa6889116fc8be5dde72b2fd21e397" }
cubit = { git = "https://github.com/dojoengine/cubit", branch = "cairo_2.7" }
Expand Down
4 changes: 2 additions & 2 deletions contracts/dojo_dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ default = "eternum"

[env]
## dev
account_address = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca"
private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
account_address = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"
private_key = "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912"

[world]
seed = "eternum"
Expand Down
Loading

0 comments on commit a0506a2

Please sign in to comment.