From 7aec5d7ce88e893661099413502f3e6bbf7e56b5 Mon Sep 17 00:00:00 2001 From: elshenak Date: Fri, 10 Nov 2023 15:43:30 -0500 Subject: [PATCH 1/3] chore: aing mainnet --- src/nibiru/index.ts | 52 +++++++++----------------------------- src/stores/useDashboard.ts | 2 +- 2 files changed, 13 insertions(+), 41 deletions(-) diff --git a/src/nibiru/index.ts b/src/nibiru/index.ts index f588a4fdc5..f4f0f007c8 100644 --- a/src/nibiru/index.ts +++ b/src/nibiru/index.ts @@ -3,46 +3,17 @@ 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 => { +export const getNetwork = async ( + url: string +): Promise => { 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; - } catch (error) { - console.log(error); - return; - } -}; - -export const getDevnets = async (): Promise => { - 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 => { - try { - const playnets = await fetch(PLAYGROUND_NETWORKS).then((response) => - response.json() - ); - playnets.forEach((_: any, i: string | number) => { - playnets[i].visible = false; - }); - return playnets; + return net; } catch (error) { console.log(error); return; @@ -52,12 +23,13 @@ export const getPlaynets = async (): Promise => { export const getNibiruChains = async (): Promise<{ [key: string]: LocalConfig; }> => { - const [playnets, devnets, itn] = await Promise.all([ + const [playnets, devnets, itn, main] = await Promise.all([ undefined, //getPlaynets(), undefined, //getDevnets(), - getItn(), + getNetwork(ITN_NETWORKS), + getNetwork(MAIN_NETWORK), ]); - const chains = (itn ?? []).concat(playnets ?? [], devnets ?? []); + const chains = (main ?? []).concat(itn ?? [], playnets ?? [], devnets ?? []); const chainsObj: { [key: string]: LocalConfig } = {}; chains.forEach((chain) => { chainsObj[chain.chain_name] = chain; diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index cf8b2b656e..b0c2e46566 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -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}' + '{"cosmos":true,"osmosis":true,"nibiru":true,"nibiru-itn-3":true,"cataclysm-1":true,"nibiru-testnet-1":true}' ); return { status: LoadingStatus.Empty, From 2e5fcd55bb50ca666ee3ce051a6ea1fe3095b49e Mon Sep 17 00:00:00 2001 From: elshenak Date: Fri, 10 Nov 2023 17:41:52 -0500 Subject: [PATCH 2/3] refactor: pr comments --- src/nibiru/index.ts | 6 ++---- src/stores/useDashboard.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/nibiru/index.ts b/src/nibiru/index.ts index f4f0f007c8..1deae24eac 100644 --- a/src/nibiru/index.ts +++ b/src/nibiru/index.ts @@ -23,13 +23,11 @@ export const getNetwork = async ( export const getNibiruChains = async (): Promise<{ [key: string]: LocalConfig; }> => { - const [playnets, devnets, itn, main] = await Promise.all([ - undefined, //getPlaynets(), - undefined, //getDevnets(), + const [itn, main] = await Promise.all([ getNetwork(ITN_NETWORKS), getNetwork(MAIN_NETWORK), ]); - const chains = (main ?? []).concat(itn ?? [], playnets ?? [], devnets ?? []); + const chains = (main ?? []).concat(itn ?? []); const chainsObj: { [key: string]: LocalConfig } = {}; chains.forEach((chain) => { chainsObj[chain.chain_name] = chain; diff --git a/src/stores/useDashboard.ts b/src/stores/useDashboard.ts index b0c2e46566..79512ceeae 100644 --- a/src/stores/useDashboard.ts +++ b/src/stores/useDashboard.ts @@ -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,"cataclysm-1":true,"nibiru-testnet-1":true}' + '{"nibiru":true,"nibiru-itn-3":true,"cataclysm-1":true,"nibiru-testnet-1":true}' ); return { status: LoadingStatus.Empty, From 7bf114c294f409474ddad52ec4fcd6430facbc7c Mon Sep 17 00:00:00 2001 From: elshenak Date: Fri, 10 Nov 2023 17:44:10 -0500 Subject: [PATCH 3/3] chore: pr comments --- src/nibiru/index.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/nibiru/index.ts b/src/nibiru/index.ts index 1deae24eac..5fcc5f63a0 100644 --- a/src/nibiru/index.ts +++ b/src/nibiru/index.ts @@ -5,9 +5,7 @@ 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 getNetwork = async ( - url: string -): Promise => { +export const getNetwork = async (url: string): Promise => { try { const net = await fetch(url).then((response) => response.json()); net.forEach((_: any, i: string | number) => { @@ -16,7 +14,7 @@ export const getNetwork = async ( return net; } catch (error) { console.log(error); - return; + return []; } }; @@ -27,7 +25,7 @@ export const getNibiruChains = async (): Promise<{ getNetwork(ITN_NETWORKS), getNetwork(MAIN_NETWORK), ]); - const chains = (main ?? []).concat(itn ?? []); + const chains = main.concat(itn); const chainsObj: { [key: string]: LocalConfig } = {}; chains.forEach((chain) => { chainsObj[chain.chain_name] = chain;