|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { useState } from 'react' |
| 4 | +import { getContracts, type Network } from '@/lib/network-manifest' |
| 5 | + |
| 6 | +export function ContractTable() { |
| 7 | + const [network, setNetwork] = useState<Network>('testnet') |
| 8 | + const contracts = getContracts(network) |
| 9 | + |
| 10 | + return ( |
| 11 | + <div className="my-6"> |
| 12 | + <div className="flex items-center gap-3 mb-4"> |
| 13 | + <span className="text-sm font-medium text-gray-700">Network:</span> |
| 14 | + <div className="flex rounded-md border overflow-hidden text-sm"> |
| 15 | + {(['testnet', 'public'] as Network[]).map((n) => ( |
| 16 | + <button |
| 17 | + key={n} |
| 18 | + onClick={() => setNetwork(n)} |
| 19 | + className={`px-3 py-1.5 transition-colors ${ |
| 20 | + network === n |
| 21 | + ? 'bg-blue-600 text-white' |
| 22 | + : 'bg-white text-gray-600 hover:bg-gray-50' |
| 23 | + }`} |
| 24 | + > |
| 25 | + {n === 'public' ? 'Mainnet' : 'Testnet'} |
| 26 | + </button> |
| 27 | + ))} |
| 28 | + </div> |
| 29 | + </div> |
| 30 | + |
| 31 | + <div className="overflow-x-auto rounded-lg border"> |
| 32 | + <table className="w-full text-sm"> |
| 33 | + <thead className="bg-gray-50 text-left"> |
| 34 | + <tr> |
| 35 | + <th className="px-4 py-2 font-medium text-gray-600">Contract</th> |
| 36 | + <th className="px-4 py-2 font-medium text-gray-600">Contract ID</th> |
| 37 | + <th className="px-4 py-2 font-medium text-gray-600">WASM Hash</th> |
| 38 | + <th className="px-4 py-2 font-medium text-gray-600">Deployed</th> |
| 39 | + <th className="px-4 py-2 font-medium text-gray-600">Explorer</th> |
| 40 | + </tr> |
| 41 | + </thead> |
| 42 | + <tbody> |
| 43 | + {contracts.map((c) => ( |
| 44 | + <tr key={c.name} className="border-t"> |
| 45 | + <td className="px-4 py-2 font-mono font-medium">{c.name}</td> |
| 46 | + <td className="px-4 py-2 font-mono text-xs break-all">{c.contractId}</td> |
| 47 | + <td className="px-4 py-2 font-mono text-xs break-all">{c.expectedWasmHash}</td> |
| 48 | + <td className="px-4 py-2 text-xs text-gray-500"> |
| 49 | + {new Date(c.deployedAt).toLocaleDateString()} |
| 50 | + </td> |
| 51 | + <td className="px-4 py-2"> |
| 52 | + <a |
| 53 | + href={c.stellarExpertUrl} |
| 54 | + target="_blank" |
| 55 | + rel="noopener noreferrer" |
| 56 | + className="text-blue-600 hover:underline text-xs" |
| 57 | + > |
| 58 | + Stellar Expert ↗ |
| 59 | + </a> |
| 60 | + </td> |
| 61 | + </tr> |
| 62 | + ))} |
| 63 | + </tbody> |
| 64 | + </table> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + ) |
| 68 | +} |
0 commit comments