Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : App/Sources/Security/MainnetWarningView.swift8// Module : Security9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0412// Last Modified : 2026-12-0413//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI42import QyvoraCore43import QyvoraCrypto44import QyvoraUI4546/// Full-screen warning shown before the main networks are switched on in an internal build. It must be read to the47/// end, and confirmed explicitly, before `onConfirm` is offered. It lists the per-transaction limits of every enabled48/// chain (`SecLimits.entries`).49struct MainnetWarningView: View {50 let entries: [SecLimits.Entry]51 let onConfirm: () -> Void52 let onCancel: () -> Void5354 @State private var reachedEnd = false55 @State private var acknowledged = false5657 var body: some View {58 VStack(spacing: 0) {59 ScrollView {60 LazyVStack(alignment: .leading, spacing: 20) {61 Image(systemName: "exclamationmark.triangle")62 .font(.system(size: 44, weight: .light))63 .foregroundStyle(QColor.warning)64 .accessibilityHidden(true)65 .padding(.top, 24)66 VStack(alignment: .leading, spacing: 8) {67 Text("Main networks use real funds")68 .font(.system(.largeTitle, design: .default, weight: .bold))69 .foregroundStyle(QColor.textPrimary)70 .accessibilityAddTraits(.isHeader)71 Text("Read this to the end before switching it on.")72 .font(QFont.title)73 .foregroundStyle(QColor.textSecondary)74 }75 point("The cryptography is unaudited",76 "QYVORA's cryptographic engine is written from scratch: key derivation, secp256k1 and Ed25519 signatures, hashing and the post-quantum algorithms. No independent review of it has taken place; the only audit so far is internal and automated. An undiscovered defect could expose a private key or produce an invalid transaction.")77 point("Real funds are at risk",78 "On a main network, coins and tokens have monetary value. This applies to every enabled chain at once. A loss caused by a defect cannot be reversed, and nobody can refund it.")79 point("Keep small amounts only",80 "Use this wallet on main networks with amounts you can afford to lose entirely. Keep savings in a wallet that has been audited.")81 VStack(alignment: .leading, spacing: QSpace.s) {82 Text("Limits per transaction in this build")83 .font(QFont.headline).foregroundStyle(QColor.textPrimary)84 .accessibilityAddTraits(.isHeader)85 Text("A transaction above a limit is refused, and so is one whose fee is above the fee ceiling. A limit expressed in dollars needs fresh prices from two independent sources that agree within 5 %: otherwise the transaction is refused. A dollar-pegged token counts for at least 0.90 USD a unit, whatever the price source says. The limits bound a single mistake; they do not protect the balance of the wallet.")86 .font(QFont.callout).foregroundStyle(QColor.textSecondary)87 .fixedSize(horizontal: false, vertical: true)88 SecLimitsList(entries: entries).padding(.top, QSpace.xs)89 }90 .id("limits")91 point("Internal testing only",92 "This switch exists in internal builds, for testing by the publisher. It is not a recommendation to use QYVORA with real funds.")93 point("Nothing here makes the blockchains quantum-resistant",94 "Post-quantum algorithms protect the local vault, backups, transfers and the identity. Transactions are still authorized with the signatures each network validates: secp256k1 ECDSA, or Ed25519 on Solana.")95 QListSection("Audit status") {96 SecTextRow(text: QyvoraEngine.auditStatus)97 }98 Text("You can return to the test networks at any time, for every chain at once.")99 .font(QFont.callout)100 .foregroundStyle(QColor.textSecondary)101 .onAppear { reachedEnd = true }102 .id("end")103 }104 .padding(.horizontal, 24)105 .padding(.bottom, 24)106 .frame(maxWidth: 600, alignment: .leading)107 .frame(maxWidth: .infinity)108 }109 .debugScroll()110 .securityDebugTour()111 // keeps the text out from under the status bar: this screen has no navigation bar112 .padding(.top, 1)113 footer114 }115 .qScreen()116 .interactiveDismissDisabled()117 }118119 var footer: some View {120 VStack(alignment: .leading, spacing: 12) {121 Divider().overlay(QColor.stroke)122 if !reachedEnd {123 Label("Scroll to the end to continue", systemImage: "arrow.down").font(QFont.caption).foregroundStyle(QColor.textSecondary)124 }125 Toggle("I have read this. I accept that funds on main networks may be lost.", isOn: $acknowledged)126 .tint(QColor.warning)127 .font(QFont.callout)128 .disabled(!reachedEnd)129 Button("Switch to main networks", action: onConfirm)130 .buttonStyle(.qPrimary)131 .disabled(!(reachedEnd && acknowledged))132 Button("Stay on test networks", action: onCancel)133 .buttonStyle(.qSecondary)134 }135 .padding(.horizontal, 24)136 .padding(.bottom, 16)137 .background(QColor.background)138 }139140 func point(_ title: String, _ text: String) -> some View {141 VStack(alignment: .leading, spacing: 6) {142 Text(title).font(QFont.headline).foregroundStyle(QColor.textPrimary)143 Text(text).font(QFont.body).foregroundStyle(QColor.textPrimary)144 }145 .fixedSize(horizontal: false, vertical: true)146 .accessibilityElement(children: .combine)147 }148149 static func usd(_ value: Double) -> String {150 value == value.rounded() ? String(Int(value)) : String(format: "%.2f", value)151 }152}153