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 742757c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/shared/src/porter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ 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 @@ -56,16 +55,19 @@ export const getPorterUris = async (
return fullList;
};

export const getPorterUrisFromSource = async (domain: Domain): Promise<string[]> => {
const source = porterUriSource[domain];
if (!source) {
return [];
}
export const getPorterUrisFromSource = async (
domain: Domain,
): Promise<string[]> => {
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 742757c

Please sign in to comment.