diff --git a/Perigee/web/components/ConnectButton.tsx b/Perigee/web/components/ConnectButton.tsx index 720b831..0c4ba13 100644 --- a/Perigee/web/components/ConnectButton.tsx +++ b/Perigee/web/components/ConnectButton.tsx @@ -2,8 +2,13 @@ import { useWallet } from "../context/WalletContext"; import { motion, AnimatePresence } from "framer-motion"; -import { useState, useRef, useEffect } from "react"; +import { useState, useRef, useEffect, useMemo } from "react"; import { LogOut } from "lucide-react"; +import { + getCurrentNetwork, + getNetworkFromChainId, + getContractsForNetwork, +} from "../lib/contracts.config"; const ArrowDownIcon = () => ( ( fill="#33C5E0" /> -); +}); export function ConnectButton() { - const { isConnected, address, openModal, disconnect } = useWallet(); + const { isConnected, address, openModal, disconnect, chainId } = useWallet(); const [dropdownOpen, setDropdownOpen] = useState(false); - const dropdownRef = useRef(null); + const dropdownRef = useRef; + + const currentNetwork = useMemo(() => getCurrentNetwork(), []); + const network = chainId ? getNetworkFromChainId(chainId) : null; + const contracts = network ? getContractsForNetwork(network) : null; + const isWrongNetwork = + isConnected && currentNetwork && network !== currentNetwork; const formatAddress = (addr: string) => { if (!addr) return ""; @@ -56,9 +67,15 @@ export function ConnectButton() {
-
- )} - > - { - console.log('[UploadZone] Contract ready for analysis:', file.name, file.size, 'bytes'); - setWasmFile(file); - const reader = new FileReader(); - reader.onload = async (e) => { - const arrayBuffer = e.target?.result as ArrayBuffer; - const base64 = arrayBufferToBase64(arrayBuffer); - setWasmData(base64); - await handleSimulate({}, base64); - }; - reader.readAsArrayBuffer(file); - void handleWasmReady(file); - }} - onReset={() => { - setWasmFile(null); - setWasmData(null); - setCurrentResult(null); - }} - /> - - - - {/* ── Gas Golfing Results ──────────────────────────────────────── */} -
- {gasGolfingLoading ? ( - /* Skeleton for the gas golfing suggestions table */ -
-
- - -
-
- {[0, 1, 2, 3].map((i) => ( -
- - - -
- ))} -
-
- ) : gasGolfingError ? ( -
- {gasGolfingError} -
- ) : gasGolfingSuggestions.length ? ( - - ) : null} -
- - {/* ── Contract ID Input ────────────────────────────────────────── */} -
- - setContractId(e.target.value)} - placeholder="Enter Soroban contract ID" - style={{ - width: '100%', - padding: '12px 16px', - border: '1px solid #30363d', - borderRadius: '6px', - fontSize: '14px', - fontFamily: 'monospace', - boxSizing: 'border-box', - backgroundColor: '#0d1117', - color: '#c9d1d9', - }} - /> -

- Contract ID:{' '} - {contractId.substring(0, 20)}... -

- {wasmFile && ( -
- - Active WASM: - - - {wasmFile.name} - - - ({(wasmFile.size / 1024).toFixed(1)} KB) - -
- )} -
- - {/* ── Function Selection + Results ──────────────────────────────── */} -
- {/* Left Column – Function Selection & Form */} -
- { - setSelectedFunction(func); - setCurrentResult(null); - }} - /> - -
- - {/* Right Column – Results & History Tabs */} -
- {/* Tabs */} -
- - -
- - {/* Tab Content */} -
- {tab === 'explorer' ? ( - loading ? ( - /* Analysis in-flight: show skeleton for result + nutrition label */ - <> - -
- -
- - ) : ( - <> - - - {analysisReport && ( - - )} - - {currentResult?.resourceCost && ( -
- - -
- )} - - {currentResult?.resourceCost && ( -
- -
- )} - - ) - ) : ( - { - setCurrentResult(result); - setTab('explorer'); - }} - /> - )} -
-
-
- - - - {/* Wallet Modal */} - - - ); -} +export default function Home() { return null; }