SPB Git

Repository Public

HTTP.swift 26.0 KB 470 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : QYVORA7// File             : Sources/QyvoraNetworking/HTTP.swift8// Module           : Qyvora Networking9// Repository       : https://git.spboucher.ai/qyvora10// Project Website  : Not specified11// Created          : 2026-12-0412// 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 Foundation42import QyvoraCore4344/// Minimal HTTP transport, injectable so that tests never touch the network.45public protocol HTTPTransport: Sendable {46    func send(_ request: URLRequest) async throws -> (Data, HTTPURLResponse)47}4849public enum NetworkError: Error, Equatable, Sendable {50    case invalidURL51    case http(status: Int, body: String)52    case invalidResponse(String)53    case rpc(code: Int, message: String)54    case allEndpointsFailed([String])55    case disagreement(String)56    case offline57    /// The protocol of the endpoint cannot do what was asked (raw transactions on a Bitcore indexer).58    case unsupported(String)59}6061extension NetworkError {62    /// Marker of a request stopped by cold mode, as it appears in `summary` (and in the failure list of63    /// `allEndpointsFailed`). A device that merely has no connection never produces it.64    public static let coldModeSummary = "blocked by cold mode"6566    /// A short readable reason ("HTTP 429 (too many requests)", "invalid answer (tip height)"), used wherever a67    /// failure is reported next to the host that caused it. Never a Swift case name.68    public var summary: String {69        switch self {70        case .invalidURL: return "invalid request"71        case .http(let status, _):72            switch status {73            case 429: return "HTTP 429 (too many requests)"74            case 404: return "HTTP 404 (not found)"75            case 500...599: return "HTTP \(status) (server error)"76            default: return "HTTP \(status)"77            }78        case .invalidResponse(let what): return "invalid answer (\(what))"79        case .rpc(let code, let message): return "RPC error \(code): \(message)"80        case .allEndpointsFailed(let failures): return failures.joined(separator: "; ")81        case .disagreement(let text): return text82        case .offline: return Self.coldModeSummary83        case .unsupported(let what): return "not supported by this endpoint (\(what))"84        }85    }8687    /// Why a request did not get any HTTP answer, from a transport error (`URLError`): a sentence, never a type name.88    public static func transportSummary(_ error: any Error) -> String {89        if let e = error as? NetworkError { return e.summary }90        let ns = error as NSError91        guard ns.domain == NSURLErrorDomain else {92            // system errors describe themselves; anything else would print the name of a Swift type93            return ns.domain == NSCocoaErrorDomain || ns.domain == NSPOSIXErrorDomain ? ns.localizedDescription : "an unexpected error occurred"94        }95        switch ns.code {96        case NSURLErrorNotConnectedToInternet, NSURLErrorDataNotAllowed, NSURLErrorInternationalRoamingOff:97            return "this device is not connected to the Internet"98        case NSURLErrorCannotFindHost, NSURLErrorDNSLookupFailed: return "the server name could not be resolved (DNS)"99        case NSURLErrorTimedOut: return "the server did not answer in time"100        case NSURLErrorCannotConnectToHost: return "the server refused the connection"101        case NSURLErrorNetworkConnectionLost: return "the connection was lost during the request"102        case NSURLErrorCancelled: return "the request was cancelled"103        case NSURLErrorSecureConnectionFailed, NSURLErrorServerCertificateUntrusted, NSURLErrorServerCertificateHasBadDate,104             NSURLErrorServerCertificateHasUnknownRoot, NSURLErrorServerCertificateNotYetValid, NSURLErrorClientCertificateRejected,105             NSURLErrorClientCertificateRequired, NSURLErrorAppTransportSecurityRequiresSecureConnection:106            return "a secure connection could not be established (TLS)"107        case NSURLErrorBadURL, NSURLErrorUnsupportedURL: return "the endpoint address is not valid"108        case NSURLErrorHTTPTooManyRedirects, NSURLErrorRedirectToNonExistentLocation: return "the server redirected the request, which is not followed"109        case NSURLErrorBadServerResponse, NSURLErrorCannotParseResponse, NSURLErrorCannotDecodeContentData, NSURLErrorCannotDecodeRawData,110             NSURLErrorZeroByteResource:111            return "the server sent an answer that cannot be read"112        case NSURLErrorDataLengthExceedsMaximum: return "the server sent more data than accepted"113        default: return "the request failed (network error \(ns.code))"114        }115    }116}117118/// URLSession transport without cookies, cache, credentials or redirects. QYVORA sends no identifier of any kind.119public final class URLSessionTransport: HTTPTransport {120    private final class NoRedirect: NSObject, URLSessionTaskDelegate {121        func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse,122                        newRequest request: URLRequest) async -> URLRequest? {123            nil124        }125    }126127    /// Largest response body accepted by default: 32 MiB (the largest legitimate answers — a page of 25 large128    /// transactions, a market list with sparklines — are a few megabytes).129    public static let defaultMaximumResponseBytes = 32 << 20130131    private let session: URLSession132    private let maximumResponseBytes: Int133134    /// `maximumResponseBytes` bounds what one answer may hold: a longer body is abandoned and reported as135    /// `invalidResponse`, so that a faulty or hostile endpoint cannot exhaust the memory of the device.136    public convenience init(timeout: TimeInterval = 12, maximumResponseBytes: Int = URLSessionTransport.defaultMaximumResponseBytes) {137        self.init(timeout: timeout, maximumResponseBytes: maximumResponseBytes, protocolClasses: nil)138    }139140    /// `protocolClasses` lets the tests answer requests locally (URLProtocol) without touching the network.141    init(timeout: TimeInterval, maximumResponseBytes: Int, protocolClasses: [AnyClass]?) {142        self.maximumResponseBytes = max(1, maximumResponseBytes)143        let c = URLSessionConfiguration.ephemeral144        if let protocolClasses { c.protocolClasses = protocolClasses }145        c.timeoutIntervalForRequest = timeout146        c.timeoutIntervalForResource = timeout * 2147        c.httpCookieStorage = nil148        c.httpShouldSetCookies = false149        c.urlCache = nil150        c.urlCredentialStorage = nil151        c.requestCachePolicy = .reloadIgnoringLocalCacheData152        c.httpAdditionalHeaders = ["User-Agent": "QYVORA", "Accept": "application/json, text/plain"]153        session = URLSession(configuration: c, delegate: NoRedirect(), delegateQueue: nil)154    }155156    public func send(_ request: URLRequest) async throws -> (Data, HTTPURLResponse) {157        let (bytes, response) = try await session.bytes(for: request)158        guard let http = response as? HTTPURLResponse else {159            bytes.task.cancel()160            throw NetworkError.invalidResponse("not HTTP")161        }162        // The body is read as a stream so that an oversized answer is abandoned instead of being buffered whole.163        let limit = maximumResponseBytes164        guard response.expectedContentLength <= Int64(limit) else {165            bytes.task.cancel()166            throw NetworkError.invalidResponse("response larger than \(limit) bytes")167        }168        var data = Data()169        if response.expectedContentLength > 0 { data.reserveCapacity(Int(response.expectedContentLength)) }170        for try await byte in bytes {171            guard data.count < limit else {172                bytes.task.cancel()173                throw NetworkError.invalidResponse("response larger than \(limit) bytes")174            }175            data.append(byte)176        }177        return (data, http)178    }179}180181/// Untyped JSON value for JSON-RPC parameters and results.182public enum JSONValue: Codable, Equatable, Sendable {183    case null184    case bool(Bool)185    case number(Double)186    case string(String)187    case array([JSONValue])188    case object([String: JSONValue])189190    public init(from decoder: Decoder) throws {191        let c = try decoder.singleValueContainer()192        if c.decodeNil() { self = .null }193        else if let b = try? c.decode(Bool.self) { self = .bool(b) }194        else if let n = try? c.decode(Double.self) { self = .number(n) }195        else if let s = try? c.decode(String.self) { self = .string(s) }196        else if let a = try? c.decode([JSONValue].self) { self = .array(a) }197        else { self = .object(try c.decode([String: JSONValue].self)) }198    }199200    public func encode(to encoder: Encoder) throws {201        var c = encoder.singleValueContainer()202        switch self {203        case .null: try c.encodeNil()204        case .bool(let b): try c.encode(b)205        case .number(let n): try c.encode(n)206        case .string(let s): try c.encode(s)207        case .array(let a): try c.encode(a)208        case .object(let o): try c.encode(o)209        }210    }211212    public var string: String? { if case .string(let s) = self { return s }; return nil }213    public var array: [JSONValue]? { if case .array(let a) = self { return a }; return nil }214    public var object: [String: JSONValue]? { if case .object(let o) = self { return o }; return nil }215    public var isNull: Bool { self == .null }216    public subscript(key: String) -> JSONValue? { object?[key] }217}218219/// The endpoints the application talks to. Everything is user-editable (personal nodes, private RPC).220public struct EndpointConfiguration: Codable, Equatable, Sendable {221    /// Esplora-compatible REST bases per UTXO network (raw value of `BitcoinNetwork`): Bitcoin and Litecoin.222    public var esplora: [String: [String]]223    /// Blockbook API v2 bases (`…/api/v2`) per UTXO network: Litecoin, Dogecoin, Bitcoin Cash.224    public var blockbook: [String: [String]]225    /// Bitcore API bases (`…/api/<CHAIN>/<network>`) per UTXO network.226    public var bitcore: [String: [String]]227    /// Ethereum JSON-RPC URLs per network (raw value of `EthereumNetwork`).228    public var ethereumRPC: [String: [String]]229    /// Blockscout-compatible API bases (history, token discovery) per Ethereum network. Empty disables history lookups.230    public var ethereumIndexer: [String: [String]]231    /// CoinGecko-compatible price API base. Empty disables market data.232    public var priceAPI: String233    /// Second, independent price source: base of a Kraken-compatible public market API (`<base>/Ticker?pair=…`).234    /// It is asked for one figure only, the USD price of an asset whose dollar ceiling is being checked on an235    /// unaudited mainnet build (QYV-SVC-087). Empty: no cross-check is possible, and every transfer whose ceiling needs236    /// two sources is refused.237    public var priceCheckAPI: String238239    /// UTXO endpoints added with Litecoin, Dogecoin and Bitcoin Cash, all keyless. Each was checked on 2026-12-05 with240    /// read-only requests: identity block (`BitcoinNetwork.identityBlock`), tip, and the statistics, coins and history241    /// of a public address (opt-in live test `QYVORA_LIVE=1`, suite `UTXOLiveTests` of the networking tests).242    /// Findings of that day: litecoinspace.org has no `/fee-estimates` (the client falls back to243    /// `/v1/fees/recommended`) and its testnet instance was three days behind the Bitcore one; Dogecoin Testnet has no244    /// usable keyless indexer (`BitcoinNetwork.indexerAvailable`); Bitcoin Cash Testnet4 has a single source here245    /// (api.haskoin.com also serves it, with a protocol QYVORA does not implement); the Trezor Blockbook hosts refuse246    /// automated clients (HTTP 403).247    public static let utxoEsploraAdditions: [String: [String]] = [248        "litecoin": ["https://litecoinspace.org/api"],249        "litecoinTestnet": ["https://litecoinspace.org/testnet/api"],250    ]251    public static let defaultBlockbook: [String: [String]] = [252        "litecoin": ["https://blockbook.ltc.zelcore.io/api/v2", "https://litecoin.atomicwallet.io/api/v2"],253        "dogecoin": ["https://blockbook.doge.zelcore.io/api/v2"],254        "bitcoinCash": ["https://blockbook.bch.zelcore.io/api/v2"],255    ]256    public static let defaultBitcore: [String: [String]] = [257        "litecoin": ["https://api.bitcore.io/api/LTC/mainnet"],258        "litecoinTestnet": ["https://api.bitcore.io/api/LTC/testnet"],259        "dogecoin": ["https://api.bitcore.io/api/DOGE/mainnet"],260        "bitcoinCash": ["https://api.bitcore.io/api/BCH/mainnet"],261        "bitcoinCashTestnet": ["https://api.bitcore.io/api/BCH/testnet"],262    ]263264    /// Kraken's public market data: keyless, read-only. Checked on 2026-12-05 with `GET /Ticker?pair=<pair>` for every265    /// pair of `PriceClient.checkPairs` (each answered one entry with ask, bid and last trade).266    public static let defaultPriceCheckAPI = "https://api.kraken.com/0/public"267268    public static let `default` = EndpointConfiguration(269        esplora: [270            "mainnet": ["https://mempool.space/api", "https://blockstream.info/api"],271            "testnet": ["https://mempool.space/testnet/api", "https://blockstream.info/testnet/api"],272            "signet": ["https://mempool.space/signet/api", "https://blockstream.info/signet/api"],273        ].merging(utxoEsploraAdditions) { current, _ in current },274        blockbook: defaultBlockbook,275        bitcore: defaultBitcore,276        ethereumRPC: EVMEndpointDefaults.rpc,277        ethereumIndexer: EVMEndpointDefaults.indexer,278        priceAPI: "https://api.coingecko.com/api/v3",279        priceCheckAPI: defaultPriceCheckAPI280    )281282    /// `blockbook` and `bitcore` default to none: a configuration written out by hand talks to the listed hosts only.283    public init(esplora: [String: [String]], blockbook: [String: [String]] = [:], bitcore: [String: [String]] = [:],284                ethereumRPC: [String: [String]], ethereumIndexer: [String: [String]], priceAPI: String,285                priceCheckAPI: String = "") {286        self.esplora = esplora287        self.blockbook = blockbook288        self.bitcore = bitcore289        self.ethereumRPC = ethereumRPC290        self.ethereumIndexer = ethereumIndexer291        self.priceAPI = priceAPI292        self.priceCheckAPI = priceCheckAPI293    }294295    private enum CodingKeys: String, CodingKey {296        case schema, esplora, blockbook, bitcore, ethereumRPC, ethereumIndexer, priceAPI, priceCheckAPI297    }298299    /// Version of the stored form. 1 (no `schema` field): written by QYVORA 1.0, which knew Bitcoin, Ethereum and300    /// Sepolia only. 2: written since the multi-chain upgrade; the lists are complete as stored.301    static let currentSchema = 2302303    /// Decoding is tolerant, so that a profile stored by an earlier version keeps working when networks are added.304    /// A value without `schema` comes from version 1.0: a network it does not name did not exist then and receives305    /// its default endpoints; a network it names keeps exactly what was stored, an empty list included (the user306    /// disabled it). A value of the current schema is taken as it is: a network without list has no endpoint.307    /// A missing field takes its default in both cases.308    /// The UTXO lists follow the same rule with their own marker: a value without a `blockbook` field was written309    /// before Litecoin, Dogecoin and Bitcoin Cash existed (whatever its schema), so its Esplora list receives the310    /// entries of the networks it does not name, and `blockbook` and `bitcore` take their defaults.311    public init(from decoder: Decoder) throws {312        let c = try decoder.container(keyedBy: CodingKeys.self)313        let defaults = Self.default314        let schema = try c.decodeIfPresent(Int.self, forKey: .schema) ?? 1315        let beforeEVM = schema < Self.currentSchema, beforeUTXO = beforeEVM || !c.contains(.blockbook)316        func lists(_ key: CodingKeys, _ fallback: [String: [String]], legacy: Bool) throws -> [String: [String]] {317            guard let stored = try c.decodeIfPresent([String: [String]].self, forKey: key) else { return fallback }318            return legacy ? stored.merging(fallback) { kept, _ in kept } : stored319        }320        esplora = try lists(.esplora, defaults.esplora, legacy: beforeUTXO)321        blockbook = try lists(.blockbook, defaults.blockbook, legacy: beforeUTXO)322        bitcore = try lists(.bitcore, defaults.bitcore, legacy: beforeUTXO)323        ethereumRPC = try lists(.ethereumRPC, defaults.ethereumRPC, legacy: beforeEVM)324        ethereumIndexer = try lists(.ethereumIndexer, defaults.ethereumIndexer, legacy: beforeEVM)325        priceAPI = try c.decodeIfPresent(String.self, forKey: .priceAPI) ?? defaults.priceAPI326        // absent in every value stored before 2026-12-05: the default second source, without which no dollar ceiling327        // could be verified after the update328        priceCheckAPI = try c.decodeIfPresent(String.self, forKey: .priceCheckAPI) ?? defaults.priceCheckAPI329    }330331    public func encode(to encoder: Encoder) throws {332        var c = encoder.container(keyedBy: CodingKeys.self)333        try c.encode(Self.currentSchema, forKey: .schema)334        try c.encode(esplora, forKey: .esplora)335        try c.encode(blockbook, forKey: .blockbook)336        try c.encode(bitcore, forKey: .bitcore)337        try c.encode(ethereumRPC, forKey: .ethereumRPC)338        try c.encode(ethereumIndexer, forKey: .ethereumIndexer)339        try c.encode(priceAPI, forKey: .priceAPI)340        try c.encode(priceCheckAPI, forKey: .priceCheckAPI)341    }342343    /// Every UTXO indexer URL of the configuration, all protocols and networks together.344    public var utxoIndexerURLs: [String] {345        esplora.values.flatMap { $0 } + blockbook.values.flatMap { $0 } + bitcore.values.flatMap { $0 }346    }347348    /// The endpoints of one UTXO network, by protocol.349    public func utxoEndpoints(_ network: BitcoinNetwork) -> [UTXOIndexerProtocol: [String]] {350        var out = [UTXOIndexerProtocol: [String]]()351        for (kind, table) in [(UTXOIndexerProtocol.esplora, esplora), (.blockbook, blockbook), (.bitcore, bitcore)] {352            if let list = table[network.rawValue], !list.isEmpty { out[kind] = list }353        }354        return out355    }356357    /// Accepts https URLs, and http only for local or private hosts (a node on the user's own network or Tor proxy).358    public static func isAcceptable(_ text: String) -> Bool {359        guard let u = URL(string: text), let host = u.host?.lowercased(), u.user == nil, u.password == nil else { return false }360        if u.scheme == "https" { return true }361        guard u.scheme == "http" else { return false }362        if host == "localhost" || host.hasSuffix(".local") || host.hasSuffix(".onion") { return true }363        // private ranges only when the host is an IPv4 literal (a name such as 10.example.com is not private)364        let parts = host.split(separator: ".", omittingEmptySubsequences: false)365        guard parts.count == 4 else { return false }366        let octets = parts.compactMap { p -> Int? in367            guard !p.isEmpty, p.count <= 3, p.utf8.allSatisfy({ $0 >= 0x30 && $0 <= 0x39 }), let v = Int(p), v <= 255 else { return nil }368            return v369        }370        guard octets.count == 4 else { return false }371        return octets[0] == 127 || octets[0] == 10 || (octets[0] == 192 && octets[1] == 168) || (octets[0] == 172 && (16...31).contains(octets[1]))372    }373}374375func urls(_ list: [String]) -> [URL] { list.compactMap { EndpointConfiguration.isAcceptable($0) ? URL(string: $0) : nil } }376377extension HTTPTransport {378    func get(_ url: URL) async throws -> Data {379        var r = URLRequest(url: url)380        r.httpMethod = "GET"381        let (data, response) = try await send(r)382        guard (200...299).contains(response.statusCode) else {383            throw NetworkError.http(status: response.statusCode, body: String(decoding: data.prefix(300), as: UTF8.self))384        }385        return data386    }387388    /// Tries each base in order; the first success wins. Connection and HTTP errors move on to the next base.389    func firstSuccess<T: Sendable>(_ bases: [URL], _ work: @Sendable (URL) async throws -> T) async throws -> T {390        guard !bases.isEmpty else { throw NetworkError.allEndpointsFailed(["no endpoint configured"]) }391        var failures = [String]()392        for base in bases {393            do { return try await work(base) } catch let e as NetworkError {394                if case .rpc = e { throw e }395                failures.append("\(base.host ?? "?"): \(e.summary)")396            } catch {397                failures.append("\(base.host ?? "?"): \(NetworkError.transportSummary(error))")398            }399        }400        throw NetworkError.allEndpointsFailed(failures)401    }402}403404// MARK: - EVM endpoint defaults405406/// Default keyless public endpoints of the EVM networks, keyed by the raw value of `EthereumNetwork`.407///408/// Every JSON-RPC URL below was checked on 2026-12-05 with read-only requests: `eth_chainId` returned the expected409/// identifier, `eth_blockNumber` and `eth_getBlockByNumber("latest")` answered with a `baseFeePerGas`, and the410/// "finalized" block tag was served. Each network has two endpoints run by different operators, so that the chain411/// identifier and the nonce are agreed by two parties (`EthereumRPC.quorum`).412///413/// Indexers (history, token discovery), checked the same day with one address query each:414/// - Blockscout API v2, answered: eth.blockscout.com, eth-sepolia.blockscout.com, base-sepolia.blockscout.com,415///   explorer.optimism.io and testnet-explorer.optimism.io (optimism.blockscout.com and416///   optimism-sepolia.blockscout.com redirect there, and QYVORA does not follow redirects).417/// - Etherscan-compatible API of Routescan, answered for Avalanche C-Chain (43114) and Fuji (43113).418/// - No keyless source found: Base, Arbitrum One, Arbitrum Sepolia and Polygon PoS (their Blockscout instances419///   answer HTTP 403 with a browser challenge to a client that is not a browser; QYVORA does not pretend to be one),420///   Polygon Amoy, BNB Smart Chain and its test network (no public Blockscout; Routescan answers "chain not421///   supported"; the Etherscan API requires a key and a paid plan for these chains). Their list is empty: balances,422///   tokens of the built-in and custom lists, fees and sends work through the RPC, and history is reported as423///   unavailable (`noKeylessIndexerReason`). The user can enter an indexer of their own in the settings.424public enum EVMEndpointDefaults {425    public static let checkedOn = "2026-12-05"426427    public static let rpc: [String: [String]] = [428        "mainnet": ["https://ethereum-rpc.publicnode.com", "https://eth.drpc.org"],429        "sepolia": ["https://ethereum-sepolia-rpc.publicnode.com", "https://sepolia.gateway.tenderly.co"],430        "base": ["https://mainnet.base.org", "https://base-rpc.publicnode.com"],431        "baseSepolia": ["https://sepolia.base.org", "https://base-sepolia-rpc.publicnode.com"],432        "arbitrum": ["https://arb1.arbitrum.io/rpc", "https://arbitrum-one-rpc.publicnode.com"],433        "arbitrumSepolia": ["https://sepolia-rollup.arbitrum.io/rpc", "https://arbitrum-sepolia-rpc.publicnode.com"],434        "optimism": ["https://mainnet.optimism.io", "https://optimism-rpc.publicnode.com"],435        "optimismSepolia": ["https://sepolia.optimism.io", "https://optimism-sepolia-rpc.publicnode.com"],436        "polygon": ["https://polygon-bor-rpc.publicnode.com", "https://polygon.drpc.org"],437        "polygonAmoy": ["https://polygon-amoy-bor-rpc.publicnode.com", "https://polygon-amoy.drpc.org"],438        "bsc": ["https://bsc-dataseed.bnbchain.org", "https://bsc-rpc.publicnode.com"],439        "bscTestnet": ["https://bsc-testnet-dataseed.bnbchain.org", "https://bsc-testnet-rpc.publicnode.com"],440        "avalanche": ["https://api.avax.network/ext/bc/C/rpc", "https://avalanche-c-chain-rpc.publicnode.com"],441        "avalancheFuji": ["https://api.avax-test.network/ext/bc/C/rpc", "https://avalanche-fuji-c-chain-rpc.publicnode.com"],442    ]443444    /// A base whose path ends in "/api" speaks the Etherscan dialect; any other base is a Blockscout API v2 host.445    public static let indexer: [String: [String]] = [446        "mainnet": ["https://eth.blockscout.com"],447        "sepolia": ["https://eth-sepolia.blockscout.com"],448        "base": [],449        "baseSepolia": ["https://base-sepolia.blockscout.com"],450        "arbitrum": [],451        "arbitrumSepolia": [],452        "optimism": ["https://explorer.optimism.io"],453        "optimismSepolia": ["https://testnet-explorer.optimism.io"],454        "polygon": [],455        "polygonAmoy": [],456        "bsc": [],457        "bscTestnet": [],458        "avalanche": ["https://api.routescan.io/v2/network/mainnet/evm/43114/etherscan/api"],459        "avalancheFuji": ["https://api.routescan.io/v2/network/testnet/evm/43113/etherscan/api"],460    ]461462    /// What the application says about history on a network that has no default indexer.463    public static let noKeylessIndexerReason = "no keyless indexer for this network"464465    /// True when QYVORA ships a history source for the network.466    public static func hasDefaultIndexer(_ network: EthereumNetwork) -> Bool {467        !(indexer[network.rawValue] ?? []).isEmpty468    }469}470
Files main
Menu

Theme