diff --git a/packages/desktop/components/ContactAddressCard.svelte b/packages/desktop/components/ContactAddressCard.svelte
index 7c3cda58fc..19ad9e6a34 100644
--- a/packages/desktop/components/ContactAddressCard.svelte
+++ b/packages/desktop/components/ContactAddressCard.svelte
@@ -3,9 +3,9 @@
import { IContact, IContactAddress, IContactAddressMap, setSelectedContactNetworkAddress } from '@core/contact'
import { localize } from '@core/i18n'
import { resetLedgerPreparedOutput, resetShowInternalVerificationPopup } from '@core/ledger'
- import { ExplorerEndpoint, getDefaultExplorerUrl, getNameFromNetworkId, NetworkId } from '@core/network'
+ import { ExplorerEndpoint, getExplorerUrl, getNameFromNetworkId, getNetwork, NetworkId } from '@core/network'
import { Router } from '@core/router'
- import { buildUrl, truncateString } from '@core/utils'
+ import { truncateString } from '@core/utils'
import { SendFlowType, setSendFlowParameters, SubjectType } from '@core/wallet'
import { closeDrawer } from '@desktop/auxiliary/drawer'
import { openPopup, PopupId } from '@desktop/auxiliary/popup'
@@ -21,11 +21,11 @@
export let contact: IContact
export let contactAddressMap: IContactAddressMap
- const explorer = getDefaultExplorerUrl(networkId, ExplorerEndpoint.Address)
+ const hasExplorer = !!getNetwork(networkId)?.explorerUrl
function onExplorerClick(address: string): void {
- const url = buildUrl({ origin: explorer.baseUrl, pathname: `${explorer.endpoint}/${address}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(networkId, ExplorerEndpoint.Address, address)
+ openUrlInBrowser(url)
}
function onQrCodeClick(contactAddress: IContactAddress): void {
@@ -72,7 +72,7 @@
- {#if explorer.baseUrl}
+ {#if hasExplorer}
- {#if explorer?.baseUrl && address}
+ {#if network.explorerUrl && address}
diff --git a/packages/desktop/components/popup/popups/StardustActivityDetailsPopup.svelte b/packages/desktop/components/popup/popups/StardustActivityDetailsPopup.svelte
index 37bc5c7a5e..6645c1db70 100644
--- a/packages/desktop/components/popup/popups/StardustActivityDetailsPopup.svelte
+++ b/packages/desktop/components/popup/popups/StardustActivityDetailsPopup.svelte
@@ -12,10 +12,10 @@
import { openUrlInBrowser } from '@core/app'
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network'
- import { getDefaultExplorerUrl } from '@core/network/utils'
+ import { getExplorerUrl } from '@core/network/utils'
import { getNftByIdForAccount, ownedNfts, selectedNftId } from '@core/nfts/stores'
import { CollectiblesRoute, DashboardRoute, collectiblesRouter, dashboardRouter } from '@core/router'
- import { buildUrl, setClipboard, truncateString } from '@core/utils'
+ import { setClipboard, truncateString } from '@core/utils'
import { claimActivity, rejectActivity } from '@core/wallet'
import { PopupId, closePopup, openPopup } from '@desktop/auxiliary/popup'
import { StardustActivityInformation, TransactionAssetSection } from '@ui'
@@ -45,16 +45,12 @@
}
}
- $: explorerUrl = getExplorerUrl(activity)
- function getExplorerUrl(_activity: StardustActivity): string | undefined {
+ $: explorerUrl = buildExplorerUrl(activity)
+ function buildExplorerUrl(_activity: StardustActivity): string | undefined {
if (activity?.direction === ActivityDirection.Genesis) {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Output)
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${_activity?.outputId}` })
- return url?.href
+ return getExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Output, _activity?.outputId)
} else {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Transaction)
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${_activity?.transactionId}` })
- return url?.href
+ return getExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Transaction, _activity?.transactionId)
}
}
diff --git a/packages/desktop/views/dashboard/collectibles/components/Erc721CollectibleDetails.svelte b/packages/desktop/views/dashboard/collectibles/components/Erc721CollectibleDetails.svelte
index 6471eea989..df85163789 100644
--- a/packages/desktop/views/dashboard/collectibles/components/Erc721CollectibleDetails.svelte
+++ b/packages/desktop/views/dashboard/collectibles/components/Erc721CollectibleDetails.svelte
@@ -3,23 +3,21 @@
import { type IItem } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { IErc721Nft } from '@core/nfts'
- import { ExplorerEndpoint, EvmNetworkId, getDefaultExplorerUrl } from '@core/network'
+ import { ExplorerEndpoint, EvmNetworkId, getExplorerUrl } from '@core/network'
import CollectibleDetails from './CollectibleDetails.svelte'
- import { buildUrl } from '@core/utils'
export let nft: IErc721Nft
const { standard, networkId, contractMetadata, tokenId, metadata, mediaUrl } = nft
const address = contractMetadata.address
- const explorerEndpoint = getExplorerEndpoint(networkId)
+ const explorerUrl = buildExplorerUrl(networkId)
- function getExplorerEndpoint(networkId: EvmNetworkId): string | undefined {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(networkId, ExplorerEndpoint.Token)
- const url = buildUrl({
- origin: baseUrl,
- pathname: tokenId ? `${endpoint}/${address}/instance/${tokenId}` : address,
- })
- return url?.href
+ function buildExplorerUrl(networkId: EvmNetworkId): string | undefined {
+ if (tokenId) {
+ return getExplorerUrl(networkId, ExplorerEndpoint.Token, `${address}/instance/${tokenId}`)
+ } else {
+ return getExplorerUrl(networkId, ExplorerEndpoint.Address, address)
+ }
}
let details: IItem[] = []
@@ -64,4 +62,4 @@
]
-
+
diff --git a/packages/desktop/views/dashboard/collectibles/components/Irc27CollectibleDetails.svelte b/packages/desktop/views/dashboard/collectibles/components/Irc27CollectibleDetails.svelte
index ef72b2be55..89d17d44c3 100644
--- a/packages/desktop/views/dashboard/collectibles/components/Irc27CollectibleDetails.svelte
+++ b/packages/desktop/views/dashboard/collectibles/components/Irc27CollectibleDetails.svelte
@@ -1,7 +1,7 @@
-
+
diff --git a/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte b/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte
index dc4af1aa66..10585f1736 100644
--- a/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte
+++ b/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte
@@ -3,15 +3,13 @@
import { localize } from '@core/i18n'
import { EvmContractCallActivity, EvmTokenMintingActivity, EvmTokenTransferActivity } from '@core/activity'
import { openUrlInBrowser } from '@core/app'
- import { ExplorerEndpoint, getDefaultExplorerUrl } from '@core/network'
- import { buildUrl } from '@core/utils'
+ import { ExplorerEndpoint, getExplorerUrl } from '@core/network'
export let activity: EvmContractCallActivity | EvmTokenTransferActivity | EvmTokenMintingActivity
- $: explorer = getDefaultExplorerUrl(activity.destinationNetworkId, ExplorerEndpoint.Address)
function onExplorerClick(address: string): void {
- const url = buildUrl({ origin: explorer.baseUrl, pathname: `${explorer.endpoint}/${address}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(activity.destinationNetworkId, ExplorerEndpoint.Address, address)
+ openUrlInBrowser(url)
}
diff --git a/packages/shared/src/components/activities/stardust/info/StardustAliasInformation.svelte b/packages/shared/src/components/activities/stardust/info/StardustAliasInformation.svelte
index 47a38fd543..64857ecadc 100644
--- a/packages/shared/src/components/activities/stardust/info/StardustAliasInformation.svelte
+++ b/packages/shared/src/components/activities/stardust/info/StardustAliasInformation.svelte
@@ -2,17 +2,15 @@
import { Table } from '@bloomwalletio/ui'
import { localize } from '@core/i18n'
import { StardustAliasActivity } from '@core/activity'
- import { getDefaultExplorerUrl } from '@core/network/utils'
+ import { getExplorerUrl } from '@core/network/utils'
import { ExplorerEndpoint } from '@core/network/enums'
import { openUrlInBrowser } from '@core/app/utils'
- import { buildUrl } from '@core/utils/url'
export let activity: StardustAliasActivity
function onAddressClick(address: string) {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address) ?? ''
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${address}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address, address)
+ openUrlInBrowser(url)
}
diff --git a/packages/shared/src/components/activities/stardust/info/StardustFoundryInformation.svelte b/packages/shared/src/components/activities/stardust/info/StardustFoundryInformation.svelte
index 0be338be04..4fcbf565b7 100644
--- a/packages/shared/src/components/activities/stardust/info/StardustFoundryInformation.svelte
+++ b/packages/shared/src/components/activities/stardust/info/StardustFoundryInformation.svelte
@@ -4,21 +4,18 @@
import { openUrlInBrowser } from '@core/app'
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network/enums'
- import { getDefaultExplorerUrl } from '@core/network/utils'
- import { buildUrl } from '@core/utils'
+ import { getExplorerUrl } from '@core/network/utils'
export let activity: StardustFoundryActivity
function onAliasClick(aliasAddress: string) {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address)
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${aliasAddress}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address, aliasAddress)
+ openUrlInBrowser(url)
}
function onTokenClick(tokenId: string) {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Foundry)
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${tokenId}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Foundry, tokenId)
+ openUrlInBrowser(url)
}
diff --git a/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte b/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte
index b9db387564..3006ba1021 100644
--- a/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte
+++ b/packages/shared/src/components/activities/stardust/info/StardustGenericInformation.svelte
@@ -4,9 +4,8 @@
import { openUrlInBrowser } from '@core/app'
import { time } from '@core/app/stores'
import { getFormattedTimeStamp, localize } from '@core/i18n'
- import { ExplorerEndpoint, getDefaultExplorerUrl, getNetwork } from '@core/network'
+ import { ExplorerEndpoint, getExplorerUrl, getNetwork } from '@core/network'
import { formatTokenAmount } from '@core/token'
- import { buildUrl } from '@core/utils'
import { getTimeDifference } from '@core/utils/time'
import { NetworkLabel, ExpiredPill, TimelockPill, UnclaimedPill } from '@ui'
@@ -21,13 +20,14 @@
$: formattedMaxGasFee = formatAmount(BigInt(gasLimit ?? 0))
$: formattedTransactionFee = formatAmount(activity.transactionFee ?? BigInt(0))
- $: explorer = getDefaultExplorerUrl(activity.sourceNetworkId, ExplorerEndpoint.Transaction) ?? ''
+ $: hasExplorer = !!getNetwork(activity.sourceNetworkId)?.explorerUrl
function onTransactionIdClick(): void {
- const url = buildUrl({
- origin: explorer.baseUrl,
- pathname: `${explorer.endpoint}/${activity.asyncData?.claimingTransactionId}`,
- })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(
+ activity.sourceNetworkId,
+ ExplorerEndpoint.Transaction,
+ activity.asyncData?.claimingTransactionId
+ )
+ openUrlInBrowser(url)
}
function formatAmount(amount: bigint | undefined): string | undefined {
@@ -129,7 +129,7 @@
value: activity.asyncData?.claimingTransactionId,
copyable: true,
truncate: { firstCharCount: 12, endCharCount: 12 },
- onClick: explorer.baseUrl ? onTransactionIdClick : undefined,
+ onClick: hasExplorer ? onTransactionIdClick : undefined,
},
]}
/>
diff --git a/packages/shared/src/components/activities/stardust/info/StardustNftInformation.svelte b/packages/shared/src/components/activities/stardust/info/StardustNftInformation.svelte
index 6388824265..ae504475ac 100644
--- a/packages/shared/src/components/activities/stardust/info/StardustNftInformation.svelte
+++ b/packages/shared/src/components/activities/stardust/info/StardustNftInformation.svelte
@@ -5,10 +5,9 @@
import { openUrlInBrowser } from '@core/app/utils'
import { localize } from '@core/i18n'
import { ExplorerEndpoint } from '@core/network/enums'
- import { getDefaultExplorerUrl } from '@core/network/utils'
+ import { getExplorerUrl } from '@core/network/utils'
import { NftStandard } from '@core/nfts/enums'
import { getNftByIdForAccount } from '@core/nfts/stores'
- import { buildUrl } from '@core/utils'
import { getBech32AddressFromAddressTypes, getHexAddressFromAddressTypes } from '@core/wallet'
import { type Address, AddressType } from '@iota/sdk/out/types'
@@ -18,15 +17,17 @@
$: issuer = nft?.standard === NftStandard.Irc27 ? nft?.issuer : undefined
function onNftIdClick(nftId: string) {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Nft)
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${nftId}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Nft, nftId)
+ openUrlInBrowser(url)
}
function onIssuerClick(issuer: Address) {
- const { baseUrl, endpoint } = getDefaultExplorerUrl(activity?.sourceNetworkId, ExplorerEndpoint.Address)
- const url = buildUrl({ origin: baseUrl, pathname: `${endpoint}/${getBech32AddressFromAddressTypes(issuer)}` })
- openUrlInBrowser(url?.href)
+ const url = getExplorerUrl(
+ activity?.sourceNetworkId,
+ ExplorerEndpoint.Address,
+ getBech32AddressFromAddressTypes(issuer)
+ )
+ openUrlInBrowser(url)
}
diff --git a/packages/shared/src/lib/auxiliary/third-party/utils/buildPersistedProfileFromThirdPartyPersistedProfile.ts b/packages/shared/src/lib/auxiliary/third-party/utils/buildPersistedProfileFromThirdPartyPersistedProfile.ts
index 6be5908b6b..ace1a247bf 100644
--- a/packages/shared/src/lib/auxiliary/third-party/utils/buildPersistedProfileFromThirdPartyPersistedProfile.ts
+++ b/packages/shared/src/lib/auxiliary/third-party/utils/buildPersistedProfileFromThirdPartyPersistedProfile.ts
@@ -2,6 +2,7 @@ import { IPersistedAccountData } from '@core/account'
import { APP_STAGE } from '@core/app'
import { MarketCurrency } from '@core/market'
import {
+ DEFAULT_EXPLORER_URLS,
DEFAULT_ISC_CHAINS_CONFIGURATIONS,
IStardustNetworkMetadata,
NetworkNamespace,
@@ -78,6 +79,7 @@ function buildStardustNetworkFromThirdPartyPersistedNetwork(
NETWORK_NAME_TO_STARDUST_NETWORK_ID_MAP[network.protocol.networkName] ??
`${NetworkNamespace.Stardust}:${network.protocol.networkName}`
const defaultChainConfigurations = structuredClone(DEFAULT_ISC_CHAINS_CONFIGURATIONS?.[networkId])
+ const explorerUrl = DEFAULT_EXPLORER_URLS[networkId]
return {
id: networkId,
@@ -87,6 +89,7 @@ function buildStardustNetworkFromThirdPartyPersistedNetwork(
protocol: network.protocol,
baseToken: network.baseToken,
chainConfigurations: defaultChainConfigurations ? [defaultChainConfigurations] : [],
+ explorerUrl,
}
}
diff --git a/packages/shared/src/lib/core/network/classes/stardust-network.class.ts b/packages/shared/src/lib/core/network/classes/stardust-network.class.ts
index b69bd5c5af..53aa6fb8fc 100644
--- a/packages/shared/src/lib/core/network/classes/stardust-network.class.ts
+++ b/packages/shared/src/lib/core/network/classes/stardust-network.class.ts
@@ -21,6 +21,7 @@ export class StardustNetwork implements IStardustNetwork {
public readonly bech32Hrp: string
public readonly protocol: IProtocol
public readonly baseToken: IBaseToken
+ public readonly explorerUrl: string | undefined
public readonly type = NetworkType.Stardust
public iscChains: IscChain[]
@@ -38,6 +39,7 @@ export class StardustNetwork implements IStardustNetwork {
this.networkName = persistedNetwork.protocol.networkName
this.protocol = persistedNetwork.protocol
this.baseToken = persistedNetwork.baseToken
+ this.explorerUrl = persistedNetwork.explorerUrl
this.iscChains = persistedNetwork.chainConfigurations
.map((chainConfiguration) => {
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 568f5bad9e..d61574abe6 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
@@ -3,6 +3,7 @@ import { IStardustNetworkMetadata } from '../interfaces'
import { NetworkMetadata, 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 { DEFAULT_PROTOCOL } from './default-protocol.constant'
import { SupportedNetworkId } from './supported-network-id.constant'
@@ -15,6 +16,7 @@ export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in StardustNetworkId]?: N
coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.Iota],
protocol: DEFAULT_PROTOCOL[SupportedNetworkId.Iota],
baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.Iota],
+ explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.Iota],
},
[SupportedNetworkId.Shimmer]: {
id: SupportedNetworkId.Shimmer,
@@ -23,6 +25,7 @@ export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in StardustNetworkId]?: N
coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.Shimmer],
protocol: DEFAULT_PROTOCOL[SupportedNetworkId.Shimmer],
baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.Shimmer],
+ explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.Shimmer],
},
[SupportedNetworkId.Testnet]: {
id: SupportedNetworkId.Testnet,
@@ -31,5 +34,6 @@ export const DEFAULT_NETWORK_METADATA: Readonly<{ [key in StardustNetworkId]?: N
coinType: DEFAULT_COIN_TYPE[SupportedNetworkId.Testnet],
protocol: DEFAULT_PROTOCOL[SupportedNetworkId.Testnet],
baseToken: DEFAULT_BASE_TOKEN[SupportedNetworkId.Testnet],
+ explorerUrl: DEFAULT_EXPLORER_URLS[SupportedNetworkId.Testnet],
},
}
diff --git a/packages/shared/src/lib/core/network/constants/explorer-endpoints.constant.ts b/packages/shared/src/lib/core/network/constants/explorer-endpoints.constant.ts
deleted file mode 100644
index 8067074838..0000000000
--- a/packages/shared/src/lib/core/network/constants/explorer-endpoints.constant.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { ExplorerEndpoint } from '../enums'
-import { NetworkId } from '../types'
-import { SupportedNetworkId } from './supported-network-id.constant'
-
-export const EXPLORER_ENDPOINTS: Readonly<{ [key in NetworkId]?: { [key in ExplorerEndpoint]?: string } }> = {
- [SupportedNetworkId.Iota]: {
- [ExplorerEndpoint.Transaction]: `mainnet/${ExplorerEndpoint.Transaction}`,
- [ExplorerEndpoint.Output]: `mainnet/${ExplorerEndpoint.Output}`,
- [ExplorerEndpoint.Nft]: `mainnet/${ExplorerEndpoint.Nft}`,
- [ExplorerEndpoint.Foundry]: `mainnet/${ExplorerEndpoint.Foundry}`,
- [ExplorerEndpoint.Address]: 'mainnet/addr',
- },
- [SupportedNetworkId.Shimmer]: {
- [ExplorerEndpoint.Transaction]: `shimmer/${ExplorerEndpoint.Transaction}`,
- [ExplorerEndpoint.Output]: `shimmer/${ExplorerEndpoint.Output}`,
- [ExplorerEndpoint.Nft]: `shimmer/${ExplorerEndpoint.Nft}`,
- [ExplorerEndpoint.Foundry]: `shimmer/${ExplorerEndpoint.Foundry}`,
- [ExplorerEndpoint.Address]: 'shimmer/addr',
- },
- [SupportedNetworkId.Testnet]: {
- [ExplorerEndpoint.Transaction]: `testnet/${ExplorerEndpoint.Transaction}`,
- [ExplorerEndpoint.Output]: `testnet/${ExplorerEndpoint.Output}`,
- [ExplorerEndpoint.Nft]: `testnet/${ExplorerEndpoint.Nft}`,
- [ExplorerEndpoint.Foundry]: `testnet/${ExplorerEndpoint.Foundry}`,
- [ExplorerEndpoint.Address]: 'testnet/addr',
- },
- [SupportedNetworkId.IotaEvm]: {
- [ExplorerEndpoint.Transaction]: 'tx',
- [ExplorerEndpoint.Token]: ExplorerEndpoint.Token,
- [ExplorerEndpoint.Address]: ExplorerEndpoint.Address,
- },
- [SupportedNetworkId.ShimmerEvm]: {
- [ExplorerEndpoint.Transaction]: 'tx',
- [ExplorerEndpoint.Token]: ExplorerEndpoint.Token,
- [ExplorerEndpoint.Address]: ExplorerEndpoint.Address,
- },
- [SupportedNetworkId.TestnetEvm]: {
- [ExplorerEndpoint.Transaction]: 'tx',
- [ExplorerEndpoint.Token]: ExplorerEndpoint.Token,
- [ExplorerEndpoint.Address]: ExplorerEndpoint.Address,
- },
-}
diff --git a/packages/shared/src/lib/core/network/constants/index.ts b/packages/shared/src/lib/core/network/constants/index.ts
index ca78462814..68e176a217 100644
--- a/packages/shared/src/lib/core/network/constants/index.ts
+++ b/packages/shared/src/lib/core/network/constants/index.ts
@@ -12,7 +12,6 @@ export * from './default-protocol.constant'
export * from './default-network-metadata.constant'
export * from './default-node-urls.constant'
export * from './empty-node.constant'
-export * from './explorer-endpoints.constant'
export * from './faucet-urls.constant'
export * from './max-network-name-length.constant'
export * from './milestone-not-found.constant'
diff --git a/packages/shared/src/lib/core/network/interfaces/base-network.interface.ts b/packages/shared/src/lib/core/network/interfaces/base-network.interface.ts
index 47df3fd118..79d812d181 100644
--- a/packages/shared/src/lib/core/network/interfaces/base-network.interface.ts
+++ b/packages/shared/src/lib/core/network/interfaces/base-network.interface.ts
@@ -17,4 +17,5 @@ export interface IBaseNetworkMetadata {
name: string
baseToken: IBaseToken
coinType: number
+ explorerUrl: string | undefined
}
diff --git a/packages/shared/src/lib/core/network/interfaces/evm-network.interface.ts b/packages/shared/src/lib/core/network/interfaces/evm-network.interface.ts
index 7fb570df06..755944d7eb 100644
--- a/packages/shared/src/lib/core/network/interfaces/evm-network.interface.ts
+++ b/packages/shared/src/lib/core/network/interfaces/evm-network.interface.ts
@@ -28,7 +28,6 @@ export interface IEvmNetwork extends IBaseNetwork, IBaseNetworkMetadata {
id: EvmNetworkId
namespace: NetworkNamespace.Evm
chainId: ChainId
- explorerUrl: string | undefined
rpcEndpoint: string
provider: Web3Provider
diff --git a/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts b/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts
index 3df66fe98b..2c18279ce5 100644
--- a/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts
+++ b/packages/shared/src/lib/core/network/utils/buildPersistedNetworkFromNodeInfoResponse.ts
@@ -4,6 +4,7 @@ import {
DEFAULT_COIN_TYPE,
DEFAULT_NETWORK_METADATA,
TEST_COIN_TYPE,
+ DEFAULT_EXPLORER_URLS,
} from '../constants'
import { TokenStandard } from '@core/token/enums'
import { INodeInfoResponse, IStardustNetworkMetadata } from '../interfaces'
@@ -21,7 +22,8 @@ export function buildPersistedNetworkFromNodeInfoResponse(
const _coinType = coinType ?? DEFAULT_COIN_TYPE[id] ?? TEST_COIN_TYPE
const configuration = DEFAULT_ISC_CHAINS_CONFIGURATIONS?.[id]
- const chainConfigurations = configuration ? [configuration] : []
+ const chainConfigurations = configuration ? [structuredClone(configuration)] : []
+ const explorerUrl = DEFAULT_EXPLORER_URLS[id]
return {
id,
name,
@@ -30,5 +32,6 @@ export function buildPersistedNetworkFromNodeInfoResponse(
protocol: nodeInfoResponse?.nodeInfo?.protocol,
baseToken: { standard: TokenStandard.BaseToken, ...nodeInfoResponse?.nodeInfo?.baseToken },
chainConfigurations,
+ explorerUrl,
}
}
diff --git a/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts b/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts
deleted file mode 100644
index 18e828e77d..0000000000
--- a/packages/shared/src/lib/core/network/utils/getDefaultExplorerUrl.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { DEFAULT_EXPLORER_URLS, EXPLORER_ENDPOINTS } from '../constants'
-import { ExplorerEndpoint } from '../enums'
-import { NetworkId } from '../types'
-
-export function getDefaultExplorerUrl(
- networkId: NetworkId,
- requestedEndpoint: ExplorerEndpoint
-): {
- baseUrl: string
- endpoint: string
-} {
- const baseUrl = DEFAULT_EXPLORER_URLS?.[networkId] ?? ''
- const endpoint = EXPLORER_ENDPOINTS?.[networkId]?.[requestedEndpoint] ?? ''
-
- return {
- baseUrl,
- endpoint,
- }
-}
diff --git a/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts b/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts
new file mode 100644
index 0000000000..6d538993a2
--- /dev/null
+++ b/packages/shared/src/lib/core/network/utils/getExplorerEndpoint.ts
@@ -0,0 +1,27 @@
+import { ExplorerEndpoint } from '../enums'
+import { NetworkId } from '../types'
+import { getExplorerApiNetworkName } from './getExplorerApiNetworkName'
+import { isStardustNetwork } from './isStardustNetwork'
+import { isEvmNetwork } from './isEvmNetwork'
+
+const STARDUST_EXPLORER_ENDPOINTS: Readonly<{ [key in ExplorerEndpoint]?: string }> = {
+ [ExplorerEndpoint.Transaction]: ExplorerEndpoint.Transaction,
+ [ExplorerEndpoint.Output]: ExplorerEndpoint.Output,
+ [ExplorerEndpoint.Nft]: ExplorerEndpoint.Nft,
+ [ExplorerEndpoint.Foundry]: ExplorerEndpoint.Foundry,
+ [ExplorerEndpoint.Address]: 'addr',
+}
+
+const EVM_EXPLORER_ENDPOINTS: Readonly<{ [key in ExplorerEndpoint]?: string }> = {
+ [ExplorerEndpoint.Transaction]: 'tx',
+ [ExplorerEndpoint.Token]: ExplorerEndpoint.Token,
+ [ExplorerEndpoint.Address]: ExplorerEndpoint.Address,
+}
+
+export function getExplorerEndpoint(networkId: NetworkId, explorerEndpoint: ExplorerEndpoint): string | undefined {
+ if (isStardustNetwork(networkId)) {
+ return `${getExplorerApiNetworkName(networkId)}/${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
new file mode 100644
index 0000000000..a8dba19500
--- /dev/null
+++ b/packages/shared/src/lib/core/network/utils/getExplorerUrl.ts
@@ -0,0 +1,17 @@
+import { buildUrl } from '@core/utils/url'
+import { getExplorerEndpoint } from '../utils'
+import { ExplorerEndpoint } from '../enums'
+import { getNetwork } from '../stores'
+import { NetworkId } from '../types'
+
+export function getExplorerUrl(
+ networkId: NetworkId,
+ requestedEndpoint: ExplorerEndpoint,
+ pathParameter?: string
+): string | undefined {
+ const baseUrl = getNetwork(networkId)?.explorerUrl ?? ''
+ const endpoint = getExplorerEndpoint(networkId, requestedEndpoint) ?? ''
+
+ const url = buildUrl({ origin: 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 ccedd61c98..20ebbb806e 100644
--- a/packages/shared/src/lib/core/network/utils/index.ts
+++ b/packages/shared/src/lib/core/network/utils/index.ts
@@ -5,10 +5,11 @@ export * from './checkIfOnSameNetwork'
export * from './checkNodeUrlValidity'
export * from './getDefaultClientOptions'
export * from './getAllNetworkIds'
-export * from './getDefaultExplorerUrl'
export * from './getDefaultNodes'
export * from './getDefaultStardustNetwork'
export * from './getEvmTransactionOptions'
+export * from './getExplorerEndpoint'
+export * from './getExplorerUrl'
export * from './getExplorerApiNetworkName'
export * from './getNetworkIdFromOnboardingNetworkType'
export * from './getOnboardingNetworkTypeFromNetworkId'
diff --git a/packages/shared/src/lib/core/profile/constants/profile-version.constant.ts b/packages/shared/src/lib/core/profile/constants/profile-version.constant.ts
index 1a12367c83..0a6e60205b 100644
--- a/packages/shared/src/lib/core/profile/constants/profile-version.constant.ts
+++ b/packages/shared/src/lib/core/profile/constants/profile-version.constant.ts
@@ -1,7 +1,7 @@
import { AppStage } from '@core/app/enums'
export const PROFILE_VERSION: Record = {
- [AppStage.ALPHA]: 18,
+ [AppStage.ALPHA]: 19,
[AppStage.BETA]: 1,
[AppStage.PROD]: 9,
}
diff --git a/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-18-to-19.ts b/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-18-to-19.ts
new file mode 100644
index 0000000000..bb5d825951
--- /dev/null
+++ b/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-18-to-19.ts
@@ -0,0 +1,13 @@
+import { DEFAULT_EXPLORER_URLS } from '@core/network'
+import { IPersistedProfile } from '@core/profile/interfaces'
+
+export function alphaProfileMigration18To19(existingProfile: unknown): Promise {
+ const profile = existingProfile as IPersistedProfile
+
+ profile.network = {
+ ...profile.network,
+ explorerUrl: structuredClone(DEFAULT_EXPLORER_URLS[profile.network.id]),
+ }
+
+ return Promise.resolve()
+}
diff --git a/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-map.ts b/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-map.ts
index f3f5cb2a06..e262bfa00c 100644
--- a/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-map.ts
+++ b/packages/shared/src/lib/core/profile/migrations/alpha/alpha-profile-migration-map.ts
@@ -9,6 +9,7 @@ import { alphaProfileMigration14To15 } from './alpha-profile-migration-14-to-15'
import { alphaProfileMigration15To16 } from './alpha-profile-migration-15-to-16'
import { alphaProfileMigration16To17 } from './alpha-profile-migration-16-to-17'
import { alphaProfileMigration17To18 } from './alpha-profile-migration-17-to-18'
+import { alphaProfileMigration18To19 } from './alpha-profile-migration-18-to-19'
import { alphaProfileMigration2To3 } from './alpha-profile-migration-2-to-3'
import { alphaProfileMigration3To4 } from './alpha-profile-migration-3-to-4'
import { alphaProfileMigration4To5 } from './alpha-profile-migration-4-to-5'
@@ -37,4 +38,5 @@ export const ALPHA_PROFILE_MIGRATION_MAP: ProfileMigrationMap = {
15: alphaProfileMigration15To16,
16: alphaProfileMigration16To17,
17: alphaProfileMigration17To18,
+ 18: alphaProfileMigration18To19,
}
diff --git a/packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-8-to-9.ts b/packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-8-to-9.ts
index eb69df554d..b6e44a0789 100644
--- a/packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-8-to-9.ts
+++ b/packages/shared/src/lib/core/profile/migrations/prod/prod-profile-migration-8-to-9.ts
@@ -1,6 +1,6 @@
import { DappVerification } from '@auxiliary/wallet-connect/enums'
import { persistDapp, persistedDappNamespaces } from '@auxiliary/wallet-connect/stores'
-import { DEFAULT_BASE_TOKEN } from '@core/network/constants'
+import { DEFAULT_BASE_TOKEN, DEFAULT_EXPLORER_URLS } from '@core/network/constants'
import { IPersistedProfile } from '@core/profile/interfaces'
import { IBaseToken } from '@core/token/interfaces'
import { persistedTokens } from '@core/token/stores'
@@ -19,6 +19,11 @@ export function prodProfileMigration8To9(existingProfile: unknown): Promise ({
...evmNetwork,
baseToken: DEFAULT_BASE_TOKEN[evmNetwork.id] as IBaseToken,