diff --git a/lib/hooks/useArweaveId.tsx b/lib/hooks/useArweaveId.tsx index bd1ab42d64..9a8e9a09fc 100644 --- a/lib/hooks/useArweaveId.tsx +++ b/lib/hooks/useArweaveId.tsx @@ -4,6 +4,12 @@ interface ArweaveIdProps { arweaveId: string; } +interface ExexFallbackProps { + block_hash: string; + arweave_hash: string; + block_number: number; +} + interface BlockProps { block: number | undefined | null; } @@ -30,6 +36,23 @@ export function useArweaveId({ block }: BlockProps) { if (data.arweaveId) { return data.arweaveId; } + + const exexFallback = await fetch( + `https://arweave-exex-backfill.shuttleapp.rs/block/id/${ block }`, + { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + + const fallbackData = (await exexFallback.json()) as ExexFallbackProps; + + if (fallbackData.arweave_hash) { + return fallbackData.arweave_hash; + } + return 'Arweave Id Not Found'; }, enabled: Boolean(block),