Skip to content

Commit

Permalink
Merge branch 'develop' into feat/limit-ui-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito committed Jan 15, 2025
2 parents eabf2c8 + 2a7a51d commit 100f7ab
Show file tree
Hide file tree
Showing 52 changed files with 410 additions and 341 deletions.
18 changes: 9 additions & 9 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"apps/cowswap-frontend": "1.95.3",
"apps/explorer": "2.41.0",
"libs/permit-utils": "0.5.0",
"apps/cowswap-frontend": "1.96.1",
"apps/explorer": "2.42.0",
"libs/permit-utils": "0.6.0",
"libs/widget-lib": "0.18.0",
"libs/widget-react": "0.11.0",
"apps/widget-configurator": "1.10.1",
"apps/widget-configurator": "1.11.0",
"libs/analytics": "1.9.0",
"libs/assets": "1.12.0",
"libs/common-const": "1.13.0",
"libs/common-hooks": "1.6.0",
"libs/common-hooks": "1.6.1",
"libs/common-utils": "1.8.0",
"libs/core": "1.6.0",
"libs/ens": "1.3.0",
"libs/events": "1.5.0",
"libs/snackbars": "1.1.1",
"libs/tokens": "1.13.1",
"libs/tokens": "1.14.0",
"libs/types": "1.5.0",
"libs/ui": "1.17.1",
"libs/wallet": "1.8.1",
"libs/ui": "1.18.0",
"libs/wallet": "1.9.0",
"apps/cow-fi": "1.19.3",
"libs/wallet-provider": "1.0.0",
"libs/ui-utils": "1.1.0",
"libs/abis": "1.2.1",
"libs/balances-and-allowances": "1.2.0",
"libs/iframe-transport": "1.0.0",
"libs/hook-dapp-lib": "1.4.0",
"libs/hook-dapp-lib": "1.5.0",
"libs/multicall": "1.0.0"
}
4 changes: 2 additions & 2 deletions apps/cow-fi/app/(main)/legal/cowswap-terms/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ export default function Page() {
</p>
<p>
For more details on how to use the Interface please refer to our{' '}
<a href="https://swap.cow.fi/#/faq" target="_blank" rel="nofollow noopener">
&quot;FAQ&quot;
<a href="https://cow.fi/learn" target="_blank" rel="nofollow noopener">
&quot;Knowledge Base&quot;
</a>
.
</p>
Expand Down
6 changes: 3 additions & 3 deletions apps/cow-fi/app/(main)/legal/widget-terms/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function Page() {
<p>
You are also responsible for ensuring that all persons who access the Widget through your website are
aware of the{' '}
<a target="_blank" rel="noreferrer" href="https://swap.cow.fi/#/terms-and-conditions">
<a target="_blank" rel="noreferrer" href="https://cow.fi/legal/cowswap-terms">
Terms &amp; Conditions
</a>{' '}
of{' '}
Expand Down Expand Up @@ -132,12 +132,12 @@ export default function Page() {
</p>
<p>
The{' '}
<a target="_blank" rel="noreferrer" href="https://swap.cow.fi/#/terms-and-conditions#welcometohttpscowfi">
<a target="_blank" rel="noreferrer" href="https://cow.fi/legal/cowswap-terms">
Terms &amp; Conditions
</a>{' '}
for the use of the Interface apply to the Widget. It is your duty to ensure that all persons who access
the Widget through your website are aware of the Interface’s{' '}
<a target="_blank" rel="noreferrer" href="https://swap.cow.fi/#/terms-and-conditions">
<a target="_blank" rel="noreferrer" href="https://cow.fi/legal/cowswap-terms">
Terms &amp; Conditions
</a>{' '}
and that they comply with them.
Expand Down
7 changes: 0 additions & 7 deletions apps/cowswap-frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ INTEGRATION_TESTS_INFURA_KEY=



#######################################
# Development
#######################################

# Enables mock mode (default = false)
REACT_APP_MOCK=true



#######################################
Expand Down
5 changes: 0 additions & 5 deletions apps/cowswap-frontend/.env.production
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
#######################################
# Development
#######################################

# Enables mock mode (default = false)
REACT_APP_MOCK=false
15 changes: 15 additions & 0 deletions apps/cowswap-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [1.96.1](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.96.0...cowswap-v1.96.1) (2025-01-09)


### Bug Fixes

* **token-lists:** remove old token lists from cache ([#5275](https://github.com/cowprotocol/cowswap/issues/5275)) ([1ca7211](https://github.com/cowprotocol/cowswap/commit/1ca7211729c552c1c834b12c2d343ce981b02cf1))

## [1.96.0](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.95.3...cowswap-v1.96.0) (2025-01-09)


### Features

* executedSurplusFee removal ([#5262](https://github.com/cowprotocol/cowswap/issues/5262)) ([3be8a65](https://github.com/cowprotocol/cowswap/commit/3be8a65309048d4082f2ce25f5b39624e092dbf2))
* **swap:** partial approve ([#5256](https://github.com/cowprotocol/cowswap/issues/5256)) ([f080ffd](https://github.com/cowprotocol/cowswap/commit/f080ffdb098612e729f3a3f829410ce78697979f))

## [1.95.3](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.95.2...cowswap-v1.95.3) (2024-12-23)


Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/cowswap",
"version": "1.95.3",
"version": "1.96.1",
"description": "CoW Swap",
"main": "index.js",
"author": "",
Expand Down
45 changes: 45 additions & 0 deletions apps/cowswap-frontend/public/emergency.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,51 @@ if (window.location.pathname !== '/') {
window.location.pathname = '/'
}

/**
* Removes deprecated token lists for a particular localStorage key: `allTokenListsInfoAtom:v5`
*
* A change introduced new token lists and removed old ones.
* This code removes the old token lists from the local storage to avoid duplication without resetting user added token lists.
*/
;(function () {
const key = 'allTokenListsInfoAtom:v5'
const storageValue = localStorage.getItem(key)

// Exit early if the storage value is not set
if (!storageValue) return

const tokenLists = JSON.parse(storageValue)

const listsToSkip = new RegExp(
'CoingeckoTokensList\\.json$|' +
'UniswapTokensList\\.json$|' +
'CoinGecko\\.json$|' +
'compound\\.tokenlist\\.json$|' +
'set\\.tokenlist\\.json$|' +
'tokensoft\\.eth$|' +
'opyn-squeeth|' +
'tryroll\\.com|' +
'snx\\.eth$|' +
'aave\\.eth$|' +
'cmc\\.eth$',
)

const updatedTokenLists = Object.keys(tokenLists).reduce((acc, chainId) => {
acc[chainId] = Object.keys(tokenLists[chainId]).reduce((_acc, listPath) => {
if (!listsToSkip.test(listPath)) {
_acc[listPath] = tokenLists[chainId][listPath]
} else {
console.log('[Service worker] Skip token list', listPath)
}
return _acc
}, {})

return acc
}, {})

localStorage.setItem(key, JSON.stringify(updatedTokenLists))
})()

/**
* Remove old versions of the local storage atom stores
* We rely on the fact that store names are in the format {name}Atom:v{version}
Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/api/cowProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { getQuoteValidFor } from 'utils/orderUtils/getQuoteValidFor'
import { ApiErrorCodes } from './errors/OperatorError'
import QuoteApiError, { mapOperatorErrorToQuoteError, QuoteApiErrorDetails } from './errors/QuoteError'
import { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

export { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

function getProfileUrl(): Partial<Record<ChainId, string>> {
if (isLocal || isDev || isPr || isBarn) {
Expand Down
22 changes: 22 additions & 0 deletions apps/cowswap-frontend/src/api/cowProtocol/apiCached.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { fetchWithCache } from '@cowprotocol/common-utils'
import { NativePriceResponse, SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'

import ms from 'ms.macro'
import QuickLRU from 'quick-lru'

import * as api from './api'

export * from './api'

const nativePriceCache = new QuickLRU<string, Promise<NativePriceResponse>>({
maxSize: 1000,
maxAge: ms`1m`,
})

export async function getNativePrice(chainId: ChainId, currencyAddress: string): Promise<NativePriceResponse> {
return fetchWithCache({
key: `${chainId}:${currencyAddress}`,
fetch: () => api.getNativePrice(chainId, currencyAddress),
cache: nativePriceCache,
})
}
22 changes: 1 addition & 21 deletions apps/cowswap-frontend/src/api/cowProtocol/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
import * as realApi from './api'
import * as mockApi from './mock'

export { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

const useMock = process.env.REACT_APP_MOCK === 'true'

// Re-exporting the result, mocked or not.
// Unfortunately, did not find a way to export
// a mix of mock/real implementations
// without manually naming the exports
export const {
// functions that have a mock
getProfileData,
getQuote = realApi.getQuote,
getOrder = realApi.getOrder,
getNativePrice = realApi.getNativePrice,
getTrades = realApi.getTrades,
getOrders = realApi.getOrders,
// functions that only have a mock
} = useMock ? { ...mockApi } : { ...realApi }
export * from './apiCached'
12 changes: 0 additions & 12 deletions apps/cowswap-frontend/src/api/cowProtocol/mock.ts

This file was deleted.

10 changes: 9 additions & 1 deletion apps/cowswap-frontend/src/common/pure/NetworksList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { getChainInfo } from '@cowprotocol/common-const'
import { getExplorerBaseUrl } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { ExternalLink } from '@cowprotocol/ui'
import { Badge, BadgeTypes, ExternalLink } from '@cowprotocol/ui'

import { Trans } from '@lingui/macro'

import * as styledEl from './styled'

const NEW_NETWORK_ID = 8453

export interface NetworksListProps {
currentChainId: SupportedChainId | null
isDarkMode: boolean
Expand All @@ -25,11 +27,17 @@ export function NetworksList(props: NetworksListProps) {

const isActive = targetChainId === currentChainId
const logoUrl = getLogo(isDarkMode, isActive, logo.dark, logo.light)
const isNewNetwork = targetChainId === NEW_NETWORK_ID

const rowContent = (
<styledEl.FlyoutRow key={targetChainId} onClick={() => onSelectChain(targetChainId)} active={isActive}>
<styledEl.Logo src={logoUrl} />
<styledEl.NetworkLabel>{label}</styledEl.NetworkLabel>
{isNewNetwork && (
<Badge type={BadgeTypes.ALERT2} style={isActive ? { marginRight: '10px' } : undefined}>
NEW
</Badge>
)}
{isActive && <styledEl.FlyoutRowActiveIndicator active />}
</styledEl.FlyoutRow>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { lazy, PropsWithChildren, Suspense, useMemo } from 'react'

import { ACTIVE_CUSTOM_THEME, CustomTheme } from '@cowprotocol/common-const'
import { useMediaQuery } from '@cowprotocol/common-hooks'
import { useFeatureFlags } from '@cowprotocol/common-hooks'
import { useFeatureFlags, useMediaQuery } from '@cowprotocol/common-hooks'
import { isInjectedWidget } from '@cowprotocol/common-utils'
import { Color, Footer, GlobalCoWDAOStyles, Media, MenuBar } from '@cowprotocol/ui'

Expand Down Expand Up @@ -55,7 +54,10 @@ export function App() {
useAnalyticsReporterCowSwap()
useInitializeUtm()

const { isYieldEnabled, isChristmasEnabled, isHalloweenEnabled } = useFeatureFlags()
const { isYieldEnabled, } = useFeatureFlags()
// TODO: load them from feature flags when we want to enable again
const isChristmasEnabled = false
const isHalloweenEnabled = false

const isInjectedWidgetMode = isInjectedWidget()
const menuItems = useMenuItems()
Expand Down
Loading

0 comments on commit 100f7ab

Please sign in to comment.