diff --git a/landing/src/hooks/gql/gql.ts b/landing/src/hooks/gql/gql.ts index 371ff2a9f..7effd4df3 100644 --- a/landing/src/hooks/gql/gql.ts +++ b/landing/src/hooks/gql/gql.ts @@ -20,6 +20,7 @@ const documents = { "\n query getEternumEntityOwner($entityOwnerIds: [u32!]!) {\n s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 200) {\n edges {\n node {\n entity_id\n entity_owner_id\n entity {\n models {\n __typename\n ... on s0_eternum_OwnedResourcesTracker {\n resource_types\n }\n ... on s0_eternum_Position {\n x\n y\n }\n ... on s0_eternum_ArrivalTime {\n arrives_at\n }\n ... on s0_eternum_Weight {\n value\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumEntityOwnerDocument, "\n query getAccountTokens($accountAddress: String!) {\n tokenBalances(accountAddress: $accountAddress, limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n": types.GetAccountTokensDocument, "\n query getERC721Mints {\n tokenTransfers(accountAddress: \"0x0\", limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n": types.GetErc721MintsDocument, + "\n query eternumStatistics {\n s0EternumAddressNameModels {\n totalCount\n }\n s0EternumHyperstructureModels {\n totalCount\n }\n s0EternumRealmModels {\n totalCount\n }\n s0EternumFragmentMineDiscoveredModels {\n totalCount\n }\n }\n": types.EternumStatisticsDocument, "\n query getEntityPosition($entityIds: [u32!]!) {\n s0EternumPositionModels(where: { entity_idIN: $entityIds }) {\n edges {\n node {\n x\n y\n entity_id\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntityPositionDocument, "\n query getEntitiesResources($entityIds: [u32!]!) {\n s0EternumResourceModels(\n where: { \n entity_idIN: $entityIds\n }\n limit: 100\n ) {\n edges {\n node {\n entity_id\n resource_type\n balance\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntitiesResourcesDocument, }; @@ -44,6 +45,10 @@ export function graphql(source: "\n query getAccountTokens($accountAddress: Str * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function graphql(source: "\n query getERC721Mints {\n tokenTransfers(accountAddress: \"0x0\", limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetErc721MintsDocument; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n query eternumStatistics {\n s0EternumAddressNameModels {\n totalCount\n }\n s0EternumHyperstructureModels {\n totalCount\n }\n s0EternumRealmModels {\n totalCount\n }\n s0EternumFragmentMineDiscoveredModels {\n totalCount\n }\n }\n"): typeof import('./graphql').EternumStatisticsDocument; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/landing/src/hooks/gql/graphql.ts b/landing/src/hooks/gql/graphql.ts index 80ec93db7..7bc17ca3e 100644 --- a/landing/src/hooks/gql/graphql.ts +++ b/landing/src/hooks/gql/graphql.ts @@ -7298,6 +7298,11 @@ export type GetErc721MintsQueryVariables = Exact<{ [key: string]: never; }>; export type GetErc721MintsQuery = { __typename?: 'World__Query', tokenTransfers?: { __typename?: 'Token__TransferConnection', edges?: Array<{ __typename?: 'Token__TransferEdge', node?: { __typename?: 'Token__Transfer', tokenMetadata: { __typename: 'ERC20__Token' } | { __typename: 'ERC721__Token', tokenId: string, metadataDescription?: string | null, imagePath: string, contractAddress: string, metadata: string } } | null } | null> | null } | null }; +export type EternumStatisticsQueryVariables = Exact<{ [key: string]: never; }>; + + +export type EternumStatisticsQuery = { __typename?: 'World__Query', s0EternumAddressNameModels?: { __typename?: 's0_eternum_AddressNameConnection', totalCount: number } | null, s0EternumHyperstructureModels?: { __typename?: 's0_eternum_HyperstructureConnection', totalCount: number } | null, s0EternumRealmModels?: { __typename?: 's0_eternum_RealmConnection', totalCount: number } | null, s0EternumFragmentMineDiscoveredModels?: { __typename?: 's0_eternum_FragmentMineDiscoveredConnection', totalCount: number } | null }; + export type GetEntityPositionQueryVariables = Exact<{ entityIds: Array | Scalars['u32']['input']; }>; @@ -7438,6 +7443,22 @@ export const GetErc721MintsDocument = new TypedDocumentString(` } } `) as unknown as TypedDocumentString; +export const EternumStatisticsDocument = new TypedDocumentString(` + query eternumStatistics { + s0EternumAddressNameModels { + totalCount + } + s0EternumHyperstructureModels { + totalCount + } + s0EternumRealmModels { + totalCount + } + s0EternumFragmentMineDiscoveredModels { + totalCount + } +} + `) as unknown as TypedDocumentString; export const GetEntityPositionDocument = new TypedDocumentString(` query getEntityPosition($entityIds: [u32!]!) { s0EternumPositionModels(where: {entity_idIN: $entityIds}) { diff --git a/landing/src/hooks/query/eternumStatistics.tsx b/landing/src/hooks/query/eternumStatistics.tsx new file mode 100644 index 000000000..c0e56deff --- /dev/null +++ b/landing/src/hooks/query/eternumStatistics.tsx @@ -0,0 +1,18 @@ +import { graphql } from "../gql"; + +export const GET_ETERNUM_STATTISTICS = graphql(` + query eternumStatistics { + s0EternumAddressNameModels { + totalCount + } + s0EternumHyperstructureModels { + totalCount + } + s0EternumRealmModels { + totalCount + } + s0EternumFragmentMineDiscoveredModels { + totalCount + } + } +`); diff --git a/landing/src/routes/index.lazy.tsx b/landing/src/routes/index.lazy.tsx index 3fc9d35bc..83aa0a995 100644 --- a/landing/src/routes/index.lazy.tsx +++ b/landing/src/routes/index.lazy.tsx @@ -7,12 +7,15 @@ import { PRIZE_POOL_GUILDS, PRIZE_POOL_INDIVIDUAL_LEADERBOARD, } from "@/constants"; +import { execute } from "@/hooks/gql/execute"; +import { GET_ETERNUM_STATTISTICS } from "@/hooks/query/eternumStatistics"; import { useDonkeysBurned } from "@/hooks/use-donkeys-burned"; import { useLordsBridgeBalance } from "@/hooks/use-lords-bridged"; import { usePlayerCount } from "@/hooks/use-player-count"; import { usePrizePool } from "@/hooks/use-rewards"; import { useStructuresNumber } from "@/hooks/use-structures"; import { currencyFormat, formatNumber } from "@/lib/utils"; +import { useQuery } from "@tanstack/react-query"; import { createLazyFileRoute } from "@tanstack/react-router"; import { Castle, Coins, CoinsIcon, Flame, Pickaxe, Sparkles, UsersIcon } from "lucide-react"; import React, { useMemo } from "react"; @@ -32,6 +35,13 @@ interface GridItemType { } function Index() { + + const { data, isLoading } = useQuery({ + queryKey: ["eternumStatistics"], + queryFn: () => execute(GET_ETERNUM_STATTISTICS), + refetchInterval: 30_000, + }); + const donkeysBurned = useDonkeysBurned(); const playerCount = usePlayerCount(); const { realmsCount, hyperstructuresCount, fragmentMinesCount } = useStructuresNumber(); @@ -46,7 +56,7 @@ function Index() { rowSpan: { sm: 1, md: 1, lg: 2 }, data: { title: "players", - value: formatNumber(playerCount, 0), + value: formatNumber(data?.s0EternumAddressNameModels?.totalCount ?? 0, 0), icon: , backgroundImage: "/images/avatars/Armor.png", }, @@ -55,7 +65,7 @@ function Index() { colSpan: { sm: 2, md: 2, lg: 2 }, data: { title: "realms settled", - value: formatNumber(realmsCount, 0), + value: formatNumber(data?.s0EternumRealmModels?.totalCount ?? 0, 0), icon: , backgroundImage: "/images/avatars/Blade.png", }, @@ -64,7 +74,7 @@ function Index() { colSpan: { sm: 2, md: 2, lg: 2 }, data: { title: "hyperstructures", - value: formatNumber(hyperstructuresCount, 0), + value: formatNumber(data?.s0EternumHyperstructureModels?.totalCount ?? 0, 0), icon: , backgroundImage: "/images/avatars/Hidden.png", }, @@ -73,7 +83,7 @@ function Index() { colSpan: { sm: 2, md: 2, lg: 2 }, data: { title: "mines discovered", - value: formatNumber(fragmentMinesCount, 0), + value: formatNumber(data?.s0EternumFragmentMineDiscoveredModels?.totalCount ?? 0, 0), icon: , backgroundImage: "/images/jungle-clouds.png", },