Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adding mainnet #4

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 11 additions & 43 deletions src/nibiru/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,29 @@ import type { LocalConfig } from '@/stores';
const PLAYGROUND_NETWORKS = 'https://networks.play.nibiru.fi/ping-pub';
const DEV_NETWORKS = 'https://networks.testnet.nibiru.fi/ping-pub';
const ITN_NETWORKS = 'https://networks.itn.nibiru.fi/ping-pub';
const MAIN_NETWORK = 'https://networks.nibiru.fi/ping-pub';

export const getItn = async (): Promise<LocalConfig[] | undefined> => {
export const getNetwork = async (url: string): Promise<LocalConfig[]> => {
try {
const testnets = await fetch(ITN_NETWORKS).then((response) =>
response.json()
);
testnets.forEach((_: any, i: string | number) => {
testnets[i].visible = true;
const net = await fetch(url).then((response) => response.json());
net.forEach((_: any, i: string | number) => {
net[i].visible = true;
});
return testnets;
return net;
} catch (error) {
console.log(error);
return;
}
};

export const getDevnets = async (): Promise<LocalConfig[] | undefined> => {
try {
const devnets = await fetch(DEV_NETWORKS).then((response) =>
response.json()
);
devnets.forEach((_: any, i: string | number) => {
devnets[i].visible = false;
});
return devnets;
} catch (error) {
console.log(error);
return;
}
};

export const getPlaynets = async (): Promise<LocalConfig[] | undefined> => {
try {
const playnets = await fetch(PLAYGROUND_NETWORKS).then((response) =>
response.json()
);
playnets.forEach((_: any, i: string | number) => {
playnets[i].visible = false;
});
return playnets;
} catch (error) {
console.log(error);
return;
return [];
}
};

export const getNibiruChains = async (): Promise<{
[key: string]: LocalConfig;
}> => {
const [playnets, devnets, itn] = await Promise.all([
undefined, //getPlaynets(),
undefined, //getDevnets(),
getItn(),
const [itn, main] = await Promise.all([
getNetwork(ITN_NETWORKS),
getNetwork(MAIN_NETWORK),
]);
const chains = (itn ?? []).concat(playnets ?? [], devnets ?? []);
const chains = main.concat(itn);
const chainsObj: { [key: string]: LocalConfig } = {};
chains.forEach((chain) => {
chainsObj[chain.chain_name] = chain;
Expand Down
2 changes: 1 addition & 1 deletion src/stores/useDashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const useDashboard = defineStore('dashboard', {
state: () => {
const favMap = JSON.parse(
localStorage.getItem('favoriteMap') ??
'{"cosmos":true, "osmosis":true, "nibiru":true, "nibiru-itn-3":true}'
'{"nibiru":true,"nibiru-itn-3":true,"cataclysm-1":true,"nibiru-testnet-1":true}'
);
return {
status: LoadingStatus.Empty,
Expand Down