-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't override network with node info
Co-authored-by: Mark Nardi <[email protected]>
- Loading branch information
1 parent
bedb937
commit db75e43
Showing
5 changed files
with
29 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...red/src/lib/core/profile/actions/active-profile/checkAndInitializeActiveProfileNetwork.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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' | ||
|
||
export async function checkAndInitializeActiveProfileNetwork(): Promise<void> { | ||
const $activeProfile = get(activeProfile) | ||
const existingNetwork = $activeProfile?.network | ||
const nodeInfoResponse = await getAndUpdateNodeInfo(true) | ||
if (!nodeInfoResponse) { | ||
throw new Error(localize('error.network.mismatch')) | ||
} | ||
|
||
const networkIdFromNode = `${NetworkNamespace.Stardust}:${nodeInfoResponse?.nodeInfo?.protocol.networkName}` | ||
if (existingNetwork?.id !== networkIdFromNode) { | ||
throw new Error(localize('error.network.mismatch', { networkId: networkIdFromNode })) | ||
} | ||
|
||
if (existingNetwork?.protocol.version !== nodeInfoResponse?.nodeInfo?.protocol.version) { | ||
throw new Error(localize('error.network.version.mismatch', { networkId: networkIdFromNode })) | ||
} | ||
|
||
initializeNetworks() | ||
} |
24 changes: 0 additions & 24 deletions
24
.../shared/src/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/shared/src/lib/core/profile/actions/active-profile/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters