Skip to content

Commit

Permalink
Merge branch 'main' into feat(frontend)/add-info-box-in-activity-page
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii authored Nov 14, 2024
2 parents 1a2c336 + ee7d41e commit 4070880
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/frontend/src/lib/utils/network.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
BTC_REGTEST_NETWORK_ID,
BTC_TESTNET_NETWORK_ID,
ICP_NETWORK_ID,
SEPOLIA_NETWORK_ID,
SUPPORTED_ETHEREUM_NETWORKS_IDS
} from '$env/networks.env';
import { isTokenIcrcTestnet } from '$icp/utils/icrc-ledger.utils';
Expand Down Expand Up @@ -33,6 +34,9 @@ export const isNetworkIdBTCTestnet = (networkId: NetworkId | undefined): boolean
export const isNetworkIdBTCRegtest = (networkId: NetworkId | undefined): boolean =>
BTC_REGTEST_NETWORK_ID === networkId;

export const isNetworkIdSepolia = (networkId: NetworkId | undefined): boolean =>
SEPOLIA_NETWORK_ID === networkId;

const mapper: Record<symbol, BitcoinNetwork> = {
[BTC_MAINNET_NETWORK_ID]: 'mainnet',
[BTC_TESTNET_NETWORK_ID]: 'testnet',
Expand Down
13 changes: 13 additions & 0 deletions src/frontend/src/tests/lib/utils/network.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
isNetworkIdBitcoin,
isNetworkIdEthereum,
isNetworkIdICP,
isNetworkIdSepolia,
mapNetworkIdToBitcoinNetwork
} from '$lib/utils/network.utils';

Expand Down Expand Up @@ -127,6 +128,18 @@ describe('network utils', () => {
});
});

describe('isNetworkIdSepolia', () => {
it('should return true for Sepolia network ID', () => {
expect(isNetworkIdSepolia(SEPOLIA_NETWORK_ID)).toBe(true);
});

it('should return false for non-Sepolia network ID', () => {
expect(isNetworkIdSepolia(ETHEREUM_NETWORK_ID)).toBe(false);

expect(isNetworkIdSepolia(ICP_NETWORK_ID)).toBe(false);
});
});

describe('mapNetworkIdToBitcoinNetwork', () => {
it('should map network id to bitcoin network', () => {
expect(mapNetworkIdToBitcoinNetwork(BTC_MAINNET_NETWORK_ID)).toBe('mainnet');
Expand Down

0 comments on commit 4070880

Please sign in to comment.