Skip to content

Commit d76da53

Browse files
Fix lint errors and improve network validation
Co-Authored-By: nacho@reown.com <nacho@reown.com>
1 parent 043efec commit d76da53

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/core/src/controllers/NetworkController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const NetworkController = {
122122
if (!state.caipNetwork || !state.requestedCaipNetworks?.length) {
123123
return true; // No active network or no requested networks, so no validation needed
124124
}
125+
125126
return state.requestedCaipNetworks.some(network => network.id === state.caipNetwork?.id);
126127
}
127128
};

packages/scaffold/src/modal/w3m-network-button/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ export interface NetworkButtonProps {
1818

1919
export function NetworkButton({ disabled, style }: NetworkButtonProps) {
2020
const { isConnected } = useSnapshot(AccountController.state);
21-
const { caipNetwork } = useSnapshot(NetworkController.state);
21+
const { caipNetwork, requestedCaipNetworks } = useSnapshot(NetworkController.state);
2222
const { loading } = useSnapshot(ModalController.state);
2323
const { themeMode, themeVariables } = useSnapshot(ThemeController.state);
2424

25-
const isNetworkSupported = NetworkController.isActiveNetworkInRequestedNetworks();
25+
const isNetworkSupported = !caipNetwork || !requestedCaipNetworks?.length ||
26+
requestedCaipNetworks.some(network => network.id === caipNetwork.id);
2627

2728
const onNetworkPress = () => {
2829
if (isConnected && !isNetworkSupported) {

packages/wagmi/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ export class AppKit extends AppKitScaffold {
473473

474474
const internalState = this.wagmiConfig.chains || [];
475475
const isNetworkSupported = internalState.length === 0 ||
476-
internalState.some((chain: Chain) =>
477-
`${ConstantsUtil.EIP155}:${chain.id}` === caipChainId);
476+
internalState.some((chainItem: Chain) =>
477+
`${ConstantsUtil.EIP155}:${chainItem.id}` === caipChainId);
478478
if (!isNetworkSupported) {
479479
console.warn(`Network ${caipChainId} is not in the requested networks list`);
480480
}

0 commit comments

Comments
 (0)