Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshka committed Jul 24, 2024
1 parent 7c74d7f commit c4a40f5
Show file tree
Hide file tree
Showing 4 changed files with 8,429 additions and 4,528 deletions.
4 changes: 2 additions & 2 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"superjson": "^2.0.0",
"undici": "^5.26.3",
"valtio": "^1.11.2",
"viem": "^1.20.0",
"wagmi": "^1.4.4",
"viem": "^2.17.11",
"wagmi": "^2.12.0",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down
14 changes: 10 additions & 4 deletions examples/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ import { EditionInfo } from '@/components/editionInfo'
import { WalletPrivateKeyInput } from '@/components/walletInput'
import { useContractAddress } from '@/context/contractAddress'
import { useWallet } from '@/context/wallet'
import { useBalance } from 'wagmi'
import { useQueryClient } from '@tanstack/react-query'
import { useEffect } from 'react'
import { useBlockNumber, useBalance } from 'wagmi'

export default function Home() {
const { wallet } = useWallet()

const balance = useBalance({
const queryClient = useQueryClient()
const { data: blockNumber } = useBlockNumber({ watch: true })
const { data: balance, queryKey } = useBalance({
address: wallet?.account.address,
watch: true,
})
useEffect(() => {
queryClient.invalidateQueries({ queryKey })
}, [blockNumber, queryClient, queryKey])

const {
contractAddress,
Expand All @@ -33,7 +39,7 @@ export default function Home() {
{wallet && (
<>
<p>Balance of {wallet.account.address}</p>
<p>{balance.data ? `${Number(balance.data.formatted).toFixed(5)} eth` : 'Loading...'}</p>
<p>{balance?.decimals != null ? `${Number(balance.decimals).toFixed(5)} eth` : 'Loading...'}</p>
<br />
</>
)}
Expand Down
6 changes: 4 additions & 2 deletions examples/nextjs/src/context/wagmi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ export const publicClient = createPublicClient({
.extend(soundEditionVersionPublicActions)

const config = createConfig({
autoConnect: true,
publicClient,
chains: [chain],
transports: {
[chain.id]: http(RPC_URL),
},
})

export function WagmiContext({ children }: { children: React.ReactNode }) {
Expand Down
Loading

0 comments on commit c4a40f5

Please sign in to comment.