Open
Conversation
Update RainbowKit to v2.2.6 and adapt to wagmi v2
This commit updates @rainbow-me/rainbowkit to version 2.2.6 and its peer dependencies (wagmi to v2.9.2, viem to v2.10.9).
Key changes include:
- Updated package.json and package-lock.json with new dependency versions.
- Refactored `src/App.tsx` to align with wagmi v2 APIs:
- Replaced `useNetwork` with `useChainId`.
- Updated contract interaction hooks (usePrepareContractWrite to direct useWriteContract pattern).
- Replaced `useSwitchNetwork` with `useSwitchChain`.
- Replaced `useWaitForTransaction` with `useWaitForTransactionReceipt`.
- Adjusted how properties like `enabled`, `onError` are passed to hooks.
- Replaced `erc20ABI` import from `wagmi` with `erc20Abi` from `viem`.
- Removed 'watch: true' from `useBalance` and `useContractRead` queries, aligning with TanStack Query v5 patterns.
- Updated `src/config/wallet.ts` for new RainbowKit/wagmi configuration:
- Removed `configureChains` and `publicProvider`.
- Defined chains directly.
- Used `http` transport in `createConfig`.
- Updated `src/main.tsx` to remove the 'chains' prop from `RainbowKitProvider`.
- Restored "Add to Metamask" functionality in `src/components/AddToken.tsx`:
- Implemented `wallet_watchAsset` RPC call via `getConnectorClient().request()` due to issues locating a direct 'watchAsset' import in wagmi@2.9.2.
- Added `@tanstack/react-query` as a direct dependency to resolve a build error.
The project now successfully builds with the updated dependencies.
Update RainbowKit to v2.2.6 and adapt to wagmi v2
This commit updates @rainbow-me/rainbowkit to version 2.2.6 and its peer dependencies (wagmi to v2.9.2, viem to v2.10.9).
Key changes include:
- Updated package.json and package-lock.json with new dependency versions.
- Refactored `src/App.tsx` to align with wagmi v2 APIs:
- Replaced `useNetwork` with `useChainId`.
- Updated contract interaction hooks (usePrepareContractWrite to direct useWriteContract pattern).
- Replaced `useSwitchNetwork` with `useSwitchChain`.
- Replaced `useWaitForTransaction` with `useWaitForTransactionReceipt`.
- Adjusted how properties like `enabled`, `onError` are passed to hooks.
- Replaced `erc20ABI` import from `wagmi` with `erc20Abi` from `viem`.
- Removed 'watch: true' from `useBalance` and `useContractRead` queries, aligning with TanStack Query v5 patterns.
- Updated `src/config/wallet.ts` for new RainbowKit/wagmi configuration:
- Removed `configureChains` and `publicProvider`.
- Defined chains directly.
- Used `http` transport in `createConfig`.
- Updated `src/main.tsx` to remove the 'chains' prop from `RainbowKitProvider`.
- Restored "Add to Metamask" functionality in `src/components/AddToken.tsx`:
- Implemented `wallet_watchAsset` RPC call via `getConnectorClient().request()` due to issues locating a direct 'watchAsset' import in wagmi@2.9.2.
- Added `@tanstack/react-query` as a direct dependency to resolve a build error.
The project now successfully builds with the updated dependencies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rainbowkit