Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8] refactor: rename native and wrapped tokens consts #3211

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { COW, NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { COW, NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useEthFlowContract, useGP2SettlementContract } from '@cowprotocol/common-hooks'
import { useWalletInfo } from '@cowprotocol/wallet'
import { BigNumber } from '@ethersproject/bignumber'
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('useSendOnChainCancellation() + useGetOnChainCancellation()', () => {
it('When is ETH-flow order, then should call eth-flow contract', async () => {
const { result } = renderHook(() => useSendOnChainCancellation(), { wrapper: WithMockedWeb3 })

await result.current({ ...orderMock, inputToken: NATIVE_CURRENCY_BUY_TOKEN[chainId] })
await result.current({ ...orderMock, inputToken: NATIVE_TOKEN[chainId] })

expect(ethFlowInvalidationMock).toHaveBeenCalledTimes(1)
expect(ethFlowInvalidationMock.mock.calls[0]).toMatchSnapshot()
Expand Down
4 changes: 2 additions & 2 deletions apps/cowswap-frontend/src/common/hooks/useNativeBalance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NATIVE_CURRENCY_BUY_TOKEN, TokenWithLogo } from '@cowprotocol/common-const'
import { NATIVE_TOKEN, TokenWithLogo } from '@cowprotocol/common-const'
import { useWalletInfo } from '@cowprotocol/wallet'
import { CurrencyAmount } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
Expand All @@ -20,7 +20,7 @@ export function useNativeBalance(): SWRResponse<CurrencyAmount<TokenWithLogo> |
() => {
if (!account || !provider) return null

const nativeToken = NATIVE_CURRENCY_BUY_TOKEN[chainId]
const nativeToken = NATIVE_TOKEN[chainId]

return provider.getBalance(account).then((res) => CurrencyAmount.fromRawAmount(nativeToken, res.toHexString()))
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useState } from 'react'

import { setMaxSellTokensAnalytics } from '@cowprotocol/analytics'
import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { formatInputAmount, getIsNativeToken } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { TokenAmount } from '@cowprotocol/ui'
Expand Down Expand Up @@ -108,7 +108,7 @@ export function CurrencyInputPanel(props: CurrencyInputPanelProps) {

const selectedTokenAddress = currency
? getIsNativeToken(currency)
? NATIVE_CURRENCY_BUY_TOKEN[currency.chainId as SupportedChainId].address
? NATIVE_TOKEN[currency.chainId as SupportedChainId].address
: currency.address
: undefined

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSetAtom } from 'jotai'
import { useCallback, useEffect, useMemo, useRef } from 'react'

import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { EnrichedOrder, EthflowData, OrderClass, SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { useAllTokens } from '@cowprotocol/tokens'
import { useWalletInfo } from '@cowprotocol/wallet'
Expand Down Expand Up @@ -112,7 +112,7 @@ function _getInputToken(
sellToken: string,
allTokens: { [address: string]: Token }
): ReturnType<typeof getTokenFromMapping> {
return isEthFlow ? NATIVE_CURRENCY_BUY_TOKEN[chainId] : getTokenFromMapping(sellToken, chainId, allTokens)
return isEthFlow ? NATIVE_TOKEN[chainId] : getTokenFromMapping(sellToken, chainId, allTokens)
}

function _filterOrders(orders: EnrichedOrder[], tokens: Record<string, Token>, chainId: ChainId): Order[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useSetAtom } from 'jotai'
import { useCallback, useEffect, useMemo, useRef } from 'react'

import { priceOutOfRangeAnalytics } from '@cowprotocol/analytics'
import { GP_VAULT_RELAYER, NATIVE_CURRENCY_BUY_ADDRESS, WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { GP_VAULT_RELAYER, NATIVE_CURRENCY_BUY_ADDRESS, WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useIsWindowVisible } from '@cowprotocol/common-hooks'
import { getPromiseFulfilledValue } from '@cowprotocol/common-utils'
import { timestamp } from '@cowprotocol/contracts'
Expand Down Expand Up @@ -249,7 +249,7 @@ async function _getOrderPrice(
amount,
kind: order.kind,
// we need to get wrapped token quotes (native quotes will fail)
sellToken: isEthFlow ? WRAPPED_NATIVE_CURRENCY[chainId].address : order.sellToken,
sellToken: isEthFlow ? WRAPPED_NATIVE_TOKEN[chainId].address : order.sellToken,
buyToken: order.buyToken,
baseToken,
quoteToken,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { COW } from '@cowprotocol/common-const'
import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'

import { Order, OrderStatus } from 'legacy/state/orders/actions'

Expand Down Expand Up @@ -32,7 +32,7 @@ describe('isOrderCancellable', () => {

it("When an order's status is CREATING, then the order is cancellable", () => {
const order = {
inputToken: NATIVE_CURRENCY_BUY_TOKEN[1],
inputToken: NATIVE_TOKEN[1],
status: OrderStatus.CREATING, // <- CREATING
isCancelling: false,
cancellationHash: undefined,
Expand All @@ -44,7 +44,7 @@ describe('isOrderCancellable', () => {

it("When an order's status is PENDING, then the order is cancellable", () => {
const order = {
inputToken: NATIVE_CURRENCY_BUY_TOKEN[1],
inputToken: NATIVE_TOKEN[1],
status: OrderStatus.PENDING, // <- PENDING
isCancelling: false,
cancellationHash: undefined,
Expand All @@ -63,7 +63,7 @@ describe('isOrderCancellable', () => {
OrderStatus.EXPIRED,
].forEach((status) => {
const order = {
inputToken: NATIVE_CURRENCY_BUY_TOKEN[1],
inputToken: NATIVE_TOKEN[1],
status, // <----
isCancelling: false,
cancellationHash: undefined,
Expand Down
4 changes: 2 additions & 2 deletions apps/cowswap-frontend/src/legacy/state/claim/hooks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { USDC, GNO, ZERO_PERCENT, ONE_HUNDRED_PERCENT, NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { USDC, GNO, ZERO_PERCENT, ONE_HUNDRED_PERCENT, NATIVE_TOKEN } from '@cowprotocol/common-const'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core'

Expand Down Expand Up @@ -107,7 +107,7 @@ export function claimTypeToToken(type: ClaimType, chainId: SupportedChainId) {
case ClaimType.Investor:
return USDC[chainId]
case ClaimType.UserOption:
return NATIVE_CURRENCY_BUY_TOKEN[chainId]
return NATIVE_TOKEN[chainId]
case ClaimType.Advisor:
case ClaimType.Airdrop:
case ClaimType.Team:
Expand Down
6 changes: 3 additions & 3 deletions apps/cowswap-frontend/src/legacy/state/swap/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NATIVE_CURRENCY_BUY_TOKEN, WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { NATIVE_TOKEN, WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { parsedQueryString } from '@cowprotocol/common-hooks'
import { getIsNativeToken, getIsWrapOrUnwrap } from '@cowprotocol/common-utils'
import { SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
Expand Down Expand Up @@ -162,7 +162,7 @@ function getEthFlowOverridesOnSwitch(state: SwapState): Pick<SwapState, 'indepen

const isNativeOut = getIsNativeToken(chainId, outputCurrencyId || '')
const isWrapUnwrap = getIsWrapOrUnwrap(chainId, inputCurrencyId, outputCurrencyId)
const isWrappedIn = inputCurrencyId === WRAPPED_NATIVE_CURRENCY[chainId].symbol?.toUpperCase()
const isWrappedIn = inputCurrencyId === WRAPPED_NATIVE_TOKEN[chainId].symbol?.toUpperCase()

if (isWrapUnwrap) {
return state
Expand Down Expand Up @@ -199,7 +199,7 @@ function getEthFlowOverridesOnSelect(
): Pick<SwapState, 'independentField' | 'typedValue'> {
if (
inputCurrencyId?.toUpperCase() ===
NATIVE_CURRENCY_BUY_TOKEN[(state.chainId as ChainId) || ChainId.MAINNET]?.symbol?.toUpperCase()
NATIVE_TOKEN[(state.chainId as ChainId) || ChainId.MAINNET]?.symbol?.toUpperCase()
) {
const independentField = Field.INPUT
const formerIndependentField = state.independentField
Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/legacy/state/swap/trade.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEFAULT_PRECISION, LONG_PRECISION, WRAPPED_NATIVE_CURRENCY as WETH } from '@cowprotocol/common-const'
import { DEFAULT_PRECISION, LONG_PRECISION, WRAPPED_NATIVE_TOKEN as WETH } from '@cowprotocol/common-const'
import { OrderKind } from '@cowprotocol/cow-sdk'
import { SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { parseUnits } from '@ethersproject/units'
Expand Down
4 changes: 2 additions & 2 deletions apps/cowswap-frontend/src/legacy/state/swap/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TOKEN_SHORTHANDS, WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { TOKEN_SHORTHANDS, WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { getIsNativeToken, getWrappedToken, isAddress } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { Currency } from '@uniswap/sdk-core'
Expand All @@ -16,7 +16,7 @@ export function isWrappingTrade(
): boolean {
if (!chainId) return false

const wethByChain = WRAPPED_NATIVE_CURRENCY[chainId]
const wethByChain = WRAPPED_NATIVE_TOKEN[chainId]

return Boolean(
(sellCurrency &&
Expand Down
6 changes: 2 additions & 4 deletions apps/cowswap-frontend/src/legacy/state/user/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useMemo } from 'react'

import { L2_DEADLINE_FROM_NOW, NATIVE_CURRENCY_BUY_TOKEN, SupportedLocale } from '@cowprotocol/common-const'
import { L2_DEADLINE_FROM_NOW, NATIVE_TOKEN, SupportedLocale } from '@cowprotocol/common-const'
import { calculateValidTo, getIsNativeToken } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { useWalletInfo } from '@cowprotocol/wallet'
Expand Down Expand Up @@ -232,9 +232,7 @@ export function useSelectedWallet(): string | undefined {
}

export function serializeToken(token: Currency): SerializedToken {
const address = getIsNativeToken(token)
? NATIVE_CURRENCY_BUY_TOKEN[token.chainId as SupportedChainId].address
: token.address
const address = getIsNativeToken(token) ? NATIVE_TOKEN[token.chainId as SupportedChainId].address : token.address

return {
chainId: token.chainId,
Expand Down
6 changes: 3 additions & 3 deletions apps/cowswap-frontend/src/lib/hooks/useNativeCurrency.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useMemo } from 'react'

import { NATIVE_CURRENCY_BUY_TOKEN, TokenWithLogo } from '@cowprotocol/common-const'
import { NATIVE_TOKEN, TokenWithLogo } from '@cowprotocol/common-const'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { useWalletInfo } from '@cowprotocol/wallet'

export const MAINNET_NATIVE_CURRENCY = NATIVE_CURRENCY_BUY_TOKEN[SupportedChainId.MAINNET]
export const MAINNET_NATIVE_CURRENCY = NATIVE_TOKEN[SupportedChainId.MAINNET]

export default function useNativeCurrency(): TokenWithLogo {
const { chainId } = useWalletInfo()

return useMemo(() => NATIVE_CURRENCY_BUY_TOKEN[chainId], [chainId])
return useMemo(() => NATIVE_TOKEN[chainId], [chainId])
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useSetAtom } from 'jotai'
import { useAtomValue } from 'jotai'
import { useMemo } from 'react'

import { WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useWalletInfo } from '@cowprotocol/wallet'

import { WrapUnwrapCallback } from 'legacy/hooks/useWrapCallback'
Expand Down Expand Up @@ -69,7 +69,7 @@ export function useEthFlowActions(callbacks: EthFlowActionCallbacks): EthFlowAct
if (!chainId || !trade) return

callbacks.dismiss()
onCurrencySelection(Field.INPUT, WRAPPED_NATIVE_CURRENCY[chainId])
onCurrencySelection(Field.INPUT, WRAPPED_NATIVE_TOKEN[chainId])
openSwapConfirmModal(trade)
}

Expand All @@ -95,7 +95,7 @@ export function useEthFlowActions(callbacks: EthFlowActionCallbacks): EthFlowAct
if (!chainId || !trade) return

callbacks.dismiss()
onCurrencySelection(Field.INPUT, WRAPPED_NATIVE_CURRENCY[chainId])
onCurrencySelection(Field.INPUT, WRAPPED_NATIVE_TOKEN[chainId])
callbacks.directSwap()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSetAtom } from 'jotai'

import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useEthFlowContract } from '@cowprotocol/common-hooks'
import { OrderKind, SupportedChainId } from '@cowprotocol/cow-sdk'

Expand All @@ -23,7 +23,7 @@ export function useEthFlowContext(): EthFlowContext | null {

const baseContext = getFlowContext({
baseProps,
sellToken: baseProps.chainId ? NATIVE_CURRENCY_BUY_TOKEN[baseProps.chainId as SupportedChainId] : undefined,
sellToken: baseProps.chainId ? NATIVE_TOKEN[baseProps.chainId as SupportedChainId] : undefined,
kind: OrderKind.SELL,
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Erc20, Weth } from '@cowprotocol/abis'
import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useTokenContract, useWETHContract } from '@cowprotocol/common-hooks'
import { calculateValidTo, getAddress, getIsNativeToken } from '@cowprotocol/common-utils'
import { OrderClass, OrderKind, SupportedChainId } from '@cowprotocol/cow-sdk'
Expand Down Expand Up @@ -199,7 +199,7 @@ export function getFlowContext({ baseProps, sellToken, kind }: BaseGetFlowContex
const isGnosisSafeWallet = !!gnosisSafeInfo

const buyToken = getIsNativeToken(trade.outputAmount.currency)
? NATIVE_CURRENCY_BUY_TOKEN[chainId as SupportedChainId]
? NATIVE_TOKEN[chainId as SupportedChainId]
: trade.outputAmount.currency
const marketLabel = [sellToken?.symbol, buyToken.symbol].join(',')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { getWrappedToken } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'

import { EthFlowBannerContent, EthFlowBannerContentProps } from '.'

const defaultProps: EthFlowBannerContentProps = {
native: NATIVE_CURRENCY_BUY_TOKEN[SupportedChainId.MAINNET],
native: NATIVE_TOKEN[SupportedChainId.MAINNET],
get wrapped() {
return getWrappedToken(this.native)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WRAPPED_NATIVE_CURRENCY as WETH } from '@cowprotocol/common-const'
import { WRAPPED_NATIVE_TOKEN as WETH } from '@cowprotocol/common-const'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { CurrencyAmount } from '@uniswap/sdk-core'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode } from 'react'

import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { genericPropsChecker, getWrappedToken } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { AutoRow, ButtonError, ButtonPrimary, ButtonSize, TokenSymbol } from '@cowprotocol/ui'
Expand Down Expand Up @@ -72,8 +72,8 @@ const swapButtonStateMap: { [key in SwapButtonState]: (props: SwapButtonsContext
[SwapButtonState.TransferToSmartContract]: (props: SwapButtonsContext) => (
<GreyCard style={{ textAlign: 'center' }}>
<Trans>
Buying {NATIVE_CURRENCY_BUY_TOKEN[(props.chainId as SupportedChainId) || SupportedChainId.MAINNET].symbol} with
smart contract wallets is not currently supported
Buying {NATIVE_TOKEN[(props.chainId as SupportedChainId) || SupportedChainId.MAINNET].symbol} with smart
contract wallets is not currently supported
</Trans>
</GreyCard>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NATIVE_CURRENCY_BUY_TOKEN, WRAPPED_NATIVE_CURRENCY as WETH } from '@cowprotocol/common-const'
import { NATIVE_TOKEN, WRAPPED_NATIVE_TOKEN as WETH } from '@cowprotocol/common-const'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { CurrencyAmount } from '@uniswap/sdk-core'

Expand All @@ -9,7 +9,7 @@ import { WrappingPreviewProps } from 'modules/swap/pure/EthFlow/WrappingPreview'
import { EthFlowState } from 'modules/swap/services/ethFlow/types'
import { defaultEthFlowContext, EthFlowActionContext } from 'modules/swap/state/EthFlow/ethFlowContextAtom'

const native = NATIVE_CURRENCY_BUY_TOKEN[SupportedChainId.GOERLI]
const native = NATIVE_TOKEN[SupportedChainId.GOERLI]
const wrapped = WETH[SupportedChainId.GOERLI]
const nativeInput = CurrencyAmount.fromRawAmount(native, 5.987654 * 10 ** 18)
const nativeBalance = CurrencyAmount.fromRawAmount(native, 15.12123 * 10 ** 18)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CoWSwapEthFlow } from '@cowprotocol/abis'
import { WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { MAX_VALID_TO_EPOCH } from '@cowprotocol/common-utils'
import type { Order } from '@cowprotocol/contracts'
import { OrderSigningUtils } from '@cowprotocol/cow-sdk'
Expand Down Expand Up @@ -47,7 +47,7 @@ export async function calculateUniqueOrderId(
const orderDigest = hashOrder(domain, {
...order,
validTo: MAX_VALID_TO_EPOCH,
sellToken: WRAPPED_NATIVE_CURRENCY[chainId].address,
sellToken: WRAPPED_NATIVE_TOKEN[chainId].address,
} as Order)
// Generate the orderId from owner, orderDigest, and max validTo
const orderId = packOrderUidParams({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useMemo } from 'react'

import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useInterfaceMulticall } from '@cowprotocol/common-hooks'
import { getIsNativeToken, isAddress } from '@cowprotocol/common-utils'
import { useWalletInfo } from '@cowprotocol/wallet'
Expand Down Expand Up @@ -49,7 +49,7 @@ export function useNativeCurrencyBalances(
const value = results?.[i]?.result?.[0]
if (value && chainId)
memo[lowerCaseAddress ? address.toLowerCase() : address] = CurrencyAmount.fromRawAmount(
NATIVE_CURRENCY_BUY_TOKEN[chainId],
NATIVE_TOKEN[chainId],
JSBI.BigInt(value.toString())
)
return memo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react'

import { WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { NATIVE_TOKEN } from '@cowprotocol/common-const'
import { useWalletInfo } from '@cowprotocol/wallet'

import { useTradeNavigate } from './useTradeNavigate'
Expand All @@ -20,8 +20,8 @@ export function useDisableNativeTokenSelling() {
const navigate = useTradeNavigate()

useEffect(() => {
const nativeToken = chainId ? NATIVE_CURRENCY_BUY_TOKEN[chainId] : null
const wrappedToken = chainId ? WRAPPED_NATIVE_CURRENCY[chainId] : null
const nativeToken = chainId ? NATIVE_TOKEN[chainId] : null
const wrappedToken = chainId ? WRAPPED_NATIVE_TOKEN[chainId] : null

if (!chainId || !nativeToken || !wrappedToken) return

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useMemo } from 'react'

import { WRAPPED_NATIVE_CURRENCY } from '@cowprotocol/common-const'
import { WRAPPED_NATIVE_TOKEN } from '@cowprotocol/common-const'
import { doesTokenMatchSymbolOrAddress } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { useWalletInfo } from '@cowprotocol/wallet'

import { useTradeState } from './useTradeState'

function getIsWrappedNativeToken(chainId: SupportedChainId, tokenId: string): boolean {
const nativeToken = WRAPPED_NATIVE_CURRENCY[chainId]
const nativeToken = WRAPPED_NATIVE_TOKEN[chainId]

return doesTokenMatchSymbolOrAddress(nativeToken, tokenId)
}
Expand Down
Loading