diff --git a/static/display-popup-modal.ts b/static/display-popup-modal.ts index 648477a..1e08e8b 100644 --- a/static/display-popup-modal.ts +++ b/static/display-popup-modal.ts @@ -1,3 +1,5 @@ +import { appState, explorersUrl } from "./main"; + export function renderErrorInModal(error: Error) { const modal = document.getElementById("error-modal"); const closeButton = document.getElementsByClassName("error-close-modal"); @@ -32,6 +34,20 @@ export function renderSuccessModal(transactionHash: string) { if (successMessageElement) { successMessageElement.innerHTML = `You've successfully signed the transaction. Your allowance balance should be updated in a few blocks.

transaction hash: ${transactionHash}`; + const chainId = appState.getChainId(); + const explorerUrl = chainId !== undefined ? explorersUrl[chainId] : ""; + const txLink = document.createElement("a"); + txLink.href = `${explorerUrl}/tx/${transactionHash}`; + txLink.target = "_blank"; + txLink.rel = "noopener noreferrer"; + txLink.style.color = "white"; + txLink.textContent = transactionHash; + + const txHashElement = successMessageElement.querySelector(".tx-hash"); + if (txHashElement) { + txHashElement.innerHTML = ""; + txHashElement.appendChild(txLink); + } } if (modal) {