Skip to content

Commit

Permalink
feat: add anchor tx link to btc block page
Browse files Browse the repository at this point in the history
  • Loading branch information
He1DAr committed Feb 21, 2025
1 parent 348a807 commit 295daf4
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { useParamsBlockHash } from '../../../app/block/[hash]/useParamsBlockHash
import { KeyValueVertical } from '../../../common/components/KeyValueVertical';
import { Section } from '../../../common/components/Section';
import { useGlobalContext } from '../../../common/context/useGlobalContext';
import { useBlockByHash } from '../../../common/queries/useBlockByHash';

Check warning on line 10 in src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx#L10

Added line #L10 was not covered by tests
import { useSuspenseBurnBlock } from '../../../common/queries/useBurnBlock';
import { toRelativeTime, truncateMiddle } from '../../../common/utils/utils';
import { Link } from '../../../ui/Link';
import { Text } from '../../../ui/Text';
import { TextLink } from '../../../ui/TextLink';

Check warning on line 15 in src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx#L15

Added line #L15 was not covered by tests
import BitcoinIcon from '../../../ui/icons/BitcoinIcon';
import { ExplorerErrorBoundary } from '../../_components/ErrorBoundary';

Expand All @@ -24,6 +26,10 @@ export function BitcoinAnchorDetailsBase() {
const { data: btcBlock } = useSuspenseBurnBlock(useParamsBlockHash(), {
refetchOnWindowFocus: true,
});
const stxBlockHash = btcBlock?.stacks_blocks?.[0];
const { data: stxBlock } = useBlockByHash(stxBlockHash, {

Check warning on line 30 in src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/btcblock/[hash]/BitcoinAnchorDetails.tsx#L29-L30

Added lines #L29 - L30 were not covered by tests
enabled: !!stxBlockHash,
});

const { btcBlockBaseUrl, btcTxBaseUrl } = useGlobalContext().activeNetwork;
const btcBlockBlockTimeUTC = new Date(btcBlock.burn_block_time_iso).toUTCString();
Expand Down Expand Up @@ -64,21 +70,23 @@ export function BitcoinAnchorDetailsBase() {
}
copyValue={btcBlock.burn_block_hash}
/>
<KeyValueVertical
className="key-value-vertical"
label={'Anchor transaction ID'}
value={
<Link
target="_blank"
href={`${btcTxBaseUrl}/${btcBlock.burn_block_hash.replace('0x', '')}`}
>
<Text fontSize="sm" fontWeight="medium">
{truncateMiddle(btcBlock.burn_block_hash, 8)}
</Text>
</Link>
}
copyValue={btcBlock.burn_block_hash}
/>
{!!stxBlock?.miner_txid && (
<KeyValueVertical
label={'Anchor transaction ID'}
value={
<TextLink
as="a"
target="_blank"
href={`${btcTxBaseUrl}/${stxBlock.miner_txid.replace('0x', '')}`}
>
<Text fontSize={'sm'} fontWeight={'medium'}>
{truncateMiddle(stxBlock.miner_txid, 8)}
</Text>
</TextLink>
}
copyValue={stxBlock.miner_txid}
/>
)}
<KeyValueVertical
className="key-value-vertical"
label={'Timestamp'}
Expand Down

0 comments on commit 295daf4

Please sign in to comment.