Skip to content

Commit

Permalink
chore: use arweave-exex-backfill as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
codingknite committed Sep 26, 2024
1 parent 00143fa commit 75eb994
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/hooks/useArweaveId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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),
Expand Down

0 comments on commit 75eb994

Please sign in to comment.