Skip to content

Commit

Permalink
update use-chain example
Browse files Browse the repository at this point in the history
  • Loading branch information
twhy committed Sep 27, 2023
1 parent 0be65af commit afedd5e
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions packages/example/pages/use-chain.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import Link from "next/link";
import { useState } from "react";
import { useChain } from "@cosmos-kit/react-lite";
import { Button } from "components/button";

export default function () {
const cosmoshub = useChain('cosmoshub')
const [chainName, setChainName] = useState('cosmoshub')
const chain = useChain(chainName)

return <div className="space-y-4 mx-auto max-w-3xl">
<pre>
<code>const cosmoshub = useChain('cosmoshub');</code>
</pre>
<Button onClick={() => cosmoshub.connect() }>
{ cosmoshub.isWalletConnected ? 'Disconnect' : 'Connect' }
<h1 className="text-2xl font-semibold">useChain</h1>
<select
value={chainName}
onChange={(e) => setChainName(e.target.value)}
className="h-9 px-3 mr-4 border rounded-md shadow-sm">
<option value="juno">Juno</option>
<option value="osmosis">Osmosis</option>
<option value="stargaze">Stargaze</option>
<option value="cosmoshub">Cosmos Hub</option>
</select>

<Button onClick={() => chain.connect() }>
{ chain.isWalletConnected ? 'Disconnect' : 'Connect' }
</Button>
<p>Address: {cosmoshub.address}</p>

<p>Address: {chain.address}</p>
<p className="text-center"><Link href="/use-chains">See useChains</Link></p>
</div>;
}

0 comments on commit afedd5e

Please sign in to comment.