Skip to content

Commit 873be96

Browse files
authored
FIX - wagmi lib to v3 (#1295)
* Refactor: Replace useAccount with useConnection in BlockchainInfo and ConnectWallet components; update documentation for Wagmi v3 * fix: llms
1 parent ff2c42b commit 873be96

File tree

17 files changed

+2170
-27298
lines changed

17 files changed

+2170
-27298
lines changed

.ai/categories/basics.md

Lines changed: 159 additions & 2168 deletions
Large diffs are not rendered by default.

.ai/categories/dapps.md

Lines changed: 247 additions & 3539 deletions
Large diffs are not rendered by default.

.ai/categories/infrastructure.md

Lines changed: 128 additions & 2505 deletions
Large diffs are not rendered by default.

.ai/categories/networks.md

Lines changed: 124 additions & 2501 deletions
Large diffs are not rendered by default.

.ai/categories/parachains.md

Lines changed: 107 additions & 2128 deletions
Large diffs are not rendered by default.

.ai/categories/polkadot-protocol.md

Lines changed: 140 additions & 3095 deletions
Large diffs are not rendered by default.

.ai/categories/reference.md

Lines changed: 0 additions & 493 deletions
Large diffs are not rendered by default.

.ai/categories/smart-contracts.md

Lines changed: 83 additions & 2823 deletions
Large diffs are not rendered by default.

.ai/categories/tooling.md

Lines changed: 1152 additions & 5100 deletions
Large diffs are not rendered by default.

.ai/pages/smart-contracts-libraries-wagmi.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ cd wagmi-polkadot-hub
2424

2525
## Install Dependencies
2626

27-
Install Wagmi and its peer dependencies:
27+
Install Wagmi v3 and its peer dependencies:
2828

2929
```bash
30-
npm install wagmi viem @tanstack/react-query
30+
npm install wagmi@3 viem @tanstack/react-query
3131
```
3232

3333
## Configure Wagmi for Polkadot Hub
@@ -140,12 +140,12 @@ Create a component to connect wallets to your dApp. Create a file named `app/com
140140
"use client";
141141

142142
import React from "react";
143-
import { useConnect, useAccount, useDisconnect } from "wagmi";
143+
import { useConnect, useConnection, useDisconnect } from "wagmi";
144144
import { injected } from "wagmi/connectors";
145145

146146
export function ConnectWallet() {
147147
const { connect } = useConnect();
148-
const { address, isConnected } = useAccount();
148+
const { address, isConnected } = useConnection();
149149
const { disconnect } = useDisconnect();
150150

151151
if (isConnected) {
@@ -170,7 +170,7 @@ This component uses the following React hooks:
170170

171171
- **[`useConnect`](https://wagmi.sh/react/api/hooks/useConnect#useconnect){target=\_blank}**: Provides functions and state for connecting the user's wallet to your dApp. The `connect` function initiates the connection flow with the specified connector.
172172
- **[`useDisconnect`](https://wagmi.sh/react/api/hooks/useDisconnect#usedisconnect){target=\_blank}**: Provides a function to disconnect the currently connected wallet.
173-
- **[`useAccount`](https://2.x.wagmi.sh/react/api/hooks/useAccount#useaccount){target=\_blank}**: Returns data about the connected account, including the address and connection status.
173+
- **[`useConnection`](https://wagmi.sh/react/api/hooks/useConnection#useconnection){target=\_blank}**: Returns data about the connected account, including the address and connection status. In Wagmi v3, `useAccount` has been renamed to `useConnection`.
174174

175175
## Fetch Blockchain Data
176176

@@ -179,10 +179,10 @@ Wagmi provides various hooks to fetch blockchain data. Here's an example compone
179179
```typescript title="app/components/BlockchainInfo.tsx"
180180
"use client";
181181

182-
import { useBlockNumber, useBalance, useAccount } from "wagmi";
182+
import { useBlockNumber, useBalance, useConnection } from "wagmi";
183183

184184
export function BlockchainInfo() {
185-
const { address } = useAccount();
185+
const { address } = useConnection();
186186
// Get the latest block number
187187
const { data: blockNumber } = useBlockNumber({ watch: true });
188188

@@ -373,10 +373,10 @@ Update your main page to combine all the components. Create or update the file `
373373
import { BlockchainInfo } from "./components/BlockchainInfo";
374374
import { ConnectWallet } from "./components/ConnectWallet";
375375
import { StorageContract } from "./components/StorageContract";
376-
import { useAccount } from "wagmi";
376+
import { useConnection } from "wagmi";
377377

378378
export default function Home() {
379-
const { isConnected } = useAccount();
379+
const { isConnected } = useConnection();
380380

381381
return (
382382
<main>

0 commit comments

Comments
 (0)