Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : App/Sources/Wallet/SendFormView.swift8// Module : Wallet9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0512// Last Modified : 2026-12-0513//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 QyvoraBitcoin44import QyvoraWallet45import QyvoraUI4647/// Recipient, amount and fee of a payment, on any chain. The address is validated by the service as it is typed48/// (`checkAddress`), with its precise refusal; the fee section follows the family of the chain.49struct SendFormView: View {50 @Bindable var model: SendModel51 let chain: ChainSnapshot52 let snapshot: WalletSnapshot53 let onClose: () -> Void5455 @Environment(WalletStore.self) private var wallet56 @HideAmounts private var hideAmounts57 @State private var scanning = false58 @State private var editingCustom = false59 @State private var pickingCoins = false6061 var descriptor: ChainDescriptor { chain.chain }62 var quote: MarketQuote? { model.quote(snapshot) }63 var problem: String? { model.formProblem(chain: chain, quote: quote) }6465 var body: some View {66 SendScaffold(title: (snapshot.isWatchOnly ? "Prepare " : "Send ") + model.symbol, subtitle: nil, onBack: { model.step = .asset }, onClose: onClose) {67 assetHeader68 if chain.data.value?.isFromPreviousSession == true || chain.data.value == nil {69 WarningBanner(.warning, title: "Not synchronized in this session",70 message: "The balance shown was not read since the launch. The service reads the chain again before it builds the payment"71 + (descriptor.family == .utxo ? "; a \(descriptor.nativeName) payment needs a synchronization first." : "."),72 actionTitle: "Synchronize", action: { Task { await wallet.synchronize(chains: [chain.id]) } })73 }74 RecipientCard(text: $model.recipient, validity: model.validity, notes: recipientNotes, network: chain.network, onScan: { scanning = true })75 .privacySensitive()76 amountCard.id("amount")77 feeSection.id("fee")78 if model.supportsMemo { memoSection }79 evmOptions80 if let inFlight = model.inFlightID {81 WarningBanner(.warning, title: "The same payment is still in flight",82 message: "A payment with this recipient, asset and amount was broadcast and is neither confirmed nor expired (\(MiddleTruncation.truncate(inFlight, head: 8, tail: 6))). A second one is not prepared until the first can no longer be executed: both could go through.")83 } else {84 InlineError(message: model.error)85 }86 } footer: {87 LoadingButton("Review", loadingTitle: descriptor.family == .utxo ? "Building the transaction" : "Reading the chain", state: model.preparing ? .loading : .idle) {88 Task { await model.prepare(wallet, snapshot: snapshot) }89 }90 .disabled(problem != nil || model.preparing)91 }92 .task(id: "\(chain.id.rawValue)|\(model.recipient)") { await validate() }93 .task(id: chain.id) { await loadFees() }94 .task(id: "\(chain.id.rawValue)|\(model.token?.address ?? "")") { await loadFeeQuote() }95 .sheet(isPresented: $scanning) {96 VStack(spacing: QSpace.l) {97 SheetHeader("Scan the recipient") { scanning = false }98 QRScannerView { text in99 applyScan(text)100 scanning = false101 }102 }103 .padding(QMetric.screenPadding)104 .qScreen()105 .presentedPrivacyCover()106 }107 .sheet(isPresented: $pickingCoins) {108 SendCoinControlSheet(model: model, chain: chain).presentedPrivacyCover().qSheetChrome(detents: QDetents.full)109 }110 .alert(descriptor.family == .solana ? "Compute-unit price" : "Fee rate", isPresented: $editingCustom) {111 if descriptor.family == .solana {112 TextField("Micro-lamports per unit", text: $model.customUnitPrice).keyboardType(.numberPad)113 } else {114 TextField("sat/vB", text: $model.customRate).keyboardType(.decimalPad)115 }116 Button("Use") {}117 Button("Cancel", role: .cancel) { if customIsEmpty { model.tier = .normal } }118 } message: {119 Text(descriptor.family == .solana120 ? "Price of one compute unit, in micro-lamports. The service refuses a priority fee above its ceiling."121 : "In sat/vB: base units of \(descriptor.nativeSymbol) per virtual byte. The service keeps the rate between the network's floor and its ceiling.")122 }123 .qHaptic(trigger: model.error) { $0 == nil ? nil : .failed }124 }125126 var customIsEmpty: Bool { descriptor.family == .solana ? model.customUnitPrice.isEmpty : model.customRate.isEmpty }127128 // MARK: Asset129130 var assetHeader: some View {131 HStack(spacing: QSpace.m) {132 AssetIdentityGlyph(model.token.map { .token(symbol: $0.symbol, network: chain.network) } ?? .native(chain.network))133 VStack(alignment: .leading, spacing: 2) {134 Text(model.token?.name ?? descriptor.nativeName).font(QFont.headline).foregroundStyle(QColor.textPrimary)135 NetworkBadge(chain.network, style: .plain)136 }137 Spacer(minLength: QSpace.s)138 Button("Change") { model.step = .asset }139 .font(QFont.callout.weight(.medium))140 .foregroundStyle(QColor.violet)141 .frame(minHeight: QMetric.minTap)142 }143 .accessibilityElement(children: .contain)144 }145146 // MARK: Recipient147148 var recipientNotes: [RecipientNote] {149 guard case .valid = model.validity, let check = model.check else { return [] }150 var notes = [RecipientNote]()151 for (index, text) in check.notes.enumerated() {152 let lower = text.lowercased()153 if check.isOwnAddress, lower.contains("this wallet") {154 notes.append(.ownAddress(text))155 } else if lower.contains("checksum") {156 notes.append(.noChecksum(text))157 } else {158 notes.append(RecipientNote(id: "note-\(index)", text: text, tone: .warning, systemImage: "exclamationmark.triangle"))159 }160 }161 if check.isOwnAddress, !notes.contains(where: { $0.id == "own" }) { notes.append(.ownAddress()) }162 if !check.isOwnAddress, let history = chain.data.value?.history.value {163 let paid = history.contains { $0.direction == .sent && ($0.counterparty?.caseInsensitiveCompare(check.canonical) == .orderedSame) }164 if !paid {165 notes.append(.firstPayment("No earlier payment to this address appears in the history this wallet read. Compare it with the address you were given, on its original source."))166 }167 }168 return notes169 }170171 /// Validation as typed, by the service: a refusal says exactly why (another family, another network, a missing172 /// prefix, a wrong checksum). No network request is involved.173 func validate() async {174 let text = model.recipient.trimmingCharacters(in: .whitespacesAndNewlines)175 guard !text.isEmpty else {176 model.validity = .empty177 model.check = nil178 return179 }180 try? await Task.sleep(for: .milliseconds(180))181 guard !Task.isCancelled, let service = wallet.service else { return }182 do {183 let check = try await service.checkAddress(text, chain: chain.id)184 guard !Task.isCancelled else { return }185 model.check = check186 model.validity = .valid(check.canonical == text ? nil : "Canonical form: \(MiddleTruncation.truncate(check.canonical, head: 10, tail: 8))")187 } catch {188 guard !Task.isCancelled else { return }189 model.check = nil190 model.validity = .invalid(WalletStore.message(for: error))191 }192 }193194 /// A scanned code: a bare address, or a payment request for this very network and asset, whose address (and195 /// amount) is taken. A request of another scheme, another EVM network or another asset fills nothing in and the196 /// form says why (QYV-APP-101): test networks share address forms and a legacy Bitcoin Cash address is a Bitcoin197 /// address, so "the address is valid here" does not mean the request was meant for this network.198 func applyScan(_ text: String) {199 model.error = nil200 switch WalletScanParser.parse(text) {201 case .payment(let payment):202 guard payment.matches(descriptor) else {203 model.error = "The code scanned is a \(payment.scheme) payment request" + (payment.evmChainID.map { " for chain \($0)" } ?? "")204 + ", not one for \(descriptor.displayName). Nothing was filled in."205 return206 }207 let requested = payment.token, chosen = model.token?.address208 guard (requested == nil && chosen == nil) || (requested != nil && chosen != nil && requested!.caseInsensitiveCompare(chosen!) == .orderedSame) else {209 model.error = requested == nil210 ? "The code scanned asks for \(descriptor.nativeSymbol), not for \(model.symbol). Nothing was filled in: change the asset, or scan an address."211 : "The code scanned asks for another token than \(model.symbol). Nothing was filled in: choose that token first."212 return213 }214 model.recipient = payment.address215 guard model.amountText.isEmpty else { return }216 if let amount = payment.amount {217 model.amountText = amount218 } else if let base = payment.baseAmount, let units = UInt256(decimal: base) {219 model.amountText = BaseUnits.format(units, decimals: model.decimals)220 }221 case .unsupported(let reason):222 model.error = reason223 case .text(let value):224 let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines)225 guard trimmed.count <= WalletScanParser.maximumAddressLength else {226 model.error = "The code scanned is not an address."227 return228 }229 model.recipient = trimmed230 case .signedTransaction, .unsignedTransaction, .watchOnlyPackage, .identity, .transferPackage:231 model.error = "The code scanned is a QYVORA code, not an address. Use the Scan action of the dashboard for it."232 }233 }234235 // MARK: Amount236237 var amountCard: some View {238 let available = model.available(chain)239 let balanceText = available.map { hideAmounts ? "••••" : WalletChainFormat.amount($0, decimals: model.decimals, symbol: model.symbol, maxFractionDigits: 8) }240 let text = Binding<String>(get: { model.amountText }, set: { new in241 if new != model.amountText { model.sendMax = false }242 model.amountText = new243 })244 let unit = model.amountInFiat ? snapshot.currency.rawValue.uppercased() : model.symbol245 let digits = model.amountInFiat ? 2 : AssetPrecision.entryFractionDigits(decimals: model.decimals)246 let onSwitch: (() -> Void)? = quote == nil ? nil : { switchUnit() }247 var onMax: (() -> Void)?248 if let available { onMax = { setMax(available) } }249 let message: String? = (problem ?? "").isEmpty ? nil : problem250 return AmountEntryCard(text: text, unit: unit, maxFractionDigits: digits, converted: converted, onSwitchUnit: onSwitch, balance: balanceText,251 onMax: onMax, note: amountNote, error: message)252 .privacySensitive()253 }254255 var converted: String? {256 guard let quote, !model.amountText.isEmpty, let amount = model.baseAmount(quote: quote) else { return nil }257 if model.amountInFiat { return "≈ " + WalletChainFormat.amount(amount, decimals: model.decimals, symbol: model.symbol, maxFractionDigits: 8) }258 return WalletChainFormat.fiat(units: amount, decimals: model.decimals, quote: quote, isTest: descriptor.isTest).map { "≈ " + $0 }259 }260261 var amountNote: String? {262 if model.sendMax {263 return model.token == nil ? "Everything: the fee is taken from the amount. The review shows the exact figure sent." : "The whole \(model.symbol) balance."264 }265 if let limits = chain.limits { return model.token == nil ? limits.native : (limits.tokens ?? limits.native) }266 if model.token != nil { return "The fee is paid in \(descriptor.nativeSymbol), not in \(model.symbol)." }267 return descriptor.isTest && quote != nil ? "Test coins have no value: fiat figures are a reference at main-network prices." : nil268 }269270 func switchUnit() {271 guard let quote else { return }272 let amount = model.baseAmount(quote: quote)273 model.amountInFiat.toggle()274 model.sendMax = false275 guard let amount, let units = Double(BaseUnits.format(amount, decimals: model.decimals)) else {276 model.amountText = ""277 return278 }279 model.amountText = model.amountInFiat ? String(format: "%.2f", units * quote.price)280 : BaseUnits.format(amount, decimals: model.decimals, maxFractionDigits: AssetPrecision.entryFractionDigits(decimals: model.decimals))281 }282283 func setMax(_ value: UInt256) {284 model.amountInFiat = false285 model.amountText = BaseUnits.format(value, decimals: model.decimals, maxFractionDigits: AssetPrecision.entryFractionDigits(decimals: model.decimals))286 model.sendMax = true287 }288289 // MARK: Fee290291 @ViewBuilder var feeSection: some View {292 VStack(alignment: .leading, spacing: QSpace.m) {293 QEyebrow("Network fee")294 switch descriptor.family {295 case .utxo: utxoFee296 case .evm:297 FeeTierPicker(tiers: [298 FeeTier(.slow, timeHint: "Half the suggested priority fee", fee: quoted(.slow)),299 FeeTier(.normal, timeHint: "The suggested priority fee", fee: quoted(.normal)),300 FeeTier(.fast, timeHint: "Twice the suggested priority fee", fee: quoted(.fast)),301 ], selection: $model.tier)302 if let basis = model.feeQuote?.basis { WalletNoteLine(text: basis) }303 WalletNoteLine(text: "The fee is paid in \(descriptor.nativeSymbol). Its expected and maximum amounts are computed from the block read when the review is built.")304 case .solana:305 FeeTierPicker(tiers: [306 FeeTier(.slow, timeHint: "Half the recent priority price", fee: quoted(.slow)),307 FeeTier(.normal, timeHint: "The recent priority price", fee: quoted(.normal)),308 FeeTier(.fast, timeHint: "Twice the recent priority price", fee: quoted(.fast)),309 FeeTier(.custom, timeHint: "Compute-unit price", fee: model.customUnitPrice.isEmpty ? nil : "\(model.customUnitPrice) µ-lamports", rate: nil),310 ], selection: $model.tier, onEditCustom: { editingCustom = true })311 if let basis = model.feeQuote?.basis { WalletNoteLine(text: basis) }312 WalletNoteLine(text: "A Solana fee is 0.000005 SOL per signature plus a priority fee: the compute-unit price times the units reserved. The review shows both.")313 case .tron:314 tronFee315 }316 }317 }318319 @ViewBuilder var utxoFee: some View {320 switch model.utxoFees {321 case .loaded(let fees):322 FeeTierPicker(tiers: fees.all.map { option in323 FeeTier(FeeTier.Kind(rawValue: option.tier.rawValue) ?? .normal,324 timeHint: option.targetBlocks.map { $0 <= 1 ? "Next block" : "About \($0) blocks" }, fee: option.rate.description)325 } + [FeeTier(.custom, timeHint: "Your own rate", fee: model.customRate.isEmpty ? nil : "\(model.customRate) sat/vB")],326 selection: $model.tier, onEditCustom: { editingCustom = true })327 if fees.source == .minimumRelayFloor {328 WalletNoteLine(text: "The endpoint gave no usable estimate: every tier is the network's minimum rate. Confirmation may take long when blocks are full.",329 systemImage: "exclamationmark.triangle", tone: QColor.warning)330 }331 WalletNoteLine(text: "The fee is the rate times the size of the transaction, which depends on the coins it spends: the review shows the amount.")332 case .failed(let reason):333 UnavailableDataView(reason: reason, title: "Fee rates unavailable", compact: true) { Task { await loadFees(force: true) } }334 default:335 VStack(spacing: QSpace.s) {336 ForEach(0..<3, id: \.self) { _ in QSkeletonRow().padding(.horizontal, 14).background(QColor.surface, in: RoundedRectangle(cornerRadius: QMetric.radiusSmall)) }337 }338 }339 if descriptor.capabilities.coinControl, let coins = chain.utxoSnapshot, !coins.utxos.isEmpty {340 QListSection(separatorInset: 58) {341 WalletActionRow(title: "Coin control", subtitle: coinControlSummary(coins), systemImage: "circle.grid.2x2") { pickingCoins = true }342 }343 }344 }345346 func coinControlSummary(_ coins: BitcoinSnapshot) -> String {347 if model.selectedCoins.isEmpty { return model.includeUnconfirmed ? "Automatic, unconfirmed coins allowed" : "Automatic: the wallet chooses the coins" }348 return "\(model.selectedCoins.count) of \(coins.utxos.count) coins " + (model.onlySelectedCoins ? "only" : "at least")349 }350351 /// The service's estimate for a tier, marked as one ("≈ 0.000042 ETH"); nil while it is not known (the picker352 /// then shows no figure).353 func quoted(_ tier: SendFeeTier) -> String? {354 guard let quote = model.feeQuote, quote.chain == chain.id, quote.asset == model.asset, let amount = quote.tier(tier) else { return nil }355 return "≈ " + WalletChainFormat.amount(amount.expected, decimals: quote.decimals, symbol: quote.symbol, maxFractionDigits: 9)356 }357358 /// Reads the estimate of a plain transfer of the chosen asset. A failure leaves the tiers without figures: the359 /// review, which states the real fee, does not depend on it.360 func loadFeeQuote() async {361 guard descriptor.family != .utxo, !snapshot.profile.coldMode, let service = wallet.service else { return }362 let id = chain.id, asset = model.asset363 if let known = model.feeQuote, known.chain == id, known.asset == asset { return }364 model.feeQuote = nil365 let quote = try? await service.feeQuote(chain: id, asset: asset)366 guard !Task.isCancelled else { return }367 model.feeQuote = quote368 }369370 @ViewBuilder var tronFee: some View {371 if let estimate = model.feeQuote?.tron, model.feeQuote?.chain == chain.id, model.feeQuote?.asset == model.asset {372 // the service's preview for this account, read now373 ReviewSection("Estimate", footnote: "TRON has no fee choice. What the account lacks in bandwidth or energy is paid by burning TRX; the review shows the exact resources and the most the payment can burn.") {374 ForEach(estimate.lines, id: \.self) { line in375 Text(line).font(QFont.callout).foregroundStyle(QColor.textPrimary).fixedSize(horizontal: false, vertical: true)376 .frame(maxWidth: .infinity, alignment: .leading).padding(.vertical, QSpace.s)377 }378 }379 } else if let extras = chain.tronExtras {380 let r = extras.resources381 ReviewSection(footnote: "TRON has no fee choice. A payment uses bandwidth for its bytes and, for a token, energy; what the account lacks is paid by burning TRX. The review shows the exact resources and the most the payment can burn.") {382 ReviewRow("Free bandwidth left today", value: "\(r.freeBandwidth.formatted()) bytes", secondary: "A TRX transfer takes about 270")383 if r.netLimit > 0 { ReviewRow("Staked bandwidth", value: "\(r.stakedBandwidth.formatted()) bytes") }384 ReviewRow("Energy", value: r.energyLimit == 0 ? "None" : "\(r.energy.formatted()) units",385 secondary: model.token == nil ? "Not needed for TRX" : (r.energy == 0 ? "A token transfer will burn TRX instead" : nil))386 }387 } else {388 WalletNoteLine(text: "TRON has no fee choice. The review shows the bandwidth and energy this payment needs and the most it can burn.")389 }390 }391392 func loadFees(force: Bool = false) async {393 guard descriptor.family == .utxo else { return }394 if case .loaded = model.utxoFees, !force { return }395 model.utxoFees = .loading396 let id = chain.id397 do {398 guard let service = wallet.service else { return }399 model.utxoFees = .loaded(try await service.feeOptions(chain: id))400 } catch {401 guard !Task.isCancelled else { return }402 model.utxoFees = .failed(WalletStore.message(for: error))403 }404 }405406 // MARK: Memo and options407408 var memoSection: some View {409 VStack(alignment: .leading, spacing: QSpace.s) {410 QEyebrow("Public note (optional)")411 TextField("For example an exchange deposit reference", text: $model.memo, axis: .vertical)412 .lineLimit(1...3)413 .autocorrectionDisabled()414 .padding(14)415 .background(QColor.surface, in: RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous))416 .overlay(RoundedRectangle(cornerRadius: QMetric.radiusSmall, style: .continuous).strokeBorder(QColor.stroke, lineWidth: 1))417 Text("A note is written on chain: public and permanent. Never put a secret in it." + (descriptor.family == .tron ? " On TRON the network may charge a fee for it." : ""))418 .font(QFont.caption).foregroundStyle(QColor.textSecondary).fixedSize(horizontal: false, vertical: true)419 }420 }421422 @ViewBuilder var evmOptions: some View {423 if descriptor.family == .evm {424 if chain.evmSnapshot?.hasPendingTransaction == true {425 optionToggle("Replace the pending transaction", "A transaction of this account is waiting. On: this payment takes its place (same nonce). Off: the service refuses a new payment while one is pending.",426 $model.replacePending)427 }428 if model.offersAllowContract {429 optionToggle("Send to a contract anyway", "The recipient is a contract. Coins sent to a contract that cannot handle them are lost. The review will carry a warning to acknowledge.",430 $model.allowContract)431 }432 }433 }434435 func optionToggle(_ title: String, _ text: String, _ value: Binding<Bool>) -> some View {436 Toggle(isOn: value) {437 VStack(alignment: .leading, spacing: 2) {438 Text(title).font(QFont.body).foregroundStyle(QColor.textPrimary)439 Text(text).font(QFont.caption).foregroundStyle(QColor.textSecondary).fixedSize(horizontal: false, vertical: true)440 }441 }442 .tint(QColor.violet)443 .padding(QMetric.padding)444 .background(QColor.surface, in: RoundedRectangle(cornerRadius: QMetric.radius, style: .continuous))445 .overlay(RoundedRectangle(cornerRadius: QMetric.radius, style: .continuous).strokeBorder(QColor.stroke, lineWidth: 1))446 }447}448449/// Coin control of one payment: which coins must be spent, whether only those, and whether unconfirmed coins may450/// be selected. Frozen coins stay out of automatic selection (they are frozen on the chain's coin list).451struct SendCoinControlSheet: View {452 @Bindable var model: SendModel453 let chain: ChainSnapshot454 @Environment(\.dismiss) private var dismiss455 @HideAmounts private var hideAmounts456457 var body: some View {458 let coins = chain.utxoSnapshot?.utxos ?? []459 let selectedValue = coins.filter { model.selectedCoins.contains($0.utxo.outPoint) }.reduce(UInt64(0)) { $0 + $1.value }460 return QSheetScaffold("Coin control", subtitle: model.selectedCoins.isEmpty ? "Automatic selection" : "\(model.selectedCoins.count) selected", onClose: { dismiss() }) {461 QListSection(separatorInset: QMetric.padding) {462 Toggle("Spend only the selected coins", isOn: $model.onlySelectedCoins)463 .tint(QColor.violet).frame(minHeight: QMetric.rowMinHeight)464 .disabled(model.selectedCoins.isEmpty)465 Toggle("Allow unconfirmed coins", isOn: $model.includeUnconfirmed)466 .tint(QColor.violet).frame(minHeight: QMetric.rowMinHeight)467 }468 if !model.selectedCoins.isEmpty {469 WalletNoteLine(text: "Selected: \(hideAmounts ? "••••" : WalletChainFormat.amount(UInt256(selectedValue), decimals: chain.chain.nativeDecimals, symbol: chain.chain.nativeSymbol)). Spending coins of several addresses together links those addresses.")470 }471 QListSection("\(coins.count) coin\(coins.count == 1 ? "" : "s")", footnote: "Without a selection the wallet chooses the coins itself and never takes a frozen one.",472 separatorInset: QMetric.padding) {473 ForEach(coins) { coin in474 let on = model.selectedCoins.contains(coin.utxo.outPoint)475 Button {476 if on { model.selectedCoins.remove(coin.utxo.outPoint) } else { model.selectedCoins.insert(coin.utxo.outPoint) }477 if model.selectedCoins.isEmpty { model.onlySelectedCoins = false }478 } label: {479 HStack(spacing: QSpace.m) {480 Image(systemName: on ? "checkmark.circle.fill" : "circle").font(.title3).foregroundStyle(on ? QColor.violet : QColor.strokeStrong)481 .accessibilityHidden(true)482 VStack(alignment: .leading, spacing: 4) {483 AmountText(units: coin.value, decimals: chain.chain.nativeDecimals, symbol: chain.chain.nativeSymbol, hidden: hideAmounts)484 if let address = coin.address {485 Text(MiddleTruncation.truncate(address, head: 10, tail: 8)).font(QFont.mono).foregroundStyle(QColor.textSecondary)486 }487 FlowLayout(spacing: 6) {488 QBadge(WalletFormat.exposureLabel(coin.exposure), tone: WalletFormat.exposureTone(coin.exposure))489 if coin.confirmations == 0 { QBadge("Unconfirmed", tone: .warning) }490 if coin.isFrozen { QBadge("Frozen", systemImage: "snowflake", tone: .accent) }491 }492 }493 Spacer(minLength: 0)494 }495 .padding(.vertical, QSpace.m)496 .contentShape(Rectangle())497 }498 .buttonStyle(.qRow)499 .accessibilityAddTraits(on ? .isSelected : [])500 }501 }502 } footer: {503 if !model.selectedCoins.isEmpty {504 Button("Clear the selection") {505 model.selectedCoins = []506 model.onlySelectedCoins = false507 }508 .buttonStyle(.qSecondary)509 }510 Button("Done") { dismiss() }.buttonStyle(.qPrimary)511 }512 .qHaptic(.selection, trigger: model.selectedCoins)513 }514}515