Skip to content
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

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

cpl121
Copy link
Member

@cpl121 cpl121 commented Mar 7, 2024

Closes #8132

Summary

Get the node's base token information instead of getting the hardcoded default information

Changelog

- Delete baseToken and protocol param of profile network
- Add bech32 param in profile network

Testing

Platforms

  • Desktop
    • MacOS
    • Linux
    • Windows

Checklist

Please tick the following boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or modified tests that prove my changes work as intended
  • I have verified that new and existing unit tests pass locally with my changes
  • I have verified that my latest changes pass CI workflows for testing and linting
  • I have made corresponding changes to the documentation

@cpl121 cpl121 marked this pull request as ready for review March 7, 2024 09:52
@cpl121 cpl121 requested a review from marc2332 March 14, 2024 15:02
@evavirseda evavirseda self-requested a review March 19, 2024 09:44
delete oldNetwork.baseToken

const newNetwork = oldNetwork as unknown as IPersistedNetwork
const defaultBech32Hrp = DEFAULT_NETWORK_METADATA[existingProfile.network.id]?.bech32Hrp || ''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what cases would DEFAULT_NETWORK_METADATA[existingProfile.network.id]?.bech32Hrp not exist? I just because it seems weird to me to leave '' as fallback value, it will likely break if that ever happens.

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',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add 'Unknown Network' as fallback value here now? This will likely break it as well and it doesn't make sense to use a human-readable phrase for this either


export const nodeInfoBaseToken = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.baseToken)

export const nodeInfoProtocol = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.protocol)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used

Suggested change
export const nodeInfoProtocol = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.protocol)


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)
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 nodeInfo store

@@ -161,7 +161,7 @@ export function setTotalUnclaimedShimmerRewards(_totalUnclaimedShimmerRewards: n

function showRewardsFoundNotification(updatedTotalUnclaimedShimmerRewards: number): void {
const foundRewardsAmount = updatedTotalUnclaimedShimmerRewards - totalUnclaimedShimmerRewards
const foundRewardsAmountFormatted = formatTokenAmountBestMatch(foundRewardsAmount, getOnboardingBaseToken())
const foundRewardsAmountFormatted = formatTokenAmountBestMatch(foundRewardsAmount, getBaseToken())
Copy link
Collaborator

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.

@cpl121 cpl121 requested a review from marc2332 April 17, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Remove hardcoded base token dependencies from the app
2 participants