diff --git a/packages/desktop/features/onboarding.features.ts b/packages/desktop/features/onboarding.features.ts index 54ec956446..36ef2c4878 100644 --- a/packages/desktop/features/onboarding.features.ts +++ b/packages/desktop/features/onboarding.features.ts @@ -96,7 +96,7 @@ const onboardingFeaturesForShimmer: IOnboardingFeaturesForNetwork = { }, } -const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = { +const onboardingFeaturesForIotaTestnet: IOnboardingFeaturesForNetwork = { enabled: true, newProfile: { enabled: true, @@ -124,7 +124,41 @@ const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = { }, claimRewards: { enabled: true, - hidden: false, + hidden: true, + recoveryPhrase: { + enabled: true, + }, + strongholdBackup: { + enabled: true, + }, + ledgerBackup: { + enabled: true, + }, + }, + defaultIscChains: { + enabled: true, + }, + defaultEvmChains: { + enabled: true, + }, +} + +const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = { + enabled: true, + newProfile: { + enabled: true, + softwareProfile: { + enabled: true, + skipVerification: { + enabled: false, + }, + }, + ledgerProfile: { + enabled: true, + }, + }, + restoreProfile: { + enabled: true, recoveryPhrase: { enabled: true, }, @@ -135,6 +169,19 @@ const onboardingFeaturesForTestnet: IOnboardingFeaturesForNetwork = { enabled: true, }, }, + claimRewards: { + enabled: true, + hidden: false, + recoveryPhrase: { + enabled: false, + }, + strongholdBackup: { + enabled: false, + }, + ledgerBackup: { + enabled: false, + }, + }, defaultIscChains: { enabled: true, }, @@ -183,7 +230,7 @@ const onboardingFeaturesForCustom: IOnboardingFeaturesForNetwork = { }, }, defaultIscChains: { - enabled: false, + enabled: true, }, defaultEvmChains: { enabled: false, @@ -194,6 +241,7 @@ const onboardingFeatures: OnboardingFeatures = { enabled: true, iota: onboardingFeaturesForIota, shimmer: onboardingFeaturesForShimmer, + iotaTestnet: onboardingFeaturesForIotaTestnet, testnet: onboardingFeaturesForTestnet, custom: onboardingFeaturesForCustom, importFromThirdParty: { diff --git a/packages/desktop/lib/electron/managers/transak.manager.ts b/packages/desktop/lib/electron/managers/transak.manager.ts index 67344cacd7..442bee3740 100644 --- a/packages/desktop/lib/electron/managers/transak.manager.ts +++ b/packages/desktop/lib/electron/managers/transak.manager.ts @@ -258,7 +258,7 @@ export default class TransakManager implements ITransakManager { colorMode, } - const urlObject = buildUrl({ origin: TRANSAK_WIDGET_URL, query: queryParams }) + const urlObject = buildUrl({ base: TRANSAK_WIDGET_URL, query: queryParams }) return urlObject?.href ?? '' } diff --git a/packages/desktop/views/dashboard/campaigns/components/CampaignHeader.svelte b/packages/desktop/views/dashboard/campaigns/components/CampaignHeader.svelte index 1f89a57bbb..805382afd8 100644 --- a/packages/desktop/views/dashboard/campaigns/components/CampaignHeader.svelte +++ b/packages/desktop/views/dashboard/campaigns/components/CampaignHeader.svelte @@ -46,14 +46,14 @@ function onProjectClick(): void { const url = buildUrl({ - origin: TIDE_BASE_URL, + base: TIDE_BASE_URL, pathname: `${TideWebsiteEndpoint.Project}/${campaign.projectId}`, }) openUrlInBrowser(url?.href) } function onCampaignClick(): void { - const url = buildUrl({ origin: TIDE_BASE_URL, pathname: `${TideWebsiteEndpoint.Campaign}/${campaign.id}` }) + const url = buildUrl({ base: TIDE_BASE_URL, pathname: `${TideWebsiteEndpoint.Campaign}/${campaign.id}` }) openUrlInBrowser(url?.href) } diff --git a/packages/desktop/views/onboarding/views/network-setup/NetworkSetupRouterView.svelte b/packages/desktop/views/onboarding/views/network-setup/NetworkSetupRouterView.svelte index a8bc4d6910..524071e423 100644 --- a/packages/desktop/views/onboarding/views/network-setup/NetworkSetupRouterView.svelte +++ b/packages/desktop/views/onboarding/views/network-setup/NetworkSetupRouterView.svelte @@ -3,7 +3,7 @@ import features from '@features/features' import { NetworkSetupRoute } from './network-setup-route.enum' import { networkSetupRoute } from './network-setup-router' - import { ChooseNetworkView, CustomNetworkView } from './views' + import { ChooseNetworkView, CustomNetworkView, TestnetSelectionView } from './views' $: if (features.analytics.onboardingRoute.enabled && $networkSetupRoute) { Platform.trackEvent('network-setup-route', { route: $networkSetupRoute }) @@ -12,6 +12,8 @@ {#if $networkSetupRoute === NetworkSetupRoute.ChooseNetwork} +{:else if $networkSetupRoute === NetworkSetupRoute.TestnetSelection} + {:else if $networkSetupRoute === NetworkSetupRoute.CustomNetwork} {/if} diff --git a/packages/desktop/views/onboarding/views/network-setup/network-setup-route.enum.ts b/packages/desktop/views/onboarding/views/network-setup/network-setup-route.enum.ts index db798051fc..fd66d1069e 100644 --- a/packages/desktop/views/onboarding/views/network-setup/network-setup-route.enum.ts +++ b/packages/desktop/views/onboarding/views/network-setup/network-setup-route.enum.ts @@ -1,4 +1,5 @@ export enum NetworkSetupRoute { ChooseNetwork = 'chooseNetwork', + TestnetSelection = 'testnetSelection', CustomNetwork = 'customNetwork', } diff --git a/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts b/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts index 1664ac4289..c9f358bf87 100644 --- a/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts +++ b/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts @@ -11,20 +11,26 @@ export class NetworkSetupRouter extends Subrouter { super(NetworkSetupRoute.ChooseNetwork, networkSetupRoute, parentRouter) } - next(): void { + next(params?: { type: 'testnet' | 'custom' }): void { const _onboardingProfile = get(onboardingProfile) const currentRoute = get(this.routeStore) switch (currentRoute) { case NetworkSetupRoute.ChooseNetwork: { const network = _onboardingProfile?.network - if (network) { + if (params?.type === 'testnet') { + networkSetupRoute.set(NetworkSetupRoute.TestnetSelection) + return + } else if (network) { this.parentRouter?.next() return } else { - this.setNext(NetworkSetupRoute.CustomNetwork) - break + networkSetupRoute.set(NetworkSetupRoute.CustomNetwork) + return } } + case NetworkSetupRoute.TestnetSelection: + this.parentRouter?.next() + return case NetworkSetupRoute.CustomNetwork: this.parentRouter?.next() return diff --git a/packages/desktop/views/onboarding/views/network-setup/views/ChooseNetworkView.svelte b/packages/desktop/views/onboarding/views/network-setup/views/ChooseNetworkView.svelte index 62cff0eb43..fd2892b9d4 100644 --- a/packages/desktop/views/onboarding/views/network-setup/views/ChooseNetworkView.svelte +++ b/packages/desktop/views/onboarding/views/network-setup/views/ChooseNetworkView.svelte @@ -37,14 +37,26 @@ } function onContinueClick(): void { - if (selectedNetworkType !== OnboardingNetworkType.Custom) { - const networkName = getNetworkNameFromOnboardingNetworkType(selectedNetworkType) - const networkId: StardustNetworkId = `${NetworkNamespace.Stardust}:${networkName}` - const network = getDefaultStardustNetwork(networkId) - const clientOptions = getDefaultClientOptions(networkId) - updateOnboardingProfile({ network, clientOptions }) + switch (selectedNetworkType) { + case OnboardingNetworkType.Iota: + case OnboardingNetworkType.Shimmer: + { + const networkName = getNetworkNameFromOnboardingNetworkType(selectedNetworkType) + const networkId: StardustNetworkId = `${NetworkNamespace.Stardust}:${networkName}` + const network = getDefaultStardustNetwork(networkId) + const clientOptions = getDefaultClientOptions(networkId) + updateOnboardingProfile({ network, clientOptions }) + $networkSetupRouter.next() + } + break + case OnboardingNetworkType.IotaTestnet: + case OnboardingNetworkType.Testnet: + $networkSetupRouter.next({ type: 'testnet' }) + break + case OnboardingNetworkType.Custom: + $networkSetupRouter.next({ type: 'custom' }) + break } - $networkSetupRouter.next() } function getNetworkNameFromOnboardingNetworkType( @@ -55,6 +67,8 @@ return StardustNetworkName.Iota case OnboardingNetworkType.Shimmer: return StardustNetworkName.Shimmer + case OnboardingNetworkType.IotaTestnet: + return StardustNetworkName.IotaTestnet case OnboardingNetworkType.Testnet: return StardustNetworkName.Testnet case OnboardingNetworkType.Custom: @@ -96,8 +110,8 @@ )} icon={IconName.Iota} iconSize="md" - iconColor="#ffffff" - backgroundColor="#000000" + iconColor="iota" + backgroundColor="iota-background" hidden={features?.onboarding?.[OnboardingNetworkType.Iota]?.hidden} disabled={!features?.onboarding?.[OnboardingNetworkType.Iota]?.enabled} onClick={() => onNetworkClick(OnboardingNetworkType.Iota)} @@ -112,8 +126,8 @@ )} icon={IconName.Shimmer} iconSize="md" - iconColor="blue-900" - backgroundColor="shimmer" + iconColor="shimmer" + backgroundColor="shimmer-background" hidden={features?.onboarding?.[OnboardingNetworkType.Shimmer]?.hidden} disabled={!features?.onboarding?.[OnboardingNetworkType.Shimmer]?.enabled} onClick={() => onNetworkClick(OnboardingNetworkType.Shimmer)} diff --git a/packages/desktop/views/onboarding/views/network-setup/views/TestnetSelectionView.svelte b/packages/desktop/views/onboarding/views/network-setup/views/TestnetSelectionView.svelte new file mode 100644 index 0000000000..df58bf029b --- /dev/null +++ b/packages/desktop/views/onboarding/views/network-setup/views/TestnetSelectionView.svelte @@ -0,0 +1,111 @@ + + + +
+
+
diff --git a/packages/desktop/views/onboarding/views/network-setup/views/index.js b/packages/desktop/views/onboarding/views/network-setup/views/index.js index 883477729b..f165066715 100644 --- a/packages/desktop/views/onboarding/views/network-setup/views/index.js +++ b/packages/desktop/views/onboarding/views/network-setup/views/index.js @@ -1,2 +1,3 @@ export { default as ChooseNetworkView } from './ChooseNetworkView.svelte' export { default as CustomNetworkView } from './CustomNetworkView.svelte' +export { default as TestnetSelectionView } from './TestnetSelectionView.svelte' diff --git a/packages/shared/src/components/avatars/NetworkAvatar.svelte b/packages/shared/src/components/avatars/NetworkAvatar.svelte index 44c4831988..35230168a1 100644 --- a/packages/shared/src/components/avatars/NetworkAvatar.svelte +++ b/packages/shared/src/components/avatars/NetworkAvatar.svelte @@ -12,19 +12,23 @@ const AVATAR_BACKGROUND_COLOR: { [id in NetworkId]?: string } = { [SupportedNetworkId.Iota]: 'iota-background', [SupportedNetworkId.Shimmer]: 'shimmer-background', - [SupportedNetworkId.Testnet]: 'shimmer-background', + [SupportedNetworkId.Testnet]: 'text-secondary', + [SupportedNetworkId.IotaTestnet]: 'text-secondary', [SupportedNetworkId.IotaEvm]: 'iota-evm-background', [SupportedNetworkId.ShimmerEvm]: 'shimmer-evm-background', - [SupportedNetworkId.TestnetEvm]: 'shimmer-evm-background', + [SupportedNetworkId.IotaTestnetEvm]: 'iota-evm-background/90', + [SupportedNetworkId.TestnetEvm]: 'shimmer-evm-background/90', } const AVATAR_TEXT_COLOR: { [id in NetworkId]?: string } = { [SupportedNetworkId.Iota]: 'iota', [SupportedNetworkId.Shimmer]: 'shimmer', - [SupportedNetworkId.Testnet]: 'shimmer', + [SupportedNetworkId.IotaTestnet]: '#FFFFFF', + [SupportedNetworkId.Testnet]: '#FFFFFF', [SupportedNetworkId.IotaEvm]: 'iota-evm', [SupportedNetworkId.ShimmerEvm]: 'shimmer-evm', - [SupportedNetworkId.TestnetEvm]: 'shimmer-evm', + [SupportedNetworkId.IotaTestnetEvm]: '#FFFFFF', + [SupportedNetworkId.TestnetEvm]: '#FFFFFF', } let anchor: HTMLElement diff --git a/packages/shared/src/components/avatars/TokenAvatar.svelte b/packages/shared/src/components/avatars/TokenAvatar.svelte index 084371e337..e0b5f09d6c 100644 --- a/packages/shared/src/components/avatars/TokenAvatar.svelte +++ b/packages/shared/src/components/avatars/TokenAvatar.svelte @@ -20,8 +20,11 @@ [SupportedNetworkId.Shimmer]: { [BASE_TOKEN_ID]: 'shimmer-background', }, + [SupportedNetworkId.IotaTestnet]: { + [BASE_TOKEN_ID]: 'text-secondary', + }, [SupportedNetworkId.Testnet]: { - [BASE_TOKEN_ID]: 'shimmer-background', + [BASE_TOKEN_ID]: 'text-secondary', }, [SupportedNetworkId.IotaEvm]: { [BASE_TOKEN_ID]: 'iota-background', @@ -29,8 +32,11 @@ [SupportedNetworkId.ShimmerEvm]: { [BASE_TOKEN_ID]: 'shimmer-background', }, + [SupportedNetworkId.IotaTestnetEvm]: { + [BASE_TOKEN_ID]: 'text-secondary', + }, [SupportedNetworkId.TestnetEvm]: { - [BASE_TOKEN_ID]: 'shimmer-background', + [BASE_TOKEN_ID]: 'text-secondary', }, } @@ -41,8 +47,11 @@ [SupportedNetworkId.Shimmer]: { [BASE_TOKEN_ID]: 'shimmer', }, + [SupportedNetworkId.IotaTestnet]: { + [BASE_TOKEN_ID]: '#FFFFFF', + }, [SupportedNetworkId.Testnet]: { - [BASE_TOKEN_ID]: 'shimmer', + [BASE_TOKEN_ID]: '#FFFFFF', }, [SupportedNetworkId.IotaEvm]: { [BASE_TOKEN_ID]: 'iota', @@ -50,8 +59,11 @@ [SupportedNetworkId.ShimmerEvm]: { [BASE_TOKEN_ID]: 'shimmer', }, + [SupportedNetworkId.IotaTestnetEvm]: { + [BASE_TOKEN_ID]: '#FFFFFF', + }, [SupportedNetworkId.TestnetEvm]: { - [BASE_TOKEN_ID]: 'shimmer', + [BASE_TOKEN_ID]: '#FFFFFF', }, } diff --git a/packages/shared/src/components/organisms/NodeConfigurationForm.svelte b/packages/shared/src/components/organisms/NodeConfigurationForm.svelte index b42569c40d..48ecc49379 100644 --- a/packages/shared/src/components/organisms/NodeConfigurationForm.svelte +++ b/packages/shared/src/components/organisms/NodeConfigurationForm.svelte @@ -69,7 +69,11 @@ return Promise.reject({ type: 'validationError', error: formError }) } - const errorUrlValidity = checkNodeUrlValidity(currentClientOptions?.nodes, node.url, false) + const errorUrlValidity = checkNodeUrlValidity( + currentClientOptions?.nodes, + node.url, + $activeProfile?.features?.developer ?? false + ) if (errorUrlValidity) { formError = localize(errorUrlValidity) ?? '' return Promise.reject({ type: 'validationError', error: formError }) diff --git a/packages/shared/src/lib/auxiliary/icon/constants/default-network-icon.ts b/packages/shared/src/lib/auxiliary/icon/constants/default-network-icon.ts index f3fce1ede5..6faca58ddb 100644 --- a/packages/shared/src/lib/auxiliary/icon/constants/default-network-icon.ts +++ b/packages/shared/src/lib/auxiliary/icon/constants/default-network-icon.ts @@ -4,8 +4,10 @@ import { NetworkId, SupportedNetworkId } from '@core/network' export const DEFAULT_NETWORK_ICON: { [id in NetworkId]?: IconName } = { [SupportedNetworkId.Iota]: IconName.Iota, [SupportedNetworkId.Shimmer]: IconName.Shimmer, + [SupportedNetworkId.IotaTestnet]: IconName.Iota, [SupportedNetworkId.Testnet]: IconName.Shimmer, [SupportedNetworkId.IotaEvm]: IconName.Iota, [SupportedNetworkId.ShimmerEvm]: IconName.Shimmer, + [SupportedNetworkId.IotaTestnetEvm]: IconName.Iota, [SupportedNetworkId.TestnetEvm]: IconName.Shimmer, } diff --git a/packages/shared/src/lib/auxiliary/icon/constants/default-token-icon.ts b/packages/shared/src/lib/auxiliary/icon/constants/default-token-icon.ts index 36e1b0d718..8021d9eb27 100644 --- a/packages/shared/src/lib/auxiliary/icon/constants/default-token-icon.ts +++ b/packages/shared/src/lib/auxiliary/icon/constants/default-token-icon.ts @@ -9,6 +9,9 @@ export const DEFAULT_TOKEN_ICON: { [networkId in NetworkId]?: { [tokenId: string [SupportedNetworkId.Shimmer]: { [BASE_TOKEN_ID]: IconName.Shimmer, }, + [SupportedNetworkId.IotaTestnet]: { + [BASE_TOKEN_ID]: IconName.Iota, + }, [SupportedNetworkId.Testnet]: { [BASE_TOKEN_ID]: IconName.Shimmer, }, @@ -18,6 +21,9 @@ export const DEFAULT_TOKEN_ICON: { [networkId in NetworkId]?: { [tokenId: string [SupportedNetworkId.ShimmerEvm]: { [BASE_TOKEN_ID]: IconName.Shimmer, }, + [SupportedNetworkId.IotaTestnetEvm]: { + [BASE_TOKEN_ID]: IconName.Iota, + }, [SupportedNetworkId.TestnetEvm]: { [BASE_TOKEN_ID]: IconName.Shimmer, }, diff --git a/packages/shared/src/lib/contexts/onboarding/enums/onboarding-network-type.enum.ts b/packages/shared/src/lib/contexts/onboarding/enums/onboarding-network-type.enum.ts index 1707bd5626..e6ace5c5da 100644 --- a/packages/shared/src/lib/contexts/onboarding/enums/onboarding-network-type.enum.ts +++ b/packages/shared/src/lib/contexts/onboarding/enums/onboarding-network-type.enum.ts @@ -1,6 +1,7 @@ export enum OnboardingNetworkType { Iota = 'iota', Shimmer = 'shimmer', + IotaTestnet = 'iotaTestnet', Testnet = 'testnet', Custom = 'custom', } diff --git a/packages/shared/src/lib/core/market/apis/coingecko.api.ts b/packages/shared/src/lib/core/market/apis/coingecko.api.ts index c85a54b03b..172deb11a8 100644 --- a/packages/shared/src/lib/core/market/apis/coingecko.api.ts +++ b/packages/shared/src/lib/core/market/apis/coingecko.api.ts @@ -9,7 +9,7 @@ export class CoinGeckoApi { static async makeRequest(endpoint: string, query?: QueryParameters): Promise { try { const url = buildUrl({ - origin: MARKET_API_BASE_URL, + base: MARKET_API_BASE_URL, pathname: `api/v3/${endpoint}`, query, }) diff --git a/packages/shared/src/lib/core/network/apis/explorer.api.ts b/packages/shared/src/lib/core/network/apis/explorer.api.ts index d1ac5378f2..1abe0060a0 100644 --- a/packages/shared/src/lib/core/network/apis/explorer.api.ts +++ b/packages/shared/src/lib/core/network/apis/explorer.api.ts @@ -1,18 +1,24 @@ -import { DEFAULT_APPLICATION_JSON_REQUEST_OPTIONS } from '@core/utils' -import {} from '../enums' +import { DEFAULT_APPLICATION_JSON_REQUEST_OPTIONS } from '@core/utils/constants' +import { buildUrl } from '@core/utils/url' +import { SupportedNetworkId } from '../constants' import { DEFAULT_EXPLORER_API_BASE_URL } from '../constants/default-explorer-api-base-url.constant' import { ExplorerApiEndpoint } from '../enums' -import { IExplorerApiNetworks } from '../interfaces' -import { getExplorerApiNetworkName } from '../utils' -import { NetworkId } from '../types' +import { IExplorerApiNetwork, IExplorerApiNetworks } from '../interfaces' +import type { NetworkId } from '../types' export class ExplorerApi { - static async makeRequest(endpoint: ExplorerApiEndpoint, queryParams?: string): Promise { + static async makeRequest(endpoint: ExplorerApiEndpoint): Promise { try { - const response = await fetch( - `${DEFAULT_EXPLORER_API_BASE_URL}${endpoint}?${queryParams ?? ''}`, - DEFAULT_APPLICATION_JSON_REQUEST_OPTIONS - ) + const requestUrl = buildUrl({ + base: DEFAULT_EXPLORER_API_BASE_URL, + pathname: endpoint, + }) + + if (!requestUrl) { + throw new Error('Invalid request URL') + } + + const response = await fetch(requestUrl.href, DEFAULT_APPLICATION_JSON_REQUEST_OPTIONS) const data = await response.json() return data } catch (err) { @@ -21,10 +27,19 @@ export class ExplorerApi { } } + static async getNetworkInfo(networkId: NetworkId): Promise { + const ExplorerNetworkId = { + [SupportedNetworkId.Iota]: 'mainnet', + [SupportedNetworkId.Shimmer]: 'shimmer', + [SupportedNetworkId.IotaTestnet]: 'iota-testnet', + [SupportedNetworkId.Testnet]: 'shimmer-testnet', + } + const networksInfo = await ExplorerApi.makeRequest(ExplorerApiEndpoint.Networks) + const networkInfo = networksInfo?.networks.find((network) => network.network === ExplorerNetworkId[networkId]) + return networkInfo + } + static async getCirculatingSupply(networkId: NetworkId): Promise { - const networkName = getExplorerApiNetworkName(networkId) - const networksInfo = await this.makeRequest(ExplorerApiEndpoint.Networks, networkId) - const networkInfo = networksInfo?.networks.find((network) => network.network === networkName) - return networkInfo?.circulatingSupply ?? 0 + return (await ExplorerApi.getNetworkInfo(networkId))?.circulatingSupply ?? 0 } } diff --git a/packages/shared/src/lib/core/network/constants/default-base-token.constant.ts b/packages/shared/src/lib/core/network/constants/default-base-token.constant.ts index bd3eba72f9..a75a41fbe1 100644 --- a/packages/shared/src/lib/core/network/constants/default-base-token.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-base-token.constant.ts @@ -31,6 +31,20 @@ export const SHIMMER_EVM_BASE_TOKEN: IBaseToken = { decimals: 18, } +const IOTA_TESTNET_BASE_TOKEN: IBaseToken = { + standard: TokenStandard.BaseToken, + name: 'Test Token', + tickerSymbol: 'TST', + unit: 'TST', + decimals: 6, + subunit: 'testies', +} + +export const IOTA_TESTNET_EVM_BASE_TOKEN: IBaseToken = { + ...IOTA_TESTNET_BASE_TOKEN, + decimals: 18, +} + export const EVM_BASE_TOKEN: IBaseToken = { standard: TokenStandard.BaseToken, name: 'Ether', @@ -42,9 +56,11 @@ export const EVM_BASE_TOKEN: IBaseToken = { export const DEFAULT_BASE_TOKEN: Readonly<{ [id in NetworkId]: IBaseToken }> = { [SupportedNetworkId.Iota]: IOTA_BASE_TOKEN, [SupportedNetworkId.Shimmer]: SHIMMER_BASE_TOKEN, + [SupportedNetworkId.IotaTestnet]: IOTA_TESTNET_BASE_TOKEN, [SupportedNetworkId.Testnet]: SHIMMER_BASE_TOKEN, [SupportedNetworkId.IotaEvm]: IOTA_EVM_BASE_TOKEN, [SupportedNetworkId.ShimmerEvm]: SHIMMER_EVM_BASE_TOKEN, + [SupportedNetworkId.IotaTestnetEvm]: IOTA_TESTNET_EVM_BASE_TOKEN, [SupportedNetworkId.TestnetEvm]: SHIMMER_EVM_BASE_TOKEN, [SupportedNetworkId.Ethereum]: EVM_BASE_TOKEN, [SupportedNetworkId.Sepolia]: EVM_BASE_TOKEN, diff --git a/packages/shared/src/lib/core/network/constants/default-bech32-hrp.constant.ts b/packages/shared/src/lib/core/network/constants/default-bech32-hrp.constant.ts index a122bf8885..2c0b5158fa 100644 --- a/packages/shared/src/lib/core/network/constants/default-bech32-hrp.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-bech32-hrp.constant.ts @@ -3,6 +3,7 @@ import { SupportedNetworkId } from './supported-network-id.constant' export const IOTA_BECH32_HRP = 'iota' export const SHIMMER_BECH32_HRP = 'smr' +export const IOTA_TESTNET_BECH32_HRP = 'tst' export const TESTNET_BECH32_HRP = 'rms' export const DEFAULT_BECH32_HRP: Readonly<{ [id in StardustNetworkId]?: string }> = { diff --git a/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts b/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts index 4e99839e71..dc817746d4 100644 --- a/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-coin-type.constant.ts @@ -9,9 +9,11 @@ export const ETHEREUM_COIN_TYPE = 60 export const DEFAULT_COIN_TYPE: Readonly<{ [key in NetworkId]: number }> = { [SupportedNetworkId.Iota]: IOTA_COIN_TYPE, [SupportedNetworkId.Shimmer]: SHIMMER_COIN_TYPE, + [SupportedNetworkId.IotaTestnet]: TEST_COIN_TYPE, [SupportedNetworkId.Testnet]: TEST_COIN_TYPE, [SupportedNetworkId.IotaEvm]: ETHEREUM_COIN_TYPE, [SupportedNetworkId.ShimmerEvm]: ETHEREUM_COIN_TYPE, + [SupportedNetworkId.IotaTestnetEvm]: ETHEREUM_COIN_TYPE, [SupportedNetworkId.TestnetEvm]: ETHEREUM_COIN_TYPE, [SupportedNetworkId.Ethereum]: ETHEREUM_COIN_TYPE, [SupportedNetworkId.Sepolia]: ETHEREUM_COIN_TYPE, diff --git a/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts b/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts index 80089e9471..2e0bb24349 100644 --- a/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-explorer-urls.constant.ts @@ -2,12 +2,14 @@ import { NetworkId } from '../types' import { SupportedNetworkId } from './supported-network-id.constant' export const DEFAULT_EXPLORER_URLS: Readonly<{ [key in NetworkId]?: string }> = { - [SupportedNetworkId.Iota]: 'https://explorer.iota.org', - [SupportedNetworkId.Shimmer]: 'https://explorer.shimmer.network', - [SupportedNetworkId.Testnet]: 'https://explorer.shimmer.network', + [SupportedNetworkId.Iota]: 'https://explorer.iota.org/mainnet/', + [SupportedNetworkId.Shimmer]: 'https://explorer.shimmer.network/shimmer/', + [SupportedNetworkId.IotaTestnet]: 'https://explorer.iota.org/iota-testnet/', + [SupportedNetworkId.Testnet]: 'https://explorer.shimmer.network/testnet/', [SupportedNetworkId.IotaEvm]: 'https://explorer.evm.iota.org', - [SupportedNetworkId.Ethereum]: 'https://eth.blockscout.com', [SupportedNetworkId.ShimmerEvm]: 'https://explorer.evm.shimmer.network', + [SupportedNetworkId.IotaTestnetEvm]: 'https://explorer.evm.testnet.iota.org', [SupportedNetworkId.TestnetEvm]: 'https://explorer.evm.testnet.shimmer.network', + [SupportedNetworkId.Ethereum]: 'https://eth.blockscout.com', [SupportedNetworkId.Sepolia]: 'https://eth-sepolia.blockscout.com', } diff --git a/packages/shared/src/lib/core/network/constants/default-isc-chains-configurations.constant.ts b/packages/shared/src/lib/core/network/constants/default-isc-chains-configurations.constant.ts index be69e5248f..206f3dd5fc 100644 --- a/packages/shared/src/lib/core/network/constants/default-isc-chains-configurations.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-isc-chains-configurations.constant.ts @@ -3,6 +3,7 @@ import { IIscChainConfiguration } from '../interfaces' import { StardustNetworkId } from '../types' import { DEFAULT_BASE_TOKEN } from './default-base-token.constant' import { DEFAULT_COIN_TYPE } from './default-coin-type.constant' +import { DEFAULT_EXPLORER_URLS } from './default-explorer-urls.constant' import { SupportedIscNetworkId, SupportedNetworkId, SupportedStardustNetworkId } from './supported-network-id.constant' import { isFeatureEnabled } from '@lib/features/utils' @@ -38,11 +39,25 @@ const SHIMMER_EVM_CHAIN_CONFIGURATION: IIscChainConfiguration = { explorerUrl: 'https://explorer.evm.shimmer.network/', } +const IOTA_TESTNET_EVM_CHAIN_CONFIGURATION: IIscChainConfiguration = { + id: SupportedIscNetworkId.IotaTestnetEvm, + type: NetworkType.Isc, + name: 'IOTA Testnet EVM', + chainId: ChainId.IotaTestnetEvm, + namespace: NetworkNamespace.Evm, + baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.IotaTestnetEvm], + coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.IotaTestnetEvm] ?? 0, + aliasAddress: 'tst1pzxsrr7apqkdzz633dyntmvxwtyvk029p39te5j0m33q6946h7akzv663zu', + rpcEndpoint: 'https://json-rpc.evm.testnet.iotaledger.net/', + apiEndpoint: 'https://api.evm.testnet.iotaledger.net/', + explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.IotaTestnetEvm], +} + // exported as used in tests export const TESTNET_EVM_CHAIN_CONFIGURATION: IIscChainConfiguration = { id: SupportedIscNetworkId.TestnetEvm, type: NetworkType.Isc, - name: 'Testnet EVM', + name: 'Shimmer Testnet EVM', chainId: ChainId.TestnetEvm, namespace: NetworkNamespace.Evm, baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.TestnetEvm], @@ -60,6 +75,9 @@ export const DEFAULT_ISC_CHAINS_CONFIGURATIONS: Readonly<{ [id in StardustNetwor ...(isFeatureEnabled('onboarding.shimmer.defaultIscChains') && { [SupportedStardustNetworkId.Shimmer]: SHIMMER_EVM_CHAIN_CONFIGURATION, }), + ...(isFeatureEnabled('onboarding.iotaTestnet.defaultIscChains') && { + [SupportedStardustNetworkId.IotaTestnet]: IOTA_TESTNET_EVM_CHAIN_CONFIGURATION, + }), ...(isFeatureEnabled('onboarding.testnet.defaultIscChains') && { [SupportedStardustNetworkId.Testnet]: TESTNET_EVM_CHAIN_CONFIGURATION, }), diff --git a/packages/shared/src/lib/core/network/constants/default-network-metadata.constant.ts b/packages/shared/src/lib/core/network/constants/default-network-metadata.constant.ts index d61574abe6..61f1927e2f 100644 --- a/packages/shared/src/lib/core/network/constants/default-network-metadata.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-network-metadata.constant.ts @@ -27,9 +27,18 @@ export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in StardustNetworkId]?: N baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.Shimmer], explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.Shimmer], }, + [SupportedNetworkId.IotaTestnet]: { + id: SupportedNetworkId.IotaTestnet, + name: 'IOTA Testnet', + namespace: NetworkNamespace.Stardust, + coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.IotaTestnet], + protocol: DEFAULT_PROTOCOL[SupportedNetworkId.IotaTestnet], + baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.IotaTestnet], + explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.IotaTestnet], + }, [SupportedNetworkId.Testnet]: { id: SupportedNetworkId.Testnet, - name: 'Testnet', + name: 'Shimmer Testnet', namespace: NetworkNamespace.Stardust, coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.Testnet], protocol: DEFAULT_PROTOCOL[SupportedNetworkId.Testnet], diff --git a/packages/shared/src/lib/core/network/constants/default-node-urls.constant.ts b/packages/shared/src/lib/core/network/constants/default-node-urls.constant.ts index 9cffeaa2ec..4ae6014944 100644 --- a/packages/shared/src/lib/core/network/constants/default-node-urls.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-node-urls.constant.ts @@ -4,5 +4,6 @@ import { SupportedNetworkId } from './supported-network-id.constant' export const DEFAULT_NODE_URLS: Readonly<{ [id in StardustNetworkId]?: string[] }> = { [SupportedNetworkId.Iota]: ['https://api.stardust-mainnet.iotaledger.net', 'https://iota-node.tanglebay.com'], [SupportedNetworkId.Shimmer]: ['https://api.shimmer.network', 'https://shimmer-node.tanglebay.com'], + [SupportedNetworkId.IotaTestnet]: ['https://api.testnet.iotaledger.net'], [SupportedNetworkId.Testnet]: ['https://api.testnet.shimmer.network'], } diff --git a/packages/shared/src/lib/core/network/constants/default-protocol.constant.ts b/packages/shared/src/lib/core/network/constants/default-protocol.constant.ts index 3ea18c3330..e3bd50f44b 100644 --- a/packages/shared/src/lib/core/network/constants/default-protocol.constant.ts +++ b/packages/shared/src/lib/core/network/constants/default-protocol.constant.ts @@ -32,6 +32,20 @@ const DEFAULT_SHIMMER_PROTOCOL: IProtocol = { tokenSupply: TokenSupply.Shimmer, } +const DEFAULT_IOTA_TESTNET_PROTOCOL: IProtocol = { + version: 2, + networkName: StardustNetworkName.IotaTestnet, + bech32Hrp: DEFAULT_BECH32_HRP[SupportedNetworkId.IotaTestnet] ?? '', + minPowScore: 1500, + belowMaxDepth: 15, + rentStructure: { + vByteCost: 250, + vByteFactorData: 1, + vByteFactorKey: 10, + }, + tokenSupply: TokenSupply.Iota, +} + const DEFAULT_TESTNET_PROTOCOL: IProtocol = { version: 2, networkName: StardustNetworkName.Testnet, @@ -49,5 +63,6 @@ const DEFAULT_TESTNET_PROTOCOL: IProtocol = { export const DEFAULT_PROTOCOL: Readonly<{ [id in StardustNetworkId]?: IProtocol }> = { [SupportedNetworkId.Iota]: DEFAULT_IOTA_PROTOCOL, [SupportedNetworkId.Shimmer]: DEFAULT_SHIMMER_PROTOCOL, + [SupportedNetworkId.IotaTestnet]: DEFAULT_IOTA_TESTNET_PROTOCOL, [SupportedNetworkId.Testnet]: DEFAULT_TESTNET_PROTOCOL, } diff --git a/packages/shared/src/lib/core/network/constants/faucet-urls.constant.ts b/packages/shared/src/lib/core/network/constants/faucet-urls.constant.ts index 13c7bb4979..6607ed7059 100644 --- a/packages/shared/src/lib/core/network/constants/faucet-urls.constant.ts +++ b/packages/shared/src/lib/core/network/constants/faucet-urls.constant.ts @@ -2,5 +2,6 @@ import { StardustNetworkId } from '../types' import { SupportedNetworkId } from './supported-network-id.constant' export const FAUCET_URLS: Readonly<{ [id in StardustNetworkId]?: string }> = { + [SupportedNetworkId.IotaTestnet]: 'https://faucet.testnet.iotaledger.net/api/enqueue', [SupportedNetworkId.Testnet]: 'https://faucet.testnet.shimmer.network/api/enqueue', } diff --git a/packages/shared/src/lib/core/network/constants/supported-network-id.constant.ts b/packages/shared/src/lib/core/network/constants/supported-network-id.constant.ts index 60f69f58df..5503ead686 100644 --- a/packages/shared/src/lib/core/network/constants/supported-network-id.constant.ts +++ b/packages/shared/src/lib/core/network/constants/supported-network-id.constant.ts @@ -1,4 +1,4 @@ -import { EvmNetworkId, StardustNetworkId } from '../types' +import type { EvmNetworkId, StardustNetworkId } from '../types/network-id.type' import { ChainId } from '../enums/chain-id.enum' import { NetworkNamespace } from '../enums/network-namespace.enum' import { StardustNetworkName } from '../enums/stardust-network-name.enum' @@ -7,6 +7,7 @@ export const SupportedStardustNetworkId: Record = { Iota: `${NetworkNamespace.Stardust}:${StardustNetworkName.Iota}`, Shimmer: `${NetworkNamespace.Stardust}:${StardustNetworkName.Shimmer}`, Testnet: `${NetworkNamespace.Stardust}:${StardustNetworkName.Testnet}`, + IotaTestnet: `${NetworkNamespace.Stardust}:${StardustNetworkName.IotaTestnet}`, } export const SupportedL1EvmNetworkId: Record = { @@ -18,6 +19,7 @@ export const SupportedIscNetworkId: Record = { IotaEvm: `${NetworkNamespace.Evm}:${ChainId.IotaEvm}`, ShimmerEvm: `${NetworkNamespace.Evm}:${ChainId.ShimmerEvm}`, TestnetEvm: `${NetworkNamespace.Evm}:${ChainId.TestnetEvm}`, + IotaTestnetEvm: `${NetworkNamespace.Evm}:${ChainId.IotaTestnetEvm}`, } export const SupportedNetworkId = { diff --git a/packages/shared/src/lib/core/network/enums/chain-id.enum.ts b/packages/shared/src/lib/core/network/enums/chain-id.enum.ts index 9ba80d7efa..65b05db509 100644 --- a/packages/shared/src/lib/core/network/enums/chain-id.enum.ts +++ b/packages/shared/src/lib/core/network/enums/chain-id.enum.ts @@ -1,7 +1,8 @@ export enum ChainId { IotaEvm = '8822', - Ethereum = '1', ShimmerEvm = '148', - TestnetEvm = '1073', + IotaTestnetEvm = '1073', + TestnetEvm = '1075', + Ethereum = '1', Sepolia = '11155111', } diff --git a/packages/shared/src/lib/core/network/enums/stardust-network-name.enum.ts b/packages/shared/src/lib/core/network/enums/stardust-network-name.enum.ts index 8c26268d2c..19f4b7d6ae 100644 --- a/packages/shared/src/lib/core/network/enums/stardust-network-name.enum.ts +++ b/packages/shared/src/lib/core/network/enums/stardust-network-name.enum.ts @@ -2,4 +2,5 @@ export enum StardustNetworkName { Iota = 'iota-mainnet', Shimmer = 'shimmer', Testnet = 'testnet-2', + IotaTestnet = 'testnet', } diff --git a/packages/shared/src/lib/core/network/tests/network.test.ts b/packages/shared/src/lib/core/network/tests/network.test.ts index 900d64b992..fe673e03e8 100644 --- a/packages/shared/src/lib/core/network/tests/network.test.ts +++ b/packages/shared/src/lib/core/network/tests/network.test.ts @@ -23,6 +23,7 @@ describe('File: network.ts', () => { const EXPECTED_NODE_URLS: Readonly<{ [key in StardustNetworkId]?: string[] }> = { [SupportedNetworkId.Iota]: ['https://api.stardust-mainnet.iotaledger.net', 'https://iota-node.tanglebay.com'], [SupportedNetworkId.Shimmer]: ['https://api.shimmer.network', 'https://shimmer-node.tanglebay.com'], + [SupportedNetworkId.IotaTestnet]: ['https://api.testnet.iotaledger.net'], [SupportedNetworkId.Testnet]: ['https://api.testnet.shimmer.network'], } diff --git a/packages/shared/src/lib/core/network/utils/getExplorerApiNetworkName.ts b/packages/shared/src/lib/core/network/utils/getExplorerApiNetworkName.ts deleted file mode 100644 index 0e56fa9cb1..0000000000 --- a/packages/shared/src/lib/core/network/utils/getExplorerApiNetworkName.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { SupportedStardustNetworkId } from '../constants' -import { NetworkId } from '../types' - -export function getExplorerApiNetworkName(networkId: NetworkId): string { - switch (networkId) { - case SupportedStardustNetworkId.Iota: - return 'mainnet' - case SupportedStardustNetworkId.Shimmer: - return 'shimmer' - case SupportedStardustNetworkId.Testnet: - return 'testnet' - default: - return '' - } -} diff --git a/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts b/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts index 6d538993a2..e6ddaf8251 100644 --- a/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts +++ b/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts @@ -1,6 +1,5 @@ import { ExplorerEndpoint } from '../enums' import { NetworkId } from '../types' -import { getExplorerApiNetworkName } from './getExplorerApiNetworkName' import { isStardustNetwork } from './isStardustNetwork' import { isEvmNetwork } from './isEvmNetwork' @@ -20,7 +19,7 @@ const EVM_EXPLORER_ENDPOINTS: Readonly<{ [key in ExplorerEndpoint]?: string }> = export function getExplorerEndpoint(networkId: NetworkId, explorerEndpoint: ExplorerEndpoint): string | undefined { if (isStardustNetwork(networkId)) { - return `${getExplorerApiNetworkName(networkId)}/${STARDUST_EXPLORER_ENDPOINTS[explorerEndpoint]}` + return STARDUST_EXPLORER_ENDPOINTS[explorerEndpoint] } else if (isEvmNetwork(networkId)) { return EVM_EXPLORER_ENDPOINTS[explorerEndpoint] } diff --git a/packages/shared/src/lib/core/network/utils/getExplorerUrl.ts b/packages/shared/src/lib/core/network/utils/getExplorerUrl.ts index a8dba19500..d866c1cbb2 100644 --- a/packages/shared/src/lib/core/network/utils/getExplorerUrl.ts +++ b/packages/shared/src/lib/core/network/utils/getExplorerUrl.ts @@ -12,6 +12,6 @@ export function getExplorerUrl( const baseUrl = getNetwork(networkId)?.explorerUrl ?? '' const endpoint = getExplorerEndpoint(networkId, requestedEndpoint) ?? '' - const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}${pathParameter ? '/' + pathParameter : ''}` }) + const url = buildUrl({ base: baseUrl, pathname: `${endpoint}${pathParameter ? '/' + pathParameter : ''}` }) return url?.href } diff --git a/packages/shared/src/lib/core/network/utils/index.ts b/packages/shared/src/lib/core/network/utils/index.ts index 20ebbb806e..215202d625 100644 --- a/packages/shared/src/lib/core/network/utils/index.ts +++ b/packages/shared/src/lib/core/network/utils/index.ts @@ -10,7 +10,6 @@ export * from './getDefaultStardustNetwork' export * from './getEvmTransactionOptions' export * from './getExplorerEndpoint' export * from './getExplorerUrl' -export * from './getExplorerApiNetworkName' export * from './getNetworkIdFromOnboardingNetworkType' export * from './getOnboardingNetworkTypeFromNetworkId' export * from './getSplitNetworkId' diff --git a/packages/shared/src/lib/core/router/classes/router.class.ts b/packages/shared/src/lib/core/router/classes/router.class.ts index b15ec87813..c791d4c679 100644 --- a/packages/shared/src/lib/core/router/classes/router.class.ts +++ b/packages/shared/src/lib/core/router/classes/router.class.ts @@ -1,6 +1,6 @@ import { get, Writable } from 'svelte/store' -import { IRouter, IRouterEvent } from '../interfaces' +import { IRouter } from '../interfaces' export abstract class Router implements IRouter { protected history: R[] = [] @@ -35,9 +35,9 @@ export abstract class Router implements IRouter { } // This function should be implemented in the child router - next(event?: IRouterEvent): void { + next(params?: Record): void { throw Error(`Unimplemented state machine within custom router!\n - Called with event: ${JSON.stringify(event)}`) + Called with event: ${JSON.stringify(params)}`) } previous(): void { diff --git a/packages/shared/src/lib/core/router/interfaces/index.ts b/packages/shared/src/lib/core/router/interfaces/index.ts index 5d16bfea85..e9ef49e0dc 100644 --- a/packages/shared/src/lib/core/router/interfaces/index.ts +++ b/packages/shared/src/lib/core/router/interfaces/index.ts @@ -1,4 +1,3 @@ export * from './router.interface' -export * from './router-event.interface' export * from './router-manager.interface' export * from './router-manager-options.interface' diff --git a/packages/shared/src/lib/core/router/interfaces/router-event.interface.ts b/packages/shared/src/lib/core/router/interfaces/router-event.interface.ts deleted file mode 100644 index 3539c3c657..0000000000 --- a/packages/shared/src/lib/core/router/interfaces/router-event.interface.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface IRouterEvent { - reset?: boolean - shouldAddProfile?: boolean - thirdPartyProfilesImported?: boolean -} diff --git a/packages/shared/src/lib/core/router/interfaces/router.interface.ts b/packages/shared/src/lib/core/router/interfaces/router.interface.ts index 3db3b416da..2b66123787 100644 --- a/packages/shared/src/lib/core/router/interfaces/router.interface.ts +++ b/packages/shared/src/lib/core/router/interfaces/router.interface.ts @@ -1,7 +1,5 @@ -import { IRouterEvent } from './router-event.interface' - export interface IRouter { - next(event?: IRouterEvent): void + next(params?: Record): void previous(): void reset?(): void diff --git a/packages/shared/src/lib/core/router/routers/app-router.ts b/packages/shared/src/lib/core/router/routers/app-router.ts index d60db086e3..e0624664b1 100644 --- a/packages/shared/src/lib/core/router/routers/app-router.ts +++ b/packages/shared/src/lib/core/router/routers/app-router.ts @@ -4,7 +4,6 @@ import { profiles } from '@core/profile/stores' import { Router } from '../classes' import { AppRoute, LoginRoute } from '../enums' -import { IRouterEvent } from '../interfaces' import { loginRoute } from '../subrouters' export const appRoute = writable(undefined) @@ -25,13 +24,11 @@ export class AppRouter extends Router { this.init() } - public next(event?: IRouterEvent): void { - const params = event || {} - + public next(params?: { shouldAddProfile?: boolean; reset?: boolean; thirdPartyProfilesImported?: boolean }): void { const currentRoute = get(this.routeStore) switch (currentRoute) { case AppRoute.Login: { - if (params.shouldAddProfile) { + if (params?.shouldAddProfile) { this.setNext(AppRoute.Onboarding) } else { this.setNext(AppRoute.Dashboard) @@ -39,17 +36,17 @@ export class AppRouter extends Router { break } case AppRoute.Dashboard: { - if (params.reset) { + if (params?.reset) { this.setNext(AppRoute.Login) } break } case AppRoute.Onboarding: { - if (params.shouldAddProfile) { + if (params?.shouldAddProfile) { this.setNext(AppRoute.Onboarding) } else { loginRoute.set( - params.thirdPartyProfilesImported ? LoginRoute.SelectProfile : LoginRoute.LoadProfile + params?.thirdPartyProfilesImported ? LoginRoute.SelectProfile : LoginRoute.LoadProfile ) this.setNext(AppRoute.Login) } diff --git a/packages/shared/src/lib/core/router/subrouters/login-router.ts b/packages/shared/src/lib/core/router/subrouters/login-router.ts index 17bfbe9fd2..380b93f61e 100644 --- a/packages/shared/src/lib/core/router/subrouters/login-router.ts +++ b/packages/shared/src/lib/core/router/subrouters/login-router.ts @@ -9,7 +9,6 @@ import { } from '../../../../../../desktop/views/update-stronghold/update-stronghold-router' import { Subrouter } from '../classes' import { LoginRoute } from '../enums' -import { IRouterEvent } from '../interfaces' import { appRouter } from '../routers' export const loginRoute = writable(undefined) @@ -20,7 +19,7 @@ export class LoginRouter extends Subrouter { super(LoginRoute.SelectProfile, loginRoute, get(appRouter)) } - next(event?: IRouterEvent): void { + next(params?: Record): void { const currentRoute = get(this.routeStore) const requiresUpdate = @@ -31,8 +30,8 @@ export class LoginRouter extends Subrouter { switch (currentRoute) { case LoginRoute.SelectProfile: { - if (event?.shouldAddProfile) { - this.parentRouter?.next(event) + if (params?.shouldAddProfile) { + this.parentRouter?.next(params) return } else { this.setNext(LoginRoute.EnterPin) @@ -51,7 +50,7 @@ export class LoginRouter extends Subrouter { this.setNext(LoginRoute.LoadProfile) break case LoginRoute.LoadProfile: - this.parentRouter?.next(event) + this.parentRouter?.next(params) return } } diff --git a/packages/shared/src/lib/core/utils/api.ts b/packages/shared/src/lib/core/utils/api.ts index f8cd749d3c..b1d214f18e 100644 --- a/packages/shared/src/lib/core/utils/api.ts +++ b/packages/shared/src/lib/core/utils/api.ts @@ -50,7 +50,7 @@ export class BaseApi { } const url = buildUrl({ - origin: this._baseUrl, + base: this._baseUrl, pathname: `${this._basePath ? this._basePath + '/' : ''}${path}`, query: queryParameters, }) diff --git a/packages/shared/src/lib/core/utils/string.ts b/packages/shared/src/lib/core/utils/string.ts index 4a1bbbd34a..5f046583a2 100644 --- a/packages/shared/src/lib/core/utils/string.ts +++ b/packages/shared/src/lib/core/utils/string.ts @@ -15,6 +15,10 @@ export function stripTrailingSlash(str: string): string { return str ? str.replace(/\/+$/, '') : '' } +export function addTrailingSlash(str: string): string { + return stripTrailingSlash(str) + '/' +} + /** * Strip spaces from the text * @param str The text to strip the values from diff --git a/packages/shared/src/lib/core/utils/url.ts b/packages/shared/src/lib/core/utils/url.ts index db670eac24..05c1961bfd 100644 --- a/packages/shared/src/lib/core/utils/url.ts +++ b/packages/shared/src/lib/core/utils/url.ts @@ -1,4 +1,4 @@ -import { stripSpaces, stripTrailingSlash } from './string' +import { addTrailingSlash, stripSpaces, stripTrailingSlash } from './string' import { QueryParameters } from './types' export function cleanUrl( @@ -25,14 +25,15 @@ export function cleanUrl( } type UrlParams = { - origin: string + base: string pathname?: string query?: QueryParameters } export function buildUrl(urlParams: UrlParams): URL | undefined { try { - const url = new URL(urlParams.pathname ?? '', urlParams.origin) + // URL parser requires a slash at the end of the base URL to parse the URL correctly + const url = new URL(urlParams.pathname ?? '', addTrailingSlash(urlParams.base)) for (const key of Object.keys(urlParams.query ?? {})) { const value = urlParams.query?.[key] if (!value) continue diff --git a/packages/shared/src/locales/en.json b/packages/shared/src/locales/en.json index 739362b321..efecc6e730 100644 --- a/packages/shared/src/locales/en.json +++ b/packages/shared/src/locales/en.json @@ -54,6 +54,17 @@ "secondary": "Connect to any network with custom settings" } }, + "testnetSelection": { + "title": "Select your testnet", + "iotaTestnet": { + "primary": "IOTA Testnet", + "secondary": "Test network using valueless TST tokens" + }, + "testnet": { + "primary": "Shimmer Testnet", + "secondary": "Test network using valueless RMS tokens" + } + }, "setupCustomNetwork": { "title": "Advanced configuration" }