Skip to content

Commit

Permalink
Update openbit static content URL
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed May 29, 2024
1 parent 42cd93b commit 71e779b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/extension-base/src/utils/fetchStaticData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
const branchName = process.env.BRANCH_NAME || 'koni-dev';
const fetchTarget = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';

const swStaticDomain = 'https://static-data.subwallet.app';
const obStaticDomain = 'https://static-data.openbit.app';
const swSlugList = ['chains', 'chain-assets/disabled-xcm-channels', 'chain-assets/price-map'];

export async function fetchStaticData<T> (slug: string, targetFile?: string, isJson = true) {
const fetchFile = targetFile || fetchTarget;

// If targetFile in swSlugList, fetch from swStaticDomain
const staticDomain = swSlugList.includes(slug) ? swStaticDomain : obStaticDomain;

try {
if (isJson) {
return await fetchJson<T>(`https://static-data.subwallet.app/${slug}/${fetchFile}`);
return await fetchJson<T>(`${staticDomain}/${slug}/${fetchFile}`);
} else {
return await fetchText<T>(`https://static-data.subwallet.app/${slug}/${fetchFile}`);
return await fetchText<T>(`${staticDomain}/${slug}/${fetchFile}`);
}
} catch (e) {
return staticData[slug as StaticKey] as T;
Expand Down

1 comment on commit 71e779b

@saltict
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.