Skip to content

Commit

Permalink
feat: update to wagmi 0.9 (#903)
Browse files Browse the repository at this point in the history
* feat: upgrade to wagmi 0.9

* chore: update to 0.9
  • Loading branch information
jxom authored Dec 12, 2022
1 parent b73ca75 commit a1d6776
Show file tree
Hide file tree
Showing 37 changed files with 261 additions and 251 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-numbers-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rainbow-me/create-rainbowkit': patch
---

Updated `wagmi` to `0.9.x`
19 changes: 19 additions & 0 deletions .changeset/unlucky-hairs-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@rainbow-me/rainbowkit': patch
---

The wagmi peer dependency has been updated to `0.9.x`.

Follow the steps below to migrate.

#### 1. Upgrade RainbowKit and `wagmi` to their latest version:

```bash
npm i @rainbow-me/rainbowkit@^0.9.0 wagmi@^0.9.0
```

#### 2. Check for breaking changes in `wagmi`

If you use `wagmi` hooks in your application, you will need to check if your application has been affected by the breaking changes in `wagmi`.

[You can see their migration guide here](https://wagmi.sh/react/migration-guide#09x-breaking-changes).
2 changes: 1 addition & 1 deletion examples/with-create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react": "^18.1.0",
"typescript": "^4.7.2",
"util": "0.12.4",
"wagmi": "^0.8.4",
"wagmi": "^0.9.0",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions examples/with-create-react-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import './index.css';

import '@rainbow-me/rainbowkit/styles.css';
import { getDefaultWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';
import App from './App';

const { chains, provider, webSocketProvider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
...(process.env.REACT_APP_ENABLE_TESTNETS === 'true' ? [chain.goerli] : []),
mainnet,
polygon,
optimism,
arbitrum,
...(process.env.REACT_APP_ENABLE_TESTNETS === 'true' ? [goerli] : []),
],
[
alchemyProvider({ apiKey: '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC' }),
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next-custom-button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
15 changes: 7 additions & 8 deletions examples/with-next-custom-button/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ import {
trustWallet,
ledgerWallet,
} from '@rainbow-me/rainbowkit/wallets';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';

const { chains, provider, webSocketProvider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true'
? [chain.goerli]
: []),
mainnet,
polygon,
optimism,
arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true' ? [goerli] : []),
],
[
alchemyProvider({ apiKey: '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC' }),
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next-mint-nft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
25 changes: 14 additions & 11 deletions examples/with-next-mint-nft/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
connectorsForWallets,
} from '@rainbow-me/rainbowkit';
import { argentWallet, trustWallet } from '@rainbow-me/rainbowkit/wallets';
import { createClient, configureChains, WagmiConfig, Chain } from 'wagmi';
import { createClient, configureChains, WagmiConfig } from 'wagmi';
import { Chain } from 'wagmi/chains';
import { publicProvider } from 'wagmi/providers/public';

const rinkeby: Chain = {
Expand All @@ -16,21 +17,23 @@ const rinkeby: Chain = {
network: 'rinkeby',
nativeCurrency: { name: 'Rinkeby Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
alchemy: 'https://eth-rinkeby.alchemyapi.io/v2',
default: 'https://rpc.ankr.com/eth_rinkeby',
infura: 'https://rinkeby.infura.io/v3',
public: 'https://rpc.ankr.com/eth_rinkeby',
alchemy: { http: ['https://eth-rinkeby.alchemyapi.io/v2'] },
default: { http: ['https://rpc.ankr.com/eth_rinkeby'] },
infura: { http: ['https://rinkeby.infura.io/v3'] },
public: { http: ['https://rpc.ankr.com/eth_rinkeby'] },
},
blockExplorers: {
etherscan: { name: 'Etherscan', url: 'https://rinkeby.etherscan.io' },
default: { name: 'Etherscan', url: 'https://rinkeby.etherscan.io' },
},
ens: {
address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
},
multicall: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 10299530,
contracts: {
ensRegistry: {
address: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e',
},
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 10299530,
},
},
testnet: true,
};
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next-siwe-iron-session/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"siwe": "^1.1.6",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
15 changes: 7 additions & 8 deletions examples/with-next-siwe-iron-session/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@ import {
trustWallet,
ledgerWallet,
} from '@rainbow-me/rainbowkit/wallets';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';
import { SiweMessage } from 'siwe';
import { useEffect, useMemo, useRef, useState } from 'react';

const { chains, provider, webSocketProvider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true'
? [chain.goerli]
: []),
mainnet,
polygon,
optimism,
arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true' ? [goerli] : []),
],
[
alchemyProvider({ apiKey: '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC' }),
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next-siwe-next-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"siwe": "^1.1.6",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
15 changes: 7 additions & 8 deletions examples/with-next-siwe-next-auth/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
trustWallet,
ledgerWallet,
} from '@rainbow-me/rainbowkit/wallets';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';
import { SessionProvider } from 'next-auth/react';
Expand All @@ -22,13 +23,11 @@ import {

const { chains, provider, webSocketProvider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true'
? [chain.goerli]
: []),
mainnet,
polygon,
optimism,
arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true' ? [goerli] : []),
],
[
alchemyProvider({ apiKey: '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC' }),
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
15 changes: 7 additions & 8 deletions examples/with-next/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ import {
trustWallet,
ledgerWallet,
} from '@rainbow-me/rainbowkit/wallets';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';

const { chains, provider, webSocketProvider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true'
? [chain.goerli]
: []),
mainnet,
polygon,
optimism,
arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true' ? [goerli] : []),
],
[
alchemyProvider({ apiKey: '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC' }),
Expand Down
16 changes: 5 additions & 11 deletions examples/with-remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import type {
LinksFunction,
LoaderFunction,
} from '@remix-run/node';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';
import type { Chain } from 'wagmi';
Expand Down Expand Up @@ -64,18 +65,11 @@ export default function App() {
// and a lazy initialization function.
// See: https://remix.run/docs/en/v1/guides/constraints#no-module-side-effects
const [{ client, chains }] = useState(() => {
const testChains =
ENV.PUBLIC_ENABLE_TESTNETS === 'true' ? [chain.goerli] : [];
const testChains = ENV.PUBLIC_ENABLE_TESTNETS === 'true' ? [goerli] : [];

const { chains, provider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
...testChains,
],
[alchemyProvider({ apiKey: ENV.ALCHEMY_API_KEY }), publicProvider()]
[mainnet, polygon, optimism, arbitrum, ...testChains],
[alchemyProvider({ apiKey: ENV.ALCHEMY_API_KEY! }), publicProvider()]
);

const { connectors } = getDefaultWallets({
Expand Down
2 changes: 1 addition & 1 deletion examples/with-remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ethers": "^5.0.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@remix-run/dev": "^1.5.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ethers": "^5.0.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/react": "^18.0.9",
Expand Down
5 changes: 3 additions & 2 deletions examples/with-vite/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import './polyfills';
import './global.css';
import '@rainbow-me/rainbowkit/styles.css';
import { getDefaultWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum } from 'wagmi/chains';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

const { chains, provider } = configureChains(
[chain.mainnet, chain.polygon, chain.optimism, chain.arbitrum],
[mainnet, polygon, optimism, arbitrum],
[
alchemyProvider({ apiKey: '_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC' }),
publicProvider(),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@typescript-eslint/parser": "^5.5.0",
"@vanilla-extract/esbuild-plugin": "^2.2.0",
"@vanilla-extract/vite-plugin": "^3.6.0",
"@wagmi/core": "^0.7.4",
"@wagmi/core": "^0.8.0",
"autoprefixer": "^10.4.0",
"esbuild": "^0.14.39",
"eslint": "7.32.0",
Expand All @@ -77,7 +77,7 @@
"recursive-readdir-files": "^2.0.7",
"typescript": "^4.7.2",
"vitest": "^0.5.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"pnpm": {
"onlyBuiltDependencies": [
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rainbowkit/generated-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
13 changes: 7 additions & 6 deletions packages/create-rainbowkit/generated-test-app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import '../styles/globals.css';
import '@rainbow-me/rainbowkit/styles.css';
import type { AppProps } from 'next/app';
import { RainbowKitProvider, getDefaultWallets } from '@rainbow-me/rainbowkit';
import { chain, configureChains, createClient, WagmiConfig } from 'wagmi';
import { configureChains, createClient, WagmiConfig } from 'wagmi';
import { mainnet, polygon, optimism, arbitrum, goerli } from 'wagmi/chains'
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { publicProvider } from 'wagmi/providers/public';

const { chains, provider, webSocketProvider } = configureChains(
[
chain.mainnet,
chain.polygon,
chain.optimism,
chain.arbitrum,
mainnet,
polygon,
optimism,
arbitrum,
...(process.env.NEXT_PUBLIC_ENABLE_TESTNETS === 'true'
? [chain.goerli]
? [goerli]
: []),
],
[
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rainbowkit/templates/next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"next": "^12.1.6",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"wagmi": "^0.8.4"
"wagmi": "^0.9.0"
},
"devDependencies": {
"@types/node": "^17.0.35",
Expand Down
Loading

2 comments on commit a1d6776

@vercel
Copy link

@vercel vercel bot commented on a1d6776 Dec 12, 2022

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on a1d6776 Dec 12, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.