Skip to content

Commit

Permalink
Merge branch 'develop' into fix-metamask-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito authored Dec 19, 2024
2 parents ccb6955 + 1626a04 commit 43c5b60
Show file tree
Hide file tree
Showing 101 changed files with 1,218 additions and 466 deletions.
22 changes: 11 additions & 11 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"apps/cowswap-frontend": "1.93.2",
"apps/explorer": "2.38.0",
"apps/cowswap-frontend": "1.95.0",
"apps/explorer": "2.40.1",
"libs/permit-utils": "0.5.0",
"libs/widget-lib": "0.18.0",
"libs/widget-react": "0.11.0",
"apps/widget-configurator": "1.10.0",
"apps/widget-configurator": "1.10.1",
"libs/analytics": "1.9.0",
"libs/assets": "1.11.0",
"libs/common-const": "1.12.2",
"libs/assets": "1.12.0",
"libs/common-const": "1.13.0",
"libs/common-hooks": "1.6.0",
"libs/common-utils": "1.8.0",
"libs/core": "1.5.0",
"libs/core": "1.6.0",
"libs/ens": "1.3.0",
"libs/events": "1.5.0",
"libs/snackbars": "1.1.0",
"libs/tokens": "1.13.0",
"libs/tokens": "1.13.1",
"libs/types": "1.5.0",
"libs/ui": "1.16.0",
"libs/wallet": "1.7.0",
"apps/cow-fi": "1.19.2",
"libs/ui": "1.17.0",
"libs/wallet": "1.8.0",
"apps/cow-fi": "1.19.3",
"libs/wallet-provider": "1.0.0",
"libs/ui-utils": "1.1.0",
"libs/abis": "1.2.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",
Expand Down
7 changes: 7 additions & 0 deletions apps/cow-fi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.19.3](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.19.2...cow-fi-v1.19.3) (2024-12-16)


### Bug Fixes

* **cowfi:** fix pages crashes ([#5206](https://github.com/cowprotocol/cowswap/issues/5206)) ([525d079](https://github.com/cowprotocol/cowswap/commit/525d0794c10e0950dc0036f2f9c2e8e728117969))

## [1.19.2](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.19.1...cow-fi-v1.19.2) (2024-12-12)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { Article, getArticles, getCategories } from '../../../../../services/cms'
import { ArticlesPageComponents } from '@/components/ArticlesPageComponents'
import { redirect } from 'next/navigation'

const ITEMS_PER_PAGE = 24

Expand All @@ -28,7 +29,14 @@ export async function generateStaticParams() {

export default async function Page({ params }: Props) {
const pageParam = (await params)?.pageIndex
const page = pageParam && pageParam.length > 0 ? parseInt(pageParam[0], 10) : 1
const paramsAreSet = Boolean(pageParam && pageParam.length > 0)
const pageIndexIsValid = Boolean(pageParam && /^\d+$/.test(pageParam))

if (paramsAreSet && !pageIndexIsValid) {
return redirect('/learn/articles')
}

const page = pageParam && pageIndexIsValid ? parseInt(pageParam, 10) : 1

const articlesResponse = (await getArticles({ page, pageSize: ITEMS_PER_PAGE })) as ArticlesResponse

Expand Down
5 changes: 5 additions & 0 deletions apps/cow-fi/app/(main)/tokens/[tokenId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TokenPageComponent } from '@/components/TokenPageComponent'
import type { Metadata } from 'next'
import type { TokenDetails } from '../../../../types'
import { getPageMetadata } from '@/util/getPageMetadata'
import { redirect } from 'next/navigation'

type Props = {
params: Promise<{ tokenId: string }>
Expand All @@ -35,6 +36,8 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {

const token = await getTokenDetails(tokenId)

if (!token) return {}

return getPageMetadata(getTokenMetaData(token))
}

Expand All @@ -51,5 +54,7 @@ export default async function Page({ params }: Props) {

const token = await getTokenDetails(tokenId)

if (!token) return redirect('/tokens')

return <TokenPageComponent token={token} />
}
2 changes: 1 addition & 1 deletion apps/cow-fi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/cow-fi",
"version": "1.19.2",
"version": "1.19.3",
"description": "CoW DAO website",
"main": "index.js",
"author": "",
Expand Down
4 changes: 2 additions & 2 deletions apps/cow-fi/services/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export async function getTokensInfo(): Promise<TokenInfo[]> {
*
* @returns token details for the given token id
*/
export async function getTokenDetails(coingeckoId: string): Promise<TokenDetails> {
export async function getTokenDetails(coingeckoId: string): Promise<TokenDetails | undefined> {
const id = coingeckoId.toLowerCase()
const tokensRaw = await _getAllTokensData()
return tokensRaw.find(({ id: _id }) => _id === id) as TokenDetails
return tokensRaw.find(({ id: _id }) => _id === id) as TokenDetails | undefined
}

function _getDescriptionFilePaths(): string[] {
Expand Down
19 changes: 19 additions & 0 deletions apps/cowswap-frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## [1.95.0](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.94.0...cowswap-v1.95.0) (2024-12-18)


### Features

* force release to release, pleaseeee ([a59eb27](https://github.com/cowprotocol/cowswap/commit/a59eb275a96fb13c9521784a051f734d947a1b1f))

## [1.94.0](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.93.2...cowswap-v1.94.0) (2024-12-18)


### Features

* allow 1 year max deadline ([#5227](https://github.com/cowprotocol/cowswap/issues/5227)) ([64e3f40](https://github.com/cowprotocol/cowswap/commit/64e3f40a19da19ba7d44f4ebcb1b494fd4426882))


### Bug Fixes

* account for a bad CMS request ([#5221](https://github.com/cowprotocol/cowswap/issues/5221)) ([8d2edd7](https://github.com/cowprotocol/cowswap/commit/8d2edd7d87f0622fdc5885b45175b89b49eae1ec))

## [1.93.2](https://github.com/cowprotocol/cowswap/compare/cowswap-v1.93.1...cowswap-v1.93.2) (2024-12-13)


Expand Down
1 change: 0 additions & 1 deletion apps/cowswap-frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<meta name="twitter:site" content="@CoWSwap" />
<meta name="twitter:title" content="CoW Swap | The smartest way to trade cryptocurrencies" />
<meta name="twitter:image" content="https://swap.cow.fi/images/og-meta-cowswap.png?v=4" />

<style>
html,
body {
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.93.2",
"version": "1.95.0",
"description": "CoW Swap",
"main": "index.js",
"author": "",
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/common/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ms from 'ms.macro'

export const HIGH_FEE_WARNING_PERCENTAGE = new Percent(1, 10)

export const MAX_ORDER_DEADLINE = ms`182d` + ms`12h` // 6 months, matching backend's https://github.com/cowprotocol/infrastructure/blob/901ed8e2fe3ea57956585f107bdd7539c2e7d3d1/services/Pulumi.yaml#L15
export const MAX_ORDER_DEADLINE = ms`1y` // https://github.com/cowprotocol/infrastructure/blob/staging/services/Pulumi.yaml#L7

// Use a 150K gas as a fallback if there's issue calculating the gas estimation (fixes some issues with some nodes failing to calculate gas costs for SC wallets)
export const GAS_LIMIT_DEFAULT = BigNumber.from('150000')
61 changes: 61 additions & 0 deletions apps/cowswap-frontend/src/common/hooks/useAnnouncements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useAtomValue } from 'jotai'
import { useMemo } from 'react'

import { isProdLike } from '@cowprotocol/common-utils'
import { Announcement, Announcements, announcementsAtom } from '@cowprotocol/core'
import { CowEnv, SupportedChainId } from '@cowprotocol/cow-sdk'

function getAnnouncementSpecificity(chainId: SupportedChainId, env: CowEnv, announcement: Announcement): number {
let specificity = 0

const matchesChain = announcement.chainIds.some((announcementChain) => announcementChain === chainId)
const matchesEnv = announcement.envs.some((announcementEnv) => announcementEnv === env)
const matchesEveryChain = announcement.chainIds.length === 0
const matchesEveryEnv = announcement.envs.length === 0

if (matchesChain) specificity += 2
if (matchesEnv) specificity += 2
if (matchesEveryChain) specificity += 1
if (matchesEveryEnv) specificity += 1

return specificity
}

function useAnnouncements(chainId: SupportedChainId): Announcements {
const allAnnouncements = useAtomValue(announcementsAtom)

return useMemo(() => {
const env = isProdLike ? 'prod' : 'staging'

const filtered = allAnnouncements
.filter((announcement) => {
const showForEveryChain = announcement.chainIds.length === 0
const showForEveryEnv = announcement.envs.length === 0

const matchesChainId = announcement.chainIds.some((announcementChain) => announcementChain === chainId)
const matchesEnv = announcement.envs.some((announcementEnv) => announcementEnv === env)

return (showForEveryChain || matchesChainId) && (showForEveryEnv || matchesEnv)
})
.sort((a, b) => {
const specificityA = getAnnouncementSpecificity(chainId, env, a)
const specificityB = getAnnouncementSpecificity(chainId, env, b)

return specificityB - specificityA
})

return filtered
}, [chainId, allAnnouncements])
}

export function useCriticalAnnouncements(chainId: SupportedChainId): Announcements {
const announcements = useAnnouncements(chainId)

return announcements.filter(({ isCritical }) => isCritical)
}

export function useNonCriticalAnnouncements(chainId: SupportedChainId): Announcements {
const announcements = useAnnouncements(chainId)

return announcements.filter(({ isCritical }) => !isCritical)
}
19 changes: 19 additions & 0 deletions apps/cowswap-frontend/src/common/hooks/useCmsAnnouncements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CmsAnnouncements, getAnnouncements } from '@cowprotocol/core'

import ms from 'ms.macro'
import useSWR, { SWRConfiguration } from 'swr'

const ANNOUNCEMENTS_SWR_CONFIG: SWRConfiguration = {
refreshInterval: ms`5min`, // we do need to show this sort of ASAP
refreshWhenHidden: false,
refreshWhenOffline: false,
revalidateOnFocus: false,
}

const EMPTY_VALUE: CmsAnnouncements = []

export function useCmsAnnouncements() {
const { data } = useSWR<CmsAnnouncements, Error, string>('/announcements', getAnnouncements, ANNOUNCEMENTS_SWR_CONFIG)

return data || EMPTY_VALUE
}
4 changes: 3 additions & 1 deletion apps/cowswap-frontend/src/common/hooks/useCmsSolversInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ const SOLVERS_INFO_SWR_CONFIG: SWRConfiguration = {
revalidateOnFocus: false,
}

const EMPTY_VALUE: CmsSolversInfo = []

export function useCmsSolversInfo() {
const { data } = useSWR<CmsSolversInfo, Error, string>('/solvers', getSolversInfo, SOLVERS_INFO_SWR_CONFIG)

return data || []
return data || EMPTY_VALUE
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { isTruthy } from '@cowprotocol/common-utils'
import { TokensByAddress } from '@cowprotocol/tokens'
import { LpTokenProvider } from '@cowprotocol/types'

import styled from 'styled-components/macro'

import { upToSmall, useMediaQuery } from 'legacy/hooks/useMediaQuery'

import { VampireAttackContext } from 'modules/yield/types'
Expand All @@ -17,6 +19,10 @@ import { CoWAmmBannerContext } from './types'

import { useSafeMemoObject } from '../../hooks/useSafeMemo'

const Wrapper = styled.div`
z-index: 100;
`

interface CoWAmmBannerContentProps {
id: string
title: string
Expand Down Expand Up @@ -139,7 +145,7 @@ export function CoWAmmBannerContent({
)

return (
<div data-banner-id={id}>
<Wrapper data-banner-id={id}>
{isTokenSelectorView ? (
<TokenSelectorContent isDarkMode={isDarkMode} context={context}>
{Content}
Expand All @@ -159,6 +165,6 @@ export function CoWAmmBannerContent({
{Content}
</GlobalContent>
)}
</div>
</Wrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,8 @@ function FinishedStep(props: OrderProgressBarV2Props) {
{solvers.length > 1 && (
<p>
<b>
{solvers.length} out of {totalSolvers} solvers
{solvers.length}
{totalSolvers ? ` out of ${totalSolvers}` : ''} solvers
</b>{' '}
submitted a solution
</p>
Expand Down
20 changes: 20 additions & 0 deletions apps/cowswap-frontend/src/common/updaters/AnnouncementsUpdater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useSetAtom } from 'jotai'
import { useEffect } from 'react'

import { announcementsAtom, mapCmsAnnouncementsToAnnouncements } from '@cowprotocol/core'

import { useCmsAnnouncements } from 'common/hooks/useCmsAnnouncements'

export function AnnouncementsUpdater() {
const setAnnouncements = useSetAtom(announcementsAtom)

const cmsAnnouncements = useCmsAnnouncements()

useEffect(() => {
const announcements = mapCmsAnnouncementsToAnnouncements(cmsAnnouncements)

announcements && setAnnouncements(announcements)
}, [cmsAnnouncements, setAnnouncements])

return null
}
Loading

0 comments on commit 43c5b60

Please sign in to comment.