Skip to content

Commit

Permalink
fix: wrong api query implement (#10862)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the handling of farm configurations in two API endpoints
by switching the order of farm configuration constants used, ensuring
that the testnet farms are prioritized correctly.

### Detailed summary
- In `apps/web/src/pages/api/configs/farms/v2/index.ts`:
- Changed the order of `farmConfig` assignment to prioritize
`UNIVERSAL_FARMS_WITH_TESTNET` over `UNIVERSAL_FARMS`.
  
- In `apps/web/src/pages/api/configs/farms/v2/[chain].ts`:
- Updated `farmConfig` to filter `UNIVERSAL_FARMS_WITH_TESTNET` instead
of `UNIVERSAL_FARMS`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
ChefJerry authored Oct 23, 2024
1 parent 6203ccd commit 36cbc2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/web/src/pages/api/configs/farms/v2/[chain].ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChainId, chainNames, chainNameToChainId } from '@pancakeswap/chains'
import { formatUniversalFarmToSerializedFarm, UNIVERSAL_FARMS } from '@pancakeswap/farms'
import { ChainId, chainNameToChainId, chainNames } from '@pancakeswap/chains'
import { UNIVERSAL_FARMS_WITH_TESTNET, formatUniversalFarmToSerializedFarm } from '@pancakeswap/farms'
import { NextApiHandler } from 'next'
import { stringify } from 'viem'
import { enum as enum_, nativeEnum } from 'zod'
Expand All @@ -24,7 +24,7 @@ const handler: NextApiHandler = async (req, res) => {
}

try {
const farmConfig = UNIVERSAL_FARMS.filter((farm) => farm.chainId === chainId)
const farmConfig = UNIVERSAL_FARMS_WITH_TESTNET.filter((farm) => farm.chainId === chainId)
const legacyFarmConfig = formatUniversalFarmToSerializedFarm(farmConfig)
// cache for long time, it should revalidate on every deployment
res.setHeader('Cache-Control', `max-age=10800, s-maxage=31536000`)
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/pages/api/configs/farms/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { formatUniversalFarmToSerializedFarm, UNIVERSAL_FARMS, UNIVERSAL_FARMS_WITH_TESTNET } from '@pancakeswap/farms'
import { UNIVERSAL_FARMS, UNIVERSAL_FARMS_WITH_TESTNET, formatUniversalFarmToSerializedFarm } from '@pancakeswap/farms'
import { NextApiHandler } from 'next'
import { stringify } from 'viem'

const handler: NextApiHandler = async (req, res) => {
const includeTestnet = !!req.query.includeTestnet

try {
const farmConfig = includeTestnet ? UNIVERSAL_FARMS : UNIVERSAL_FARMS_WITH_TESTNET
const farmConfig = includeTestnet ? UNIVERSAL_FARMS_WITH_TESTNET : UNIVERSAL_FARMS
const legacyFarmConfig = formatUniversalFarmToSerializedFarm(farmConfig)
// cache for long time, it should revalidate on every deployment
res.setHeader('Cache-Control', `max-age=10800, s-maxage=31536000`)
Expand Down

0 comments on commit 36cbc2b

Please sign in to comment.