packages = ["matplotlib", "numpy"] [[fetch]] # Hier binden wir deine Core-Logik und alle Frontend-Scripts ein files = [ "ai-chain.py", "auth-logic.js", "scripts/ui.js", "scripts/charts.js", "scripts/hash-generator.js", "scripts/login.js", "scripts/register.js", "scripts/admin.js", "scripts/banking.js", "scripts/dex.js" ]
AI-Chain – RFOF-NETWORK

Chain Viewer

Blocks (Genesis → Latest)

Block Details

from js import document, console, fetch import json import asyncio import hashlib from pyodide.ffi import create_proxy # ----------------------------- # Helper: fetch JSON from API # ----------------------------- async def fetch_json(url: str): resp = await fetch(url) text = await resp.text() try: return json.loads(text) except Exception: return None # ----------------------------- # Chain Viewer Logic # ----------------------------- block_list_el = document.getElementById("block-list") block_details_el = document.getElementById("block-details") async def load_blocks(): # EXPECTED API: /api/blocks -> list of blocks data = await fetch_json("/api/blocks") if not data: block_list_el.innerHTML = "No blocks available." return block_list_el.innerHTML = "" for blk in data: div = document.createElement("div") div.classList.add("block-item") # clickable text links: index, hash, license_ref span_index = document.createElement("span") span_index.classList.add("link") span_index.innerText = f"Block #{blk.get('index', '?')}" span_index.onclick = (lambda b=blk: lambda ev: show_block_details(b))() span_hash = document.createElement("span") span_hash.classList.add("link") span_hash.innerText = f" | hash: {blk.get('hash', '')[:12]}..." span_hash.onclick = (lambda b=blk: lambda ev: show_block_details(b))() span_license = document.createElement("span") span_license.classList.add("link") lic = blk.get("data", {}).get("license_metadata", {}) span_license.innerText = f" | {lic.get('license_ref', '')}" span_license.onclick = (lambda b=blk: lambda ev: show_block_details(b))() div.appendChild(span_index) div.appendChild(span_hash) div.appendChild(span_license) block_list_el.appendChild(div) def show_block_details(block): block_details_el.innerHTML = "" pre = document.createElement("pre") pre.innerText = json.dumps(block, indent=2) block_details_el.appendChild(pre) asyncio.ensure_future(load_blocks()) #------------------------------ # CONSOLE # ----------------------------- def console_command(self, cmd): if cmd == "health": return self.system_health() if cmd == "metrics": return self.show_chain_metrics() if cmd == "chain": return self.chain if cmd == "user": return self.user_profiles if cmd == "balances": return self.balances return f"Unknown command: {cmd}" # ----------------------------- # Wallet Logic (simplified) # ----------------------------- wallet_address_el = document.getElementById("wallet-address") wallet_balances_el = document.getElementById("wallet-balances") wallet_txs_el = document.getElementById("wallet-txs") async def create_wallet(event=None): username = document.getElementById("wallet-username").value password = document.getElementById("wallet-password").value if not username or not password: console.log("Missing username or password") return # EXPECTED API: POST /api/wallet/create payload = json.dumps({"username": username, "password": password}) resp = await fetch("/api/wallet/create", { "method": "POST", "body": payload, "headers": {"Content-Type": "application/json"} }) text = await resp.text() data = json.loads(text) wallet_address_el.innerHTML = f"Wallet Address: {data.get('address', '')}" async def login_wallet(event=None): username = document.getElementById("login-username").value password = document.getElementById("login-password").value if not username or not password: console.log("Missing login credentials") return # EXPECTED API: POST /api/wallet/login payload = json.dumps({"username": username, "password": password}) resp = await fetch("/api/wallet/login", { "method": "POST", "body": payload, "headers": {"Content-Type": "application/json"} }) text = await resp.text() data = json.loads(text) addr = data.get("address", "") wallet_address_el.innerHTML = f"Wallet Address: {addr}" await load_wallet_state(addr) async def load_wallet_state(address: str): # EXPECTED API: /api/wallet/state/{address} data = await fetch_json(f"/api/wallet/state/{address}") if not data: wallet_balances_el.innerHTML = "No wallet data." return balances = data.get("balances", {}) wallet_balances_el.innerHTML = "Balances: " + json.dumps(balances) txs = data.get("transactions", []) wallet_txs_el.innerHTML = "" for tx in txs: div = document.createElement("div") div.classList.add("block-item") div.innerText = f"{tx.get('tx_hash','')[:12]}... | {tx.get('token','')} {tx.get('amount','')}" wallet_txs_el.appendChild(div) document.getElementById("btn-create-wallet").onclick = create_wallet document.getElementById("btn-login-wallet").onclick = login_wallet # ----------------------------- # Settings: License & ECCU Info # ----------------------------- license_info_el = document.getElementById("license-info") fee_info_el = document.getElementById("fee-info") eccu_info_el = document.getElementById("eccu-info") async def load_system_info(): # EXPECTED API: /api/system/info data = await fetch_json("/api/system/info") if not data: license_info_el.innerHTML = "No system info." return license_info_el.innerHTML = "License: " + data.get("license_ref", "") fee_info_el.innerHTML = "Fee Split: " + json.dumps(data.get("fee_split", {})) eccu_info_el.innerHTML = "ECCU Fond: " + json.dumps(data.get("eccu_fond", {})) asyncio.ensure_future(load_system_info()) # ----------------------------- # PHRASEN LOGIK: WALLET & SETTINGS # ----------------------------- def open_phrase_modal(event): """Erstellt das Raster und öffnet das Modal-Fenster.""" username_el = document.getElementById("login-username") if not username_el: return username = username_el.value if not username: console.log("Fehler: Kein Username für Phrase-Login.") return modal = document.getElementById("phrase-modal") grid = document.getElementById("phrase-grid") grid.innerHTML = "" # Dynamische Anzahl basierend auf Rang: Admin = 48, User = 24 🧩 phrase_count = 48 if username.lower() == "admin" else 24 for i in range(1, phrase_count + 1): container = document.createElement("div") input_el = document.createElement("input") input_el.type = "text" input_el.placeholder = f"{i}." input_el.style.width = "100%" input_el.classList.add("phrase-input") container.appendChild(input_el) grid.appendChild(container) document.getElementById("modal-username-display").innerText = username modal.classList.remove("hidden") def submit_phrase(event): """Liest Wörter aus, hasht sie doppelt und validiert gegen die Chain.""" grid = document.getElementById("phrase-grid") inputs = grid.getElementsByTagName("input") # 1. Wörter einsammeln und normalisieren 🧹 phrase_list = [inputs.item(i).value.strip().lower() for i in range(inputs.length)] full_phrase = " ".join([w for w in phrase_list if w]) # Nur ausgefüllte Wörter if not full_phrase: console.log("Fehler: Keine Phrase eingegeben.") return # 2. Double SHA-256 Hashing (RFOF-PZQQET Standard) 🔐🔐 # Erster Durchgang first_pass = hashlib.sha256(full_phrase.encode("utf-8")).digest() # Zweiter Durchgang (Hex-Output für den Vergleich) final_hash = hashlib.sha256(first_pass).hexdigest() # 3. Validierung gegen den Genesis-Admin-Hash 🏆 # Wert aus deiner blockchain.py (PZQQET AXIOME) admin_target = "5b3e57a9f4de5a155f5d7d33584467942b456d6e4b02f0139b47b0291f7e626b" if final_hash == admin_target: console.log("✅ Validierung erfolgreich! Zugriff auf Admin-Wallet gewährt.") document.getElementById("phrase-modal").classList.add("hidden") # Umschalten auf Wallet-Sektion via JS-Interop showSection('wallet') # Admin-Status visuell bestätigen addr_display = document.getElementById("wallet-address") if addr_display: addr_display.innerHTML = "Sovereign Admin: 1JGSqDHRoEfwLaB4wh9Up9j7NgckpyYYjZ" else: console.log("❌ Validierung fehlgeschlagen. Der Hash stimmt nicht überein.") # Visuelles Feedback: Roter Rahmen für das Grid grid.style.border = "1px solid #ff4444" # ----------------------------- # SETUP (Event-Binding via Proxy) 🚀 # ----------------------------- def setup(): # Wir erstellen Proxies, damit JS die Python-Funktionen sicher findet open_proxy = create_proxy(open_phrase_modal) submit_proxy = create_proxy(submit_phrase) # Verknüpfung mit den Buttons im DOM btn_login = document.getElementById("btn-phrase-login") btn_submit = document.getElementById("btn-submit-phrase") if btn_login: btn_login.addEventListener("click", open_proxy) if btn_submit: btn_submit.addEventListener("click", submit_proxy) console.log("PRAI-System: Event-Binding abgeschlossen.") # Initialisierung starten setup()