Skip to content

Commit

Permalink
chore: update block explorer mempool.space
Browse files Browse the repository at this point in the history
  • Loading branch information
waldenraines authored and bucko13 committed Nov 13, 2023
1 parent 7cfada6 commit 0e1ca4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/block_explorer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ describe("block_explorer", () => {
describe("blockExplorerURL", () => {
it("should properly return the base mainnet block explorer url for empty path", () => {
expect(blockExplorerURL("", Network.MAINNET)).toBe(
"https://blockstream.info"
"https://mempool.space"
);
});

it("should properly return the mainnet block explorer url for a given path path", () => {
const path =
"/block/00000000000000000011341d69792271766e4683e29b3ea169eacc59bde10a57";
expect(blockExplorerURL(path, Network.MAINNET)).toBe(
`https://blockstream.info${path}`
`https://mempool.space${path}`
);
});

it("should properly return the base testnet block explorer url for empty path", () => {
expect(blockExplorerURL("", Network.TESTNET)).toBe(
"https://blockstream.info/testnet"
"https://mempool.space/testnet"
);
});

it("should properly return the testnet block explorer url for a given path path", () => {
const path =
"/tx/4f0ef69f88829bd2f6b7793e32dd8bfcfbc87ddb9a2de3d8ef3f2aabbaff0be3";
expect(blockExplorerURL(path, Network.TESTNET)).toBe(
`https://blockstream.info/testnet${path}`
`https://mempool.space/testnet${path}`
);
});
});
Expand All @@ -42,15 +42,15 @@ describe("block_explorer", () => {
const path =
"/tx/1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0";
expect(blockExplorerAPIURL(path, Network.MAINNET)).toBe(
`https://blockstream.info/api${path}`
`https://mempool.space/api${path}`
);
});

it("should properly return the testnet block explorer api url for path", () => {
const path =
"/tx/4f0ef69f88829bd2f6b7793e32dd8bfcfbc87ddb9a2de3d8ef3f2aabbaff0be3";
expect(blockExplorerAPIURL(path, Network.TESTNET)).toBe(
`https://blockstream.info/testnet/api${path}`
`https://mempool.space/testnet/api${path}`
);
});
});
Expand All @@ -60,15 +60,15 @@ describe("block_explorer", () => {
const path =
"1814a10fb22e9551a17a94a1e68971e19b4f59eaf1689e0af85b97929b3b9ae0";
expect(blockExplorerTransactionURL(path, Network.MAINNET)).toBe(
`https://blockstream.info/tx/${path}`
`https://mempool.space/tx/${path}`
);
});

it("should properly return the testnet block explorer transaction url for a given path", () => {
const path =
"4f0ef69f88829bd2f6b7793e32dd8bfcfbc87ddb9a2de3d8ef3f2aabbaff0be3";
expect(blockExplorerTransactionURL(path, Network.TESTNET)).toBe(
`https://blockstream.info/testnet/tx/${path}`
`https://mempool.space/testnet/tx/${path}`
);
});
});
Expand All @@ -77,14 +77,14 @@ describe("block_explorer", () => {
it("should properly return the mainnet block explorer address url for a given path", () => {
const path = "39YqNoLULDpbjmeCTdGJ42DQhrQLzRcMdX";
expect(blockExplorerAddressURL(path, Network.MAINNET)).toBe(
`https://blockstream.info/address/${path}`
`https://mempool.space/address/${path}`
);
});

it("should properly return the testnet block explorer address url for a given path", () => {
const path = "2N16oE62ZjAPup985dFBQYAuy5zpDraH7Hk";
expect(blockExplorerAddressURL(path, Network.TESTNET)).toBe(
`https://blockstream.info/testnet/address/${path}`
`https://mempool.space/testnet/address/${path}`
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/block_explorer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* This module provides functions for creating URLs for Blockstream's
* [block explorer]{@link https://blockstream.info}.
* [block explorer]{@link https://mempool.space}.
*
* This module does NOT provide implementations of HTTP requests which
* fetch data from these URLs.
*/

import { Network } from "./networks";

const BASE_URL_MAINNET = "https://blockstream.info";
const BASE_URL_TESTNET = "https://blockstream.info/testnet";
const BASE_URL_MAINNET = "https://mempool.space";
const BASE_URL_TESTNET = "https://mempool.space/testnet";

function blockExplorerBaseURL(network: Network) {
return network === Network.TESTNET ? BASE_URL_TESTNET : BASE_URL_MAINNET;
Expand Down

0 comments on commit 0e1ca4d

Please sign in to comment.