-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove hardcoded base token dependencies from the app #8160
base: develop
Are you sure you want to change the base?
Changes from 6 commits
66e2c32
ba84d75
af26deb
dad031b
f0106bb
a65e832
0fed75e
f7ca246
b6d9193
954c85b
fe3fb2e
85fdce6
465ee97
d3bb6ae
0267ccf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,8 +1,12 @@ | ||||
import { INodeInfo } from '@iota/sdk/out/types' | ||||
import { writable } from 'svelte/store' | ||||
import { writable, derived } from 'svelte/store' | ||||
|
||||
export const nodeInfo = writable<INodeInfo | undefined>(undefined) | ||||
|
||||
export function setNodeInfo(newNodeInfo: INodeInfo | undefined): void { | ||||
return nodeInfo.set(newNodeInfo) | ||||
} | ||||
|
||||
export const nodeInfoBaseToken = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.baseToken) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the point of this store? You don't seem to be reading it from any svelte file so all the reactivity features it comes with are effectively not used at all, thus it seems more appropiate to me to just read the |
||||
|
||||
export const nodeInfoProtocol = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.protocol) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { TokenStandard } from '@core/wallet/enums' | ||
import { COIN_TYPE, DEFAULT_NETWORK_METADATA } from '../constants' | ||
import { NetworkId } from '../enums' | ||
import { INodeInfoResponse, IPersistedNetwork } from '../interfaces' | ||
import { getNetworkIdFromNetworkName } from './getNetworkIdFromNetworkName' | ||
|
||
|
@@ -10,14 +8,14 @@ export function buildPersistedNetworkFromNodeInfoResponse( | |
): IPersistedNetwork { | ||
const networkName = nodeInfoResponse?.nodeInfo?.protocol.networkName | ||
const networkId = getNetworkIdFromNetworkName(networkName) | ||
const name = networkId === NetworkId.Custom ? networkName : DEFAULT_NETWORK_METADATA[networkId]?.name | ||
const bech32Hrp = nodeInfoResponse?.nodeInfo?.protocol.bech32Hrp ?? DEFAULT_NETWORK_METADATA?.[networkId]?.bech32Hrp | ||
const name = networkName ?? DEFAULT_NETWORK_METADATA?.[networkId]?.name | ||
const _coinType = coinType ?? COIN_TYPE[networkId] ?? 1 | ||
return { | ||
id: networkId, | ||
name: name ?? 'Unknown Network', | ||
coinType: _coinType, | ||
protocol: nodeInfoResponse?.nodeInfo?.protocol, | ||
baseToken: { standard: TokenStandard.BaseToken, ...nodeInfoResponse?.nodeInfo?.baseToken }, | ||
bech32Hrp: bech32Hrp ?? 'Unknown Network', | ||
chains: [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import { activeProfile } from '@core/profile/stores' | ||
import { IBaseToken } from '@core/wallet' | ||
import { IBaseToken, TokenStandard } from '@core/wallet' | ||
import { nodeInfoBaseToken } from '@core/network' | ||
import { get } from 'svelte/store' | ||
|
||
export function getBaseToken(): IBaseToken { | ||
const $activeProfile = get(activeProfile) | ||
return $activeProfile?.network?.baseToken | ||
const $nodeInfoBaseToken = get(nodeInfoBaseToken) | ||
|
||
return { | ||
standard: TokenStandard.BaseToken, | ||
...$nodeInfoBaseToken, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break because there is no Node Info loaded in the onboarding, it's only loaded once you log in.