Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
Browse files Browse the repository at this point in the history
… fix/coinshift-support
  • Loading branch information
shoom3301 committed Dec 3, 2024
2 parents 7f21561 + 973b93a commit fbb9828
Show file tree
Hide file tree
Showing 596 changed files with 14,256 additions and 5,778 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/vercel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ jobs:
REACT_APP_NETWORK_URL_1=${{ secrets.REACT_APP_NETWORK_URL_1 }}
REACT_APP_NETWORK_URL_100=${{ secrets.REACT_APP_NETWORK_URL_100 }}
REACT_APP_NETWORK_URL_42161=${{ secrets.REACT_APP_NETWORK_URL_42161 }}
REACT_APP_NETWORK_URL_8453=${{ secrets.REACT_APP_NETWORK_URL_8453 }}
REACT_APP_NETWORK_URL_11155111=${{ secrets.REACT_APP_NETWORK_URL_11155111 }}
REACT_APP_WC_PROJECT_ID=${{ secrets.REACT_APP_WC_PROJECT_ID }}
REACT_APP_IPFS_READ_URI=${{ secrets.REACT_APP_IPFS_READ_URI }}
REACT_APP_EXPLORER_SENTRY_DSN=${{ secrets.EXPLORER_SENTRY_DSN }}
REACT_APP_SUBGRAPH_URL_MAINNET=${{ secrets.REACT_APP_SUBGRAPH_URL_MAINNET }}
REACT_APP_SUBGRAPH_URL_ARBITRUM_ONE=${{ secrets.REACT_APP_SUBGRAPH_URL_ARBITRUM_ONE }}
REACT_APP_SUBGRAPH_URL_BASE=${{ secrets.REACT_APP_SUBGRAPH_URL_BASE }}
REACT_APP_SUBGRAPH_URL_GNOSIS_CHAIN=${{ secrets.REACT_APP_SUBGRAPH_URL_GNOSIS_CHAIN }}
REACT_APP_BFF_BASE_URL=${{ secrets.BFF_BASE_URL }}
REACT_APP_CMS_BASE_URL=${{ secrets.CMS_BASE_URL }}
Expand Down
31 changes: 16 additions & 15 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{
"apps/cowswap-frontend": "1.84.0",
"apps/explorer": "2.34.1",
"libs/permit-utils": "0.3.1",
"libs/widget-lib": "0.15.0",
"apps/cowswap-frontend": "1.90.0",
"apps/explorer": "2.36.1",
"libs/permit-utils": "0.4.0",
"libs/widget-lib": "0.17.0",
"libs/widget-react": "0.11.0",
"apps/widget-configurator": "1.7.0",
"apps/widget-configurator": "1.9.0",
"libs/analytics": "1.8.0",
"libs/assets": "1.8.0",
"libs/common-const": "1.7.0",
"libs/assets": "1.10.0",
"libs/common-const": "1.10.1",
"libs/common-hooks": "1.4.0",
"libs/common-utils": "1.7.2",
"libs/core": "1.3.0",
"libs/ens": "1.2.0",
"libs/events": "1.5.0",
"libs/snackbars": "1.1.0",
"libs/tokens": "1.9.0",
"libs/types": "1.2.0",
"libs/ui": "1.10.0",
"libs/wallet": "1.6.0",
"apps/cow-fi": "1.14.0",
"libs/tokens": "1.11.0",
"libs/types": "1.4.0",
"libs/ui": "1.14.0",
"libs/wallet": "1.6.1",
"apps/cow-fi": "1.16.0",
"libs/wallet-provider": "1.0.0",
"libs/ui-utils": "1.1.0",
"libs/abis": "1.1.0",
"libs/balances-and-allowances": "1.0.0",
"libs/abis": "1.2.0",
"libs/balances-and-allowances": "1.1.1",
"libs/iframe-transport": "1.0.0",
"libs/hook-dapp-lib": "1.0.0"
"libs/hook-dapp-lib": "1.3.0",
"libs/multicall": "1.0.0"
}
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ yarn test

# 🔎 Explorer

Start the Explorer on http://localhost:4200
Start the Explorer on <http://localhost:4200>

[Read more about the Explorer](apps/explorer/README.md)

Expand All @@ -69,7 +69,7 @@ yarn build:explorer

# 🐄 cow.fi

Start CoW.fi on http://localhost:3001
Start CoW.fi on <http://localhost:3001>

### Start

Expand All @@ -85,7 +85,7 @@ yarn build:cowfi

# 🖼️ Widget Configurator

Start the Widget Configurator on http://127.0.0.1:4200/widget-configurator
Start the Widget Configurator on <http://127.0.0.1:4200/widget-configurator>

```bash
# Start
Expand All @@ -97,7 +97,7 @@ yarn build:widget

# 🌌 Cosmos UI Library

Start the Cosmos UI Library on http://localhost:5000
Start the Cosmos UI Library on <http://localhost:5000>

```bash
yarn run cosmos
Expand Down Expand Up @@ -174,6 +174,7 @@ REACT_APP_NETWORK_URL_1: https://...
REACT_APP_NETWORK_URL_11155111: https://...
REACT_APP_NETWORK_URL_100: https://...
REACT_APP_NETWORK_URL_42161: https://...
REACT_APP_NETWORK_URL_8453: https://...
```

Additionally, if you plan to run the integration tests locally you must define:
Expand Down Expand Up @@ -216,7 +217,6 @@ The API endpoint is configured using the environment variable
REACT_APP_BFF_BASE_URL=https://bff.cow.fi
```
## CMS API Endpoints (Content Management System)
The CMS API is a helper API that provides some additional content to the frontend.
Expand All @@ -235,10 +235,6 @@ The API endpoint is configured using the environment variable
REACT_APP_CMS_BASE_URL=https://cms.cow.fi/api
```
## Price feeds
CoW Swap tries to find the best price available on-chain using some price feeds.
Expand Down Expand Up @@ -295,4 +291,3 @@ In case of problems with the service worker cache you force a reset using
1. [Oveall Architecture](docs/architecture-overview.md)
2. [Amounts formatting](apps/cowswap-frontend/src/utils/amountFormat/README.md)
3. [ABIs](libs/abis/README.md)
14 changes: 14 additions & 0 deletions apps/cow-fi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [1.16.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.15.0...cow-fi-v1.16.0) (2024-10-29)


### Features

* fix path ([#5022](https://github.com/cowprotocol/cowswap/issues/5022)) ([92ad33c](https://github.com/cowprotocol/cowswap/commit/92ad33c5d6a280bd1a9e40e6cf49486f6f71130a))

## [1.15.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.14.0...cow-fi-v1.15.0) (2024-10-10)


### Features

* **cow.fi:** modify sitemap lastmod and lazy load twitter js ([#4951](https://github.com/cowprotocol/cowswap/issues/4951)) ([6017924](https://github.com/cowprotocol/cowswap/commit/6017924aec4df1a53181b5ab4c818afc5d2c5091))

## [1.14.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.13.0...cow-fi-v1.14.0) (2024-09-30)


Expand Down
2 changes: 1 addition & 1 deletion apps/cow-fi/components/ArticlesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface ArticlesListProps {
articles: Article[]
}

const ARTICLES_PATH = '/learn/articles/'
const ARTICLES_PATH = '/learn/'

export const ArticlesList: React.FC<ArticlesListProps> = ({ articles }) => (
<LinkColumn>
Expand Down
103 changes: 40 additions & 63 deletions apps/cow-fi/next-sitemap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,100 +20,77 @@ module.exports = {
transform: async (config, url) => {
// Handle /learn/* pages with lastmod from CMS
if (url.startsWith('/learn/')) {
const articles = await getAllArticleSlugsWithDates()
const article = articles.find(({ slug }) => `/learn/${slug}` === url)
if (article) {
return {
loc: url,
changefreq: 'weekly',
priority: 0.6,
lastmod: article.lastModified,
try {
console.log(`Transforming learn page: ${url}`)
const articles = await getAllArticleSlugsWithDates()
const article = articles.find(({ slug }) => `/learn/${slug}` === url)

if (article) {
console.log(`Found matching article for ${url}`)
return {
loc: url,
changefreq: config.changefreq,
priority: config.priority,
lastmod: article.updatedAt,
}
} else {
console.log(`No matching article found for ${url}`)
}
} catch (error) {
console.error(`Error processing ${url}:`, error)
}
}

// Handle /tokens/* pages
if (url.startsWith('/tokens/')) {
return {
loc: url,
changefreq: 'daily',
priority: 0.6,
lastmod: new Date().toISOString(), // Assume updated daily
}
}

// Default transformation for all other pages
console.log(`Applying default transformation for: ${url}`)
return {
loc: url,
changefreq: 'weekly',
priority: 0.5,
changefreq: config.changefreq,
priority: config.priority,
lastmod: new Date().toISOString(),
}
},
}

/**
* Function to fetch all article slugs with lastModified dates from the CMS API
* Implements caching to avoid redundant network requests
* Implements pagination to fetch all pages of articles
*/
async function getAllArticleSlugsWithDates() {
// Check if articles are already cached
if (getAllArticleSlugsWithDates.cachedArticles) {
return getAllArticleSlugsWithDates.cachedArticles
}

const articles = []
const cmsBaseUrl = process.env.NEXT_PUBLIC_CMS_BASE_URL || 'https://cms.cow.fi/api'
const cmsApiUrl = `${cmsBaseUrl}/articles`

let allArticles = []
let page = 1
const pageSize = 100
let totalPages = 1
let hasMorePages = true

while (page <= totalPages) {
while (hasMorePages) {
try {
console.log(`Fetching page ${page} of articles from CMS...`)

const params = new URLSearchParams({
'query[fields]': 'slug,updatedAt', // Fetch both slug and updatedAt
'query[pagination][page]': page,
'query[pagination][pageSize]': pageSize,
})

const response = await fetch(`${cmsApiUrl}?${params.toString()}`, {
headers: {
// Include Authorization header if required
// Authorization: `Bearer ${process.env.CMS_API_KEY}`,
},
})
const url = `${cmsApiUrl}?pagination[page]=${page}&pagination[pageSize]=100`
console.log(`Fetching articles from: ${url}`)
const response = await fetch(url)

if (!response.ok) {
throw new Error(`Failed to fetch articles: ${response.statusText}`)
throw new Error(`HTTP error! status: ${response.status}`)
}

const data = await response.json()
const articles = data.data
allArticles = allArticles.concat(articles)

// Adjust based on your actual CMS API response structure
data.data.forEach((article) => {
articles.push({
slug: article.attributes.slug, // Ensure 'slug' is the correct field
lastModified: article.attributes.updatedAt, // Ensure 'updatedAt' is the correct field
})
})
console.log(`Fetched ${articles.length} articles from page ${page}`)

const pagination = data.meta.pagination
totalPages = pagination.pageCount
page += 1
// Check if there are more pages
hasMorePages = data.meta.pagination.page < data.meta.pagination.pageCount
page++
} catch (error) {
console.error('Error fetching articles for sitemap:', error)
throw error
hasMorePages = false // Stop trying if there's an error
}
}

console.log(`Total articles fetched: ${articles.length}`)

// Cache the fetched articles
getAllArticleSlugsWithDates.cachedArticles = articles
console.log(`Total articles fetched: ${allArticles.length}`)

return articles
return allArticles.map((article) => ({
slug: article.attributes.slug,
updatedAt: article.attributes.updatedAt,
}))
}
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.14.0",
"version": "1.16.0",
"description": "CoW DAO website",
"main": "index.js",
"author": "",
Expand Down
31 changes: 24 additions & 7 deletions apps/cow-fi/pages/cow-swap.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react'
import { useEffect, useRef } from 'react'

import { GetStaticProps } from 'next'
import { Color, ProductLogo, ProductVariant } from '@cowprotocol/ui'
Expand Down Expand Up @@ -49,12 +49,29 @@ interface PageProps {
}

export default function Page({ tweets }: PageProps) {
// Load Twitter script
const tweetSectionRef = useRef<HTMLDivElement>(null)

useEffect(() => {
const script = document.createElement('script')
script.src = 'https://platform.twitter.com/widgets.js'
script.async = true
document.head.appendChild(script)
const observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting) {
const script = document.createElement('script')
script.src = 'https://platform.twitter.com/widgets.js'
script.async = true
document.head.appendChild(script)
observer.disconnect()
}
},
{ rootMargin: '100px' },
)

if (tweetSectionRef.current) {
observer.observe(tweetSectionRef.current)
}

return () => {
observer.disconnect()
}
}, [])

return (
Expand Down Expand Up @@ -341,7 +358,7 @@ export default function Page({ tweets }: PageProps) {
</ContainerCardSection>
</ContainerCard>

<ContainerCard bgColor={'transparent'}>
<ContainerCard bgColor={'transparent'} ref={tweetSectionRef}>
<ContainerCardSection>
<SectionTitleWrapper maxWidth={1100}>
<SectionTitleText textAlign="center">Don't take our word for it</SectionTitleText>
Expand Down
16 changes: 8 additions & 8 deletions apps/cowswap-frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
# To set your own `AppData`, change `REACT_APP_FULL_APP_DATA_<environment>`

# AppData, build yours at https://explorer.cow.fi/appdata
REACT_APP_FULL_APP_DATA_PRODUCTION='{"version":"1.2.0","appCode":"CoW Swap","environment":"production","metadata":{}}'
REACT_APP_FULL_APP_DATA_ENS='{"version":"1.2.0","appCode":"CoW Swap","environment":"ens","metadata":{}}'
REACT_APP_FULL_APP_DATA_BARN='{"version":"1.2.0","appCode":"CoW Swap","environment":"barn","metadata":{}}'
REACT_APP_FULL_APP_DATA_STAGING='{"version":"1.2.0","appCode":"CoW Swap","environment":"staging","metadata":{}}'
REACT_APP_FULL_APP_DATA_PR='{"version":"1.2.0","appCode":"CoW Swap","environment":"pr","metadata":{}}'
REACT_APP_FULL_APP_DATA_DEVELOPMENT='{"version":"1.2.0","appCode":"CoW Swap","environment":"development","metadata":{}}'
REACT_APP_FULL_APP_DATA_LOCAL='{"version":"1.2.0","appCode":"CoW Swap","environment":"local","metadata":{}}'
REACT_APP_FULL_APP_DATA_PRODUCTION='{"version":"1.3.0","appCode":"CoW Swap","environment":"production","metadata":{}}'
REACT_APP_FULL_APP_DATA_ENS='{"version":"1.3.0","appCode":"CoW Swap","environment":"ens","metadata":{}}'
REACT_APP_FULL_APP_DATA_BARN='{"version":"1.3.0","appCode":"CoW Swap","environment":"barn","metadata":{}}'
REACT_APP_FULL_APP_DATA_STAGING='{"version":"1.3.0","appCode":"CoW Swap","environment":"staging","metadata":{}}'
REACT_APP_FULL_APP_DATA_PR='{"version":"1.3.0","appCode":"CoW Swap","environment":"pr","metadata":{}}'
REACT_APP_FULL_APP_DATA_DEVELOPMENT='{"version":"1.3.0","appCode":"CoW Swap","environment":"development","metadata":{}}'
REACT_APP_FULL_APP_DATA_LOCAL='{"version":"1.3.0","appCode":"CoW Swap","environment":"local","metadata":{}}'



Expand Down Expand Up @@ -135,4 +135,4 @@ REACT_APP_MOCK=true
# REACT_APP_DOMAIN_REGEX_ENS="(:?^cowswap\.eth|ipfs)"

# Path regex (to detect environment)
# REACT_APP_PATH_REGEX_ENS="/ipfs"
# REACT_APP_PATH_REGEX_ENS="/ipfs"
Loading

0 comments on commit fbb9828

Please sign in to comment.