Skip to content

Commit cf2f81c

Browse files
authored
fix: [lw-11726] filter available networks by ft availability for shared wallet (#1473)
1 parent 248659b commit cf2f81c

File tree

1 file changed

+15
-2
lines changed
  • apps/browser-extension-wallet/src/views/browser-view/features/settings/components

1 file changed

+15
-2
lines changed

apps/browser-extension-wallet/src/views/browser-view/features/settings/components/NetworkChoice.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { config } from '@src/config';
1111
import { useWalletManager } from '@hooks';
1212
import { useAnalyticsContext } from '@providers';
1313
import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
14+
import { usePostHogClientContext } from '@providers/PostHogClientProvider';
1415

1516
const { AVAILABLE_CHAINS } = config();
1617

@@ -40,9 +41,17 @@ const walletProfileEventByNetworkName: Record<Wallet.ChainName, networkEventUser
4041
Sanchonet: PostHogAction.UserWalletProfileNetworkSanchonetClick
4142
};
4243

44+
export const cardanoNetworkMap: { [key in Wallet.ChainName]: Wallet.Cardano.NetworkMagics } = {
45+
Mainnet: Wallet.Cardano.NetworkMagics.Mainnet,
46+
Preprod: Wallet.Cardano.NetworkMagics.Preprod,
47+
Preview: Wallet.Cardano.NetworkMagics.Preview,
48+
Sanchonet: Wallet.Cardano.NetworkMagics.Sanchonet
49+
};
50+
4351
export const NetworkChoice = ({ section }: { section?: 'settings' | 'wallet-profile' }): React.ReactElement => {
4452
const { t } = useTranslation();
45-
const { environmentName } = useWalletStore();
53+
const posthog = usePostHogClientContext();
54+
const { environmentName, isSharedWallet } = useWalletStore();
4655
const { switchNetwork } = useWalletManager();
4756
const analytics = useAnalyticsContext();
4857

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

93+
const availableChains = isSharedWallet
94+
? AVAILABLE_CHAINS.filter((chain) => posthog?.featureFlags[cardanoNetworkMap[chain]]['shared-wallets'])
95+
: AVAILABLE_CHAINS;
96+
8497
return (
8598
<Radio.Group
8699
className={styles.radioGroup}
87100
onChange={handleNetworkChange}
88101
value={environmentName}
89102
data-testid={'network-choice-radio-group'}
90103
>
91-
{AVAILABLE_CHAINS.map((network) => (
104+
{availableChains.map((network) => (
92105
<a className={styles.radio} key={network}>
93106
<Radio
94107
value={network}

0 commit comments

Comments
 (0)