Wallet.swift (4653B)
1 // 2 // Wallet.swift 3 // damus 4 // 5 // Created by Benjamin Hakes on 12/29/22. 6 // 7 8 import Foundation 9 10 enum Wallet: String, CaseIterable, Identifiable, StringCodable { 11 var id: String { self.rawValue } 12 13 struct Model: Identifiable, Hashable { 14 var id: String { self.tag } 15 var index: Int 16 var tag: String 17 var displayName : String 18 var link : String 19 var appStoreLink : String? 20 var image: String 21 } 22 23 func to_string() -> String { 24 return rawValue 25 } 26 27 init?(from string: String) { 28 guard let w = Wallet(rawValue: string) else { 29 return nil 30 } 31 self = w 32 } 33 34 // New url prefixes needed to be added to LSApplicationQueriesSchemes 35 case system_default_wallet 36 case strike 37 case cashapp 38 case muun 39 case bluewallet 40 case walletofsatoshi 41 case zebedee 42 case zeusln 43 case lnlink 44 case phoenix 45 case breez 46 case bitcoinbeach 47 case blixtwallet 48 case river 49 50 var model: Model { 51 switch self { 52 case .system_default_wallet: 53 return .init(index: -1, tag: "systemdefaultwallet", displayName: NSLocalizedString("Local default", comment: "Dropdown option label for system default for Lightning wallet."), 54 link: "lightning:", appStoreLink: nil, image: "") 55 case .strike: 56 return .init(index: 0, tag: "strike", displayName: "Strike", link: "strike:", 57 appStoreLink: "https://apps.apple.com/us/app/strike-bitcoin-payments/id1488724463", image: "strike") 58 case .cashapp: 59 return .init(index: 1, tag: "cashapp", displayName: "Cash App", link: "https://cash.app/launch/lightning/", 60 appStoreLink: "https://apps.apple.com/us/app/cash-app/id711923939", image: "cashapp") 61 case .muun: 62 return .init(index: 2, tag: "muun", displayName: "Muun", link: "muun:", appStoreLink: "https://apps.apple.com/us/app/muun-wallet/id1482037683", image: "muun") 63 case .bluewallet: 64 return .init(index: 3, tag: "bluewallet", displayName: "Blue Wallet", link: "bluewallet:lightning:", 65 appStoreLink: "https://apps.apple.com/us/app/bluewallet-bitcoin-wallet/id1376878040", image: "bluewallet") 66 case .walletofsatoshi: 67 return .init(index: 4, tag: "walletofsatoshi", displayName: "Wallet of Satoshi", link: "walletofsatoshi:lightning:", 68 appStoreLink: "https://apps.apple.com/us/app/wallet-of-satoshi/id1438599608", image: "walletofsatoshi") 69 case .zebedee: 70 return .init(index: 5, tag: "zebedee", displayName: "Zebedee", link: "zebedee:lightning:", 71 appStoreLink: "https://apps.apple.com/us/app/zebedee-wallet/id1484394401", image: "zebedee") 72 case .zeusln: 73 return .init(index: 6, tag: "zeusln", displayName: "Zeus LN", link: "zeusln:lightning:", 74 appStoreLink: "https://apps.apple.com/us/app/zeus-ln/id1456038895", image: "zeusln") 75 case .lnlink: 76 return .init(index: 7, tag: "lnlink", displayName: "LNLink", link: "lnlink:lightning:", 77 appStoreLink: "https://testflight.apple.com/join/aNY4yuuZ", image: "lnlink") 78 case .phoenix: 79 return .init(index: 8, tag: "phoenix", displayName: "Phoenix", link: "phoenix://", 80 appStoreLink: "https://apps.apple.com/us/app/phoenix-wallet/id1544097028", image: "phoenix") 81 case .breez: 82 return .init(index: 9, tag: "breez", displayName: "Breez", link: "breez:", 83 appStoreLink: "https://apps.apple.com/us/app/breez-lightning-client-pos/id1463604142", image: "breez") 84 case .bitcoinbeach: 85 return .init(index: 10, tag: "bitcoinbeach", displayName: "Bitcoin Beach", link: "bitcoinbeach://", 86 appStoreLink: "https://apps.apple.com/sv/app/bitcoin-beach-wallet/id1531383905", image: "bbw") 87 case .blixtwallet: 88 return .init(index: 11, tag: "blixtwallet", displayName: "Blixt Wallet", link: "blixtwallet:lightning:", 89 appStoreLink: "https://testflight.apple.com/join/EXvGhRzS", image: "blixt-wallet") 90 case .river: 91 return .init(index: 12, tag: "river", displayName: "River", link: "river://", 92 appStoreLink: "https://apps.apple.com/us/app/river-buy-mine-bitcoin/id1536176542", image: "river") 93 94 } 95 } 96 97 static var allModels: [Model] { 98 return Self.allCases.map { $0.model } 99 } 100 }