diff --git a/components/header/AccountDropdown.vue b/components/header/AccountDropdown.vue index b125ffe4b..5461de38c 100644 --- a/components/header/AccountDropdown.vue +++ b/components/header/AccountDropdown.vue @@ -23,7 +23,7 @@ no-chevron :active="active" as="a" - :href="`${selectedNetwork.blockExplorerUrl}/address/${account.address!}`" + :href="buildExplorerUrl(selectedNetwork.blockExplorerUrl, account.address)" target="_blank" class="options-item" > diff --git a/components/header/MobileAccountNavigation.vue b/components/header/MobileAccountNavigation.vue index ccf77c7ab..fb29e2a4e 100644 --- a/components/header/MobileAccountNavigation.vue +++ b/components/header/MobileAccountNavigation.vue @@ -16,7 +16,7 @@ diff --git a/utils/helpers.ts b/utils/helpers.ts index b8c7ca2cf..6669a13c1 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -168,3 +168,17 @@ export function getTokensWithCustomBridgeTokens( return sortedTokens; } + +export function buildExplorerUrl(baseUrl: string, value?: string): string | undefined { + if (!value) return; + + const [urlPart, queryPart] = baseUrl.split("?"); + const base = urlPart.replace(/\/$/, ""); + + const type = value.length === 66 ? "tx" : value.length === 42 ? "address" : undefined; + + if (!type) return; + + const url = `${base}/${type}/${value}`; + return queryPart ? `${url}?${queryPart}` : url; +} diff --git a/views/transactions/Deposit.vue b/views/transactions/Deposit.vue index a1e184b25..6e88bc18a 100644 --- a/views/transactions/Deposit.vue +++ b/views/transactions/Deposit.vue @@ -233,7 +233,7 @@