Skip to content

Commit

Permalink
filter chains
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 committed Mar 12, 2024
1 parent 8968b66 commit 22ce990
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/lib/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const allChains: Chain[] = []
for (const [k, v] of Object.entries(chains)) {
if (typeof v !== 'object') continue
if (!('id' in v)) continue
if (v.id.toString() === '31337') continue
if (k === 'localhost') continue
if (k.includes('wanchain')) continue
if (k === 'saigon') continue
if (k === 'skale') continue
chainMap[k] = v
allChains.push(v)
}
Expand Down
12 changes: 5 additions & 7 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import '../app.postcss'
import { Check, ChevronUp, MagnifyingGlass } from 'radix-icons-svelte'
import type { Address } from 'viem'
import * as allChains from 'viem/chains'
import { chainMap } from '$lib/chains'
import * as Popover from '$lib/components/ui/popover'
import { afterNavigate, goto } from '$app/navigation'
import { navigating } from '$app/stores'
Expand All @@ -17,12 +17,10 @@
let address: Address | undefined
let searchOpen = false
const chainOptions = Object.entries(allChains)
.map(([key, chain]) => ({
value: key,
label: chain.name,
}))
.filter((f) => f.value !== 'localhost' && f.value !== 'hardhat')
const chainOptions = Object.entries(chainMap).map(([key, chain]) => ({
value: key,
label: chain.name,
}))
chainOptions.push({ value: 'ethereum', label: 'Ethereum' })
$: selectedValue = chainOptions.find((f) => f.value === network)?.label ?? 'Select a chain...'
Expand Down

0 comments on commit 22ce990

Please sign in to comment.