From 2c59e95c0d68d20d281bde21a7d9b941c0f02512 Mon Sep 17 00:00:00 2001 From: Mark Nardi Date: Tue, 14 May 2024 09:32:37 +0200 Subject: [PATCH] chore: remove node info store (#2487) * remove node info * merge conflict --------- Co-authored-by: Tuditi <45079109+Tuditi@users.noreply.github.com> --- .../components/FaucetRequestButton.svelte | 11 ++++++----- .../organisms/NodeConfigurationForm.svelte | 5 +++-- .../network/actions/getAndUpdateNodeInfo.ts | 19 ------------------- .../src/lib/core/network/actions/index.ts | 1 - .../network/classes/stardust-network.class.ts | 4 ++-- .../src/lib/core/network/stores/index.ts | 1 - .../core/network/stores/node-info.store.ts | 8 -------- .../checkAndInitializeActiveProfileNetwork.ts | 4 ++-- 8 files changed, 13 insertions(+), 40 deletions(-) delete mode 100644 packages/shared/src/lib/core/network/actions/getAndUpdateNodeInfo.ts delete mode 100644 packages/shared/src/lib/core/network/stores/node-info.store.ts diff --git a/packages/desktop/views/dashboard/developer/components/FaucetRequestButton.svelte b/packages/desktop/views/dashboard/developer/components/FaucetRequestButton.svelte index 4af0278b08..d045fd7b2a 100644 --- a/packages/desktop/views/dashboard/developer/components/FaucetRequestButton.svelte +++ b/packages/desktop/views/dashboard/developer/components/FaucetRequestButton.svelte @@ -1,11 +1,12 @@ -{#if FAUCET_URLS?.[$activeProfile?.network?.id] && $nodeInfo} +{#if network && FAUCET_URLS?.[network?.id]} { - let nodeInfoResponse: INodeInfoResponse | undefined - try { - nodeInfoResponse = await getNodeInfo() - setNodeInfo(nodeInfoResponse?.nodeInfo) - return nodeInfoResponse - } catch (err) { - setNodeInfo(undefined) - if (forwardErrors) { - return Promise.reject(err) - } else { - console.error(err) - } - } -} diff --git a/packages/shared/src/lib/core/network/actions/index.ts b/packages/shared/src/lib/core/network/actions/index.ts index b4e17cce77..62159f9e61 100644 --- a/packages/shared/src/lib/core/network/actions/index.ts +++ b/packages/shared/src/lib/core/network/actions/index.ts @@ -1,7 +1,6 @@ export * from './addNodeToClientOptions' export * from './editNodeInClientOptions' export * from './getActiveNetworkId' -export * from './getAndUpdateNodeInfo' export * from './getNameFromNetworkId' export * from './getNodeInfoWhileLoggedOut' export * from './removeNodeFromClientOptions' diff --git a/packages/shared/src/lib/core/network/classes/stardust-network.class.ts b/packages/shared/src/lib/core/network/classes/stardust-network.class.ts index 91c2a02f61..b69bd5c5af 100644 --- a/packages/shared/src/lib/core/network/classes/stardust-network.class.ts +++ b/packages/shared/src/lib/core/network/classes/stardust-network.class.ts @@ -4,13 +4,13 @@ import { NetworkHealth, NetworkNamespace, NetworkType } from '../enums' import { IIscChainConfiguration, IProtocol, IStardustNetwork, IStardustNetworkMetadata } from '../interfaces' import { EvmNetworkId, StardustNetworkId } from '../types' -import { getAndUpdateNodeInfo } from '@core/network/actions' import { getNetworkStatusFromNodeInfo } from '@core/network/helpers' import { NETWORK_STATUS_POLL_INTERVAL } from '@core/network/constants' import { IBaseToken } from '@core/token/interfaces' import { addChain, removeChain } from '../stores' import { IscChain } from './isc-chain.class' +import { getNodeInfo } from '@core/profile-manager/api' export class StardustNetwork implements IStardustNetwork { public readonly id: StardustNetworkId @@ -50,7 +50,7 @@ export class StardustNetwork implements IStardustNetwork { startStatusPoll(): void { this.statusPoll = window.setInterval(() => { - getAndUpdateNodeInfo().then((nodeResponse) => { + getNodeInfo().then((nodeResponse) => { const { health, currentMilestone } = getNetworkStatusFromNodeInfo(nodeResponse?.nodeInfo) this.currentMilestone.set(currentMilestone) this.health.set(health) diff --git a/packages/shared/src/lib/core/network/stores/index.ts b/packages/shared/src/lib/core/network/stores/index.ts index 8300aeaa26..7fccb118c7 100644 --- a/packages/shared/src/lib/core/network/stores/index.ts +++ b/packages/shared/src/lib/core/network/stores/index.ts @@ -1,3 +1,2 @@ export * from './networks.store' -export * from './node-info.store' export * from './selected-network-for-network-drawer.store' diff --git a/packages/shared/src/lib/core/network/stores/node-info.store.ts b/packages/shared/src/lib/core/network/stores/node-info.store.ts deleted file mode 100644 index 9bd4f4e968..0000000000 --- a/packages/shared/src/lib/core/network/stores/node-info.store.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { INodeInfo } from '@iota/sdk' -import { writable } from 'svelte/store' - -export const nodeInfo = writable(undefined) - -export function setNodeInfo(newNodeInfo: INodeInfo | undefined): void { - return nodeInfo.set(newNodeInfo) -} diff --git a/packages/shared/src/lib/core/profile/actions/active-profile/checkAndInitializeActiveProfileNetwork.ts b/packages/shared/src/lib/core/profile/actions/active-profile/checkAndInitializeActiveProfileNetwork.ts index c0cd4872c8..52021338b7 100644 --- a/packages/shared/src/lib/core/profile/actions/active-profile/checkAndInitializeActiveProfileNetwork.ts +++ b/packages/shared/src/lib/core/profile/actions/active-profile/checkAndInitializeActiveProfileNetwork.ts @@ -1,13 +1,13 @@ import { get } from 'svelte/store' import { localize } from '@core/i18n' -import { getAndUpdateNodeInfo } from '@core/network/actions' import { activeProfile } from '@core/profile/stores' import { NetworkNamespace, initializeNetworks } from '@core/network' +import { getNodeInfo } from '@core/profile-manager' export async function checkAndInitializeActiveProfileNetwork(): Promise { const $activeProfile = get(activeProfile) const existingNetwork = $activeProfile?.network - const nodeInfoResponse = await getAndUpdateNodeInfo(true) + const nodeInfoResponse = await getNodeInfo() if (!nodeInfoResponse) { throw new Error(localize('error.network.mismatch')) }