Skip to content

Commit

Permalink
Merge pull request #200 from balancer/fix/use-hook-logic
Browse files Browse the repository at this point in the history
fix: pool hook metadata search
  • Loading branch information
alter-eggo authored Nov 28, 2024
2 parents 02e79ae + 55789fb commit b5135a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 6 additions & 2 deletions packages/lib/modules/hooks/useHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ export function useHook(pool: Pool) {
const hooks = hookAddresses
.map(hookAddress =>
metadata?.find(metadata => {
const metadataAddresses = metadata.addresses[chainId.toString()]
return hookAddress && metadataAddresses && metadataAddresses.includes(hookAddress)
const metadataAddresses = metadata.addresses[chainId.toString()].map(address =>
address.toLowerCase()
)
return (
hookAddress && metadataAddresses && metadataAddresses.includes(hookAddress.toLowerCase())
)
})
)
.filter(Boolean)
Expand Down
7 changes: 2 additions & 5 deletions packages/lib/modules/pool/PoolDetail/PoolHookTag.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { Badge, Center, Popover, PopoverContent, PopoverTrigger, Text } from '@chakra-ui/react'

import { HookIcon } from '@repo/lib/shared/components/icons/HookIcon'
import { useHook } from '../../hooks/useHook'
import { usePool } from '../PoolProvider'
import { getChainId } from '@repo/lib/config/app.config'

export function PoolHookTag() {
const { pool } = usePool()
const { hooks } = useHook(pool)

// TODO: add nested hook support when needed
const hook = hooks.find(
hook => pool.hook && hook?.addresses[getChainId(pool.chain)]?.includes(pool.hook.address)
)

const hook = hooks[0]

if (!hook) return null

Expand Down

0 comments on commit b5135a5

Please sign in to comment.