Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : App/Sources/Security/SecurityHandoff.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 QyvoraWallet4344/// Hands a Bitcoin plan built by a security screen (sweep of exposed coins) to the send-review screen.45///46/// The wallet screens install it once, above the tab view:47///48/// .environment(\.bitcoinPlanHandoff, BitcoinPlanHandoff { plan in reviewedPlan = plan })49///50/// and present their own review for `plan` (which signs with `signAndBroadcastBitcoin`). While no handoff is51/// installed, the security screens fall back to their own minimal review sheet.52struct BitcoinPlanHandoff: Sendable {53 let review: @MainActor @Sendable (BitcoinSendPlan) -> Void5455 init(_ review: @escaping @MainActor @Sendable (BitcoinSendPlan) -> Void) {56 self.review = review57 }58}5960/// Hands an Ethereum review built by a security screen (revocation of an approval) to the send-review screen,61/// which signs with `signAndBroadcastEthereum`. Same contract as `BitcoinPlanHandoff`.62struct EthereumReviewHandoff: Sendable {63 let review: @MainActor @Sendable (EthereumSendReview) -> Void6465 init(_ review: @escaping @MainActor @Sendable (EthereumSendReview) -> Void) {66 self.review = review67 }68}6970/// Hands a payment of ANY chain, prepared by a security screen (sweep of exposed coins of Litecoin, Dogecoin or71/// Bitcoin Cash, revocation of an approval on any EVM network, a TRON revocation…), to the send-review screen, which72/// signs with `signAndBroadcast(_ review:)`. The wallet screens install it once, above the tab view:73///74/// .environment(\.secSendReviewHandoff, SecSendReviewHandoff { review in reviewed = review })75///76/// When it is installed the security screens use it for every chain. `BitcoinPlanHandoff` and `EthereumReviewHandoff`77/// keep working for the two primary chains when it is not; while none is installed, the security screens fall back to78/// their own minimal review sheet.79struct SecSendReviewHandoff: Sendable {80 let review: @MainActor @Sendable (SendReview) -> Void81 init(_ review: @escaping @MainActor @Sendable (SendReview) -> Void) {82 self.review = review83 }84}8586extension EnvironmentValues {87 /// nil until the wallet screens install their multi-chain review.88 @Entry var secSendReviewHandoff: SecSendReviewHandoff? = nil89 /// nil until the wallet screens install their Bitcoin review.90 @Entry var bitcoinPlanHandoff: BitcoinPlanHandoff? = nil91 /// nil until the wallet screens install their Ethereum review.92 @Entry var ethereumReviewHandoff: EthereumReviewHandoff? = nil93}94