Skip to content

Commit

Permalink
feat(frontend): add exporerUrl to BTC networks [GIX-2795] (#2557)
Browse files Browse the repository at this point in the history
# Motivation

The goal is to extend BTC networks with already defined explorer URLs.
It will be used in the BTC transaction detail modal.
  • Loading branch information
DenysKarmazynDFINITY committed Sep 27, 2024
1 parent 2c22341 commit 62d463c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/frontend/src/btc/types/network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Network, NetworkAppMetadata } from '$lib/types/network';

export type BitcoinNetwork = Network & Partial<NetworkAppMetadata>;
18 changes: 13 additions & 5 deletions src/frontend/src/env/networks.env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { ETHEREUM_EXPLORER_URL, SEPOLIA_EXPLORER_URL } from '$env/explorers.env';
import type { BitcoinNetwork } from '$btc/types/network';
import {
BTC_MAINNET_EXPLORER_URL,
BTC_TESTNET_EXPLORER_URL,
ETHEREUM_EXPLORER_URL,
SEPOLIA_EXPLORER_URL
} from '$env/explorers.env';
import { ETH_MAINNET_ENABLED } from '$env/networks.eth.env';
import sepolia from '$eth/assets/sepolia.svg';
import type { EthereumChainId, EthereumNetwork } from '$eth/types/network';
Expand Down Expand Up @@ -82,36 +88,38 @@ export const BTC_MAINNET_NETWORK_SYMBOL = 'BTC';

export const BTC_MAINNET_NETWORK_ID = Symbol(BTC_MAINNET_NETWORK_SYMBOL);

export const BTC_MAINNET_NETWORK: Network = {
export const BTC_MAINNET_NETWORK: BitcoinNetwork = {
id: BTC_MAINNET_NETWORK_ID,
env: 'mainnet',
name: 'Bitcoin',
icon: bitcoin,
explorerUrl: BTC_MAINNET_EXPLORER_URL,
buy: { onramperId: 'bitcoin' }
};

export const BTC_TESTNET_NETWORK_SYMBOL = 'BTC (Testnet)';

export const BTC_TESTNET_NETWORK_ID = Symbol(BTC_TESTNET_NETWORK_SYMBOL);

export const BTC_TESTNET_NETWORK: Network = {
export const BTC_TESTNET_NETWORK: BitcoinNetwork = {
id: BTC_TESTNET_NETWORK_ID,
env: 'testnet',
name: 'Bitcoin',
explorerUrl: BTC_TESTNET_EXPLORER_URL,
icon: bitcoinTestnet
};

export const BTC_REGTEST_NETWORK_SYMBOL = 'BTC (Regtest)';

export const BTC_REGTEST_NETWORK_ID = Symbol(BTC_REGTEST_NETWORK_SYMBOL);

export const BTC_REGTEST_NETWORK: Network = {
export const BTC_REGTEST_NETWORK: BitcoinNetwork = {
id: BTC_REGTEST_NETWORK_ID,
env: 'testnet',
name: 'Bitcoin (Regtest)'
};

export const BITCOIN_NETWORKS: Network[] = [
export const BITCOIN_NETWORKS: BitcoinNetwork[] = [
BTC_MAINNET_NETWORK,
BTC_TESTNET_NETWORK,
...(LOCAL ? [BTC_REGTEST_NETWORK] : [])
Expand Down
8 changes: 2 additions & 6 deletions src/frontend/src/eth/types/network.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import type { Network } from '$lib/types/network';
import type { Network, NetworkAppMetadata } from '$lib/types/network';

export type EthereumChainId = bigint;

export interface NetworkChainId {
chainId: EthereumChainId;
}

export interface EthereumAppMetadata {
explorerUrl: string;
}

export type EthereumNetwork = Network & NetworkChainId & EthereumAppMetadata;
export type EthereumNetwork = Network & NetworkChainId & NetworkAppMetadata;
4 changes: 4 additions & 0 deletions src/frontend/src/lib/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export interface Network {
export interface NetworkBuy {
onramperId?: OnramperNetworkId;
}

export interface NetworkAppMetadata {
explorerUrl: string;
}

0 comments on commit 62d463c

Please sign in to comment.