Skip to content

Commit

Permalink
hot fix: don't reset chainId to default network (arbitrum) if chain i…
Browse files Browse the repository at this point in the history
…s set (#217)
  • Loading branch information
Diogomartf authored Dec 18, 2024
1 parent f8d425b commit 2998434
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/app/contexts/NetworkContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ interface NetworkContextProviderProps {
children: ReactNode;
}

const INVALID_CHAIN_ID = 0;

export const NetworkContextProvider = ({
children,
}: NetworkContextProviderProps) => {
Expand Down Expand Up @@ -90,7 +92,8 @@ export const NetworkContextProvider = ({
useEffect(() => {
const parsedSearchParamsChainId = searchParamsChainId
? parseInt(searchParamsChainId)
: 0;
: INVALID_CHAIN_ID;

const newChainIsDiferentFromCurrent =
parsedSearchParamsChainId !== chain?.id;

Expand All @@ -116,9 +119,14 @@ export const NetworkContextProvider = ({
}
}
}
// set default chain
setSelectedChain(arbitrum);
setSelectedChainId(arbitrum.id);

const chainIsNotSet = !chain?.id;

if (!isValidSearchParamsChainId && chainIsNotSet) {
// set default chain
setSelectedChain(arbitrum);
setSelectedChainId(arbitrum.id);
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isConnected, chains, searchParamsChainId, switchChain]);
Expand Down

0 comments on commit 2998434

Please sign in to comment.