Skip to content

Commit

Permalink
URIs file source is JSON with all network in one
Browse files Browse the repository at this point in the history
  • Loading branch information
vzotova committed Jul 26, 2024
2 parents 8f61dfb + 23d7146 commit 59a0df1
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/shared/src/porter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ const defaultPorterUri: Record<string, string> = {
lynx: 'https://porter-lynx.nucypher.community',
};

const porterUriSource: Record<string, string> = {
mainnet: 'https://raw.githubusercontent.com/nucypher/nucypher-porter/main/pytest.ini',
tapir: 'https://raw.githubusercontent.com/nucypher/nucypher-porter/main/pytest.ini',
lynx: 'https://raw.githubusercontent.com/nucypher/nucypher-porter/main/pytest.ini',
};
const porterUriSource: string = 'https://raw.githubusercontent.com/nucypher/taco-web/main/.changeset/config.json';

export type Domain = keyof typeof defaultPorterUri;

type PorterURIsRepsonse = Record<string, string[]>;

export const domains: Record<string, Domain> = {
DEVNET: 'lynx',
TESTNET: 'tapir',
Expand All @@ -57,15 +55,16 @@ export const getPorterUris = async (
};

export const getPorterUrisFromSource = async (domain: Domain): Promise<string[]> => {
const source = porterUriSource[domain];
if (!source) {
return [];
}
try {
const resp = await axios.get(source, {
const response = await axios.get(porterUriSource, {
responseType: 'blob',
});
return resp.data.split(/\r?\n/).filter(Boolean);
const urisFile: PorterURIsRepsonse = JSON.parse(response.data);
const uris: string[] = urisFile[domain];
if (!uris) {
return [];
}
return uris;
} catch (e) {
return [];
}
Expand Down

0 comments on commit 59a0df1

Please sign in to comment.