Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/header/AccountDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down
2 changes: 1 addition & 1 deletion components/header/MobileAccountNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<DestinationItem
label="View on Explorer"
as="a"
:href="`${selectedNetwork.blockExplorerUrl}/address/${account.address}`"
:href="buildExplorerUrl(selectedNetwork.blockExplorerUrl, account.address)"
target="_blank"
:icon="ArrowTopRightOnSquareIcon"
size="sm"
Expand Down
2 changes: 1 addition & 1 deletion components/transaction/TransactionHashButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
size="xs"
variant="light"
as="a"
:href="`${explorerUrl}/tx/${transactionHash}`"
:href="buildExplorerUrl(explorerUrl, transactionHash)"
target="_blank"
class="transaction-hash-button"
>
Expand Down
14 changes: 14 additions & 0 deletions utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions views/transactions/Deposit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<template v-for="allowanceReceipt in setAllowanceReceipts" :key="allowanceReceipt.transactionHash">
<a
v-if="l1BlockExplorerUrl"
:href="`${l1BlockExplorerUrl}/tx/${allowanceReceipt.transactionHash}`"
:href="buildExplorerUrl(l1BlockExplorerUrl, allowanceReceipt.transactionHash)"
target="_blank"
class="inline-flex items-center gap-1 underline underline-offset-2"
>
Expand All @@ -257,7 +257,7 @@
>
<a
v-if="l1BlockExplorerUrl && allowanceTransactionHash"
:href="`${l1BlockExplorerUrl}/tx/${allowanceTransactionHash}`"
:href="buildExplorerUrl(l1BlockExplorerUrl, allowanceTransactionHash)"
target="_blank"
class="inline-flex items-center gap-1 underline underline-offset-2"
>
Expand Down
2 changes: 1 addition & 1 deletion views/transactions/TransferSubmitted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Your funds will be available at the
<a
v-if="blockExplorerUrl"
:href="`${blockExplorerUrl}/address/${transaction!.to.address}`"
:href="buildExplorerUrl(blockExplorerUrl, transaction!.to.address)"
target="_blank"
class="font-medium underline underline-offset-2"
>destination address</a
Expand Down