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

update: use viem for siwe #387

Merged
merged 26 commits into from
Jun 5, 2024
Merged

update: use viem for siwe #387

merged 26 commits into from
Jun 5, 2024

Conversation

lochie
Copy link
Member

@lochie lochie commented May 28, 2024

This PR update requires updating viem dependencies to >=2.13.3

An attempt to keep developer APIs streamlined and easy to use, we have included an easy way to include network details to your server in the same way that you set up your ConnectKit/wagmi provider.

If you have followed the ConnectKit Next.js SIWE documentation, these updates require the following changes:

First, export your ConnectKit configuration:

export const ckConfig = getDefaultConfig({ ... });

Next, in your @/utils/siweServer.ts:

import { ckConfig } from '@/components/Web3Provider';

export const siweServer = configureServerSideSIWE({
  config: {
    chains: ckConfig.chains,
    transports: ckConfig.transports,
  },
  ...
})

If you do not include this information, a default publicClient will be created attempting to use a public transport, which does not guarantee a valid communcation to the RPC url:

let chain = config?.chains
? Object.values(config.chains).find((c) => c.id === parsed.chainId)
: undefined;
if (!chain) {
// Try to find chain from allChains if not found in user-provided chains
chain = Object.values(allChains).find((c) => c.id === parsed.chainId);
}
if (!chain) {
throw new Error('Chain not found.');
}


closes #323

Copy link

vercel bot commented May 28, 2024

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

Name Status Preview Comments Updated (UTC)
connectkit-cra ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 2:17am
connectkit-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 2:17am
connectkit-testbench ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 2:17am
connectkit-vite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 2:17am

Copy link
Member Author

Choose a reason for hiding this comment

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

irrelevant to SIWE update, but this required updating as useSwitchChain returns different data since the last wagmi update

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

Successfully merging this pull request may close these issues.

None yet

2 participants