From 66e2c32edd45843b6a6182dbd52442e8f336e06b Mon Sep 17 00:00:00 2001 From: cpl121 Date: Thu, 7 Mar 2024 10:42:42 +0100 Subject: [PATCH 01/11] feat: remove hardcoded base token dependencies from the app --- .../components/popups/NodeInfoPopup.svelte | 3 +- .../stores/onboarding-profile.store.ts | 2 +- .../constants/default-base-token.constant.ts | 50 ------------- .../default-network-metadata.constant.ts | 70 ++++--------------- .../lib/core/network/constants/index.ts | 1 - .../lib/core/network/interfaces/index.ts | 1 - .../network/interfaces/protocol.interface.ts | 11 --- .../stardust-network-metadata.interface.ts | 4 +- .../core/network/stores/node-info.store.ts | 6 +- .../checkAndUpdateActiveProfileNetwork.ts | 7 +- .../wallet/interfaces/base-token.interface.ts | 9 +-- .../wallet/tests/convertToRawAmount.test.ts | 43 +++++++++--- 12 files changed, 62 insertions(+), 145 deletions(-) delete mode 100644 packages/shared/lib/core/network/constants/default-base-token.constant.ts delete mode 100644 packages/shared/lib/core/network/interfaces/protocol.interface.ts diff --git a/packages/desktop/components/popups/NodeInfoPopup.svelte b/packages/desktop/components/popups/NodeInfoPopup.svelte index 73599496cc3..765ac2294e6 100644 --- a/packages/desktop/components/popups/NodeInfoPopup.svelte +++ b/packages/desktop/components/popups/NodeInfoPopup.svelte @@ -2,7 +2,8 @@ import { onMount } from 'svelte' import { Button, Checkbox, CopyableBox, Spinner, Text } from 'shared/components' import { formatNumber, localize } from '@core/i18n' - import { INode, INodeInfo } from '@core/network' + import { INode } from '@core/network' + import { INodeInfo } from '@iota/sdk/out/types' import { closePopup } from '@auxiliary/popup' import { showAppNotification } from '@auxiliary/notification' import { resolveObjectPath, setClipboard } from '@core/utils' diff --git a/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts b/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts index 05bb340800d..0a9b3434dac 100644 --- a/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts +++ b/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts @@ -37,6 +37,6 @@ export function updateShimmerClaimingAccount(shimmerClaimingAccount: IShimmerCla updateOnboardingProfile({ shimmerClaimingAccounts }) } -export function getOnboardingBaseToken(): IBaseToken { +export function getOnboardingBaseToken(): IBaseToken | undefined { return get(onboardingProfile)?.network?.baseToken } diff --git a/packages/shared/lib/core/network/constants/default-base-token.constant.ts b/packages/shared/lib/core/network/constants/default-base-token.constant.ts deleted file mode 100644 index c70ba34bb02..00000000000 --- a/packages/shared/lib/core/network/constants/default-base-token.constant.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { NetworkId } from '@core/network/enums' -import { IBaseToken } from '@core/wallet/interfaces' -import { TokenStandard } from '@core/wallet/enums' - -const DEFAULT_IOTA_BASE_TOKEN: IBaseToken = { - standard: TokenStandard.BaseToken, - name: 'IOTA', - tickerSymbol: 'IOTA', - unit: 'IOTA', - decimals: 6, - subunit: 'micro', - useMetricPrefix: false, -} - -const DEFAULT_IOTA_ALPHANET_BASE_TOKEN: IBaseToken = { - standard: TokenStandard.BaseToken, - name: 'IOTA', - tickerSymbol: 'IOTA', - unit: 'IOTA', - decimals: 6, - subunit: 'micro', - useMetricPrefix: false, -} - -const DEFAULT_SHIMMER_BASE_TOKEN: IBaseToken = { - standard: TokenStandard.BaseToken, - name: 'Shimmer', - tickerSymbol: 'SMR', - unit: 'SMR', - decimals: 6, - subunit: 'glow', - useMetricPrefix: false, -} - -const DEFAULT_TESTNET_BASE_TOKEN: IBaseToken = { - standard: TokenStandard.BaseToken, - name: 'Shimmer', - tickerSymbol: 'SMR', - unit: 'SMR', - decimals: 6, - subunit: 'glow', - useMetricPrefix: false, -} - -export const DEFAULT_BASE_TOKEN: Readonly<{ [key in NetworkId]?: IBaseToken }> = { - [NetworkId.Iota]: DEFAULT_IOTA_BASE_TOKEN, - [NetworkId.IotaAlphanet]: DEFAULT_IOTA_ALPHANET_BASE_TOKEN, - [NetworkId.Shimmer]: DEFAULT_SHIMMER_BASE_TOKEN, - [NetworkId.Testnet]: DEFAULT_TESTNET_BASE_TOKEN, -} diff --git a/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts b/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts index 57f85bf488b..b0010ac4f43 100644 --- a/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts +++ b/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts @@ -1,83 +1,37 @@ -import { COIN_TYPE, DEFAULT_BASE_TOKEN } from '../constants' -import { NetworkId, TokenSupply } from '../enums' +import { COIN_TYPE } from '../constants' +import { NetworkId } from '../enums' import { IStardustNetworkMetadata } from '../interfaces' import { NetworkMetadata } from '../types' +import { nodeInfoBaseToken, nodeInfoProtocol } from '../stores/node-info.store' +import { get } from 'svelte/store' export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in NetworkId]?: NetworkMetadata }> = { [NetworkId.Shimmer]: { id: NetworkId.Shimmer, name: 'Shimmer', coinType: COIN_TYPE[NetworkId.Shimmer], - protocol: { - version: 2, - networkName: 'shimmer', - bech32Hrp: 'smr', - minPowScore: 1500, - belowMaxDepth: 15, - rentStructure: { - vByteCost: 100, - vByteFactorData: 1, - vByteFactorKey: 10, - }, - tokenSupply: TokenSupply.Shimmer, - }, - baseToken: DEFAULT_BASE_TOKEN[NetworkId.Shimmer], + protocol: get(nodeInfoProtocol), + baseToken: get(nodeInfoBaseToken), }, [NetworkId.Testnet]: { id: NetworkId.Testnet, name: 'Testnet', coinType: COIN_TYPE[NetworkId.Testnet], - protocol: { - version: 2, - networkName: 'testnet', - bech32Hrp: 'rms', - minPowScore: 1500, - belowMaxDepth: 15, - rentStructure: { - vByteCost: 100, - vByteFactorData: 1, - vByteFactorKey: 10, - }, - tokenSupply: TokenSupply.Testnet, - }, - baseToken: DEFAULT_BASE_TOKEN[NetworkId.Testnet], + protocol: get(nodeInfoProtocol), + baseToken: get(nodeInfoBaseToken), }, [NetworkId.Iota]: { id: NetworkId.Iota, name: 'IOTA', coinType: COIN_TYPE[NetworkId.Iota], - protocol: { - version: 2, - networkName: 'iota', - bech32Hrp: 'iota', - minPowScore: 1500, - belowMaxDepth: 15, - rentStructure: { - vByteCost: 250, - vByteFactorData: 1, - vByteFactorKey: 10, - }, - tokenSupply: TokenSupply.Iota, - }, - baseToken: DEFAULT_BASE_TOKEN[NetworkId.Iota], + protocol: get(nodeInfoProtocol), + baseToken: get(nodeInfoBaseToken), }, [NetworkId.IotaAlphanet]: { id: NetworkId.IotaAlphanet, name: 'IOTA Alphanet', coinType: COIN_TYPE[NetworkId.IotaAlphanet], - protocol: { - version: 2, - networkName: 'iota-alphanet-2', - bech32Hrp: 'atoi', - minPowScore: 1500, - belowMaxDepth: 15, - rentStructure: { - vByteCost: 250, - vByteFactorData: 1, - vByteFactorKey: 10, - }, - tokenSupply: TokenSupply.Iota, - }, - baseToken: DEFAULT_BASE_TOKEN[NetworkId.IotaAlphanet], + protocol: get(nodeInfoProtocol), + baseToken: get(nodeInfoBaseToken), }, } diff --git a/packages/shared/lib/core/network/constants/index.ts b/packages/shared/lib/core/network/constants/index.ts index b10972bc5b5..75194f80ad1 100644 --- a/packages/shared/lib/core/network/constants/index.ts +++ b/packages/shared/lib/core/network/constants/index.ts @@ -1,5 +1,4 @@ export * from './coin-type.constant' -export * from './default-base-token.constant' export * from './default-chain-configurations.constant' export * from './default-max-parallel-api-requests' export * from './default-network-metadata.constant' diff --git a/packages/shared/lib/core/network/interfaces/index.ts b/packages/shared/lib/core/network/interfaces/index.ts index 228da613644..b10517a02d1 100644 --- a/packages/shared/lib/core/network/interfaces/index.ts +++ b/packages/shared/lib/core/network/interfaces/index.ts @@ -6,6 +6,5 @@ export * from './network-status.interface' export * from './node-info-response.interface' export * from './node.interface' export * from './persisted-network.interface' -export * from './protocol.interface' export * from './rent-structure.interface' export * from './stardust-network-metadata.interface' diff --git a/packages/shared/lib/core/network/interfaces/protocol.interface.ts b/packages/shared/lib/core/network/interfaces/protocol.interface.ts deleted file mode 100644 index 1a0dfdd1dea..00000000000 --- a/packages/shared/lib/core/network/interfaces/protocol.interface.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IRentStructure } from './rent-structure.interface' - -export interface IProtocol { - version: number - networkName: string - bech32Hrp: string - minPowScore: number - belowMaxDepth?: number - rentStructure: IRentStructure - tokenSupply: string -} diff --git a/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts b/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts index 1922f7daddc..10a5255d10e 100644 --- a/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts +++ b/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts @@ -1,6 +1,6 @@ import { IBaseToken } from '@core/wallet' import { NetworkId } from '../enums' -import { IProtocol } from './protocol.interface' +import { INodeInfoProtocol } from '@iota/sdk' /** * Holds relevant data @@ -11,6 +11,6 @@ export interface IStardustNetworkMetadata { id: NetworkId name: string coinType: number - protocol: IProtocol + protocol: INodeInfoProtocol baseToken: IBaseToken } diff --git a/packages/shared/lib/core/network/stores/node-info.store.ts b/packages/shared/lib/core/network/stores/node-info.store.ts index 8b6708bc65c..f8f8ae3a00c 100644 --- a/packages/shared/lib/core/network/stores/node-info.store.ts +++ b/packages/shared/lib/core/network/stores/node-info.store.ts @@ -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(undefined) export function setNodeInfo(newNodeInfo: INodeInfo | undefined): void { return nodeInfo.set(newNodeInfo) } + +export const nodeInfoBaseToken = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.baseToken) + +export const nodeInfoProtocol = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.protocol) diff --git a/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts b/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts index a21eba0b11e..1ef44f4c9c6 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts @@ -7,7 +7,12 @@ export async function checkAndUpdateActiveProfileNetwork(): Promise { const $activeProfile = get(activeProfile) const nodeInfoResponse = await getAndUpdateNodeInfo(true) const networkId = $activeProfile?.network?.id - if (!networkId || networkId === NetworkId.Custom) { + if ( + !networkId || + networkId === NetworkId.Custom || + !$activeProfile?.network?.protocol || + !$activeProfile?.network?.baseToken + ) { const network = buildPersistedNetworkFromNodeInfoResponse(nodeInfoResponse) network.chains = $activeProfile.network?.chains || [] updateActiveProfile({ network }) diff --git a/packages/shared/lib/core/wallet/interfaces/base-token.interface.ts b/packages/shared/lib/core/wallet/interfaces/base-token.interface.ts index 355ccd1fc83..7dfe1844162 100644 --- a/packages/shared/lib/core/wallet/interfaces/base-token.interface.ts +++ b/packages/shared/lib/core/wallet/interfaces/base-token.interface.ts @@ -1,11 +1,6 @@ +import { INodeInfoBaseToken } from '@iota/sdk/out/types' import { TokenStandard } from '../enums' -export interface IBaseToken { +export interface IBaseToken extends INodeInfoBaseToken { standard: TokenStandard.BaseToken - name: string - tickerSymbol?: string - unit: string - subunit?: string | null - decimals: number - useMetricPrefix?: boolean } diff --git a/packages/shared/lib/core/wallet/tests/convertToRawAmount.test.ts b/packages/shared/lib/core/wallet/tests/convertToRawAmount.test.ts index 9242a5a2863..2b3928b9884 100644 --- a/packages/shared/lib/core/wallet/tests/convertToRawAmount.test.ts +++ b/packages/shared/lib/core/wallet/tests/convertToRawAmount.test.ts @@ -4,7 +4,8 @@ import { convertToRawAmount } from '../utils' import { TokenMetadata } from '../types' import { TokenStandard } from '../enums' import { MAX_SUPPORTED_DECIMALS } from '../constants' -import { DEFAULT_BASE_TOKEN, NetworkId } from '@core/network' +import { NetworkId } from '@core/network' +import { IBaseToken } from '../interfaces' const WEB3_TOKEN_METADATA: TokenMetadata = { name: 'RAWR', @@ -35,6 +36,26 @@ const INVALID_TOKEN_METADATA: TokenMetadata = { decimals: 0, } +const DEFAULT_IOTA_BASE_TOKEN: IBaseToken = { + standard: TokenStandard.BaseToken, + name: 'IOTA', + tickerSymbol: 'IOTA', + unit: 'IOTA', + decimals: 6, + subunit: 'micro', + useMetricPrefix: false, +} + +const DEFAULT_SHIMMER_BASE_TOKEN: IBaseToken = { + standard: TokenStandard.BaseToken, + name: 'Shimmer', + tickerSymbol: 'SMR', + unit: 'SMR', + decimals: 6, + subunit: 'glow', + useMetricPrefix: false, +} + describe('File: convertToRawAmount.ts', () => { it('should return undefined if amount is empty', () => { expect(convertToRawAmount('', INVALID_TOKEN_METADATA)).toStrictEqual(undefined) @@ -43,40 +64,40 @@ describe('File: convertToRawAmount.ts', () => { describe('given the tokenMetadata standard is BaseToken', () => { describe("given useMetricPrefix is false (currently IOTA's case)", () => { it("should return Big(amount) * decimal property if selectedUnit is unit and baseToken's decimal is less than MAX_SUPPORTED_DECIMALS", () => { - let value = convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Iota], 'IOTA') - expect(value).toStrictEqual(Big('1').mul(Big(10).pow(DEFAULT_BASE_TOKEN[NetworkId.Iota].decimals))) + let value = convertToRawAmount('1', DEFAULT_IOTA_BASE_TOKEN, 'IOTA') + expect(value).toStrictEqual(Big('1').mul(Big(10).pow(DEFAULT_IOTA_BASE_TOKEN.decimals))) }) it("should return XXX if selectedUnit is unit and baseToken's decimals property is greater than MAX_SUPPORTED_DECIMALS", () => { let value = convertToRawAmount('1', WEB3_TOKEN_METADATA, 'RAWR') expect(value).toStrictEqual(Big('1').mul(Big(10).pow(MAX_SUPPORTED_DECIMALS))) }) it('should return same Big(amount) if selectedUnit is subunit', () => { - expect(convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Iota], 'micro')).toStrictEqual(Big('1')) + expect(convertToRawAmount('1', DEFAULT_IOTA_BASE_TOKEN, 'micro')).toStrictEqual(Big('1')) }) it('should return undefined if a unit is not provided', () => { - expect(convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Iota])).toStrictEqual(undefined) + expect(convertToRawAmount('1', DEFAULT_IOTA_BASE_TOKEN)).toStrictEqual(undefined) }) it('should return undefined if provided unit does not match the tokenMetadata unit or subunit', () => { - expect(convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Iota], 'test')).toStrictEqual(undefined) + expect(convertToRawAmount('1', DEFAULT_IOTA_BASE_TOKEN, 'test')).toStrictEqual(undefined) }) }) describe("given useMetricPrefix is false (currently Shimmer's case)", () => { it("should return Big(amount) * decimal property if selectedUnit is unit and baseToken's decimal is less than MAX_SUPPORTED_DECIMALS", () => { - let value = convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Shimmer], 'SMR') - expect(value).toStrictEqual(Big('1').mul(Big(10).pow(DEFAULT_BASE_TOKEN[NetworkId.Shimmer].decimals))) + let value = convertToRawAmount('1', DEFAULT_SHIMMER_BASE_TOKEN, 'SMR') + expect(value).toStrictEqual(Big('1').mul(Big(10).pow(DEFAULT_SHIMMER_BASE_TOKEN.decimals))) }) it("should return XXX if selectedUnit is unit and baseToken's decimals property is greater than MAX_SUPPORTED_DECIMALS", () => { let value = convertToRawAmount('1', WEB3_TOKEN_METADATA, 'RAWR') expect(value).toStrictEqual(Big('1').mul(Big(10).pow(MAX_SUPPORTED_DECIMALS))) }) it('should return same Big(amount) if selectedUnit is subunit', () => { - expect(convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Shimmer], 'glow')).toStrictEqual(Big('1')) + expect(convertToRawAmount('1', DEFAULT_SHIMMER_BASE_TOKEN, 'glow')).toStrictEqual(Big('1')) }) it('should return undefined if a unit is not provided', () => { - expect(convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Shimmer])).toStrictEqual(undefined) + expect(convertToRawAmount('1', DEFAULT_SHIMMER_BASE_TOKEN)).toStrictEqual(undefined) }) it('should return undefined if provided unit does not match the tokenMetadata unit or subunit', () => { - expect(convertToRawAmount('1', DEFAULT_BASE_TOKEN[NetworkId.Shimmer], 'test')).toStrictEqual(undefined) + expect(convertToRawAmount('1', DEFAULT_SHIMMER_BASE_TOKEN, 'test')).toStrictEqual(undefined) }) }) }) From af26debc7d1a3788306c8f445645e6472248407d Mon Sep 17 00:00:00 2001 From: cpl121 Date: Thu, 14 Mar 2024 16:00:54 +0100 Subject: [PATCH 02/11] refactor: remove baseToken and protocol of IStardustNetworkMetadata --- .../views/ImportStrongholdView.svelte | 2 +- .../restore-profile/views/ClaimFinderView.svelte | 6 ++---- .../onboarding/actions/findShimmerRewards.ts | 16 ++++++++-------- .../actions/restoreBackupFromStrongholdFile.ts | 2 +- .../actions/syncShimmerClaimingAccount.ts | 5 +++-- .../stores/onboarding-profile.store.ts | 5 ----- .../default-network-metadata.constant.ts | 14 ++++---------- .../stardust-network-metadata.interface.ts | 5 +---- .../buildPersistedNetworkFromNodeInfoResponse.ts | 8 +++----- .../checkAndUpdateActiveProfileNetwork.ts | 7 +------ .../actions/active-profile/getBaseToken.ts | 12 ++++++++---- .../actions/active-profile/getNetworkHrp.ts | 2 +- .../wallet/utils/formatTokenAmountPrecise.ts | 2 +- 13 files changed, 34 insertions(+), 52 deletions(-) diff --git a/packages/desktop/views/onboarding/views/restore-from-stronghold/views/ImportStrongholdView.svelte b/packages/desktop/views/onboarding/views/restore-from-stronghold/views/ImportStrongholdView.svelte index de291337ab3..73beefe68e1 100644 --- a/packages/desktop/views/onboarding/views/restore-from-stronghold/views/ImportStrongholdView.svelte +++ b/packages/desktop/views/onboarding/views/restore-from-stronghold/views/ImportStrongholdView.svelte @@ -79,7 +79,7 @@ async function shouldMigrate(): Promise { try { - await restoreBackup(importFilePath, '', $onboardingProfile.network.protocol.bech32Hrp) + await restoreBackup(importFilePath, '', $onboardingProfile.network.bech32Hrp) } catch (err) { const isMigrationRequired = CLIENT_ERROR_REGEXES[ClientError.MigrationRequired].test(err?.error) return isMigrationRequired diff --git a/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte b/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte index f9e88dd9c01..9c5e03e4cf3 100644 --- a/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte +++ b/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte @@ -36,6 +36,7 @@ import { onDestroy, onMount } from 'svelte' import { restoreProfileRouter } from '../restore-profile-router' import { AnimationEnum } from '@auxiliary/animation' + import { getBaseToken } from '@core/profile' $: shimmerClaimingAccounts = $onboardingProfile?.shimmerClaimingAccounts ?? [] @@ -199,10 +200,7 @@ {#if shimmerClaimingAccounts && shimmerClaimingAccounts?.length > 0}
{#each shimmerClaimingAccounts as shimmerClaimingAccount} - + {/each}
{/if} diff --git a/packages/shared/lib/contexts/onboarding/actions/findShimmerRewards.ts b/packages/shared/lib/contexts/onboarding/actions/findShimmerRewards.ts index 61b4f32fcbf..4d9d02b9200 100644 --- a/packages/shared/lib/contexts/onboarding/actions/findShimmerRewards.ts +++ b/packages/shared/lib/contexts/onboarding/actions/findShimmerRewards.ts @@ -2,19 +2,19 @@ import { showAppNotification } from '@auxiliary/notification' import { IAccount } from '@core/account' import { localize } from '@core/i18n' import { updateLedgerNanoStatus } from '@core/ledger' -import { AccountRecoveryProfileConfiguration, ProfileType, UnableToFindProfileTypeError } from '@core/profile' +import { + AccountRecoveryProfileConfiguration, + ProfileType, + UnableToFindProfileTypeError, + getBaseToken, +} from '@core/profile' import { RecoverAccountsPayload, recoverAccounts } from '@core/profile-manager' import { zip } from '@core/utils' import { formatTokenAmountBestMatch } from '@core/wallet/utils' import { get } from 'svelte/store' import { SHIMMER_CLAIMING_ACCOUNT_RECOVERY_CONFIGURATION, SHIMMER_CLAIMING_ACCOUNT_SYNC_OPTIONS } from '../constants' import { getSortedRenamedBoundAccounts, prepareShimmerClaimingAccount } from '../helpers' -import { - getOnboardingBaseToken, - onboardingProfile, - shimmerClaimingProfileManager, - updateShimmerClaimingAccount, -} from '../stores' +import { onboardingProfile, shimmerClaimingProfileManager, updateShimmerClaimingAccount } from '../stores' import { sumTotalUnclaimedRewards } from '../utils' const DEPTH_SEARCH_ACCOUNT_START_INDEX = 0 @@ -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()) showAppNotification({ type: 'success', alert: true, diff --git a/packages/shared/lib/contexts/onboarding/actions/restoreBackupFromStrongholdFile.ts b/packages/shared/lib/contexts/onboarding/actions/restoreBackupFromStrongholdFile.ts index 4d8b756cb5a..380c1784fe8 100644 --- a/packages/shared/lib/contexts/onboarding/actions/restoreBackupFromStrongholdFile.ts +++ b/packages/shared/lib/contexts/onboarding/actions/restoreBackupFromStrongholdFile.ts @@ -7,7 +7,7 @@ import { onboardingProfile } from '../stores' export async function restoreBackupFromStrongholdFile(strongholdPassword: string): Promise { const { id, importFilePath, clientOptions, network } = get(onboardingProfile) try { - await restoreBackup(importFilePath, strongholdPassword, network.protocol.bech32Hrp) + await restoreBackup(importFilePath, strongholdPassword, network.bech32Hrp) } catch (err) { const storageDirectory = await getStorageDirectoryOfProfile(id) await restoreBackupByCopyingFile( diff --git a/packages/shared/lib/contexts/onboarding/actions/syncShimmerClaimingAccount.ts b/packages/shared/lib/contexts/onboarding/actions/syncShimmerClaimingAccount.ts index ae003e641f0..7acaea7e830 100644 --- a/packages/shared/lib/contexts/onboarding/actions/syncShimmerClaimingAccount.ts +++ b/packages/shared/lib/contexts/onboarding/actions/syncShimmerClaimingAccount.ts @@ -6,10 +6,11 @@ import { getAccount, profileManager } from '@core/profile-manager' import { MissingShimmerClaimingProfileManagerError } from '../errors' import { prepareShimmerClaimingAccount } from '../helpers' -import { getOnboardingBaseToken, shimmerClaimingProfileManager, updateShimmerClaimingAccount } from '../stores' +import { shimmerClaimingProfileManager, updateShimmerClaimingAccount } from '../stores' import { setTotalUnclaimedShimmerRewards } from '@contexts/onboarding' import { formatTokenAmountBestMatch } from '@core/wallet/utils' import { showAppNotification } from '@auxiliary/notification' +import { getBaseToken } from '@core/profile' export async function syncShimmerClaimingAccount(account: IAccount): Promise { const _shimmerClaimingProfileManager = get(shimmerClaimingProfileManager) @@ -28,7 +29,7 @@ export async function syncShimmerClaimingAccount(account: IAccount): Promise 0) { const foundRewardsAmount = syncedShimmerClaimingAccount?.unclaimedRewards - const foundRewardsAmountFormatted = formatTokenAmountBestMatch(foundRewardsAmount, getOnboardingBaseToken()) + const foundRewardsAmountFormatted = formatTokenAmountBestMatch(foundRewardsAmount, getBaseToken()) showAppNotification({ type: 'success', diff --git a/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts b/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts index 0a9b3434dac..5eeca341cbb 100644 --- a/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts +++ b/packages/shared/lib/contexts/onboarding/stores/onboarding-profile.store.ts @@ -3,7 +3,6 @@ import { derived, get, Readable, writable } from 'svelte/store' import { isLedgerProfile } from '@core/profile' import { IOnboardingProfile, IShimmerClaimingAccount } from '../interfaces' -import { IBaseToken } from '@core/wallet/interfaces' import { IPersistedNetwork } from '@core/network' export const onboardingProfile = writable>(null) @@ -36,7 +35,3 @@ export function updateShimmerClaimingAccount(shimmerClaimingAccount: IShimmerCla ) updateOnboardingProfile({ shimmerClaimingAccounts }) } - -export function getOnboardingBaseToken(): IBaseToken | undefined { - return get(onboardingProfile)?.network?.baseToken -} diff --git a/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts b/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts index b0010ac4f43..8a47a793f78 100644 --- a/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts +++ b/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts @@ -2,36 +2,30 @@ import { COIN_TYPE } from '../constants' import { NetworkId } from '../enums' import { IStardustNetworkMetadata } from '../interfaces' import { NetworkMetadata } from '../types' -import { nodeInfoBaseToken, nodeInfoProtocol } from '../stores/node-info.store' -import { get } from 'svelte/store' export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in NetworkId]?: NetworkMetadata }> = { [NetworkId.Shimmer]: { id: NetworkId.Shimmer, name: 'Shimmer', coinType: COIN_TYPE[NetworkId.Shimmer], - protocol: get(nodeInfoProtocol), - baseToken: get(nodeInfoBaseToken), + bech32Hrp: 'smr', }, [NetworkId.Testnet]: { id: NetworkId.Testnet, name: 'Testnet', coinType: COIN_TYPE[NetworkId.Testnet], - protocol: get(nodeInfoProtocol), - baseToken: get(nodeInfoBaseToken), + bech32Hrp: 'rms', }, [NetworkId.Iota]: { id: NetworkId.Iota, name: 'IOTA', coinType: COIN_TYPE[NetworkId.Iota], - protocol: get(nodeInfoProtocol), - baseToken: get(nodeInfoBaseToken), + bech32Hrp: 'iota', }, [NetworkId.IotaAlphanet]: { id: NetworkId.IotaAlphanet, name: 'IOTA Alphanet', coinType: COIN_TYPE[NetworkId.IotaAlphanet], - protocol: get(nodeInfoProtocol), - baseToken: get(nodeInfoBaseToken), + bech32Hrp: 'atoi', }, } diff --git a/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts b/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts index 10a5255d10e..3dbbcf4204c 100644 --- a/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts +++ b/packages/shared/lib/core/network/interfaces/stardust-network-metadata.interface.ts @@ -1,6 +1,4 @@ -import { IBaseToken } from '@core/wallet' import { NetworkId } from '../enums' -import { INodeInfoProtocol } from '@iota/sdk' /** * Holds relevant data @@ -11,6 +9,5 @@ export interface IStardustNetworkMetadata { id: NetworkId name: string coinType: number - protocol: INodeInfoProtocol - baseToken: IBaseToken + bech32Hrp: string } diff --git a/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts b/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts index 6c69d819296..6ee00457e39 100644 --- a/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts +++ b/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts @@ -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: [], } } diff --git a/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts b/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts index 1ef44f4c9c6..a21eba0b11e 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/checkAndUpdateActiveProfileNetwork.ts @@ -7,12 +7,7 @@ export async function checkAndUpdateActiveProfileNetwork(): Promise { const $activeProfile = get(activeProfile) const nodeInfoResponse = await getAndUpdateNodeInfo(true) const networkId = $activeProfile?.network?.id - if ( - !networkId || - networkId === NetworkId.Custom || - !$activeProfile?.network?.protocol || - !$activeProfile?.network?.baseToken - ) { + if (!networkId || networkId === NetworkId.Custom) { const network = buildPersistedNetworkFromNodeInfoResponse(nodeInfoResponse) network.chains = $activeProfile.network?.chains || [] updateActiveProfile({ network }) diff --git a/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts b/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts index bfb2182ddd8..a83a9ee675c 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts @@ -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, + } } diff --git a/packages/shared/lib/core/profile/actions/active-profile/getNetworkHrp.ts b/packages/shared/lib/core/profile/actions/active-profile/getNetworkHrp.ts index d44190554ec..f6980a4d38c 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/getNetworkHrp.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/getNetworkHrp.ts @@ -3,5 +3,5 @@ import { get } from 'svelte/store' export function getNetworkHrp(): string { const $activeProfile = get(activeProfile) - return $activeProfile.network.protocol.bech32Hrp + return $activeProfile.network.bech32Hrp } diff --git a/packages/shared/lib/core/wallet/utils/formatTokenAmountPrecise.ts b/packages/shared/lib/core/wallet/utils/formatTokenAmountPrecise.ts index 8829fb90845..b5a0a246a89 100644 --- a/packages/shared/lib/core/wallet/utils/formatTokenAmountPrecise.ts +++ b/packages/shared/lib/core/wallet/utils/formatTokenAmountPrecise.ts @@ -4,7 +4,7 @@ import { TokenMetadata } from '../types' export function formatTokenAmountPrecise(amount: number, tokenMetadata: TokenMetadata): string { const formattedAmount = formatNumber(amount, 0, 0, 0, true) - if (tokenMetadata.standard === TokenStandard.BaseToken) { + if (tokenMetadata?.standard === TokenStandard.BaseToken) { if (tokenMetadata?.useMetricPrefix) { return formattedAmount + ' ' + tokenMetadata?.unit } else { From dad031bf4446da06b5e8804d5a90b4885e155e31 Mon Sep 17 00:00:00 2001 From: cpl121 Date: Thu, 14 Mar 2024 16:01:34 +0100 Subject: [PATCH 03/11] feat: update profile version deleting old params of network --- .../profiles/checkAndMigrateProfiles.ts | 22 +++++++++++++++++++ .../constants/profile-version.constant.ts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts index 40c7d1c21aa..94aafa51ef9 100644 --- a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts +++ b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts @@ -3,6 +3,7 @@ import { COIN_TYPE, DEFAULT_CHAIN_CONFIGURATIONS, DEFAULT_MAX_PARALLEL_API_REQUESTS, + DEFAULT_NETWORK_METADATA, getDefaultPersistedNetwork, IIscpChainMetadata, NetworkId, @@ -73,6 +74,7 @@ const persistedProfileMigrationsMap: Record Date: Thu, 14 Mar 2024 16:05:21 +0100 Subject: [PATCH 04/11] fix: format --- .../core/profile/actions/profiles/checkAndMigrateProfiles.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts index 94aafa51ef9..9fdc08e674a 100644 --- a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts +++ b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts @@ -350,6 +350,6 @@ function persistedProfileMigrationToV18(existingProfile: IPersistedProfile): voi newNetwork.bech32Hrp = defaultBech32Hrp existingProfile.network = newNetwork - saveProfile(existingProfile ) + saveProfile(existingProfile) } } From 0fed75eb3b548ae79dfcf50e1de38e8abae7d55a Mon Sep 17 00:00:00 2001 From: cpl121 Date: Wed, 17 Apr 2024 11:41:40 +0200 Subject: [PATCH 05/11] fix: remove nodeInfo deriveds --- packages/shared/lib/core/network/stores/node-info.store.ts | 6 +----- .../lib/core/profile/actions/active-profile/getBaseToken.ts | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/shared/lib/core/network/stores/node-info.store.ts b/packages/shared/lib/core/network/stores/node-info.store.ts index f8f8ae3a00c..8b6708bc65c 100644 --- a/packages/shared/lib/core/network/stores/node-info.store.ts +++ b/packages/shared/lib/core/network/stores/node-info.store.ts @@ -1,12 +1,8 @@ import { INodeInfo } from '@iota/sdk/out/types' -import { writable, derived } from 'svelte/store' +import { writable } from 'svelte/store' export const nodeInfo = writable(undefined) export function setNodeInfo(newNodeInfo: INodeInfo | undefined): void { return nodeInfo.set(newNodeInfo) } - -export const nodeInfoBaseToken = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.baseToken) - -export const nodeInfoProtocol = derived(nodeInfo, ($nodeInfo) => $nodeInfo?.protocol) diff --git a/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts b/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts index a83a9ee675c..4021bceff24 100644 --- a/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts +++ b/packages/shared/lib/core/profile/actions/active-profile/getBaseToken.ts @@ -1,12 +1,12 @@ import { IBaseToken, TokenStandard } from '@core/wallet' -import { nodeInfoBaseToken } from '@core/network' +import { nodeInfo } from '@core/network' import { get } from 'svelte/store' export function getBaseToken(): IBaseToken { - const $nodeInfoBaseToken = get(nodeInfoBaseToken) + const $nodeInfo = get(nodeInfo) return { standard: TokenStandard.BaseToken, - ...$nodeInfoBaseToken, + ...$nodeInfo?.baseToken, } } From f7ca2464a329ba3c3df1fb707306023c32824308 Mon Sep 17 00:00:00 2001 From: cpl121 Date: Wed, 17 Apr 2024 11:42:36 +0200 Subject: [PATCH 06/11] fix: remove Unknown Network as value of hrp --- .../network/utils/buildPersistedNetworkFromNodeInfoResponse.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts b/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts index 6ee00457e39..a0e97a15214 100644 --- a/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts +++ b/packages/shared/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts @@ -15,7 +15,7 @@ export function buildPersistedNetworkFromNodeInfoResponse( id: networkId, name: name ?? 'Unknown Network', coinType: _coinType, - bech32Hrp: bech32Hrp ?? 'Unknown Network', + bech32Hrp, chains: [], } } From b6d91933fab8209ce8c8431c7577b11bacb5aa8c Mon Sep 17 00:00:00 2001 From: cpl121 Date: Wed, 17 Apr 2024 11:43:02 +0200 Subject: [PATCH 07/11] fix: improve defaultBech32Hrp in the migration profile --- .../profile/actions/profiles/checkAndMigrateProfiles.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts index 9fdc08e674a..39002b2f894 100644 --- a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts +++ b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts @@ -342,11 +342,15 @@ function persistedProfileMigrationToV18(existingProfile: IPersistedProfile): voi } const oldNetwork = existingProfile.network as unknown as IOldPersistedNetwork + + // If the networkId is Custom the default hrp is not known, and is obtained from the previous network protocol + const defaultBech32Hrp = + DEFAULT_NETWORK_METADATA[existingProfile.network.id]?.bech32Hrp || oldNetwork?.protocol?.bech32Hrp || '' + delete oldNetwork.protocol delete oldNetwork.baseToken const newNetwork = oldNetwork as unknown as IPersistedNetwork - const defaultBech32Hrp = DEFAULT_NETWORK_METADATA[existingProfile.network.id]?.bech32Hrp || '' newNetwork.bech32Hrp = defaultBech32Hrp existingProfile.network = newNetwork From 954c85bcde2c0be81ab8da99974d0c188aa55e8c Mon Sep 17 00:00:00 2001 From: cpl121 Date: Wed, 17 Apr 2024 13:53:59 +0200 Subject: [PATCH 08/11] fix: update node info in shimmer claiming --- .../views/restore-profile/views/ClaimFinderView.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte b/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte index 9c5e03e4cf3..8d4f2e46bf5 100644 --- a/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte +++ b/packages/desktop/views/onboarding/views/restore-profile/views/ClaimFinderView.svelte @@ -37,6 +37,7 @@ import { restoreProfileRouter } from '../restore-profile-router' import { AnimationEnum } from '@auxiliary/animation' import { getBaseToken } from '@core/profile' + import { getAndUpdateNodeInfo } from '@core/network' $: shimmerClaimingAccounts = $onboardingProfile?.shimmerClaimingAccounts ?? [] @@ -173,7 +174,8 @@ } } - onMount(() => { + onMount(async () => { + await getAndUpdateNodeInfo() void ledgerRaceConditionProtectionWrapper(setupShimmerClaiming) }) From 85fdce64b533e7bf82beb9c1e77273c73d788f71 Mon Sep 17 00:00:00 2001 From: cpl121 Date: Fri, 19 Apr 2024 20:31:13 +0200 Subject: [PATCH 09/11] fix: update bech32Hrpfor new testnets --- .../core/network/constants/default-network-metadata.constant.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts b/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts index a53b5fe36f2..9d0a328888a 100644 --- a/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts +++ b/packages/shared/lib/core/network/constants/default-network-metadata.constant.ts @@ -14,6 +14,7 @@ export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in NetworkId]?: NetworkMe id: NetworkId.ShimmerTestnet, name: 'Shimmer Testnet', coinType: COIN_TYPE[NetworkId.ShimmerTestnet], + bech32Hrp: 'rms', }, [NetworkId.Iota]: { id: NetworkId.Iota, @@ -25,6 +26,7 @@ export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in NetworkId]?: NetworkMe id: NetworkId.IotaTestnet, name: 'IOTA Testnet', coinType: COIN_TYPE[NetworkId.IotaTestnet], + bech32Hrp: 'tst', }, [NetworkId.IotaAlphanet]: { id: NetworkId.IotaAlphanet, From 465ee97605e0306d6f974dafdda145166e25c141 Mon Sep 17 00:00:00 2001 From: cpl121 Date: Fri, 19 Apr 2024 20:31:33 +0200 Subject: [PATCH 10/11] fix: error with asset icons and iota names --- packages/shared/components/AssetIcon.svelte | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/shared/components/AssetIcon.svelte b/packages/shared/components/AssetIcon.svelte index b91f112f1a8..adc525add08 100644 --- a/packages/shared/components/AssetIcon.svelte +++ b/packages/shared/components/AssetIcon.svelte @@ -2,7 +2,7 @@ import { AnimationRenderer } from '@auxiliary/animation' import { Icon as IconEnum, NETWORK_ICON_SVG } from '@auxiliary/icon' import { getIconColorFromString } from '@core/account' - import { COIN_TYPE, DEFAULT_BASE_TOKEN, NetworkId } from '@core/network' + import { COIN_TYPE, NetworkId } from '@core/network' import { isBright } from '@core/utils' import { ANIMATED_TOKEN_IDS, IPersistedAsset, TokenStandard, getAssetInitials } from '@core/wallet' import { Animation, AssetIconSize, Icon, VerificationBadge } from 'shared/components' @@ -17,6 +17,8 @@ let assetIconWrapperWidth: number let assetLogoUrl: string + const IOTA_NAMES = [NetworkId.Iota, 'tst'] + $: isAnimation = asset.id in ANIMATED_TOKEN_IDS $: asset, updateAssetIcon() $: assetIconColor = isBright(assetIconBackgroundColor) ? 'text-gray-800' : 'text-white' @@ -42,19 +44,13 @@ ].includes(assetId) ) { assetIconBackgroundColor = '#C4D1E8' - } else if (String(DEFAULT_BASE_TOKEN[NetworkId.Iota]?.name?.toLowerCase()) === assetName) { + } else if (String(NetworkId.Iota) === assetName) { assetIconBackgroundColor = '#000000' - } else if (String(DEFAULT_BASE_TOKEN[NetworkId.Shimmer]?.name?.toLowerCase()) === assetName) { + } else if (String(NetworkId.Shimmer) === assetName) { assetIconBackgroundColor = '#25DFCA' } - if ( - [ - String(DEFAULT_BASE_TOKEN[NetworkId.Iota]?.name?.toLowerCase()), - String(DEFAULT_BASE_TOKEN[NetworkId.IotaTestnet]?.name?.toLowerCase()), - String(DEFAULT_BASE_TOKEN[NetworkId.IotaAlphanet]?.name?.toLowerCase()), - ].includes(assetName) - ) { + if (IOTA_NAMES.includes(assetName)) { icon = NETWORK_ICON_SVG[NetworkId.Iota] } else { icon = NETWORK_ICON_SVG[NetworkId.Shimmer] From d3bb6aec3332da675e3dcde9a003def4f09fe53e Mon Sep 17 00:00:00 2001 From: cpl121 Date: Fri, 19 Apr 2024 20:40:58 +0200 Subject: [PATCH 11/11] fix: check error --- .../core/profile/actions/profiles/checkAndMigrateProfiles.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts index 762a93f8776..da3bdd6155a 100644 --- a/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts +++ b/packages/shared/lib/core/profile/actions/profiles/checkAndMigrateProfiles.ts @@ -355,7 +355,8 @@ function persistedProfileMigrationToV18(existingProfile: IPersistedProfile): voi function persistedProfileMigrationToV19(existingProfile: IPersistedProfile): void { if (existingProfile.network) { interface IOldPersistedNetwork { - protocol: unknown + // eslint-disable-next-line @typescript-eslint/no-explicit-any + protocol: any // protocol with 'any' instead of 'unknown' to get the value of bech32Hrp later baseToken: unknown }