Skip to content

Get client by provider instead of importing the correct chain #361

Discussion options

You must be logged in to vote

If you don't care about bundle size and tree-shaking (which you generally should), then you can certainly do this. However, I'd not use a wildcard import for that but instead set up a strict const mapping of [chain id] => [chain] for the chains you plan to support. Otherwise, you are including literally every single chain in your final app bundle (throwing tree shaking out the window essentially). Another benefit is that, through the strict const mapping of chain ids & chains, you'd be able to infer the resulting type with a type guard more easily.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ryespresso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants