Skip to content

Commit

Permalink
feat: use local manifest as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeday committed Jun 19, 2024
1 parent ef19ee8 commit a2f27f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions config/external-config/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useMemo } from 'react';
import { getConfig } from '../get-config';
import type { Manifest, ManifestEntry } from './types';
import {
type DexWithdrawalApi,
getDexConfig,
} from 'features/withdrawals/request/withdrawal-rates';

const config = getConfig();
import FallbackLocalManifest from 'IPFS.json' assert { type: 'json' };

// TODO: refactor on config expansion
export const isManifestEntryValid = (
Expand Down Expand Up @@ -57,6 +56,8 @@ export const useFallbackManifestEntry = (
): ManifestEntry => {
return useMemo(() => {
const isValid = isManifestValid(prefetchedManifest, chain);
return isValid ? prefetchedManifest[chain] : config.FALLBACK_MANIFEST_ENTRY;
return isValid
? prefetchedManifest[chain]
: (FallbackLocalManifest as unknown as Manifest)[chain];
}, [prefetchedManifest, chain]);
};
4 changes: 3 additions & 1 deletion utilsApi/fetch-external-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { responseTimeExternalMetricWrapper } from './fetchApiWrapper';
import { standardFetcher } from 'utils/standardFetcher';
import { config } from 'config';

import FallbackLocalManifest from 'IPFS.json' assert { type: 'json' };

export type ExternalConfigResult = {
___prefetch_manifest___: object | null;
revalidate: number;
Expand Down Expand Up @@ -61,6 +63,6 @@ export const fetchExternalManifest = async () => {
);
return {
revalidate: config.ERROR_REVALIDATION,
___prefetch_manifest___: null,
___prefetch_manifest___: FallbackLocalManifest,
};
};

0 comments on commit a2f27f8

Please sign in to comment.