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

refactor(wagmi): optimize the implementation of wagmi provider #1003

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jeasonstudio
Copy link
Collaborator

Fix #919

Copy link

changeset-bot bot commented Jun 26, 2024

⚠️ No Changeset found

Latest commit: b7d48bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ant-design-web3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2024 8:58am

Copy link

github-actions bot commented Jun 26, 2024

Preview is ready

@jeasonstudio
Copy link
Collaborator Author

几个比较大的变化:

  1. WagmiWeb3ConfigProvider 更推荐传入 createConfig 的参数,而不是 config 本身:
<WagmiWeb3ConfigProvider chains={[mainnet, polygon]} multiInjectedProviderDiscovery />
  1. 弱化 Wallet 这个概念,更建议用户使用 EIP6963(目前是默认开启的)而不是手动配置钱包;除非有特殊的自定义需求:
<WagmiWeb3ConfigProvider connectors={[metaMask({ group: 'Popular' }), imToken({ name: 'ImToken' })]} />
  1. 在 provider 内部自动补齐 chain 信息:用户传进来的是 wagmi/viem 的 chain,但我们的 chain 定义多了一些 UI 相关的信息,目前的想法是通过 chainId 自动 patch 进去,自定义的 chain 就 patch 一个兜底的 UI 信息。

  2. 提供一个更底层的 WagmiPureConfigProvider,相比于上面的 provider 少包了一层 WagmiProviderQueryClientProvider,这样可以方便更高级的用户自定义,比如用其他的 QueryClient 配置,参考这篇文档

<WagmiProvider config={myConfig}>
  <PersistQueryClientProvider client={myQueryClient} persistOptions={{ persister }}>
    <WagmiPureConfigProvider>{* ... *}</WagmiPureConfigProvider>
  </PersistQueryClientProvider>
</WagmiProvider>

@yutingzhao1991
Copy link
Collaborator

对于用户自定义的需求,PersistQueryClientProvider 放在外面可行吗?

   <PersistQueryClientProvider client={myQueryClient} persistOptions={{ persister }}>
     <WagmiWeb3ConfigProvider>
     </WagmiWeb3ConfigProvider>
  </PersistQueryClientProvider>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants