Skip to content

Fix/game client #2656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/apps/landing/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const envSchema = z.object({

// Version and chain info
VITE_PUBLIC_CHAIN: z.enum(["sepolia", "mainnet", "slot", "local"]), // Add other chains as needed

// Ark Marketplace API
// VITE_PUBLIC_ARK_MARKETPLACE_API: z.string().url(),
// VITE_PUBLIC_IMAGE_CDN_URL: z.string().url(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import ControllerConnector from "@cartridge/connector/controller";
import { ColorMode } from "@cartridge/controller";
import { mainnet, sepolia } from "@starknet-react/chains";
import { StarknetConfig, argent, braavos, jsonRpcProvider, useInjectedConnectors, voyager } from "@starknet-react/core";
import React, { useCallback } from "react";
import { constants } from "starknet";
import { env } from "../../../env";
import { getResourceAddresses } from "../ui/utils/addresses";
//import { cartridgeController } from "./cartridge-controller";

const resourceAddresses = await getResourceAddresses();

Expand All @@ -19,14 +17,14 @@ const theme: string = "eternum";
const slot: string = env.VITE_PUBLIC_SLOT;
const namespace: string = "eternum";
const preset: string = "eternum";
const colorMode: ColorMode = "dark";

const cartridgeController = new ControllerConnector({
chains: [{ rpcUrl: env.VITE_PUBLIC_NODE_URL }],
defaultChainId: constants.StarknetChainId.SN_SEPOLIA,
namespace,
slot,
preset,
policies: {},
theme,
tokens: {
erc20: [LORDS, ...otherResources],
Expand Down
3 changes: 1 addition & 2 deletions client/apps/landing/src/components/ui/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,5 @@ export {
SidebarRail,
SidebarSeparator,
SidebarTrigger,
useSidebar
useSidebar,
};

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
"starknet": "^6.8.0",
"viem": "^2.21.45",
"vocs": "latest",
"@cartridge/connector": "^0.5.7",
"@cartridge/controller": "^0.5.7",
"@cartridge/connector": "^0.6.x",
"@cartridge/controller": "^0.6.x",
Comment on lines +89 to +90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Fix the version range specification while maintaining package coupling

The version range ^0.6.x is non-standard in npm. Since these packages are tightly coupled (as seen in starknet-provider.tsx), they should maintain version alignment using standard semver:

-    "@cartridge/connector": "^0.6.x",
-    "@cartridge/controller": "^0.6.x",
+    "@cartridge/connector": "^0.6.0",
+    "@cartridge/controller": "^0.6.0",
🔗 Analysis chain

Fix the version range specification.

The version range ^0.6.x is non-standard and might cause issues:

  1. It's unclear if x is meant to be a wildcard
  2. npm semver doesn't recognize this format

Apply this diff to fix the version ranges:

-    "@cartridge/connector": "^0.6.x",
-    "@cartridge/controller": "^0.6.x",
+    "@cartridge/connector": "^0.6.0",
+    "@cartridge/controller": "^0.6.0",

Also, since this is a major version upgrade from 0.5.7, please verify compatibility with the new versions.

Run this script to check for breaking changes:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in the new versions

# Fetch release notes or changelogs
curl -s "https://registry.npmjs.org/@cartridge/connector" | jq '.versions["0.6.0"].dist.tarball' -r
curl -s "https://registry.npmjs.org/@cartridge/controller" | jq '.versions["0.6.0"].dist.tarball' -r

# Look for migration guides or breaking changes in the repository
rg -i "breaking.*changes|migration.*guide" README.md docs/

Length of output: 499


Script:

#!/bin/bash
# Search for usage patterns of both packages
echo "=== Searching for import/require patterns ==="
rg -l "@cartridge/connector.*@cartridge/controller|@cartridge/controller.*@cartridge/connector"

echo -e "\n=== Checking for other package.json files with these dependencies ==="
fd package.json --exec grep -l "@cartridge/\(connector\|controller\)"

echo -e "\n=== Verify if these packages are commonly imported together ==="
rg -B2 -A2 "require\(['\"']@cartridge/(connector|controller)['\"']\)|import.*from.*['\"']@cartridge/(connector|controller)['\"']"

Length of output: 1852

"@dojoengine/create-burner": "1.0.4-alpha.3.1.0",
"@dojoengine/react": "1.0.4-alpha.3.1.0",
"@dojoengine/recs": "^2.0.13",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export const getStructureAtPosition = (
};

export const getStructure = (
entityId: ID,
entityId: Entity | ID,
playerAddress: ContractAddress,
components: ClientComponents,
): Structure | undefined => {
const structureEntity = getEntityIdFromKeys([BigInt(entityId)]);
const structureEntity = typeof entityId === "string" ? entityId : getEntityIdFromKeys([BigInt(entityId)]);
return getStructureInfo(structureEntity, playerAddress, components);
};

Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/hooks/helpers/use-armies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export const useArmiesByStructure = ({ structureEntityId }: { structureEntityId:
const armies = useEntityQuery([
Has(components.Army),
Has(components.Position),
NotValue(components.Health, { current: 0n }),
Has(components.Quantity),
HasValue(components.EntityOwner, { entity_owner_id: structureEntityId }),
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/helpers/use-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const usePlayerStructures = (playerAddress?: ContractAddress) => {

const playerStructures = useMemo(() => {
return entities
.map((id) => getStructure(Number(id), ContractAddress(account.address), components))
.map((id) => getStructure(id, ContractAddress(account.address), components))
.filter((structure): structure is Structure => structure !== undefined)
.sort((a, b) => a.category.localeCompare(b.category));
}, [entities]);
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/hooks/helpers/use-players.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Player } from "@bibliothecadao/eternum";
import { useEntityQuery } from "@dojoengine/react";
import { getComponentValue, Has } from "@dojoengine/recs";
import { useMemo } from "react";
import { shortString } from "starknet";
import { useDojo } from "../context";

export const usePlayers = (): Player[] => {
Expand All @@ -16,7 +17,11 @@ export const usePlayers = (): Player[] => {
.map((id) => {
const addressName = getComponentValue(components.AddressName, id);
if (!addressName) return;
return { entity: id, address: addressName.address, name: addressName.name.toString() };
return {
entity: id,
address: addressName.address,
name: shortString.decodeShortString(addressName.name.toString()),
};
})
.filter(Boolean) as Player[];
}, [entities]);
Expand Down
44 changes: 20 additions & 24 deletions pnpm-lock.yaml

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

Loading