Skip to content

Commit

Permalink
Hotfix 🔥 - 1.40.1 (#2687)
Browse files Browse the repository at this point in the history
* fix: unsupported chain app crash (#2676)

* chore: version bump

* fix: account page issue

* Revert "chore: version bump"

This reverts commit 8d21bd3.
  • Loading branch information
nenadV91 authored Jun 19, 2023
1 parent 8c87f50 commit eadf970
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/lib/hooks/useNativeCurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { NativeCurrency } from '@uniswap/sdk-core'

import { nativeOnChain } from 'legacy/constants/tokens'
import { supportedChainId } from 'legacy/utils/supportedChainId'

import { useWalletInfo } from 'modules/wallet'

export const MAINNET_NATIVE_CURRENCY = nativeOnChain(SupportedChainId.MAINNET)

export default function useNativeCurrency(): NativeCurrency {
const { chainId } = useWalletInfo()
const { chainId: _chainId } = useWalletInfo()
const chainId = supportedChainId(_chainId)

return useMemo(
() =>
chainId
Expand Down
5 changes: 5 additions & 0 deletions src/modules/trade/hooks/useIsNativeInOrOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react'
import { SupportedChainId } from '@cowprotocol/cow-sdk'

import { NATIVE_CURRENCY_BUY_TOKEN } from 'legacy/constants'
import { supportedChainId } from 'legacy/utils/supportedChainId'

import { useWalletInfo } from 'modules/wallet'

Expand All @@ -13,6 +14,10 @@ import { useTradeState } from './useTradeState'
function getIsNativeToken(chainId: SupportedChainId, tokenId: string): boolean {
const nativeToken = NATIVE_CURRENCY_BUY_TOKEN[chainId]

if (!supportedChainId(chainId)) {
return false
}

return doesTokenMatchSymbolOrAddress(nativeToken, tokenId)
}

Expand Down
5 changes: 5 additions & 0 deletions src/modules/trade/hooks/useIsWrappedInOrOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react'
import { SupportedChainId } from '@cowprotocol/cow-sdk'

import { WRAPPED_NATIVE_CURRENCY } from 'legacy/constants/tokens'
import { supportedChainId } from 'legacy/utils/supportedChainId'

import { useWalletInfo } from 'modules/wallet'

Expand All @@ -13,6 +14,10 @@ import { useTradeState } from './useTradeState'
function getIsWrappedNativeToken(chainId: SupportedChainId, tokenId: string): boolean {
const nativeToken = WRAPPED_NATIVE_CURRENCY[chainId]

if (!supportedChainId(chainId)) {
return false
}

return doesTokenMatchSymbolOrAddress(nativeToken, tokenId)
}

Expand Down
5 changes: 4 additions & 1 deletion src/pages/Account/Balances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { SwapVCowStatus } from 'legacy/state/cowToken/actions'
import { useVCowData, useSwapVCowCallback, useSetSwapVCowStatus, useSwapVCowStatus } from 'legacy/state/cowToken/hooks'
import { getBlockExplorerUrl } from 'legacy/utils'
import { getProviderErrorMessage } from 'legacy/utils/misc'
import { supportedChainId } from 'legacy/utils/supportedChainId'

import { useTokenBalance } from 'modules/tokens/hooks/useCurrencyBalance'
import { useWalletInfo } from 'modules/wallet'
Expand Down Expand Up @@ -71,7 +72,9 @@ export default function Profile() {
const vCowToken = V_COW[chainId]
// Cow balance
const cow =
useTokenBalance(account || undefined, chainId ? cowToken : undefined) || CurrencyAmount.fromRawAmount(cowToken, 0)
useTokenBalance(account || undefined, chainId ? cowToken : undefined) || supportedChainId(chainId)
? CurrencyAmount.fromRawAmount(cowToken, 0)
: null

// vCow balance values
const { unvested, vested, total, isLoading: isVCowLoading } = useVCowData()
Expand Down

0 comments on commit eadf970

Please sign in to comment.