Skip to content

Commit

Permalink
chore: remove node info store (#2487)
Browse files Browse the repository at this point in the history
* remove node info

* merge conflict

---------

Co-authored-by: Tuditi <[email protected]>
  • Loading branch information
MarkNerdi and Tuditi authored May 14, 2024
1 parent 653082e commit 2c59e95
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<script lang="ts">
import { IconName } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { FAUCET_URLS, nodeInfo } from '@core/network'
import { activeProfile } from '@core/profile/stores'
import { FAUCET_URLS, getL1Network } from '@core/network'
import { PopupId, openPopup } from '@desktop/auxiliary/popup'
import { ButtonTile } from '../../../components'
const network = getL1Network()
function onGetTokensClick(): void {
openPopup({
id: PopupId.FaucetRequest,
})
}
</script>

{#if FAUCET_URLS?.[$activeProfile?.network?.id] && $nodeInfo}
{#if network && FAUCET_URLS?.[network?.id]}
<ButtonTile
primaryText={localize('actions.faucetRequest', {
values: { token: $nodeInfo.baseToken.name },
values: { token: network.baseToken.name },
})}
secondaryText={localize('general.faucetRequestDescription', {
values: { network: $nodeInfo.protocol.networkName },
values: { network: network.name },
})}
onClick={onGetTokensClick}
icon={IconName.CoinsHand}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { INode } from '@iota/sdk/out/types'
import { DEFAULT_NETWORK_METADATA, EMPTY_NODE } from '@core/network/constants'
import { IClientOptions, INodeInfoResponse } from '@core/network/interfaces'
import { nodeInfo } from '@core/network/stores'
import { getL1Network } from '@core/network/stores'
import {
checkIfOnSameNetwork,
checkNodeUrlValidity,
Expand Down Expand Up @@ -92,7 +92,8 @@
const networkName = nodeInfoResponse?.nodeInfo?.protocol.networkName
if (options.checkSameNetwork) {
const isInSameNetwork = !!$nodeInfo && $nodeInfo.protocol.networkName === networkName
const stardustNetwork = getL1Network()
const isInSameNetwork = stardustNetwork?.protocol.networkName === networkName
if (!isInSameNetwork) {
formError = localize('error.node.differentNetwork')
return Promise.reject({ type: 'validationError', error: formError })
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packages/shared/src/lib/core/network/actions/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/lib/core/network/stores/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './networks.store'
export * from './node-info.store'
export * from './selected-network-for-network-drawer.store'

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<void> {
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'))
}
Expand Down

0 comments on commit 2c59e95

Please sign in to comment.