diff --git a/landing/src/components/modules/bridge-in.tsx b/landing/src/components/modules/bridge-in.tsx
index 1beb42d53..851a1e0fe 100644
--- a/landing/src/components/modules/bridge-in.tsx
+++ b/landing/src/components/modules/bridge-in.tsx
@@ -77,7 +77,7 @@ export const BridgeIn = () => {
});
};
- const { playerRealms } = useEntities();
+ const { playerStructures } = useEntities();
const travelTime = useMemo(() => {
if (realmEntityId) {
@@ -238,21 +238,21 @@ export const BridgeIn = () => {
}
>
{address ? (
-
+
) : (
-- Connect your wallet --
)}
- {playerRealms?.length
- ? playerRealms.map((realm) => {
+ {playerStructures?.length
+ ? playerStructures.map((structure) => {
return (
-
- #{realm.realmId} - {realm.name}
+
+ #{structure.realmId} - {structure.name}
);
})
- : "No Realms settled in Eternum"}
+ : "No Structure settled in Eternum"}
diff --git a/landing/src/components/modules/bridge-out-step-1.tsx b/landing/src/components/modules/bridge-out-step-1.tsx
index 231c62aff..a8dd204de 100644
--- a/landing/src/components/modules/bridge-out-step-1.tsx
+++ b/landing/src/components/modules/bridge-out-step-1.tsx
@@ -87,7 +87,7 @@ export const BridgeOutStep1 = () => {
}
}, [getBalance, realmEntityId]);
- const { playerRealms } = useEntities();
+ const { playerStructures } = useEntities();
const travelTime = useMemo(() => {
if (realmEntityId) {
@@ -226,13 +226,13 @@ export const BridgeOutStep1 = () => {
: "border-gold/40")
}
>
- {address ? : -- Connect your wallet --
}
+ {address ? : -- Connect your wallet --
}
- {playerRealms?.map((realm) => {
+ {playerStructures?.map((structure) => {
return (
-
- #{realm.realmId} - {realm.name}
+
+ #{structure.realmId} - {structure.name}
);
})}
diff --git a/landing/src/components/modules/bridge-out-step-2.tsx b/landing/src/components/modules/bridge-out-step-2.tsx
index 0caaa59cd..559ceb328 100644
--- a/landing/src/components/modules/bridge-out-step-2.tsx
+++ b/landing/src/components/modules/bridge-out-step-2.tsx
@@ -19,11 +19,9 @@ import { BridgeFees } from "./bridge-fees";
export const BridgeOutStep2 = () => {
const { address } = useAccount();
- const { playerRealms } = useEntities();
+ const { playerStructures } = useEntities();
- console.log({ playerRealms });
-
- const { donkeyInfos } = useDonkeyArrivals(playerRealms.map((realm) => realm.entityId));
+ const { donkeyInfos } = useDonkeyArrivals(playerStructures.map((structure) => structure.entityId));
const [isLoading, setIsLoading] = useState(false);
const [isRefreshing, setIsRefreshing] = useState(false);
diff --git a/landing/src/hooks/gql/graphql.ts b/landing/src/hooks/gql/graphql.ts
index 7bc17ca3e..34c0aceaa 100644
--- a/landing/src/hooks/gql/graphql.ts
+++ b/landing/src/hooks/gql/graphql.ts
@@ -7352,7 +7352,7 @@ export const GetCapacitySpeedConfigDocument = new TypedDocumentString(`
`) as unknown as TypedDocumentString;
export const GetEternumOwnerRealmIdsDocument = new TypedDocumentString(`
query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {
- s0EternumOwnerModels(where: {address: $accountAddress}) {
+ s0EternumOwnerModels(where: {address: $accountAddress}, limit: 1000) {
edges {
node {
address
diff --git a/landing/src/hooks/helpers/use-sync-entity.tsx b/landing/src/hooks/helpers/use-sync-entity.tsx
deleted file mode 100644
index e3511daff..000000000
--- a/landing/src/hooks/helpers/use-sync-entity.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { addToSubscription } from "@/dojo/queries";
-import { useEffect, useMemo, useState } from "react";
-import { useDojo } from "../context/DojoContext";
-import { useEntities } from "./useEntities";
-
-export const useSyncEntity = (entityIds: number | number[]) => {
- const dojo = useDojo();
- const [isSyncing, setIsSyncing] = useState(false);
-
- useEffect(() => {
- setIsSyncing(true);
- const fetch = async () => {
- try {
- const ids = Array.isArray(entityIds) ? entityIds : [entityIds];
- await Promise.all(
- ids.map((id) =>
- addToSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any, id.toString()),
- ),
- );
- } catch (error) {
- console.error("Fetch failed", error);
- } finally {
- setIsSyncing(false);
- }
- };
- fetch();
- }, [entityIds]);
-
- return isSyncing;
-};
-
-export const useSyncPlayerRealms = () => {
- const { playerRealms } = useEntities();
- const realmEntityIds = useMemo(() => {
- return playerRealms.map((realm) => realm!.entity_id);
- }, [playerRealms]);
-
- return useSyncEntity(realmEntityIds);
-};
diff --git a/landing/src/hooks/helpers/useEntities.tsx b/landing/src/hooks/helpers/useEntities.tsx
index f605b2087..f562b08a9 100644
--- a/landing/src/hooks/helpers/useEntities.tsx
+++ b/landing/src/hooks/helpers/useEntities.tsx
@@ -14,6 +14,10 @@ export function isS0EternumRealm(model: any): model is S0EternumRealm {
return model?.__typename === "s0_eternum_Realm";
}
+export function isS0EternumStructure(model: any): model is S0EternumRealm {
+ return model?.__typename === "s0_eternum_Structure";
+}
+
export const useEntities = () => {
const { address } = useAccount();
const { getRealmNameById } = useRealm();
@@ -40,8 +44,27 @@ export const useEntities = () => {
.filter(Boolean) as { realmId: number; entityId: number; name: string }[];
}, [data, getRealmNameById]);
+ const playerStructures = useMemo(() => {
+ if (!data) return [];
+
+ return data.s0EternumOwnerModels?.edges
+ ?.map((structure) => {
+ const structureModel = structure?.node?.entity?.models?.find(isS0EternumStructure);
+ if (!structureModel) return null;
+ const realmModel = structure?.node?.entity?.models?.find(isS0EternumRealm);
+ const entityId = structure?.node?.entity_id;
+ return {
+ realmId: realmModel?.realm_id || entityId,
+ entityId,
+ name: realmModel ? getRealmNameById(realmModel?.realm_id ?? 0) : "Structure",
+ };
+ })
+ .filter(Boolean) as { realmId: number | undefined; entityId: number; name: string }[];
+ }, [data, getRealmNameById]);
+
return {
playerRealms,
+ playerStructures,
isLoading,
};
};