From 75eb994e728512fcff926c422ededd7c2374c987 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 26 Sep 2024 08:46:03 +0300 Subject: [PATCH] chore: use arweave-exex-backfill as fallback --- lib/hooks/useArweaveId.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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),