MCPcopy Create free account
hub / github.com/wevm/viem / getChainTargetById

Function getChainTargetById

scripts/generateTokenlist.ts:218–236  ·  view source on GitHub ↗
(chainIds: Set<number>)

Source from the content-addressed store, hash-verified

216}
217
218async function getChainTargetById(chainIds: Set<number>) {
219 const chainExports = getChainExports()
220 const chains = (await import(chainsIndexFile.href)) as Record<string, unknown>
221 const chainTargetById = new Map<number, ChainTarget>()
222
223 for (const chainExport of chainExports) {
224 const chain = chains[chainExport.exportedName]
225 if (!isChain(chain)) continue
226 if (!chainIds.has(chain.id)) continue
227 if (chainTargetById.has(chain.id)) continue
228 chainTargetById.set(chain.id, {
229 chain,
230 chainId: chain.id,
231 name: chainExport.exportedName,
232 })
233 }
234
235 return chainTargetById
236}
237
238function getChainExports() {
239 const source = readFileSync(chainsIndexFile, 'utf8')

Callers 1

Calls 3

getChainExportsFunction · 0.85
setMethod · 0.80
isChainFunction · 0.70

Tested by

no test coverage detected