import { useState } from 'react'; import { useWallet, useConnection, useAnchorWallet } from '@solana/wallet-adapter-react'; import * as anchor from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; import { getMXEPublicKey, } from '@arcium-hq/client'; import { Buffer } from 'buffer'; import { createAnchorProvider, } from 'arcium-frontend-sdk'; import Grid from './components/Grid'; import Row from './components/Row'; import Card from './components/Card'; import Button from './components/Button'; import Text from './components/Text'; import { ClientWalletProvider } from './contexts/ClientWalletProvider'; import { WalletConnect } from './components/WalletConnect'; function AppContent() { const { connected, publicKey } = useWallet(); const { connection } = useConnection(); const wallet = useAnchorWallet(); const [logs, setLogs] = useState([]); const [loading, setLoading] = useState(false); const addLog = (msg: string) => setLogs(prev => [...prev, `> ${msg}`]); const handleMPCInteraction = async () => { if (!wallet || !publicKey) { addLog("Wallet not connected."); return; } setLoading(true); addLog("Starting MPC interaction..."); try { // 0. Setup Provider const provider = createAnchorProvider(connection, wallet, 'confirmed'); // Use SystemProgram ID as a safe default if env is missing, to prevent "Invalid public key" crash const defaultMxeId = '11111111111111111111111111111111'; const programId = new PublicKey(import.meta.env.NEXT_PUBLIC_MXE_PROGRAM_ID || defaultMxeId); addLog("Fetching MXE Public Key..."); // 1. Fetch MXE Key const mxePublicKey = await getMXEPublicKey(provider, programId); let keyStr = 'unknown'; if (mxePublicKey && typeof mxePublicKey === 'object' && 'toBase58' in mxePublicKey) { keyStr = (mxePublicKey as any).toBase58(); } else if (mxePublicKey instanceof Uint8Array) { keyStr = Buffer.from(mxePublicKey).toString('hex'); } addLog(`MXE Key: ${keyStr.slice(0, 8)}...`); // This is where you would call: // prepareEncryptionPayload(...) // deriveCoreAccounts(...) // encodeEncryptedCall(...) // buildInstruction(...) // buildTransaction(...) addLog("MPC Interaction simulation complete."); addLog("To implement real logic, import functions from 'arcium-frontend-sdk'."); } catch (e: any) { console.error(e); addLog(`Error: ${e.message}`); } finally { setLoading(false); } }; return (
Secure Multiparty Computation Interface.
Connect your Solana wallet to begin.

STATUS: {connected ? 'ONLINE' : 'OFFLINE'}
NETWORK: DEVNET
{connected && ( Initiate encrypted computation on the Arcium Network.
)}
{logs.length === 0 ? System idle. : logs.map((log, i) => ( {log} ))}
) } function App() { return ( ) } export default App