Skip to content

Commit 9d2edec

Browse files
authored
Merge pull request #5857 from cowprotocol/release/2025-06-18
chore(release): 2025 06 18
2 parents a07ad8c + 5bd3807 commit 9d2edec

File tree

63 files changed

+1095
-813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1095
-813
lines changed

apps/cowswap-frontend/src/common/hooks/useCancelOrder/useSendOnChainCancellation.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PropsWithChildren } from 'react'
22

3-
import { COW, NATIVE_CURRENCIES } from '@cowprotocol/common-const'
3+
import { COW_TOKEN_TO_CHAIN, NATIVE_CURRENCIES } from '@cowprotocol/common-const'
44
import { useWalletInfo } from '@cowprotocol/wallet'
55
import { BigNumber } from '@ethersproject/bignumber'
66

@@ -105,8 +105,8 @@ describe('useSendOnChainCancellation() + useGetOnChainCancellation()', () => {
105105
invalidateOrder: () => Promise.resolve(BigNumber.from(100)),
106106
},
107107
invalidateOrder: ethFlowInvalidationMock,
108-
// TODO: Replace any with proper type definitions
109-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
108+
// TODO: Replace any with proper type definitions
109+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
110110
} as any,
111111
chainId,
112112
error: null,
@@ -122,8 +122,8 @@ describe('useSendOnChainCancellation() + useGetOnChainCancellation()', () => {
122122
invalidateOrder: () => Promise.resolve(BigNumber.from(200)),
123123
},
124124
invalidateOrder: settlementInvalidationMock,
125-
// TODO: Replace any with proper type definitions
126-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
125+
// TODO: Replace any with proper type definitions
126+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
127127
} as any,
128128
chainId,
129129
error: null,
@@ -154,7 +154,7 @@ describe('useSendOnChainCancellation() + useGetOnChainCancellation()', () => {
154154
it('When is NOT ETH-flow order, then should call settlement contract', async () => {
155155
const { result } = renderHook(() => useSendOnChainCancellation(), { wrapper: WithProviders })
156156

157-
await result.current({ ...orderMock, inputToken: COW[chainId] })
157+
await result.current({ ...orderMock, inputToken: COW_TOKEN_TO_CHAIN[chainId]! })
158158

159159
expect(settlementInvalidationMock).toHaveBeenCalledTimes(1)
160160
expect(settlementInvalidationMock.mock.calls[0]).toMatchSnapshot()
@@ -165,7 +165,7 @@ describe('useSendOnChainCancellation() + useGetOnChainCancellation()', () => {
165165
it('Then should change an order status, set a tx hash to order and add the transaction to store', async () => {
166166
const { result } = renderHook(() => useSendOnChainCancellation(), { wrapper: WithProviders })
167167

168-
await result.current({ ...orderMock, inputToken: COW[chainId] })
168+
await result.current({ ...orderMock, inputToken: COW_TOKEN_TO_CHAIN[chainId]! })
169169

170170
expect(transactionAdder).toHaveBeenCalledTimes(1)
171171
expect(transactionAdder.mock.calls[0]).toMatchSnapshot()

apps/cowswap-frontend/src/common/pure/ApproveButton/index.cosmos.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { COW, GNO_MAINNET } from '@cowprotocol/common-const'
1+
import { COW_TOKEN_TO_CHAIN, GNO_MAINNET } from '@cowprotocol/common-const'
22
import { SupportedChainId } from '@cowprotocol/cow-sdk'
33

44
import { DemoContainer } from 'cosmos.decorator'
@@ -8,21 +8,21 @@ import { ApprovalState } from '../../hooks/useApproveState'
88

99
import { ApproveButton } from '.'
1010

11-
const COW_TOKEN = COW[SupportedChainId.MAINNET]
11+
const COW_TOKEN = COW_TOKEN_TO_CHAIN[SupportedChainId.MAINNET]
1212
const GNO_TOKEN = GNO_MAINNET
1313

1414
// TODO: Add proper return type annotation
1515
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
1616
const Custom = () => {
1717
const [currencyRaw] = useSelect('currency', {
18-
options: [COW_TOKEN.symbol || '', GNO_TOKEN.symbol || ''],
19-
defaultValue: COW_TOKEN.symbol || '',
18+
options: [COW_TOKEN?.symbol || '', GNO_TOKEN.symbol || ''],
19+
defaultValue: COW_TOKEN?.symbol || '',
2020
})
2121
const [state] = useSelect('state', {
2222
options: Object.values(ApprovalState),
2323
defaultValue: ApprovalState.NOT_APPROVED,
2424
})
25-
const currency = currencyRaw === COW_TOKEN.symbol ? COW_TOKEN : GNO_TOKEN
25+
const currency = currencyRaw === COW_TOKEN?.symbol ? COW_TOKEN : GNO_TOKEN
2626

2727
return (
2828
<DemoContainer>

apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/defaultCurrencyInputProps.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { COW } from '@cowprotocol/common-const'
1+
import { COW_TOKEN_TO_CHAIN } from '@cowprotocol/common-const'
22
import { SupportedChainId } from '@cowprotocol/cow-sdk'
33
import { CurrencyAmount, Percent } from '@uniswap/sdk-core'
44

@@ -9,8 +9,8 @@ import { Field } from 'legacy/state/types'
99

1010
import { CurrencyInputPanelProps } from 'common/pure/CurrencyInputPanel/index'
1111

12-
const currency = COW[SupportedChainId.MAINNET]
13-
const balance = CurrencyAmount.fromRawAmount(currency, 250 * 10 ** 18)
12+
const currency = COW_TOKEN_TO_CHAIN[SupportedChainId.MAINNET]
13+
const balance = currency ? CurrencyAmount.fromRawAmount(currency, 250 * 10 ** 18) : null
1414

1515
export const defaultCurrencyInputPanelProps: CurrencyInputPanelProps & { priceImpactParams: PriceImpact } = {
1616
chainId: 100,
@@ -26,8 +26,8 @@ export const defaultCurrencyInputPanelProps: CurrencyInputPanelProps & { priceIm
2626
receiveAmountInfo: inputCurrencyInfoMock.receiveAmountInfo,
2727
currency,
2828
balance,
29-
amount: CurrencyAmount.fromRawAmount(currency, 20 * 10 ** 18),
30-
fiatAmount: CurrencyAmount.fromRawAmount(currency, 12 * 10 ** 18),
29+
amount: currency ? CurrencyAmount.fromRawAmount(currency, 20 * 10 ** 18) : null,
30+
fiatAmount: currency ? CurrencyAmount.fromRawAmount(currency, 12 * 10 ** 18) : null,
3131
},
3232
openTokenSelectWidget() {
3333
/**/
@@ -47,6 +47,6 @@ export const defaultCurrencyInputPanelProps: CurrencyInputPanelProps & { priceIm
4747
tier: 2,
4848
discount: 10,
4949
},
50-
balance,
50+
balance: balance ?? undefined,
5151
},
5252
}

apps/cowswap-frontend/src/common/pure/CurrencyInputPanel/index.cosmos.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { COW } from '@cowprotocol/common-const'
1+
import { COW_TOKEN_TO_CHAIN } from '@cowprotocol/common-const'
22
import { SupportedChainId } from '@cowprotocol/cow-sdk'
33
import { CurrencyAmount, Percent } from '@uniswap/sdk-core'
44

@@ -13,7 +13,7 @@ import { defaultCurrencyInputPanelProps } from './defaultCurrencyInputProps'
1313

1414
import { CurrencyAmountPreview } from '../CurrencyAmountPreview'
1515

16-
const currency = COW[SupportedChainId.MAINNET]
16+
const currency = COW_TOKEN_TO_CHAIN[SupportedChainId.MAINNET]
1717
const defaultProps = defaultCurrencyInputPanelProps
1818

1919
function useCustomProps(): Partial<CurrencyInputPanelProps> {
@@ -30,8 +30,8 @@ function useCustomProps(): Partial<CurrencyInputPanelProps> {
3030

3131
const [priceImpactRaw] = useValue('priceImpactParams.priceImpact', { defaultValue: 2 })
3232

33-
const balance = CurrencyAmount.fromRawAmount(currency, balanceAmountRaw * 10 ** 18)
34-
const fiatAmount = CurrencyAmount.fromRawAmount(currency, fiatAmountRaw * 10 ** 18)
33+
const balance = currency ? CurrencyAmount.fromRawAmount(currency, balanceAmountRaw * 10 ** 18) : null
34+
const fiatAmount = currency ? CurrencyAmount.fromRawAmount(currency, fiatAmountRaw * 10 ** 18) : null
3535
const priceImpact = new Percent(priceImpactRaw, 10_000)
3636

3737
const currencyInfo = {
@@ -52,7 +52,7 @@ function useCustomProps(): Partial<CurrencyInputPanelProps> {
5252
tier: useValue('subsidyAndBalance.tier', { defaultValue: 2 })[0],
5353
discount: useValue('subsidyAndBalance.discount', { defaultValue: 10 })[0],
5454
},
55-
balance,
55+
balance: balance ?? undefined,
5656
}
5757

5858
return { allowsOffchainSigning, showSetMax, currencyInfo, priceImpactParams, subsidyAndBalance }

apps/cowswap-frontend/src/common/pure/CurrencySelectButton/index.cosmos.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { COW, GNO_MAINNET } from '@cowprotocol/common-const'
1+
import { COW_TOKEN_TO_CHAIN, GNO_MAINNET } from '@cowprotocol/common-const'
22
import { SupportedChainId } from '@cowprotocol/cow-sdk'
33

44
import { useSelect } from 'react-cosmos/client'
55

66
import { CurrencySelectButton, CurrencySelectButtonProps } from 'common/pure/CurrencySelectButton/index'
77

8-
const COW_TOKEN = COW[SupportedChainId.MAINNET]
8+
const COW_TOKEN = COW_TOKEN_TO_CHAIN[SupportedChainId.MAINNET]
99
const GNO_TOKEN = GNO_MAINNET
1010

1111
function useCustomProps(): CurrencySelectButtonProps {
1212
const [currencyRaw] = useSelect('currency', {
13-
options: [COW_TOKEN.symbol || '', GNO_TOKEN.symbol || ''],
14-
defaultValue: COW_TOKEN.symbol || '',
13+
options: [COW_TOKEN?.symbol || '', GNO_TOKEN.symbol || ''],
14+
defaultValue: COW_TOKEN?.symbol || '',
1515
})
1616

17-
const currency = currencyRaw === COW_TOKEN.symbol ? COW_TOKEN : GNO_TOKEN
17+
const currency = currencyRaw === COW_TOKEN?.symbol ? COW_TOKEN : GNO_TOKEN
1818

1919
return { currency, loading: false }
2020
}

apps/cowswap-frontend/src/common/pure/RateInfo/index.cosmos.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { COW, GNO_SEPOLIA, USDC_SEPOLIA, WETH_GNOSIS_CHAIN, WETH_SEPOLIA, WXDAI } from '@cowprotocol/common-const'
1+
import {
2+
COW_TOKEN_TO_CHAIN,
3+
GNO_SEPOLIA,
4+
USDC_SEPOLIA,
5+
WETH_GNOSIS_CHAIN,
6+
WETH_SEPOLIA,
7+
WXDAI,
8+
} from '@cowprotocol/common-const'
29
import { SupportedChainId } from '@cowprotocol/cow-sdk'
310
import { TokenSymbol } from '@cowprotocol/ui'
411
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
@@ -10,7 +17,7 @@ import { RateInfo, RateInfoParams } from './index'
1017
const inputCurrency = WETH_GNOSIS_CHAIN
1118
const outputCurrency = WXDAI
1219

13-
const COW_SEPOLIA = COW[SupportedChainId.GNOSIS_CHAIN]
20+
const COW_SEPOLIA = COW_TOKEN_TO_CHAIN[SupportedChainId.SEPOLIA]
1421

1522
const rateInfoParams = {
1623
chainId: 5,
@@ -66,8 +73,8 @@ function SmartQuoteSelection() {
6673
{
6774
title: 'For other cases the quote is a token that has the smallest amount',
6875
examples: [
69-
buildRateInfoParams(COW_SEPOLIA, GNO_SEPOLIA, 12, 652),
70-
buildRateInfoParams(GNO_SEPOLIA, COW_SEPOLIA, 2, 4220),
76+
COW_SEPOLIA ? buildRateInfoParams(COW_SEPOLIA, GNO_SEPOLIA, 12, 652) : undefined,
77+
COW_SEPOLIA ? buildRateInfoParams(GNO_SEPOLIA, COW_SEPOLIA, 2, 4220) : undefined,
7178
],
7279
},
7380
]
@@ -82,7 +89,7 @@ function SmartQuoteSelection() {
8289
<div key={j}>
8390
<p>{title}</p>
8491
{examples.map((rate, i) => {
85-
const { inputCurrencyAmount, outputCurrencyAmount } = rate
92+
const { inputCurrencyAmount, outputCurrencyAmount } = rate || {}
8693

8794
return (
8895
<Box key={i}>
@@ -91,7 +98,7 @@ function SmartQuoteSelection() {
9198
{' -> '}
9299
{outputCurrencyAmount?.toExact()} {<TokenSymbol token={outputCurrencyAmount?.currency} />}{' '}
93100
</p>
94-
<RateInfo noLabel={true} rateInfoParams={rate} />
101+
{rate && <RateInfo noLabel={true} rateInfoParams={rate} />}
95102
</Box>
96103
)
97104
})}

apps/cowswap-frontend/src/common/utils/isOrderCancellable.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { COW } from '@cowprotocol/common-const'
2-
import { NATIVE_CURRENCIES } from '@cowprotocol/common-const'
1+
import { COW_TOKEN_TO_CHAIN, NATIVE_CURRENCIES } from '@cowprotocol/common-const'
32

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

@@ -10,7 +9,7 @@ import { isOrderCancellable } from './isOrderCancellable'
109
describe('isOrderCancellable', () => {
1110
it('When order cancellation in progress, the it cannot be cancelled', () => {
1211
const order = {
13-
inputToken: COW[1],
12+
inputToken: COW_TOKEN_TO_CHAIN[1],
1413
status: OrderStatus.PENDING,
1514
isCancelling: true, // <-----
1615
cancellationHash: undefined,
@@ -22,7 +21,7 @@ describe('isOrderCancellable', () => {
2221

2322
it('When an order has a cancellationHash, the it cannot be cancelled', () => {
2423
const order = {
25-
inputToken: COW[1],
24+
inputToken: COW_TOKEN_TO_CHAIN[1],
2625
status: OrderStatus.PENDING,
2726
isCancelling: false,
2827
cancellationHash: '0x0003', // <-----

apps/cowswap-frontend/src/common/utils/tradeSettingsTooltips.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReactNode } from 'react'
2+
13
import {
24
INPUT_OUTPUT_EXPLANATION,
35
MINIMUM_ETH_FLOW_DEADLINE_SECONDS,
@@ -8,9 +10,7 @@ import { SupportedChainId } from '@cowprotocol/cow-sdk'
810

911
import { Trans } from '@lingui/macro'
1012

11-
// TODO: Add proper return type annotation
12-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
13-
export function getNativeOrderDeadlineTooltip(symbols: (string | undefined)[] | undefined) {
13+
export function getNativeOrderDeadlineTooltip(symbols: (string | undefined)[] | undefined): ReactNode {
1414
return (
1515
<Trans>
1616
{symbols?.[0] || 'Native currency (e.g ETH)'} orders require a minimum transaction expiration time threshold of{' '}
@@ -22,9 +22,7 @@ export function getNativeOrderDeadlineTooltip(symbols: (string | undefined)[] |
2222
)
2323
}
2424

25-
// TODO: Add proper return type annotation
26-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
27-
export function getNonNativeOrderDeadlineTooltip() {
25+
export function getNonNativeOrderDeadlineTooltip(): ReactNode {
2826
return (
2927
<Trans>
3028
Your swap expires and will not execute if it is pending for longer than the selected duration.
@@ -35,12 +33,10 @@ export function getNonNativeOrderDeadlineTooltip() {
3533
)
3634
}
3735

38-
// TODO: Add proper return type annotation
39-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
40-
export const getNativeSlippageTooltip = (chainId: SupportedChainId, symbols: (string | undefined)[] | undefined) => (
36+
export const getNativeSlippageTooltip = (chainId: SupportedChainId, symbols: (string | undefined)[] | undefined): ReactNode => (
4137
<Trans>
4238
When selling {symbols?.[0] || 'a native currency'}, the minimum slippage tolerance is set to{' '}
43-
{MINIMUM_ETH_FLOW_SLIPPAGE[chainId].toSignificant(PERCENTAGE_PRECISION)}% to ensure a high likelihood of order
39+
{MINIMUM_ETH_FLOW_SLIPPAGE[chainId].toSignificant(PERCENTAGE_PRECISION)}% or higher to ensure a high likelihood of order
4440
matching, even in volatile market conditions.
4541
<br />
4642
<br />
@@ -49,9 +45,8 @@ export const getNativeSlippageTooltip = (chainId: SupportedChainId, symbols: (st
4945
</Trans>
5046
)
5147

52-
// TODO: Add proper return type annotation
53-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
54-
export const getNonNativeSlippageTooltip = (params?: { isDynamic?: boolean; isSettingsModal?: boolean }) => (
48+
49+
export const getNonNativeSlippageTooltip = (params?: { isDynamic?: boolean; isSettingsModal?: boolean }): ReactNode => (
5550
<Trans>
5651
{params?.isDynamic ? (
5752
<>

apps/cowswap-frontend/src/legacy/hooks/useCombinedBalance.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo } from 'react'
22

33
import { useCurrencyAmountBalance } from '@cowprotocol/balances-and-allowances'
4-
import { COW } from '@cowprotocol/common-const'
4+
import { COW_TOKEN_TO_CHAIN } from '@cowprotocol/common-const'
55
import { useWalletInfo } from '@cowprotocol/wallet'
66
import { CurrencyAmount } from '@uniswap/sdk-core'
77

@@ -16,7 +16,7 @@ import { useVCowData } from 'legacy/state/cowToken/hooks'
1616
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
1717
function useCowBalance() {
1818
const { chainId } = useWalletInfo()
19-
const cowToken = chainId ? COW[chainId] : undefined
19+
const cowToken = chainId ? COW_TOKEN_TO_CHAIN[chainId] : undefined
2020

2121
return useCurrencyAmountBalance(cowToken)
2222
}
@@ -45,7 +45,7 @@ export function useCombinedBalance() {
4545

4646
const isLoading = !!(account && (isVCowLoading /* || !lockedGnoBalance */ || !cowBalance))
4747

48-
const cow = COW[chainId]
48+
const cowToken = COW_TOKEN_TO_CHAIN[chainId]
4949

5050
if (account) {
5151
if (vCowBalance) tmpBalance = JSBI.add(tmpBalance, vCowBalance.quotient)
@@ -54,7 +54,7 @@ export function useCombinedBalance() {
5454
}
5555

5656
// TODO: check COW vs vCOW
57-
const balance = CurrencyAmount.fromRawAmount(cow, tmpBalance)
57+
const balance = cowToken ? CurrencyAmount.fromRawAmount(cowToken, tmpBalance) : null
5858

5959
return { balance, isLoading }
6060
}, [vCowBalance, /* lockedGnoBalance, */ cowBalance, chainId, account, isVCowLoading])

apps/cowswap-frontend/src/mocks/orderMock.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { COW, USDC } from '@cowprotocol/common-const'
1+
import { COW_TOKEN_TO_CHAIN, USDC } from '@cowprotocol/common-const'
22
import { OrderClass, OrderKind, SigningScheme, SupportedChainId } from '@cowprotocol/cow-sdk'
33

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

66
export const getOrderMock = (chainId: SupportedChainId): Order => {
7-
const inputToken = COW[chainId]
7+
const inputToken = COW_TOKEN_TO_CHAIN[chainId]
8+
9+
if (!inputToken) {
10+
throw new Error('Input token not found')
11+
}
12+
813
const outputToken = USDC[chainId]
914
const creationTime = '2023-05-29T15:27:32.319Z'
1015

0 commit comments

Comments
 (0)