Skip to content

Commit 1395c11

Browse files
committed
fix: default to port 8000 for devnet, closes #2174
1 parent b0d40ad commit 1395c11

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

src/app/common/hooks/use-stacks-explorer-link.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ interface HandleOpenStacksTxLinkArgs {
1010
txid: string;
1111
}
1212
export function useStacksExplorerLink() {
13-
const { mode, isNakamotoTestnet } = useCurrentNetworkState();
13+
const { chain, isNakamotoTestnet } = useCurrentNetworkState();
1414

1515
const handleOpenStacksTxLink = useCallback(
1616
({ searchParams, txid }: HandleOpenStacksTxLinkArgs) => {
1717
openInNewTab(
18-
makeStacksTxExplorerLink({ mode, searchParams, isNakamoto: isNakamotoTestnet, txid })
18+
makeStacksTxExplorerLink({
19+
mode: chain.bitcoin.mode,
20+
searchParams,
21+
isNakamoto: isNakamotoTestnet,
22+
txid,
23+
})
1924
);
2025
},
21-
[mode, isNakamotoTestnet]
26+
[chain.bitcoin.mode, isNakamotoTestnet]
2227
);
2328

24-
return {
25-
handleOpenStacksTxLink,
26-
};
29+
return { handleOpenStacksTxLink };
2730
}

src/app/common/utils.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ export function makeStacksTxExplorerLink({
2626
txid,
2727
isNakamoto = false,
2828
}: MakeStacksTxExplorerLinkArgs) {
29+
if (mode === 'regtest') return 'http://localhost:8000/txid/' + txid;
2930
searchParams.append('chain', mode);
30-
if (isNakamoto) {
31-
searchParams.append('api', HIRO_API_BASE_URL_NAKAMOTO_TESTNET);
32-
}
31+
if (isNakamoto) searchParams.append('api', HIRO_API_BASE_URL_NAKAMOTO_TESTNET);
3332
return `${HIRO_EXPLORER_URL}/txid/${txid}?${searchParams.toString()}`;
3433
}
3534

src/app/features/hiro-messages/in-app-messages.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function InAppMessages(props: FlexProps) {
1515
const location = useLocation();
1616
const messages = useRemoteLeatherMessages();
1717

18-
const { mode } = useCurrentNetworkState();
18+
const { chain } = useCurrentNetworkState();
1919
const dismissMessage = useDismissMessage();
2020
const dismissedIds = useDismissedMessageIds();
2121

@@ -25,7 +25,7 @@ export function InAppMessages(props: FlexProps) {
2525

2626
if (!firstMessage) return null;
2727

28-
if (firstMessage.chainTarget !== 'all' && firstMessage.chainTarget !== mode) {
28+
if (firstMessage.chainTarget !== 'all' && firstMessage.chainTarget !== chain.bitcoin.mode) {
2929
return null;
3030
}
3131

src/app/features/stacks-transaction-request/principal-value.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ interface PrincipalValueProps {
99
}
1010
export function PrincipalValue(props: PrincipalValueProps) {
1111
const { address } = props;
12-
const { mode, isNakamotoTestnet } = useCurrentNetworkState();
12+
const { chain, isNakamotoTestnet } = useCurrentNetworkState();
1313

1414
return (
1515
<Link
1616
onClick={() =>
1717
openInNewTab(
18-
makeStacksAddressExplorerLink({ mode, address, isNakamoto: isNakamotoTestnet })
18+
makeStacksAddressExplorerLink({
19+
mode: chain.bitcoin.mode,
20+
address,
21+
isNakamoto: isNakamotoTestnet,
22+
})
1923
)
2024
}
2125
size="sm"

src/app/features/stacks-transaction-request/transaction-error/error-messages.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const NoContractErrorMessage = memo(props => {
113113
title="Contract not found"
114114
body={`The contract (${truncateMiddle(pendingTransaction.contractAddress)}.${
115115
pendingTransaction.contractName
116-
}) that you are trying to call cannot be found on ${network.mode}.`}
116+
}) that you are trying to call cannot be found on ${network.chain.bitcoin.mode}.`}
117117
{...props}
118118
/>
119119
);

src/app/store/networks/networks.hooks.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { StacksNetwork as StacksNetworkV6 } from '@stacks/network-v6';
1212
import { ChainID, TransactionVersion as TransactionVersionV6 } from '@stacks/transactions-v6';
1313

1414
import {
15-
type BitcoinNetworkModes,
1615
HIRO_API_BASE_URL_NAKAMOTO_TESTNET,
1716
bitcoinNetworkToNetworkMode,
1817
} from '@leather.io/models';
@@ -37,8 +36,7 @@ export function useCurrentNetworkState() {
3736
const isTestnet = currentNetwork.chain.stacks.chainId === ChainId.Testnet;
3837
const isNakamotoTestnet =
3938
currentNetwork.chain.stacks.url === HIRO_API_BASE_URL_NAKAMOTO_TESTNET;
40-
const mode = (isTestnet ? 'testnet' : 'mainnet') as BitcoinNetworkModes;
41-
return { ...currentNetwork, isTestnet, isNakamotoTestnet, mode };
39+
return { ...currentNetwork, isTestnet, isNakamotoTestnet };
4240
}, [currentNetwork]);
4341
}
4442

0 commit comments

Comments
 (0)