SPB Git

Repository Public

NFTMarketView.swift 27.5 KB 437 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : SP Wallet for macOS9// File             : Features/NFTs/NFTMarketView.swift10// Description      : Market READ data of one NFT and of one collection, and the11//                    collection page. One block PER SOURCE with its name and12//                    the date of its answer: nothing is merged, averaged or13//                    picked, contradictions between sources are named, and14//                    every figure is labelled as an observed marketplace15//                    statement — never as a value of this wallet's NFT (a16//                    collection floor is a statistic of the collection). The17//                    market read is started by the owner, since it sends the18//                    asset's identifier to the marketplace. No market write19//                    exists in the backend, so none is offered.20// Module           : Features21// Repository       : https://git.spboucher.ai/sp-wallet-macos22// Created          : 2026-11-1823// Last Modified    : 2026-11-1824//25// =============================================================================26// AUTHOR & PROFESSIONAL AFFILIATION27// =============================================================================28//29// Author           : Simon-Pierre Boucher30// Position         : Professor of Finance31// Institution      : Université du Québec en Outaouais (UQO)32// Department       : Département des sciences administratives33// Organization     : SP Boucher34//35// Website          : https://spboucher.ai36// Git              : https://git.spboucher.ai37//38// =============================================================================39// OFFICIAL CONTACT DIRECTORY40// =============================================================================41//42// General          : info@spboucher.ai43// Professional     : contact@spboucher.ai44// Direct           : simon@spboucher.ai45// Research         : research@spboucher.ai46// Development      : dev@spboucher.ai47// Support          : support@spboucher.ai48// Security/Admin   : admin@spboucher.ai49// Notifications    : notifications@spboucher.ai50//51// Preferred Contact: support@spboucher.ai52//53// =============================================================================54// COPYRIGHT & INTELLECTUAL PROPERTY55// =============================================================================56//57// Copyright (c) 202658// Simon-Pierre Boucher59//60// All rights reserved where applicable.61//62// This file is governed by the applicable project license,63// copyright notices, institutional agreements and relevant law.64//65// Unless expressly authorized by the applicable license or66// rights holder, copying, redistribution, sublicensing,67// publication and commercial exploitation are not permitted.68//69// Existing third-party rights and notices remain unaffected.70//71// =============================================================================72// CONFIDENTIALITY & SECURITY73// =============================================================================74//75// Classification   : Public76// Distribution     : Public repository; use is governed by the project license77// Security Contact : admin@spboucher.ai78//79// Access to this source does not independently grant permission80// to redistribute or disclose confidential materials.81//82// Do not embed credentials, private keys, access tokens,83// certificates or confidential personal information.84//85// =============================================================================86// LICENSE & MAINTENANCE87// =============================================================================88//89// License          : None specified (no license file in this repository)90// Maintainer       : Simon-Pierre Boucher91// Technical Contact: dev@spboucher.ai92//93// =============================================================================94// END OF SP BOUCHER SOURCE HEADER95// =============================================================================9697import SwiftUI98import SPWalletCore99100/// One source's page of a paginated market list (the Core's page types have no public initializer; pages are accumulated here).101struct NFTMarketPage<Item: Sendable>: Identifiable {102    let status: NFTMarketSourceStatus103    var items: [Item]104    var cursor: String?105    var id: String { status.provider }106}107108@MainActor @Observable final class NFTMarketModel {109    let model: AppModel110    let api: NFTAPI111    let key: String112113    private(set) var answer: NFTMarketAnswer?114    private(set) var listings: [NFTMarketPage<NFTMarketListing>]?115    private(set) var offers: [NFTMarketPage<NFTMarketOffer>]?116    private(set) var events: [NFTMarketPage<NFTMarketEvent>]?117    private(set) var traits: NFTTraitAnswer?118    private(set) var busy = false119    var error: String?120121    init(model: AppModel, key: String) { self.model = model; self.key = key; api = NFTAPI(model.client) }122123    private func run(_ work: () async throws -> Void) async {124        guard !busy, model.canOperate else { return }125        busy = true; error = nil; defer { busy = false }126        do { try await work() } catch { self.error = model.describe(error) }127    }128129    func load(refresh: Bool = false) async { await run { self.answer = try await self.api.market(key: self.key, refresh: refresh) } }130131    func loadListings(more provider: String? = nil) async {132        await run {133            if let provider, let i = self.listings?.firstIndex(where: { $0.id == provider }), let cursor = self.listings?[i].cursor {134                let r = try await self.api.marketListings(key: self.key, provider: provider, cursor: cursor)135                if let s = r.sources.first(where: { $0.status.provider == provider }) { self.listings?[i].items += s.items; self.listings?[i].cursor = s.cursor }136                else { self.listings?[i].cursor = nil }137            } else {138                self.listings = try await self.api.marketListings(key: self.key).sources.map { NFTMarketPage(status: $0.status, items: $0.items, cursor: $0.cursor) }139            }140        }141    }142    func loadOffers(more provider: String? = nil) async {143        await run {144            if let provider, let i = self.offers?.firstIndex(where: { $0.id == provider }), let cursor = self.offers?[i].cursor {145                let r = try await self.api.marketOffers(key: self.key, provider: provider, cursor: cursor)146                if let s = r.sources.first(where: { $0.status.provider == provider }) { self.offers?[i].items += s.items; self.offers?[i].cursor = s.cursor }147                else { self.offers?[i].cursor = nil }148            } else {149                self.offers = try await self.api.marketOffers(key: self.key).sources.map { NFTMarketPage(status: $0.status, items: $0.items, cursor: $0.cursor) }150            }151        }152    }153    func loadEvents(more provider: String? = nil) async {154        await run {155            if let provider, let i = self.events?.firstIndex(where: { $0.id == provider }), let cursor = self.events?[i].cursor {156                let r = try await self.api.marketActivity(key: self.key, NFTMarketEventQuery(provider: provider, cursor: cursor, limit: 20))157                if let s = r.sources.first(where: { $0.status.provider == provider }) { self.events?[i].items += s.events; self.events?[i].cursor = s.cursor }158                else { self.events?[i].cursor = nil }159            } else {160                self.events = try await self.api.marketActivity(key: self.key, NFTMarketEventQuery(limit: 20)).sources.map { NFTMarketPage(status: $0.status, items: $0.events, cursor: $0.cursor) }161            }162        }163    }164    func loadTraits() async { await run { self.traits = try await self.api.traitFrequency(key: self.key) } }165}166167/// The line that says who answered and when — shown with every block of market figures.168struct NFTMarketSourceHeader: View {169    let status: NFTMarketSourceStatus170    var body: some View {171        VStack(alignment: .leading, spacing: 2) {172            HStack(spacing: 8) {173                NFTPlain(status.name).font(.subheadline.weight(.semibold))174                NFTFlag(text: status.isOK ? (status.stale ? "Périmé" : "Réponse du \(Fmt.date(status.fetchedAt))") : "Sans donnée", color: status.isOK ? (status.stale ? Theme.warning : Theme.positive) : .secondary)175                NFTPlain(NFTText.marketState(status)).font(.caption).foregroundStyle(.secondary)176                Spacer()177            }178            if status.stale, let c = status.code { NFTPlain("Dernier échec de la source : \(c). Les chiffres datent du \(Fmt.date(status.fetchedAt)).").font(.caption).foregroundStyle(Theme.warning) }179            if let a = status.attribution {180                HStack(spacing: 6) { NFTPlain(a.text).font(.caption2).foregroundStyle(.secondary); if let u = NFTText.httpsURL(a.url) { Link(u.host ?? "source", destination: u).font(.caption2) } }181            }182        }183    }184}185186struct NFTMarketSection: View {187    let model: AppModel188    let gallery: NFTGallery189    let asset: NFTAsset190    let offline: Bool191    @State private var market: NFTMarketModel?192193    var body: some View {194        Card("Données de marché observées", trailing: AnyView(NFTFlag(text: "Déclarations de places de marché — pas une évaluation", color: .secondary))) {195            Text("Ces chiffres sont ce que des places de marché déclarent, avec leur source et leur date. Ils ne sont ni vérifiés sur la chaîne ni une valeur de votre NFT, et ne sont jamais ajoutés au total du portefeuille. Un prix plancher est une statistique de la collection entière.")196                .font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)197            if let s = asset.marketSources, !s.isEmpty {198                NFTPlain("Sources du serveur : " + s.map { "\($0.name) — \($0.state == "on" ? "active" : $0.state == "needs_key" ? "clé absente\($0.unlockedBy.map { " (\($0))" } ?? "")" : "désactivée")" }.joined(separator: " · ")).font(.caption).foregroundStyle(.secondary)199            }200            if let m = market {201                if let e = m.error { Banner(.danger, e) }202                if let a = m.answer { content(m, a) }203                else if offline { Text("Indisponible hors connexion : aucune donnée de marché n’est conservée sur ce Mac.").foregroundStyle(.secondary) }204                else {205                    HStack {206                        Text("La lecture transmet l’identifiant de cet NFT (contrat et jeton, ou mint) aux places de marché actives — jamais l’adresse du portefeuille.").font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)207                        Spacer()208                        if m.busy { ProgressView().controlSize(.small) }209                        Button("Lire les données de marché") { Task { await m.load() } }.disabled(m.busy)210                    }211                }212                if let stored = asset.market, m.answer == nil { storedSnapshot(stored) }213            }214        }215        .task { if market == nil { market = NFTMarketModel(model: model, key: asset.key) } }216    }217218    @ViewBuilder private func storedSnapshot(_ s: NFTMarketSnapshot) -> some View {219        Divider()220        Text("Instantané enregistré avec la fiche").font(.subheadline.weight(.medium))221        NFTPlain(NFTText.stamp(s.source)).font(.caption).foregroundStyle(s.source.isStale ? Theme.warning : Color.secondary)222        Field(label: "En vente (déclaré)", value: NFTText.knownBool(s.listed))223        Field(label: "Prix demandé", value: NFTText.known(s.listingPrice, NFTText.amount))224        Field(label: "Meilleure offre", value: NFTText.known(s.bestOffer, NFTText.amount))225        Field(label: "Dernière vente", value: NFTText.known(s.lastSale) { "\(NFTText.amount($0)) — \(NFTText.sourceTime($0.at))" })226        Field(label: "Plancher de la collection", value: NFTText.known(s.collectionFloor, NFTText.amount) + " — statistique de la collection, pas la valeur de cet NFT")227    }228229    @ViewBuilder private func content(_ m: NFTMarketModel, _ a: NFTMarketAnswer) -> some View {230        HStack {231            NFTPlain("Réponse du serveur : \(Fmt.date(a.asOf))").font(.caption).foregroundStyle(.secondary)232            Spacer()233            if m.busy { ProgressView().controlSize(.small) }234            Button("Relire sans le cache") { Task { await m.load(refresh: true) } }.controlSize(.small).disabled(m.busy || offline)235        }236        ForEach(a.contradictions, id: \.self) { c in237            Banner(.warning, "Les sources se contredisent sur « \(c.field) » (\(c.providers.map(NFTText.sourceName).joined(separator: ", "))) : \(c.note). Aucune n’est retenue à la place de l’autre.")238        }239        ForEach(Array(a.sources.enumerated()), id: \.offset) { _, s in240            Divider()241            NFTMarketSourceHeader(status: s.status)242            if s.status.isOK { itemRow(s) }243        }244        if let v = a.value { NFTPlain("Valeur de cet NFT : indisponible (\(v.reason)). Ce portefeuille n’en établit aucune à partir d’un plancher ou d’une cotation isolée.").font(.callout).foregroundStyle(.secondary) }245246        Divider()247        HStack {248            Button("Annonces de vente") { Task { await m.loadListings() } }249            Button("Offres d’achat") { Task { await m.loadOffers() } }250            Button("Activité de marché") { Task { await m.loadEvents() } }251            Button("Fréquence des traits") { Task { await m.loadTraits() } }252            Spacer()253        }.disabled(m.busy || offline)254        if let pages = m.listings { orders(title: "Annonces de vente observées", pages: pages, more: { p in Task { await m.loadListings(more: p) } }) { l in255            "\(NFTText.money(l.price)) pour \(l.quantity) unité(s)\(l.venue.map { " · \($0)" } ?? "")\(l.seller.map { " · vendeur \($0)" } ?? "") · créée \(NFTText.sourceTime(l.createdAt)) · expire \(NFTText.sourceTime(l.expiresAt))"256        } }257        if let pages = m.offers { orders(title: "Offres d’achat observées", pages: pages, more: { p in Task { await m.loadOffers(more: p) } }) { o in258            "\(NFTText.money(o.price)) pour \(o.quantity) unité(s) · portée : \(o.scope == "item" ? "cet NFT" : o.scope == "collection" ? "toute la collection" : o.scope)\(o.venue.map { " · \($0)" } ?? "")\(o.bidder.map { " · offrant \($0)" } ?? "") · expire \(NFTText.sourceTime(o.expiresAt))"259        } }260        if let pages = m.events { orders(title: "Événements de marché rapportés (distincts de l’historique de chaîne)", pages: pages, more: { p in Task { await m.loadEvents(more: p) } }) { e in261            "\(NFTText.sourceTime(e.at)) — \(NFTText.eventType(e.type)) (« \(e.providerType) »)\(e.price.map { " · \(NFTText.money($0))" } ?? "") · quantité \(e.quantity)\(e.venue.map { " · \($0)" } ?? "")\(e.flags.map { " · vente fictive selon la source : \(NFTText.knownBool($0.washTrade))" } ?? "")\(e.tx.map { " · tx \($0)" } ?? "")"262        } }263        if let t = m.traits { traits(t) }264265        Divider()266        if let ext = a.external {267            Text("Pages de cet NFT sur des places de marché").font(.subheadline.weight(.medium))268            ForEach(ext.links, id: \.self) { l in NFTExternalLinkView(title: l.name, raw: l.url) }269            Text("Ces sites sont hors du portefeuille. Y agir exigerait une connexion de portefeuille que SP Wallet n’offre pas (\(ext.notice.walletConnect ? "annoncée par le serveur, non construite dans cette app" : "aucune connexion de portefeuille")) ; aucune clé n’est jamais exportée.")270                .font(.caption).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)271        }272        NFTPlain(a.anyActionAvailable273                 ? "Le serveur annonce une action de marché que cette version de l’app ne sait pas vérifier : elle n’est pas proposée."274                 : "Aucune action de marché n’existe dans ce portefeuille (achat, vente, mise en vente, offre, acceptation) — raison donnée par le serveur : \(Set(a.actions.compactMap(\.reason)).sorted().joined(separator: ", ")).")275            .font(.caption).foregroundStyle(.secondary)276    }277278    @ViewBuilder private func itemRow(_ s: NFTItemMarket) -> some View {279        if let f = s.flags {280            if case .known(true) = f.suspicious { Banner(.danger, "\(s.status.name) signale cet NFT comme SUSPECT.") }281            if case .known(true) = f.disabled { Banner(.warning, "\(s.status.name) a désactivé cet NFT sur sa place de marché.") }282            if case .known(true) = f.nsfw { Banner(.info, "\(s.status.name) classe cet NFT comme contenu sensible.") }283        }284        Field(label: "En vente", value: NFTText.knownBool(s.listed))285        Field(label: "Prix demandé", value: NFTText.known(s.ask) { "\(NFTText.money($0.price)) pour \($0.quantity) unité(s)\($0.venue.map { " · \($0)" } ?? "")" })286        Field(label: "Meilleure offre", value: NFTText.known(s.bestOffer) { "\(NFTText.money($0.price)) — portée : \($0.scope)" })287        Field(label: "Dernière vente rapportée", value: NFTText.known(s.lastSale) { "\(NFTText.money($0.price)) — \(NFTText.sourceTime($0.at))" })288        Field(label: "Plancher de la collection", value: NFTText.known(s.collectionFloor, NFTText.money) + " — statistique de la collection, pas la valeur de cet NFT")289        if let c = s.collection { Field(label: "Collection selon la source", value: "\(NFTClean.line(c.name) ?? "sans nom") (\(c.slug))") }290        if let v = s.verification {291            Field(label: "Badge de la source", value: v.state == "verified" ? "Vérifiée selon \(v.by)\(v.providerValue.map { " (« \($0) »)" } ?? "") — déclaration de cette place de marché" : v.state == "not_verified" ? "Non vérifiée selon \(v.by)" : "Inconnu")292        }293        if let r = s.rarity, case .known(let rank) = r { Field(label: "Rang de rareté (source)", value: "\(rank.rank)\(rank.outOf.map { " sur \($0)" } ?? "") — méthode : \(rank.method)") }294        NFTExternalLinkView(title: "Page sur \(s.status.name)", raw: s.url)295    }296297    @ViewBuilder private func orders<Item: Sendable>(title: String, pages: [NFTMarketPage<Item>], more: @escaping (String) -> Void, line: @escaping (Item) -> String) -> some View {298        Divider()299        Text(title).font(.subheadline.weight(.medium))300        ForEach(pages) { p in301            NFTMarketSourceHeader(status: p.status)302            if p.status.isOK, p.items.isEmpty { Text("Aucun élément rapporté par cette source.").font(.callout).foregroundStyle(.secondary) }303            ForEach(Array(p.items.enumerated()), id: \.offset) { _, item in304                NFTPlain(line(item)).font(.callout).textSelection(.enabled).fixedSize(horizontal: false, vertical: true)305            }306            if p.cursor != nil { Button("Suite de \(p.status.name)") { more(p.id) }.controlSize(.small).disabled(offline) }307        }308    }309310    @ViewBuilder private func traits(_ t: NFTTraitAnswer) -> some View {311        Divider()312        Text("Fréquence des traits").font(.subheadline.weight(.medium))313        if !t.computed { NFTPlain("Non calculée : \(t.reason ?? "aucune source ne donne de décompte par collection avec un total déclaré"). Rien n’est estimé à partir d’un échantillon partiel.").font(.callout).foregroundStyle(.secondary) }314        if t.mutableMetadata == true { Text("Les métadonnées de cet NFT sont modifiables : ses traits peuvent changer.").font(.caption).foregroundStyle(Theme.warning) }315        ForEach(Array(t.sources.enumerated()), id: \.offset) { _, s in316            NFTPlain("\(s.name) — \(s.computed ? "sur \(s.total ?? "?") éléments déclarés, réponse du \(Fmt.date(s.fetchedAt))\(s.stale == true ? " (périmée)" : "")" : "non calculée (\(s.reason ?? "—"))")").font(.caption).foregroundStyle(.secondary)317            ForEach(Array(s.rows.enumerated()), id: \.offset) { _, r in318                Field(label: NFTClean.line(r.traitType, max: 60) ?? "—", value: "\(NFTClean.line(r.value, max: 120) ?? "—") — " + (r.frequency.map { "\($0.count) sur \($0.total) (\($0.percent) %)" } ?? "valeur absente du décompte de la source"))319            }320        }321    }322}323324// MARK: - Collection page325326struct NFTCollectionPage: View {327    let model: AppModel328    let gallery: NFTGallery329    let key: String330    let open: (NFTRoute) -> Void331    let back: () -> Void332    @State private var detail: NFTCollectionDetail?333    @State private var market: NFTCollectionMarketAnswer?334    @State private var loading = false335    @State private var marketBusy = false336    @State private var error: String?337    @State private var marketError: String?338339    private let columns = [GridItem(.adaptive(minimum: 172, maximum: 240), spacing: 14, alignment: .top)]340    private var items: [NFTSummary] { gallery.items(inCollection: key) }341    private var declaredName: String? { NFTClean.line(detail?.metadata?.name ?? items.first?.collection?.name) }342343    var body: some View {344        Page(declaredName ?? "Collection", subtitle: "Nom déclaré par le créateur, non vérifié. Les NFT listés sont ceux de l’inventaire de ce portefeuille.") {345            NFTBackBar(title: "Retour", back: back)346            if !model.canOperate { Banner(.warning, "Hors connexion ou session indisponible : seuls les NFT de l’inventaire synchronisé sont affichés.") }347            if let e = error { Banner(.danger, e) }348            if loading { HStack { ProgressView().controlSize(.small); Text("Lecture de la collection sur la chaîne…").foregroundStyle(.secondary) } }349            if let d = detail { chainCard(d) }350            marketCard351            Card("NFT de cette collection dans l’inventaire (\(items.count))") {352                if items.isEmpty { Text("Aucun.").foregroundStyle(.secondary) }353                LazyVGrid(columns: columns, alignment: .leading, spacing: 14) {354                    ForEach(items) { item in Button { open(.item(item.key)) } label: { NFTTile(item: item, gallery: gallery) }.buttonStyle(.plain) }355                }356            }357        }358        .task { await load() }359    }360361    private func load() async {362        guard model.phase == .signedIn, !loading else { return }363        loading = true; defer { loading = false }364        do { detail = try await gallery.api.collection(key: key); error = nil } catch { self.error = model.describe(error) }365    }366367    @ViewBuilder private func chainCard(_ d: NFTCollectionDetail) -> some View {368        Card("Ce que la chaîne dit de la collection") {369            HStack(alignment: .top, spacing: 16) {370                NFTThumbView(mediaId: d.metadata?.imageId, kind: nil, pixels: NFTMediaStore.gridPixels, api: gallery.mediaAPI, maxBytes: gallery.mediaLimit).frame(width: 120, height: 120)371                VStack(alignment: .leading, spacing: 9) {372                    if let e = d.error { Banner(.warning, "La collection n’a pas pu être lue sur la chaîne (\(e)).") }373                    if let i = d.info {374                        Field(label: "Réseau", value: "\(gallery.networkName(i.chain))  (\(i.chain))")375                        Field(label: "Standard", value: NFTText.standard(i.standard))376                        Field(label: "Identifiant", value: i.id, mono: true)377                        Field(label: "Nom sur la chaîne", value: NFTClean.line(i.onchainName) ?? "—")378                        Field(label: "Taille", value: NFTText.known(i.size) { Fmt.amount($0) })379                        Field(label: "Autorité de mise à jour", value: NFTText.known(i.updateAuthority) { $0 }, mono: i.updateAuthority.isKnown)380                        if !i.features.isEmpty { Field(label: "Caractéristiques", value: i.features.joined(separator: ", ")) }381                        if let u = i.uri { Field(label: "URI (texte, non ouverte)", value: NFTClean.line(u, max: 300) ?? "—", mono: true) }382                        NFTPlain(NFTText.stamp(i.source)).font(.caption).foregroundStyle(.secondary)383                    }384                    Field(label: "Détenus par ce portefeuille", value: String(d.held))385                    if let m = d.metadata {386                        Field(label: "Nom (créateur, non vérifié)", value: NFTClean.line(m.name, max: 200) ?? "—")387                        if let t = NFTClean.text(m.description, max: 2_000) { Field(label: "Description (créateur)", value: t) }388                        Field(label: "Métadonnées", value: NFTText.metadataStatus(m.status))389                    }390                }391            }392        }393    }394395    private var marketCard: some View {396        Card("Données de marché observées de la collection", trailing: AnyView(NFTFlag(text: "Déclarations de places de marché — pas une évaluation", color: .secondary))) {397            if let e = marketError { Banner(.danger, e) }398            if let m = market {399                NFTPlain("Réponse du serveur : \(Fmt.date(m.asOf))").font(.caption).foregroundStyle(.secondary)400                if m.sources.isEmpty { Text("Aucune source de marché ne couvre cette collection.").foregroundStyle(.secondary) }401                ForEach(Array(m.sources.enumerated()), id: \.offset) { _, s in402                    Divider()403                    NFTMarketSourceHeader(status: s.status)404                    if s.status.isOK { collectionRow(s) }405                }406            } else {407                HStack {408                    Text("Plancher, volumes et nombre de détenteurs tels que rapportés par chaque place de marché, avec leur date. Statistiques de la collection entière — jamais la valeur des NFT détenus.").font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)409                    Spacer()410                    if marketBusy { ProgressView().controlSize(.small) }411                    Button("Lire les données de marché") {412                        marketBusy = true; marketError = nil413                        Task { defer { marketBusy = false }; do { market = try await gallery.api.marketCollection(key: key) } catch { marketError = model.describe(error) } }414                    }.disabled(marketBusy || !model.canOperate)415                }416            }417        }418    }419420    @ViewBuilder private func collectionRow(_ s: NFTCollectionMarket) -> some View {421        Field(label: "Nom selon la source", value: "\(NFTClean.line(s.name) ?? "—")\(s.slug.map { " (\($0))" } ?? "")")422        if let v = s.verification { Field(label: "Badge de la source", value: v.state == "verified" ? "Vérifiée selon \(v.by) — déclaration de cette place de marché" : v.state == "not_verified" ? "Non vérifiée selon \(v.by)" : "Inconnu") }423        Field(label: "Prix plancher", value: NFTText.known(s.floor, NFTText.money) + " — annonce la moins chère de la collection")424        Field(label: "NFT en vente", value: NFTText.known(s.listedCount) { Fmt.amount($0) })425        Field(label: "Détenteurs", value: NFTText.known(s.owners) { Fmt.amount($0) })426        Field(label: "Offre totale", value: NFTText.known(s.totalSupply) { Fmt.amount($0) })427        ForEach(s.volumes, id: \.self) { v in428            Field(label: "Volume \(v.interval)", value: (v.volume.map(NFTText.money) ?? v.reported.map { "\($0.value) \($0.symbol) (tel que rapporté)" } ?? "—") + (v.sales.map { " · \($0) vente(s)" } ?? ""))429        }430        if let fees = s.fees, !fees.isEmpty {431            Field(label: "Frais rapportés", value: fees.map { "\($0.kind)\($0.bps.map { " \($0) pb" } ?? "")\($0.required == true ? " (obligatoire)" : "")" }.joined(separator: " · "))432        }433        if let d = s.definitions, !d.isEmpty { NFTPlain("Définitions de la source : " + d.keys.sorted().map { "\($0) = \(d[$0] ?? "")" }.joined(separator: " ; ")).font(.caption).foregroundStyle(.secondary) }434        NFTExternalLinkView(title: "Page sur \(s.status.name)", raw: s.url)435    }436}437
Files main
Menu

Theme