Skip to content

Commit

Permalink
fix: mev toggle display logic (#11061)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->


<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing the `useShouldShowMEVToggle` hook by adding
a check for the `chainId` to ensure that the MEV toggle is only shown
when the user is connected to the Binance Smart Chain (BSC).

### Detailed summary
- Added `chainId` to the destructured return of `useActiveWeb3React()`.
- Updated the return condition to include a check for `chainId ===
ChainId.BSC`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
Chef-Yogi authored Dec 19, 2024
1 parent c6386f9 commit 96ba8e0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/web/src/views/Mev/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,21 @@ export function useIsMEVEnabled() {
staleTime: 60000,
})

return { isMEVEnabled: data?.mevEnabled ?? false, isLoading, refetch }
return { isMEVEnabled: data?.mevEnabled ?? false, isLoading, refetch, isMEVProtectAvailable: chainId === ChainId.BSC }
}

export const useShouldShowMEVToggle = () => {
const { walletSupportsAddEthereumChain, isLoading: isWalletSupportLoading } = useWalletSupportsAddEthereumChain()
const { account } = useActiveWeb3React()
const { isMEVEnabled, isLoading } = useIsMEVEnabled()
return !isMEVEnabled && !isLoading && !isWalletSupportLoading && Boolean(account) && walletSupportsAddEthereumChain
const { isMEVEnabled, isLoading, isMEVProtectAvailable } = useIsMEVEnabled()
return (
!isMEVEnabled &&
!isLoading &&
!isWalletSupportLoading &&
Boolean(account) &&
walletSupportsAddEthereumChain &&
isMEVProtectAvailable
)
}

export const useAddMevRpc = (onSuccess?: () => void, onBeforeStart?: () => void, onFinish?: () => void) => {
Expand Down

0 comments on commit 96ba8e0

Please sign in to comment.