Skip to content

Commit

Permalink
fix: use network.chain.bitcoin.url in api hooks, closes #4330
Browse files Browse the repository at this point in the history
  • Loading branch information
friedger authored and kyranjamie committed Oct 18, 2023
1 parent bd25751 commit ceaf228
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
20 changes: 3 additions & 17 deletions src/app/store/common/api-clients.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ import { useMemo } from 'react';

import { ChainID } from '@stacks/transactions';

import {
BITCOIN_API_BASE_URL_MAINNET,
BITCOIN_API_BASE_URL_SIGNET,
BITCOIN_API_BASE_URL_TESTNET,
HIRO_API_BASE_URL_MAINNET,
HIRO_API_BASE_URL_TESTNET,
} from '@shared/constants';
import { HIRO_API_BASE_URL_MAINNET, HIRO_API_BASE_URL_TESTNET } from '@shared/constants';

import { whenBitcoinNetwork, whenStacksChainId } from '@app/common/utils';
import { whenStacksChainId } from '@app/common/utils';
import { BitcoinClient } from '@app/query/bitcoin/bitcoin-client';
import { StacksClient } from '@app/query/stacks/stacks-client';
import { TokenMetadataClient } from '@app/query/stacks/token-metadata-client';
Expand All @@ -24,15 +18,7 @@ import { useCurrentNetworkState } from '../networks/networks.hooks';

export function useBitcoinClient() {
const network = useCurrentNetworkState();

const baseUrl = whenBitcoinNetwork(network.chain.bitcoin.network)({
mainnet: BITCOIN_API_BASE_URL_MAINNET,
testnet: BITCOIN_API_BASE_URL_TESTNET,
regtest: BITCOIN_API_BASE_URL_TESTNET,
signet: BITCOIN_API_BASE_URL_SIGNET,
});

return new BitcoinClient(baseUrl);
return new BitcoinClient(network.chain.bitcoin.url);
}

// Unanchored by default (microblocks)
Expand Down
4 changes: 2 additions & 2 deletions src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const HIRO_INSCRIPTIONS_API_URL = 'https://api.hiro.so/ordinals/v1/inscri

export const BITCOIN_API_BASE_URL_MAINNET = 'https://blockstream.info/api';
export const BITCOIN_API_BASE_URL_TESTNET = 'https://blockstream.info/testnet/api';
export const BITCOIN_API_BASE_URL_SIGNET = 'https://mempool.space/signet/api';
const BITCOIN_API_BASE_URL_SIGNET = 'https://mempool.space/signet/api';

const networkMainnet: NetworkConfiguration = {
id: WalletDefaultNetworkConfigurationIds.mainnet,
Expand Down Expand Up @@ -150,7 +150,7 @@ const networkSbtcDevenv: NetworkConfiguration = {
bitcoin: {
blockchain: 'bitcoin',
network: 'regtest',
url: 'http://localhost:8999/api',
url: 'http://localhost:3002',
},
},
};
Expand Down

0 comments on commit ceaf228

Please sign in to comment.