diff --git a/src/app/actions/sonar.ts b/src/app/actions/sonar.ts index e0d7356..4e53b13 100644 --- a/src/app/actions/sonar.ts +++ b/src/app/actions/sonar.ts @@ -3,10 +3,8 @@ import { createSonarServerAction } from "@/lib/sonar"; import { ListAvailableEntitiesResponse, - ReadEntityResponse, PrePurchaseCheckResponse, GeneratePurchasePermitResponse, - APIError, } from "@echoxyz/sonar-core"; type ListAvailableEntitiesInput = { saleUUID: string }; @@ -23,29 +21,6 @@ export const getEntities = createSonarServerAction( - async (client, { saleUUID, walletAddress }) => { - if (!saleUUID || !walletAddress) { - throw new Error("Missing saleUUID or walletAddress"); - } - - try { - return await client.readEntity({ saleUUID, walletAddress }); - } catch (error) { - // Special handling: 404 returns null entity instead of error - if (error instanceof APIError && error.status === 404) { - return { Entity: null } as unknown as ReadEntityResponse; - } - throw error; - } - } -); - type PrePurchaseCheckInput = { saleUUID: string; entityID: string; walletAddress: string }; /** diff --git a/src/app/hooks/use-sonar-entity.ts b/src/app/hooks/use-sonar-entity.ts deleted file mode 100644 index 9265947..0000000 --- a/src/app/hooks/use-sonar-entity.ts +++ /dev/null @@ -1,33 +0,0 @@ -"use client"; - -import { ReadEntityResponse } from "@echoxyz/sonar-core"; -import { saleUUID } from "@/lib/config"; -import { useSonarQuery } from "./use-sonar-query"; -import { getEntity } from "@/app/actions/sonar"; - -/** - * Hook to fetch Sonar entity details for a specific wallet - */ -export function useSonarEntity(walletAddress?: string) { - const query = useSonarQuery< - { saleUUID: string; walletAddress: string }, - ReadEntityResponse - >(getEntity, { - saleUUID, - walletAddress: walletAddress ?? "", - }); - - // No wallet address - return idle state - if (!walletAddress) { - return { loading: false, entity: undefined, error: undefined }; - } - - // Treat 404 as "no entity" rather than an error - const is404 = query.error?.message.includes("404"); - - return { - loading: query.loading, - entity: query.data?.Entity, - error: is404 ? undefined : query.error, - }; -}