Skip to content

Commit

Permalink
chore: rename selected chain to selected (#2431)
Browse files Browse the repository at this point in the history
* add network information for evm chains

* remove networksettingsdrawer and unify with network informations

* cleanup information drawers

* rename selected chain to selected

* rename `selectedNetwork` to `selectedNetworkForNetworkDrawer`

---------

Co-authored-by: Nicole O'Brien <[email protected]>
  • Loading branch information
MarkNerdi and nicole-obrien authored May 2, 2024
1 parent d2aa87d commit dc47edb
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 41 deletions.
14 changes: 10 additions & 4 deletions packages/desktop/components/NetworkCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import { localize } from '@core/i18n'
import { generateAndStoreEvmAddressForAccounts, pollEvmBalancesForAccount } from '@core/layer-2/actions'
import { LedgerAppName } from '@core/ledger'
import { ExplorerEndpoint, Network, NetworkNamespace, getDefaultExplorerUrl, setSelectedChain } from '@core/network'
import {
ExplorerEndpoint,
Network,
NetworkNamespace,
getDefaultExplorerUrl,
setSelectedNetworkForNetworkDrawer,
} from '@core/network'
import { ProfileType } from '@core/profile'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { activeProfile } from '@core/profile/stores'
Expand All @@ -32,15 +38,15 @@
}
function onCardClick(): void {
setSelectedChain(network)
setSelectedNetworkForNetworkDrawer(network)
$networkConfigRouter.goTo(NetworkConfigRoute.ChainInformation)
}
function onQrCodeIconClick(): void {
if (network.namespace === NetworkNamespace.Stardust) {
$networkConfigRouter.goTo(NetworkConfigRoute.ChainDepositAddress)
} else {
setSelectedChain(network)
setSelectedNetworkForNetworkDrawer(network)
$networkConfigRouter.goTo(NetworkConfigRoute.ChainDepositAddress)
}
}
Expand All @@ -57,7 +63,7 @@
}
try {
setSelectedChain(network)
setSelectedNetworkForNetworkDrawer(network)
await generateAndStoreEvmAddressForAccounts(
$activeProfile.type,
network.coinType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
EditNetworkDrawer,
RemoveNetworkDrawer,
} from './views'
import { clearSelectedChain } from '@core/network'
import { clearSelectedNetworkForNetworkDrawer } from '@core/network'
import features from '@features/features'
import { Platform } from '@core/app'
Expand All @@ -30,7 +30,7 @@
onDestroy(() => {
$networkConfigRouter = null
clearSelectedChain()
clearSelectedNetworkForNetworkDrawer()
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import { DrawerTemplate } from '@components'
import { selectedAccount } from '@core/account/stores'
import { localize } from '@core/i18n'
import { getEvmNetworks, selectedChain } from '@core/network/stores'
import { getEvmNetworks, selectedNetworkForNetworkDrawer } from '@core/network/stores'
import { Router } from '@core/router'
import { NetworkConfigRoute, networkConfigRouter } from '../'
export let drawerRouter: Router<NetworkConfigRoute>
$: evmNetwork = $selectedChain ?? getEvmNetworks()[0]
$: evmNetwork = $selectedNetworkForNetworkDrawer ?? getEvmNetworks()[0]
$: address = evmNetwork ? $selectedAccount?.evmAddresses?.[evmNetwork.coinType] : undefined
function onContinueClick(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { DrawerTemplate, NetworkCard } from '@components'
import { localize } from '@core/i18n'
import { clearSelectedChain, networks } from '@core/network'
import { clearSelectedNetworkForNetworkDrawer, networks } from '@core/network'
import { Router } from '@core/router'
import features from '@features/features'
import { Button, IconName } from '@bloomwalletio/ui'
Expand All @@ -15,7 +15,7 @@
}
onMount(() => {
clearSelectedChain()
clearSelectedNetworkForNetworkDrawer()
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
import { DrawerTemplate } from '@components'
import { selectedAccount } from '@core/account/stores'
import { localize } from '@core/i18n'
import { selectedChain } from '@core/network'
import { NetworkId, selectedNetworkForNetworkDrawer } from '@core/network'
import { Router } from '@core/router'
import { AddressBox } from '@ui'
import { NetworkConfigRoute } from '../'
import { IAccountState, getAddressFromAccountForNetwork } from '@core/account'
export let drawerRouter: Router<NetworkConfigRoute>
let depositAddress = ''
$: {
if ($selectedChain) {
const coinType = $selectedChain.coinType
depositAddress = $selectedAccount.evmAddresses[coinType]
} else {
depositAddress = $selectedAccount.depositAddress
}
}
$: depositAddress = getAddressFromAccountForNetwork(
$selectedAccount as IAccountState,
$selectedNetworkForNetworkDrawer?.id as NetworkId
)
</script>

<DrawerTemplate
title={localize(
`views.dashboard.drawers.networkConfig.chainDepositAddress.${$selectedChain ? 'title' : 'networkTitle'}`
`views.dashboard.drawers.networkConfig.chainDepositAddress.${$selectedNetworkForNetworkDrawer ? 'title' : 'networkTitle'}`
)}
{drawerRouter}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import { selectedChain, NetworkNamespace } from '@core/network'
import { selectedNetworkForNetworkDrawer, NetworkNamespace } from '@core/network'
import { Router } from '@core/router'
import { NetworkConfigRoute } from '../'
import { EvmChainInformationDrawer, StardustInformationDrawer } from './components'
export let drawerRouter: Router<NetworkConfigRoute>
</script>

{#if $selectedChain && $selectedChain.namespace === NetworkNamespace.Evm}
<EvmChainInformationDrawer network={$selectedChain} {drawerRouter} />
{:else if $selectedChain && $selectedChain.namespace === NetworkNamespace.Stardust}
<StardustInformationDrawer network={$selectedChain} {drawerRouter} />
{#if $selectedNetworkForNetworkDrawer && $selectedNetworkForNetworkDrawer.namespace === NetworkNamespace.Evm}
<EvmChainInformationDrawer network={$selectedNetworkForNetworkDrawer} {drawerRouter} />
{:else if $selectedNetworkForNetworkDrawer && $selectedNetworkForNetworkDrawer.namespace === NetworkNamespace.Stardust}
<StardustInformationDrawer network={$selectedNetworkForNetworkDrawer} {drawerRouter} />
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { formatCurrency, localize } from '@core/i18n'
import { generateAndStoreEvmAddressForAccounts, pollEvmBalancesForAccount } from '@core/layer-2/actions'
import { LedgerAppName } from '@core/ledger'
import { Network, NetworkNamespace, setSelectedChain } from '@core/network'
import { Network, NetworkNamespace, setSelectedNetworkForNetworkDrawer } from '@core/network'
import { MimeType, Nft } from '@core/nfts'
import { checkActiveProfileAuth } from '@core/profile/actions'
import { activeProfile } from '@core/profile/stores'
Expand Down Expand Up @@ -91,7 +91,7 @@
await generateAndStoreEvmAddressForAccounts($activeProfile.type, network.coinType, account)
pollEvmBalancesForAccount($activeProfile.id, account)
if ($activeProfile.type === ProfileType.Ledger) {
setSelectedChain(network)
setSelectedNetworkForNetworkDrawer(network)
toggleDashboardDrawer({
id: DashboardDrawerRoute.NetworkConfig,
initialSubroute: NetworkConfigRoute.ConfirmLedgerEvmAddress,
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/lib/core/network/stores/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './networks.store'
export * from './node-info.store'
export * from './selected-chain.store'
export * from './selected-network-for-network-drawer.store'

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Writable, writable } from 'svelte/store'
import { Network } from '../types'

export const selectedNetworkForNetworkDrawer: Writable<Network | undefined> = writable(undefined)

export function setSelectedNetworkForNetworkDrawer(evmNetwork: Network): void {
selectedNetworkForNetworkDrawer.set(evmNetwork)
}

export function clearSelectedNetworkForNetworkDrawer(): void {
selectedNetworkForNetworkDrawer.set(undefined)
}

0 comments on commit dc47edb

Please sign in to comment.