Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testnet support for transaction links, corrected whatsonchain variable name #263

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/TxHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Theme, WhiteLabelTheme } from '../theme.types';
import { useServiceContext } from '../hooks/useServiceContext';
import { useEffect, useMemo, useState } from 'react';
import { HeaderText, Text } from './Reusable';
import { BSV_DECIMAL_CONVERSION, GENERIC_NFT_ICON, GENERIC_TOKEN_ICON, URL_WHATSINCHAIN } from '../utils/constants';
import { BSV_DECIMAL_CONVERSION, GENERIC_NFT_ICON, GENERIC_TOKEN_ICON, URL_WHATSONCHAIN, URL_WHATSONCHAIN_TESTNET } from '../utils/constants';
import { FaTimes, FaChevronDown, FaChevronUp, FaLink, FaTag } from 'react-icons/fa'; // Import FaTag
import { TxLog } from 'spv-store';
import { Button } from './Button';
Expand Down Expand Up @@ -132,6 +132,7 @@ export const TxHistory = (props: TxHistoryProps) => {
const itemsPerPage = 25;
const { gorillaPoolService, chromeStorageService } = useServiceContext();
const [expandedRows, setExpandedRows] = useState<Set<string>>(new Set());
const isTestnet = chromeStorageService.getNetwork() === 'testnet';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of 'testnet' let's use the enum for consistency...

NetWork.Testnet imported from 'yours-wallet-provider'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're pushing a new update so will address this myself with new changes.


const tagPriorityOrder: Tag[] = ['list', 'bsv21', 'bsv20', 'origin', 'lock', 'fund']; // The order of these tags will determine the order of the icons and which is prioritized

Expand Down Expand Up @@ -174,7 +175,8 @@ export const TxHistory = (props: TxHistoryProps) => {
};

const handleOpenLink = (txid: string) => {
window.open(`${URL_WHATSINCHAIN}${txid}`, '_blank');
const url = isTestnet ? `${URL_WHATSONCHAIN_TESTNET}${txid}` : `${URL_WHATSONCHAIN}${txid}`;
window.open(url, '_blank');
};

const getIconForSummary = (tag: Tag, icon?: string) => {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export const WOC_BASE_URL = 'https://api.whatsonchain.com/v1/bsv/main';

export const WOC_TESTNET_BASE_URL = 'https://api.whatsonchain.com/v1/bsv/test';

export const URL_WHATSINCHAIN = 'https://whatsonchain.com/tx/';
export const URL_WHATSONCHAIN = 'https://whatsonchain.com/tx/';
export const URL_WHATSONCHAIN_TESTNET = 'https://test.whatsonchain.com/tx/';

export const GP_BASE_URL = 'https://ordinals.gorillapool.io';
export const JUNGLE_BUS_URL = 'https://junglebus.gorillapool.io';
Expand Down
Loading