Skip to content

Commit

Permalink
fix: gauge duplicated hash (#8805)
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
### Focus of the PR:
This PR focuses on updating the import statement and modifying the logic
in the `getAllGauges` function in order to use the new `GaugeConfig`
type.

### Detailed summary:
- Updated the import statement to include `GaugeConfig` in
`getAllGauges.ts`.
- Modified the logic in `getAllGauges` to use the new `GaugeConfig`
type.

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

<!-- end pr-codex -->
  • Loading branch information
ChefJerry authored Jan 12, 2024
1 parent 5342b53 commit 1ad59db
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/gauges/src/getAllGauges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CONFIG_PROD } from './constants/config/prod'
import { CONFIG_TESTNET } from './constants/config/testnet'
import { fetchAllGauges } from './fetchAllGauges'
import { fetchAllGaugesVoting } from './fetchGaugeVoting'
import { Gauge, GaugeInfoConfig } from './types'
import { Gauge, GaugeConfig, GaugeInfoConfig } from './types'

export type getAllGaugesOptions = {
testnet?: boolean
Expand All @@ -24,9 +24,15 @@ export const getAllGauges = async (

const allGaugeInfos = await fetchAllGauges(client)
const allGaugeInfoConfigs = allGaugeInfos.reduce((prev, gauge) => {
const preset = presets.find((p) => p.address === gauge.pairAddress && Number(p.chainId) === gauge.chainId)
const filters = presets.filter((p) => p.address === gauge.pairAddress && Number(p.chainId) === gauge.chainId)
let preset: GaugeConfig

if (!preset) return prev
if (!filters.length) return prev
if (filters.length > 1) {
preset = filters[filters.length - 1]
} else {
preset = filters[0]
}

return [
...prev,
Expand Down

1 comment on commit 1ad59db

@vercel
Copy link

@vercel vercel bot commented on 1ad59db Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.