|
1 | | -import { createSolanaRpcClient, type SolanaClientConfig, type WalletConnector } from '@solana/client-core'; |
2 | | -import { SolanaClientProvider, useConnectWallet, useWallet, useWalletStandardConnectors } from '@solana/react-hooks'; |
| 1 | +import { createSolanaRpcClient, type SolanaClientConfig, type WalletConnector } from '@solana/client'; |
| 2 | +import { |
| 3 | + SolanaClientProvider, |
| 4 | + SolanaQueryProvider, |
| 5 | + useConnectWallet, |
| 6 | + useWallet, |
| 7 | + useWalletStandardConnectors, |
| 8 | +} from '@solana/react-hooks'; |
3 | 9 | import { useEffect, useMemo, useRef } from 'react'; |
4 | 10 |
|
| 11 | +import { AccountInspectorCard } from './components/AccountInspectorCard.tsx'; |
| 12 | +import { AirdropCard } from './components/AirdropCard.tsx'; |
5 | 13 | import { BalanceCard } from './components/BalanceCard.tsx'; |
6 | 14 | import { ClusterStatusCard } from './components/ClusterStatusCard.tsx'; |
| 15 | +import { LatestBlockhashCard } from './components/LatestBlockhashCard.tsx'; |
| 16 | +import { ProgramAccountsCard } from './components/ProgramAccountsCard.tsx'; |
| 17 | +import { SendTransactionCard } from './components/SendTransactionCard.tsx'; |
| 18 | +import { SignatureWatcherCard } from './components/SignatureWatcherCard.tsx'; |
| 19 | +import { SimulateTransactionCard } from './components/SimulateTransactionCard.tsx'; |
7 | 20 | import { SolTransferForm } from './components/SolTransferForm.tsx'; |
8 | 21 | import { SplTokenPanel } from './components/SplTokenPanel.tsx'; |
| 22 | +import { StoreInspectorCard } from './components/StoreInspectorCard.tsx'; |
| 23 | +import { TransactionPoolPanel } from './components/TransactionPoolPanel.tsx'; |
| 24 | +import { Tabs, TabsContent, TabsList, TabsTrigger } from './components/ui/tabs.tsx'; |
9 | 25 | import { WalletControls } from './components/WalletControls.tsx'; |
10 | 26 |
|
11 | 27 | const LAST_CONNECTOR_STORAGE_KEY = 'solana:last-connector'; |
@@ -39,7 +55,9 @@ export default function App() { |
39 | 55 |
|
40 | 56 | return ( |
41 | 57 | <SolanaClientProvider config={clientConfig}> |
42 | | - <DemoApp connectors={walletConnectors} /> |
| 58 | + <SolanaQueryProvider> |
| 59 | + <DemoApp connectors={walletConnectors} /> |
| 60 | + </SolanaQueryProvider> |
43 | 61 | </SolanaClientProvider> |
44 | 62 | ); |
45 | 63 | } |
@@ -107,17 +125,44 @@ function DemoApp({ connectors }: DemoAppProps) { |
107 | 125 | </span> |
108 | 126 | <h1>Solana Client Toolkit</h1> |
109 | 127 | <p> |
110 | | - This example wraps the headless <code>@solana/client-core</code> with a React context provider |
111 | | - and showcases the hooks exposed by <code>@solana/react-hooks</code>. |
| 128 | + This example wraps the headless <code>@solana/client</code> with a React context provider and |
| 129 | + showcases the hooks exposed by <code>@solana/react-hooks</code>. Explore state, transactions, |
| 130 | + and query helpers via the tabs below. |
112 | 131 | </p> |
113 | 132 | </header> |
114 | | - <div className="grid gap-6 md:grid-cols-2"> |
115 | | - <ClusterStatusCard /> |
116 | | - <WalletControls connectors={connectors} /> |
117 | | - <BalanceCard /> |
118 | | - <SolTransferForm /> |
119 | | - <SplTokenPanel /> |
120 | | - </div> |
| 133 | + <Tabs defaultValue="state"> |
| 134 | + <TabsList> |
| 135 | + <TabsTrigger value="state">Wallet & State</TabsTrigger> |
| 136 | + <TabsTrigger value="transactions">Transfers & Transactions</TabsTrigger> |
| 137 | + <TabsTrigger value="queries">Queries & Diagnostics</TabsTrigger> |
| 138 | + </TabsList> |
| 139 | + <TabsContent value="state"> |
| 140 | + <div className="grid gap-6 lg:grid-cols-2"> |
| 141 | + <ClusterStatusCard /> |
| 142 | + <WalletControls connectors={connectors} /> |
| 143 | + <BalanceCard /> |
| 144 | + <AccountInspectorCard /> |
| 145 | + <AirdropCard /> |
| 146 | + <StoreInspectorCard /> |
| 147 | + </div> |
| 148 | + </TabsContent> |
| 149 | + <TabsContent value="transactions"> |
| 150 | + <div className="grid gap-6 lg:grid-cols-2"> |
| 151 | + <SolTransferForm /> |
| 152 | + <SendTransactionCard /> |
| 153 | + <SplTokenPanel /> |
| 154 | + <TransactionPoolPanel /> |
| 155 | + </div> |
| 156 | + </TabsContent> |
| 157 | + <TabsContent value="queries"> |
| 158 | + <div className="grid gap-6 lg:grid-cols-2"> |
| 159 | + <LatestBlockhashCard /> |
| 160 | + <ProgramAccountsCard /> |
| 161 | + <SimulateTransactionCard /> |
| 162 | + <SignatureWatcherCard /> |
| 163 | + </div> |
| 164 | + </TabsContent> |
| 165 | + </Tabs> |
121 | 166 | </div> |
122 | 167 | </div> |
123 | 168 | ); |
|
0 commit comments