Skip to content

Commit

Permalink
fix: network indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Dec 14, 2023
1 parent 607e9ec commit 13e0f42
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/client/src/views/home/account/AccountInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { FedimintGatewayCard } from './gateway/FedimintGatewayCard';
// import { useGatewayEcashTotal } from '../../../hooks/UseGatewayEcashTotal';
import { useGatewayState } from '../../../context/GatewayContext';
import { GatewayInfo } from '../../../api/types';
import { getNetworkIndicator } from './network';
import { NetworkIndicator } from './NetworkIndicator';

const S = {
grid: styled.div<{ gatewayInfo?: GatewayInfo | null }>`
Expand Down Expand Up @@ -56,7 +56,7 @@ export const AccountInfo = () => {
<>
<CardWithTitle>
<SubTitle>
Network: {getNetworkIndicator(gatewayInfo?.network || 'unknown')}
<NetworkIndicator network={gatewayInfo?.network || 'unknown'} />
</SubTitle>
{/* <Card>
<ResponsiveLine>
Expand Down
47 changes: 47 additions & 0 deletions src/client/src/views/home/account/NetworkIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { FC } from 'react';

interface NetworkIndicatorProps {
network: string;
// bitcoinRpcUrl: string;
}

const getNetworkDetails = (
network: string
// isMutinynet: boolean
) => {
const networkDetails: { [key: string]: { color: string; name: string } } = {
bitcoin: { color: '#FF9900', name: 'Mainnet' },
main: { color: '#FF9900', name: 'Mainnet' },
testnet: { color: '#6BED33', name: 'Testnet' },
test: { color: '#6BED33', name: 'Testnet' },
signet: { color: 'purple', name: 'Signet' },
// isMutinynet
// ? { color: 'red', name: 'Mutinynet' }
// : { color: 'purple', name: 'Signet' },
regtest: { color: '#33C6EC', name: 'Regtest' },
default: { color: 'gray', name: 'Unknown' },
};

return networkDetails[network] || networkDetails['default'];
};

// const isMutinynet = (bitcoinRpcUrl: string) => {
// try {
// const url = new URL(bitcoinRpcUrl);
// return url.host === 'mutinynet.com';
// } catch (e) {
// return false;
// }
// };

export const NetworkIndicator: FC<NetworkIndicatorProps> = ({
network,
// bitcoinRpcUrl,
}) => {
const { color, name } = getNetworkDetails(
network
// isMutinynet(bitcoinRpcUrl)
);

return <span style={{ color }}>{name}</span>;
};
29 changes: 0 additions & 29 deletions src/client/src/views/home/account/network.tsx

This file was deleted.

0 comments on commit 13e0f42

Please sign in to comment.