Skip to content

Commit

Permalink
fix: default network selection logic in connection flow (#30139)
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 authored Feb 5, 2025
1 parent c09f80b commit e7e8488
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ui/pages/permissions-connect/connect-page/connect-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,22 @@ export const ConnectPage: React.FC<ConnectPageProps> = ({
network.chainId === currentlySelectedNetworkChainId,
);

const selectedNetworksList = selectedTestNetwork
const defaultSelectedNetworkList = selectedTestNetwork
? [...nonTestNetworks, selectedTestNetwork].map(({ chainId }) => chainId)
: nonTestNetworks.map(({ chainId }) => chainId);

const allNetworksList = [...nonTestNetworks, ...testNetworks].map(
({ chainId }) => chainId,
);

const supportedRequestedChainIds = requestedChainIds.filter((chainId) =>
selectedNetworksList.includes(chainId),
allNetworksList.includes(chainId),
);

const defaultSelectedChainIds =
supportedRequestedChainIds.length > 0
? supportedRequestedChainIds
: selectedNetworksList;
: defaultSelectedNetworkList;

const [selectedChainIds, setSelectedChainIds] = useState(
defaultSelectedChainIds,
Expand Down

0 comments on commit e7e8488

Please sign in to comment.