diff --git a/src/app/common/hooks/use-bitcoin-contracts.ts b/src/app/common/hooks/use-bitcoin-contracts.ts index ad0fef43a4a..186769314ad 100644 --- a/src/app/common/hooks/use-bitcoin-contracts.ts +++ b/src/app/common/hooks/use-bitcoin-contracts.ts @@ -224,7 +224,7 @@ export function useBitcoinContracts() { const txMoney = createMoneyFromDecimal(bitcoinValue, 'BTC'); const txFiatValue = i18nFormatCurrency(calculateFiatValue(txMoney)).toString(); const txFiatValueSymbol = bitcoinMarketData.price.symbol; - const txLink = { blockchain: 'bitcoin', txId }; + const txLink = { blockchain: 'bitcoin', txid: txId }; return { txId, diff --git a/src/app/common/hooks/use-explorer-link.ts b/src/app/common/hooks/use-explorer-link.ts index cd446dc1c7b..89530c94a95 100644 --- a/src/app/common/hooks/use-explorer-link.ts +++ b/src/app/common/hooks/use-explorer-link.ts @@ -13,11 +13,13 @@ export interface HandleOpenTxLinkArgs { txid: string; } export function useExplorerLink() { - const { mode } = useCurrentNetworkState(); + const { mode, chain } = useCurrentNetworkState(); + const { bitcoin } = chain; const handleOpenTxLink = useCallback( - ({ blockchain, suffix, txid }: HandleOpenTxLinkArgs) => - openInNewTab(makeTxExplorerLink({ blockchain, mode, suffix, txid })), - [mode] + ({ blockchain, suffix, txid }: HandleOpenTxLinkArgs) => { + openInNewTab(makeTxExplorerLink({ blockchain, mode, suffix, txid, bitcoin })); + }, + [mode, bitcoin] ); return { diff --git a/src/app/common/utils.ts b/src/app/common/utils.ts index 50d227bdecd..9443580634f 100644 --- a/src/app/common/utils.ts +++ b/src/app/common/utils.ts @@ -7,7 +7,7 @@ import { } from '@stacks/transactions'; import { toUnicode } from 'punycode'; -import { BitcoinNetworkModes, KEBAB_REGEX } from '@shared/constants'; +import { BitcoinChainConfig, BitcoinNetworkModes, KEBAB_REGEX } from '@shared/constants'; import type { Blockchains } from '@shared/models/blockchain.model'; export function createNullArrayOfLength(length: number) { @@ -44,15 +44,20 @@ interface MakeTxExplorerLinkArgs { mode: BitcoinNetworkModes; suffix?: string; txid: string; + bitcoin: BitcoinChainConfig; } export function makeTxExplorerLink({ blockchain, mode, suffix = '', txid, + bitcoin: { bitcoinUrl, bitcoinNetwork }, }: MakeTxExplorerLinkArgs) { switch (blockchain) { case 'bitcoin': + if (bitcoinNetwork === 'regtest') { + return `${bitcoinUrl}/tx/${txid}`; + } return `https://mempool.space/${mode !== 'mainnet' ? mode + '/' : ''}tx/${txid}`; case 'stacks': return `https://explorer.hiro.so/txid/${txid}?chain=${mode}${suffix}`; diff --git a/src/shared/constants.ts b/src/shared/constants.ts index cb052ff54bf..8f8d7ce10cf 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -55,7 +55,7 @@ interface BaseChainConfig { blockchain: Blockchains; } -interface BitcoinChainConfig extends BaseChainConfig { +export interface BitcoinChainConfig extends BaseChainConfig { blockchain: 'bitcoin'; bitcoinUrl: string; bitcoinNetwork: BitcoinNetworkModes;