Skip to content

Commit

Permalink
fix: [lw-11726] filter available networks by ft availability for shar…
Browse files Browse the repository at this point in the history
…ed wallet
  • Loading branch information
vetalcore committed Oct 18, 2024
1 parent ac8887b commit 8a8caf8
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { config } from '@src/config';
import { useWalletManager } from '@hooks';
import { useAnalyticsContext } from '@providers';
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
import { usePostHogClientContext } from '@providers/PostHogClientProvider';

const { AVAILABLE_CHAINS } = config();

Expand Down Expand Up @@ -40,9 +41,17 @@ const walletProfileEventByNetworkName: Record<Wallet.ChainName, networkEventUser
Sanchonet: PostHogAction.UserWalletProfileNetworkSanchonetClick
};

export const cardanoNetworkMap: { [key in Wallet.ChainName]: Wallet.Cardano.NetworkMagics } = {
Mainnet: Wallet.Cardano.NetworkMagics.Mainnet,
Preprod: Wallet.Cardano.NetworkMagics.Preprod,
Preview: Wallet.Cardano.NetworkMagics.Preview,
Sanchonet: Wallet.Cardano.NetworkMagics.Sanchonet
};

export const NetworkChoice = ({ section }: { section?: 'settings' | 'wallet-profile' }): React.ReactElement => {
const { t } = useTranslation();
const { environmentName } = useWalletStore();
const posthog = usePostHogClientContext();
const { environmentName, isSharedWallet } = useWalletStore();
const { switchNetwork } = useWalletManager();
const analytics = useAnalyticsContext();

Expand Down Expand Up @@ -81,14 +90,18 @@ export const NetworkChoice = ({ section }: { section?: 'settings' | 'wallet-prof
return event;
};

const availableChains = isSharedWallet
? AVAILABLE_CHAINS.filter((chain) => posthog?.featureFlags[cardanoNetworkMap[chain]]['shared-wallets'])
: AVAILABLE_CHAINS;

return (
<Radio.Group
className={styles.radioGroup}
onChange={handleNetworkChange}
value={environmentName}
data-testid={'network-choice-radio-group'}
>
{AVAILABLE_CHAINS.map((network) => (
{availableChains.map((network) => (
<a className={styles.radio} key={network}>
<Radio
value={network}
Expand Down

0 comments on commit 8a8caf8

Please sign in to comment.