Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pool hook metadata search #200

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 2 additions & 3 deletions packages/lib/modules/pool/PoolDetail/PoolHookTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
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'

Check warning on line 6 in packages/lib/modules/pool/PoolDetail/PoolHookTag.tsx

View workflow job for this annotation

GitHub Actions / Lint

'getChainId' is defined but never used

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)
Comment on lines -13 to -14
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to find hook again, same logic is already in useHook

)

const hook = hooks[0]

if (!hook) return null

Expand Down
Loading