SPB Git

Repository Public

FuturesGMXView.swift 26.7 KB 408 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : SP Wallet for macOS9// File             : Features/Futures/FuturesGMXView.swift10// Description      : GMX v2 on Arbitrum, exactly as the server reports it: its11//                    two server settings and every blocker with the server's12//                    sentence, the pinned contract set, the wallet's on-chain13//                    positions (their liquidation price is the server's14//                    ESTIMATE), pending orders and operations. This app does15//                    not offer opening GMX positions (the product offers16//                    Hyperliquid only); when the server reports GMX as not17//                    tradable the reasons are shown and there is no order18//                    control. What stays available is what only removes risk or19//                    authority: reducing a position (a verified wallet intent,20//                    reviewed and approved by passkey), the GMX halt and the21//                    revocation of the GMX authorization (no passkey).22// Module           : Features23// Repository       : https://git.spboucher.ai/sp-wallet-macos24// Created          : 2026-11-1825// Last Modified    : 2026-11-1826//27// =============================================================================28// AUTHOR & PROFESSIONAL AFFILIATION29// =============================================================================30//31// Author           : Simon-Pierre Boucher32// Position         : Professor of Finance33// Institution      : Université du Québec en Outaouais (UQO)34// Department       : Département des sciences administratives35// Organization     : SP Boucher36//37// Website          : https://spboucher.ai38// Git              : https://git.spboucher.ai39//40// =============================================================================41// OFFICIAL CONTACT DIRECTORY42// =============================================================================43//44// General          : info@spboucher.ai45// Professional     : contact@spboucher.ai46// Direct           : simon@spboucher.ai47// Research         : research@spboucher.ai48// Development      : dev@spboucher.ai49// Support          : support@spboucher.ai50// Security/Admin   : admin@spboucher.ai51// Notifications    : notifications@spboucher.ai52//53// Preferred Contact: support@spboucher.ai54//55// =============================================================================56// COPYRIGHT & INTELLECTUAL PROPERTY57// =============================================================================58//59// Copyright (c) 202660// Simon-Pierre Boucher61//62// All rights reserved where applicable.63//64// This file is governed by the applicable project license,65// copyright notices, institutional agreements and relevant law.66//67// Unless expressly authorized by the applicable license or68// rights holder, copying, redistribution, sublicensing,69// publication and commercial exploitation are not permitted.70//71// Existing third-party rights and notices remain unaffected.72//73// =============================================================================74// CONFIDENTIALITY & SECURITY75// =============================================================================76//77// Classification   : Public78// Distribution     : Public repository; use is governed by the project license79// Security Contact : admin@spboucher.ai80//81// Access to this source does not independently grant permission82// to redistribute or disclose confidential materials.83//84// Do not embed credentials, private keys, access tokens,85// certificates or confidential personal information.86//87// =============================================================================88// LICENSE & MAINTENANCE89// =============================================================================90//91// License          : None specified (no license file in this repository)92// Maintainer       : Simon-Pierre Boucher93// Technical Contact: dev@spboucher.ai94//95// =============================================================================96// END OF SP BOUCHER SOURCE HEADER97// =============================================================================9899import SwiftUI100import SPWalletCore101102@MainActor @Observable final class FutGMXFlow {103    enum Sheet: Identifiable {104        case order(GmxOrderPreparation, GmxOrderApproval)105        case risk(GmxRiskApproval)106        var id: String { switch self { case .order(_, let a): "gmx-\(a.operationId)"; case .risk(let r): "gmxrisk-\(r.intent.nonce)" } }107    }108    let model: AppModel109    let store: FuturesStore110    private(set) var status = FutLoaded<GmxStatus>()111    private(set) var jurisdiction = FutLoaded<GmxJurisdictionAnswer>()112    var sheet: Sheet?113    private(set) var busy = false114    private(set) var approving = false115    var error: String?116    var sheetError: String?117    var notice: String?118    private(set) var tracked: GmxOperation?119    @ObservationIgnored private var closeKey: (key: String, fingerprint: String)?120    @ObservationIgnored private var trackTask: Task<Void, Never>?121122    init(model: AppModel, store: FuturesStore) { self.model = model; self.store = store }123    private var gmx: DerivativesGMXAPI { store.gmx }124125    func load() async {126        status.loading = true127        do { status.set(try await gmx.status(locale: store.locale)) } catch { status.fail(model.describe(error)) }128        if jurisdiction.value == nil { do { jurisdiction.set(try await gmx.jurisdiction()) } catch { jurisdiction.fail(model.describe(error)) } }129    }130131    private func run(_ body: () async throws -> Void) async {132        guard model.canOperate, !busy, !approving else { return }133        busy = true; error = nil; notice = nil134        defer { busy = false }135        do { try await body() } catch { self.error = model.describe(error) }136    }137138    func halt(reason: String) async {139        await run { let s = try await gmx.halt(reason: reason, locale: store.locale); status.set(s); notice = "Arrêt GMX engagé : aucune nouvelle position. Rien n’est annulé ni clôturé." + (s.risk?.note.map { " \($0)" } ?? "") }140    }141    func revoke() async {142        await run { status.set(try await gmx.revokeAuthorization(locale: store.locale)); notice = "Autorisation GMX révoquée. Les positions restent ouvertes." }143    }144    func prepareResume() async {145        guard let s = status.value else { return }146        await run {147            switch try await gmx.prepareResume(status: s) {148            case .notNeeded: notice = "Aucun arrêt GMX à lever."149            case .approval(let r): sheetError = nil; sheet = .risk(r)150            }151        }152    }153154    func prepareClose(_ p: GmxPositionView, fraction: String, slippageBps: Int) async {155        guard let s = status.value, let side = GmxSide(rawValue: p.side) else { return }156        await run {157            guard let own = model.address(on: s.network) else { throw APIError(status: 0, code: "no_address", message: "L’adresse Arbitrum de ce portefeuille est inconnue de l’app : impossible de vérifier l’opération.") }158            let fp = "\(p.key)|\(p.sizeUsd)|\(fraction)|\(slippageBps)"159            if closeKey?.fingerprint != fp { closeKey = (APIClient.newIdempotencyKey(), fp) }160            let prep = try await gmx.prepareClose(GmxCloseRequest(market: p.market, side: side, fraction: fraction, slippageBps: slippageBps), position: p, status: s, ownAddress: own, idempotencyKey: closeKey!.key)161            if let a = prep.approvable { sheetError = nil; sheet = .order(prep, a) }162            else { closeKey = nil; follow(prep.operation); notice = "Cette opération existait déjà et n’attend plus d’approbation : état « \(prep.operation.state) »." }163        }164    }165166    func approve() async {167        guard let sheet, model.canOperate, !approving else { return }168        approving = true; sheetError = nil169        defer { approving = false }170        do {171            switch sheet {172            case .order(_, let a):173                let op = try await gmx.approve(a, with: model.authenticator)174                closeKey = nil; self.sheet = nil175                follow(op); await load()176            case .risk(let r):177                status.set(try await gmx.approveRiskChange(r, with: model.authenticator, locale: store.locale))178                self.sheet = nil; notice = "Arrêt GMX levé par le serveur."179            }180        } catch PasskeyError.cancelled {181        } catch {182            sheetError = model.describe(error)183            // a lost answer: read what the server holds for this operation instead of signing again184            if case .order(let p, let a) = sheet, let op = try? await gmx.operation(a.operationId), op.state != p.operation.state { closeKey = nil; self.sheet = nil; self.error = sheetError; follow(op) }185        }186    }187188    func dismiss() async {189        guard let s = sheet, !approving else { return }190        sheet = nil; sheetError = nil191        if case .order(_, let a) = s { closeKey = nil; if (try? await gmx.withdraw(a.operationId)) != nil { notice = "Opération retirée : rien n’a été signé." }; await load() }192    }193194    private func follow(_ op: GmxOperation) {195        tracked = op196        trackTask?.cancel()197        guard !op.final else { return }198        trackTask = Task { [weak self] in199            while !Task.isCancelled {200                try? await Task.sleep(for: .seconds(6))201                guard let self, !Task.isCancelled, let cur = self.tracked, cur.id == op.id else { return }202                guard AppActivity.isActive, let fresh = try? await self.store.gmx.operation(cur.id) else { continue }203                self.tracked = fresh204                if fresh.final {205                    Notifier.post(title: "Opération GMX : \(fresh.state)", body: (fresh.marketName ?? fresh.kind) + (fresh.error.map { " — \($0)" } ?? ""), id: "gmx-\(fresh.id)")206                    await self.load(); await self.model.refreshAll(); return207                }208            }209        }210    }211}212213struct FutGMXView: View {214    let model: AppModel215    let store: FuturesStore216    @State private var flow: FutGMXFlow?217218    var body: some View {219        Group { if let flow { FutGMXContent(model: model, store: store, flow: flow) } else { ProgressView() } }220            .task { if flow == nil { flow = FutGMXFlow(model: model, store: store) } }221    }222}223224private struct FutGMXContent: View {225    let model: AppModel226    let store: FuturesStore227    @Bindable var flow: FutGMXFlow228    @State private var haltReason = ""229    @State private var confirmHalt = false230    @State private var confirmRevoke = false231    @State private var slippage = "50"232233    var body: some View {234        Card("GMX v2 — état rapporté par le serveur", trailing: AnyView(HStack { if flow.status.loading { ProgressView().controlSize(.small) }; Button("Actualiser") { Task { await flow.load() } }; FutModeBadge(mode: .mainnet) })) {235            Text("GMX n’a pas de compte de plateforme : le compte est l’adresse de ce portefeuille sur Arbitrum, et un ordre est une transaction du portefeuille qu’un « keeper » exécute ensuite. Il n’existe ni mode papier ni testnet pour GMX ici.").font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)236            if let e = flow.status.error { Banner(.danger, "État GMX indisponible : \(e)") }237            if let e = flow.error { Banner(.danger, e) }238            if let n = flow.notice { Banner(.info, n) }239        }240        .futPolling(every: 45, id: "gmx") { await flow.load() }241        .sheet(item: Binding(get: { flow.sheet }, set: { if $0 == nil, flow.sheet != nil { Task { await flow.dismiss() } } })) { s in FutGMXSheet(model: model, flow: flow, sheet: s) }242243        if let s = flow.status.value {244            Card("Verrous et blocages") {245                FutLockRow(name: "SPW_DERIV_LIVE_MAINNET (dérivés réels)", on: s.settings.liveMainnet, reason: s.settings.liveMainnet ? nil : s.blockerText?["mainnet_setting_off"] ?? store.capability("deriv_live_mainnet")?.why)246                FutLockRow(name: "SPW_DERIV_GMX_LIVE (GMX)", on: s.settings.gmxLive, reason: s.settings.gmxLive ? nil : s.blockerText?["gmx_setting_off"] ?? store.capability("deriv_gmx_live")?.why)247                Divider()248                Label(s.tradable ? "Le serveur indique que des ordres GMX pourraient être préparés." : "Le serveur indique que GMX n’est PAS négociable maintenant.", systemImage: s.tradable ? "checkmark.circle" : "nosign").foregroundStyle(s.tradable ? Theme.positive : Theme.warning)249                ForEach(s.refusals, id: \.code) { r in250                    HStack(alignment: .firstTextBaseline) { Text(r.code).font(Theme.monoSmall).foregroundStyle(Theme.warning); Text(r.reason.isEmpty ? "(sans phrase du serveur)" : r.reason).font(.callout).fixedSize(horizontal: false, vertical: true).textSelection(.enabled) }251                }252                Text("Cette app ne propose pas l’ouverture de positions GMX : le produit n’offre que Hyperliquid pour les nouveaux ordres. Réduire une position existante, arrêter et révoquer restent possibles ci-dessous.").font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)253            }254            if let j = flow.jurisdiction.value {255                Card("Avis de juridiction — GMX") { Text((store.locale == "fr" ? j.fr : j.en).text).font(.callout).textSelection(.enabled).fixedSize(horizontal: false, vertical: true) }256            } else if let e = flow.jurisdiction.error { Banner(.warning, "Avis de juridiction GMX indisponible : \(e)") }257258            Card("Compte, portefeuille et autorisation") {259                if let a = s.account { Field(label: "Adresse (Arbitrum)", value: a.address, mono: true) } else { Field(label: "Adresse", value: "indisponible") }260                if let w = s.wallet { Field(label: "Portefeuille", value: "\(w.usdc) USDC · \(w.eth) ETH · \(w.weth) WETH" + (w.feeCeilingEth.map { " · plafond de frais \($0) ETH" } ?? "")) }261                else { Field(label: "Portefeuille", value: "illisible" + (s.walletError.map { " : \($0)" } ?? "")) }262                if let auth = s.authorization {263                    Field(label: "Autorisation GMX", value: "\(auth.state) · expire \(Fmt.date(auth.expiresAt))" + (auth.today.map { " · aujourd’hui : \($0.increases) hausse(s), \($0.reduces) réduction(s)" } ?? ""))264                    Field(label: "Limites approuvées", value: "levier ≤ \(auth.policy.maxLeverage)× · ordre ≤ \(auth.policy.maxOrderSizeUsd) $ · \(auth.policy.maxOrdersPerDay) ordres/jour · écart ≤ \(auth.policy.maxPriceDeviationBps) pb · \(auth.policy.allowedMarkets.count) marché(s)")265                } else { Field(label: "Autorisation GMX", value: "aucune") }266                if let r = s.risk {267                    Field(label: "Arrêt GMX", value: r.halt ?? "aucun")268                    Field(label: "Limites de perte", value: "quotidienne \(r.maxDailyLoss) $ · totale \(r.maxTotalLoss) $" + (r.realizedToday.map { " · réalisé aujourd’hui \($0) $" } ?? "") + (r.realizedTotal.map { " · total \($0) $" } ?? ""))269                }270                HStack {271                    TextField("Raison de l’arrêt (facultative)", text: $haltReason).textFieldStyle(.roundedBorder).frame(maxWidth: 260)272                    Button("Arrêter les nouvelles positions GMX…", role: .destructive) { confirmHalt = true }.disabled(!model.canOperate || flow.busy)273                        .confirmationDialog("Arrêter les nouvelles positions GMX ?", isPresented: $confirmHalt) {274                            Button("Arrêter maintenant", role: .destructive) { Task { await flow.halt(reason: String(haltReason.prefix(200))) } }275                        } message: { Text("Sans passkey. Rien n’est annulé ni clôturé.") }276                    if s.risk?.halt != nil { Button("Lever l’arrêt (passkey)…") { Task { await flow.prepareResume() } }.disabled(!model.canOperate || flow.busy) }277                    Spacer()278                    if s.authorization?.state == "active" {279                        Button("Révoquer l’autorisation GMX…", role: .destructive) { confirmRevoke = true }.disabled(!model.canOperate || flow.busy)280                            .confirmationDialog("Révoquer l’autorisation GMX ?", isPresented: $confirmRevoke) {281                                Button("Révoquer", role: .destructive) { Task { await flow.revoke() } }282                            } message: { Text("Sans passkey. Les positions restent ouvertes ; après révocation, les réduire depuis ce portefeuille n’est plus possible sans nouvelle autorisation.") }283                    }284                }285            }286287            Card("Contrats épinglés", trailing: AnyView(Text(s.pins.ok == true ? "vérifiés" : s.pins.ok == false ? "PROBLÈME" : "non vérifiés").font(.caption.weight(.medium)).foregroundStyle(s.pins.ok == true ? Theme.positive : Theme.warning))) {288                Field(label: "Jeu de contrats", value: s.pins.id + (s.pins.reviewedAt.map { " · revu le \($0)" } ?? "") + (s.pins.checkedAt.map { " · contrôlé \(Fmt.relative($0))" } ?? ""))289                ForEach(s.pins.problems ?? [], id: \.self) { Banner(.danger, $0) }290                ForEach(s.pins.contracts, id: \.name) { c in Field(label: c.name, value: c.address, mono: true) }291            }292293            Card("Positions lues sur la chaîne", trailing: AnyView(FutModeBadge(mode: .mainnet))) {294                if let e = s.positionsError { Banner(.danger, "Positions illisibles : \(e). Ce n’est pas une absence de position.") }295                else if s.positions.isEmpty { Text("Aucune position GMX pour cette adresse" + (s.positionsSource.map { " (source : \($0))" } ?? "") + ".").foregroundStyle(.secondary) }296                ForEach(s.positions, id: \.key) { p in297                    VStack(alignment: .leading, spacing: 6) {298                        HStack { FutSideText(side: p.side); Text(p.marketName ?? p.market).fontWeight(.medium); Spacer(); Text("PnL ≈ \(FutNum.usd(p.pnlUsd))").foregroundStyle(Theme.change(FutNum.d(p.pnlUsd))).monospacedDigit().help("Estimation au prix mark, avant frais") }299                        FutStatGrid(minimum: 130) {300                            FutStat("Taille", FutNum.usd(p.sizeUsd))301                            FutStat("Collatéral", "\(FutNum.exact(p.collateral, maxFraction: 6)) \(p.collateralSymbol ?? "")")302                            FutStat("Prix d’entrée", FutNum.exact(p.entryPrice, maxFraction: 6))303                            FutStat("Prix (mark)", FutNum.exact(p.markPrice, maxFraction: 6))304                            FutStat("Levier", p.leverage.map { "\(FutNum.exact($0, maxFraction: 2))×" } ?? "—")305                            FutStat("Liquidation", p.liquidationPrice.map { "≈ " + FutNum.exact($0, maxFraction: 6) } ?? "non calculable", color: Theme.warning, note: "ESTIMATION du serveur — GMX n’en publie pas")306                        }307                        if let v = p.venueApi, v.agrees == false { Text("L’API de GMX ne concorde pas avec la lecture de la chaîne : \(v.detail ?? "")").font(.caption).foregroundStyle(Theme.warning) }308                        HStack {309                            TextField("pb", text: $slippage).textFieldStyle(.roundedBorder).frame(width: 60); Text("pb de glissement max").font(.caption).foregroundStyle(.secondary)310                            Spacer()311                            ForEach(["0.25", "0.5", "1"], id: \.self) { f in312                                Button("Préparer la réduction de \(FutPositionsCard.percent(f))…") { if let b = Int(slippage) { Task { await flow.prepareClose(p, fraction: f, slippageBps: b) } } }313                                    .disabled(!model.canOperate || flow.busy || Int(slippage).map { (1...500).contains($0) } != true)314                            }315                        }316                        Text("Une réduction est une transaction du portefeuille : elle vous est montrée en entier puis approuvée par votre passkey. « Créée » n’est pas « exécutée » : un keeper l’exécute ou l’annule ensuite.").font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)317                    }.padding(10).background(Color.secondary.opacity(0.06), in: RoundedRectangle(cornerRadius: 8))318                }319            }320321            if let op = flow.tracked { Card("Suivi de l’opération GMX") { operation(op, tracked: true) } }322            if !s.pendingOrders.isEmpty {323                Card("Ordres GMX en attente d’un keeper") {324                    ForEach(s.pendingOrders, id: \.key) { o in325                        HStack { FutSideText(side: o.side); Text("\(o.marketName ?? o.market) · \(o.orderType)"); Spacer(); Text("\(FutNum.usd(o.sizeUsd)) · prix acceptable \(FutNum.exact(o.acceptablePrice, maxFraction: 6))" + (o.frozen ? " · GELÉ" : "")).font(.callout).monospacedDigit().foregroundStyle(.secondary) }326                    }327                }328            }329            Card("Marchés GMX épinglés") {330                ForEach(s.markets, id: \.market) { m in331                    HStack { Text(m.name).fontWeight(.medium); Text(m.instrument).font(.caption).foregroundStyle(.secondary); if !m.allowed { Text("hors autorisation").font(.caption2).foregroundStyle(.secondary) }; Spacer(); Text("mark \(FutNum.exact(m.mark, maxFraction: 6)) · oracle \(FutNum.exact(m.oracleMin, maxFraction: 6)) – \(FutNum.exact(m.oracleMax, maxFraction: 6))").font(.callout).monospacedDigit().foregroundStyle(.secondary) }332                }333                if let f = s.facts { Text("Exécution en deux temps" + (f.requestExpirationSec.map { " ; une demande non exécutée devient annulable après \($0) s" } ?? "") + ".").font(.caption).foregroundStyle(.secondary) }334            }335            if !s.operations.isEmpty {336                Card("Opérations GMX") { ForEach(s.operations.filter { $0.id != flow.tracked?.id }.prefix(20)) { operation($0, tracked: false) } }337            }338        } else if flow.status.error == nil {339            ProgressView().frame(maxWidth: .infinity, minHeight: 120)340        }341    }342343    @ViewBuilder private func operation(_ op: GmxOperation, tracked: Bool) -> some View {344        VStack(alignment: .leading, spacing: 3) {345            HStack(spacing: 8) {346                if tracked, !op.final { ProgressView().controlSize(.small) }347                Text("\(op.kind) · \(op.marketName ?? op.market ?? "")" + (op.side.map { " · \($0)" } ?? "")).fontWeight(.medium)348                Text(op.state).font(.caption.weight(.medium)).foregroundStyle(op.state == "executed" ? Theme.positive : op.final ? Theme.negative : Theme.warning)349                    .padding(.horizontal, 7).padding(.vertical, 2).background(Color.secondary.opacity(0.12), in: Capsule())350                Spacer()351                Text(Fmt.date(op.createdAt)).font(.caption).foregroundStyle(.secondary)352            }353            if op.state == "created" { Text("Ordre créé sur la chaîne, PAS encore exécuté : un keeper GMX doit l’exécuter ou l’annuler.").font(.caption).foregroundStyle(Theme.warning) }354            if let size = op.sizeUsd { Text("Taille \(FutNum.usd(size))" + (op.acceptablePrice.map { " · prix acceptable \(FutNum.exact($0, maxFraction: 6))" } ?? "")).font(.caption).foregroundStyle(.secondary) }355            if let tx = op.txid { Text("Transaction \(tx)").font(.system(.caption, design: .monospaced)).foregroundStyle(.secondary).textSelection(.enabled).lineLimit(1) }356            if let e = op.error { Text(e).font(.caption).foregroundStyle(Theme.negative).fixedSize(horizontal: false, vertical: true) }357            if let ex = op.explorer, let url = URL(string: ex), url.scheme == "https" { Link("Ouvrir dans l’explorateur de blocs", destination: url).font(.caption) }358        }.padding(.vertical, 3)359    }360}361362private struct FutGMXSheet: View {363    let model: AppModel364    @Bindable var flow: FutGMXFlow365    let sheet: FutGMXFlow.Sheet366367    var body: some View {368        VStack(alignment: .leading, spacing: 0) {369            FutSheetHeader(title: { if case .risk = sheet { return "Lever l’arrêt GMX" }; return "Vérifier et approuver la réduction GMX" }(), mode: .mainnet)370            Divider()371            ScrollView {372                VStack(alignment: .leading, spacing: 14) {373                    switch sheet {374                    case .order(let prep, let a):375                        TransactionReview(intent: a.intent, digest: a.approval.digest, network: model.network(a.intent.network),376                                          ownAddresses: Dictionary((model.accounts?.value.accounts ?? []).map { ($0.network, $0.address) }, uniquingKeysWith: { x, _ in x }), warnings: [],377                                          extra: prep.fields.map { ReviewLine(label: "Lecture du serveur — \($0.label)", value: $0.value) } + prep.fixed.map { ReviewLine(label: "Fixé par le signataire — \($0.label)", value: $0.value) })378                        if let e = prep.estimate { VStack(alignment: .leading, spacing: 4) { HStack { Text("Estimations du serveur").font(.headline); ProvenanceTag(p: .estimate) }; Text(e.displayText).font(.system(.caption, design: .monospaced)).textSelection(.enabled).fixedSize(horizontal: false, vertical: true) } }379                    case .risk(let r):380                        let i = r.intent381                        Banner(.warning, "Lever l’arrêt permet de nouveau d’ouvrir des positions GMX.")382                        ReviewLines(lines: [383                            .init(label: "Type d’opération", value: "Levée de l’arrêt GMX", style: .strong),384                            .init(label: "Arrêt levé", value: i.subject ?? "—"),385                            .init(label: "Autorisation", value: i.authorizationId),386                            .init(label: "Champs assouplis", value: i.loosened.isEmpty ? "aucun" : i.loosened.joined(separator: ", ")),387                            .init(label: "Nonce", value: i.nonce),388                        ])389                        BindingProof(digest: r.approval.digest, expiry: i.expiry)390                    }391                }.padding(20)392            }393            Divider()394            VStack(alignment: .leading, spacing: 8) {395                if let e = flow.sheetError { Banner(.danger, e) }396                HStack {397                    Button("Fermer sans approuver", role: .destructive) { Task { await flow.dismiss() } }.disabled(flow.approving)398                    Spacer()399                    if flow.approving { ProgressView().controlSize(.small) }400                    Button { Task { await flow.approve() } } label: { Label("Approuver avec la passkey (RÉEL)", systemImage: "touchid") }401                        .buttonStyle(.borderedProminent).tint(FutMode.mainnet.color).controlSize(.large).disabled(flow.approving || !model.canOperate)402                }403            }.padding(16)404        }405        .frame(width: 740, height: 780).interactiveDismissDisabled()406    }407}408
Files main
Menu

Theme