From 8fbdfa54f455359047b138cbe73b44e5ee4e82c8 Mon Sep 17 00:00:00 2001 From: kcw-grunt Date: Mon, 13 May 2024 15:18:35 +0100 Subject: [PATCH] removed unused code Signed-off-by: kcw-grunt --- litewallet/BRTxInputExtension.swift | 5 - .../Extensions/SafariServices+Extension.swift | 18 +-- litewallet/FeeManager.swift | 3 - litewallet/ReceiveLTCViewController.swift | 9 -- litewallet/SendAddressHostingController.swift | 19 --- litewallet/StartViewModel.swift | 133 ++++++++---------- litewallet/TextView+Extension.swift | 1 - litewallet/TransactionCellViewModel.swift | 2 - litewallet/TransactionModalView.swift | 8 -- litewallet/TransactionsViewController.swift | 3 - litewallet/UnstoppableDomainView.swift | 9 -- litewallet/UnstoppableDomainViewModel.swift | 14 -- .../Import/StartImportViewController.swift | 6 +- litewallet/Views/SearchHeaderView.swift | 3 - litewallet/Views/ShadowButton.swift | 1 - 15 files changed, 63 insertions(+), 171 deletions(-) delete mode 100644 litewallet/SendAddressHostingController.swift diff --git a/litewallet/BRTxInputExtension.swift b/litewallet/BRTxInputExtension.swift index 9ef47a293..d49059848 100644 --- a/litewallet/BRTxInputExtension.swift +++ b/litewallet/BRTxInputExtension.swift @@ -18,9 +18,4 @@ extension BRTxInput { get { return [UInt8](UnsafeBufferPointer(start: script, count: scriptLen)) } set { BRTxInputSetScript(&self, newValue, newValue.count) } } - - var swiftSignature: [UInt8] { - get { return [UInt8](UnsafeBufferPointer(start: signature, count: sigLen)) } - set { BRTxInputSetSignature(&self, newValue, newValue.count) } - } } diff --git a/litewallet/Extensions/SafariServices+Extension.swift b/litewallet/Extensions/SafariServices+Extension.swift index 19605b897..d3f359a42 100644 --- a/litewallet/Extensions/SafariServices+Extension.swift +++ b/litewallet/Extensions/SafariServices+Extension.swift @@ -67,8 +67,8 @@ class SignupWebView: WKWebView, WKNavigationDelegate { webView.evaluateJavaScript(scriptContent, completionHandler: { height, error in - print(height) - print(error) + debugPrint(height ?? 0.0) + debugPrint(error) }) webView.evaluateJavaScript("document.body.innerHTML", completionHandler: { (value: Any!, error: Error!) in @@ -76,20 +76,8 @@ class SignupWebView: WKWebView, WKNavigationDelegate { // Error logic return } - // webView.invalidateIntrinsicContentSize() - // let js = "document.getElementById(\"MY_TEXTFIELD_ID\").focus();" - // webView.evaluateJavaScript(js) - - // webview.canBecomeFocused = true - - // document.getElementById('myID').focus(); - - // webview.scrollView.setZoomScale(0.3, animated: true) - - let result = value as? String - - print(value) + debugPrint(value ?? "Empty string") }) } } diff --git a/litewallet/FeeManager.swift b/litewallet/FeeManager.swift index 8967a7250..816555bbe 100644 --- a/litewallet/FeeManager.swift +++ b/litewallet/FeeManager.swift @@ -32,9 +32,6 @@ class FeeUpdater: Trackable { private let walletManager: WalletManager private let store: Store - private lazy var minFeePerKB: UInt64 = Fees.usingDefaultValues.economy - - private let maxFeePerKB = Fees.usingDefaultValues.luxury private var timer: Timer? private let feeUpdateInterval: TimeInterval = 3 private var exchangeUpdater: ExchangeUpdater diff --git a/litewallet/ReceiveLTCViewController.swift b/litewallet/ReceiveLTCViewController.swift index 0c95385df..e22cfbba5 100644 --- a/litewallet/ReceiveLTCViewController.swift +++ b/litewallet/ReceiveLTCViewController.swift @@ -1,14 +1,5 @@ import UIKit -struct WalletAddressData { - var address: String - var qrCode: UIImage - var balance: Double - var balanceText: String { - String(balance) + " Ł" - } -} - class ReceiveLTCViewController: UIViewController { var store: Store? override func viewDidLoad() { diff --git a/litewallet/SendAddressHostingController.swift b/litewallet/SendAddressHostingController.swift deleted file mode 100644 index 4939d3334..000000000 --- a/litewallet/SendAddressHostingController.swift +++ /dev/null @@ -1,19 +0,0 @@ -import Foundation -import SwiftUI - -class SendAddressHostingController: UIHostingController { - var addressString: String = "" - - let contentView = SendAddressCellView() - - init() { - addressString = contentView.viewModel.addressString - - super.init(rootView: contentView) - } - - @available(*, unavailable) - @MainActor dynamic required init?(coder _: NSCoder) { - fatalError("init(coder:) has not been implemented") - } -} diff --git a/litewallet/StartViewModel.swift b/litewallet/StartViewModel.swift index 502114302..c45a68524 100644 --- a/litewallet/StartViewModel.swift +++ b/litewallet/StartViewModel.swift @@ -68,43 +68,29 @@ class StartViewModel: ObservableObject { didTapRecover = completion } - private func checkForWalletAndSync() { - /// Test seed count - guard seedWords.count == 12 else { return } - - /// Set for default. This model needs a initial value - walletManager.forceSetPin(newPin: Partner.partnerKeyPath(name: .litewalletStart)) - - guard walletManager.setRandomSeedPhrase() != nil else { - walletCreationDidFail = true - let properties = ["error_message": "wallet_creation_fail"] - LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) - return - } - - store.perform(action: WalletChange.setWalletCreationDate(Date())) - DispatchQueue.walletQueue.async { - self.walletManager.peerManager?.connect() - DispatchQueue.main.async { - self.store.trigger(name: .didCreateOrRecoverWallet) - } - } - } - - func updateHeader() { - switch tappedIndex { - case 0: - headerTitle = S.CreateStep.MainTitle.intro.localize() - case 1: - headerTitle = S.CreateStep.MainTitle.checkboxes.localize() - case 2: - headerTitle = S.CreateStep.MainTitle.seedPhrase.localize() - case 3: - headerTitle = S.CreateStep.MainTitle.finished.localize() - default: - headerTitle = S.CreateStep.MainTitle.intro.localize() - } - } + /// DEV: For checking wallet +// private func checkForWalletAndSync() { +// /// Test seed count +// guard seedWords.count == 12 else { return } +// +// /// Set for default. This model needs a initial value +// walletManager.forceSetPin(newPin: Partner.partnerKeyPath(name: .litewalletStart)) +// +// guard walletManager.setRandomSeedPhrase() != nil else { +// walletCreationDidFail = true +// let properties = ["error_message": "wallet_creation_fail"] +// LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties) +// return +// } +// +// store.perform(action: WalletChange.setWalletCreationDate(Date())) +// DispatchQueue.walletQueue.async { +// self.walletManager.peerManager?.connect() +// DispatchQueue.main.async { +// self.store.trigger(name: .didCreateOrRecoverWallet) +// } +// } +// } func speakLanguage() { if let url = Bundle.main.url(forResource: currentLanguage.voiceFilename, withExtension: "mp3") { @@ -131,10 +117,6 @@ class StartViewModel: ObservableObject { } } - func generateNewSeedPhrase() -> [String] { - return [""] - } - // MARK: - Lengthy elements /// Set these to the bottom to make the others more readable @@ -207,38 +189,39 @@ class StartViewModel: ObservableObject { "Скасувати", ] - func stringToCurrentLanguage(languageString: String) -> LanguageSelection { - switch languageString { - case "English": - return LanguageSelection(rawValue: 0)! - case "中國人": - return LanguageSelection(rawValue: 1)! - case "中国人": - return LanguageSelection(rawValue: 2)! - case "Français": - return LanguageSelection(rawValue: 3)! - case "Deutsch": - return LanguageSelection(rawValue: 4)! - case "Bahasa Indonesia": - return LanguageSelection(rawValue: 5)! - case "Italiano": - return LanguageSelection(rawValue: 6)! - case "日本語": - return LanguageSelection(rawValue: 7)! - case "한국인": - return LanguageSelection(rawValue: 8)! - case "Português": - return LanguageSelection(rawValue: 9)! - case "Русский": - return LanguageSelection(rawValue: 10)! - case "Español": - return LanguageSelection(rawValue: 11)! - case "Türkçe": - return LanguageSelection(rawValue: 12)! - case "українська": - return LanguageSelection(rawValue: 13)! - default: - return LanguageSelection(rawValue: 0)! - } - } + /// DEV: For debugging +// func stringToCurrentLanguage(languageString: String) -> LanguageSelection { +// switch languageString { +// case "English": +// return LanguageSelection(rawValue: 0)! +// case "中國人": +// return LanguageSelection(rawValue: 1)! +// case "中国人": +// return LanguageSelection(rawValue: 2)! +// case "Français": +// return LanguageSelection(rawValue: 3)! +// case "Deutsch": +// return LanguageSelection(rawValue: 4)! +// case "Bahasa Indonesia": +// return LanguageSelection(rawValue: 5)! +// case "Italiano": +// return LanguageSelection(rawValue: 6)! +// case "日本語": +// return LanguageSelection(rawValue: 7)! +// case "한국인": +// return LanguageSelection(rawValue: 8)! +// case "Português": +// return LanguageSelection(rawValue: 9)! +// case "Русский": +// return LanguageSelection(rawValue: 10)! +// case "Español": +// return LanguageSelection(rawValue: 11)! +// case "Türkçe": +// return LanguageSelection(rawValue: 12)! +// case "українська": +// return LanguageSelection(rawValue: 13)! +// default: +// return LanguageSelection(rawValue: 0)! +// } +// } } diff --git a/litewallet/TextView+Extension.swift b/litewallet/TextView+Extension.swift index 6bbbba989..f7b2069a9 100644 --- a/litewallet/TextView+Extension.swift +++ b/litewallet/TextView+Extension.swift @@ -18,7 +18,6 @@ struct TextView: UIViewRepresentable { placeholder = placeholderString } - let udModel = UnstoppableDomainViewModel() func makeUIView(context _: Context) -> UITextView { let textView = UITextView() textView.autocapitalizationType = .sentences diff --git a/litewallet/TransactionCellViewModel.swift b/litewallet/TransactionCellViewModel.swift index ca9e88eea..b4db09601 100644 --- a/litewallet/TransactionCellViewModel.swift +++ b/litewallet/TransactionCellViewModel.swift @@ -20,8 +20,6 @@ class TransactionCellViewModel: ObservableObject { var feeText: String = "" - var directionText: String = "" - var directionImageText: String = "" var directionArrowColor: Color = .clear diff --git a/litewallet/TransactionModalView.swift b/litewallet/TransactionModalView.swift index 0dd622c46..84951915b 100644 --- a/litewallet/TransactionModalView.swift +++ b/litewallet/TransactionModalView.swift @@ -1,20 +1,12 @@ import SwiftUI import UIKit -private let qrImageSize = 180.0 - struct TransactionModalView: View { @ObservedObject var viewModel: TransactionCellViewModel let dataRowHeight: CGFloat = 65.0 - @State - var isDisplayed: Bool = false - - @State - var didCopy: Bool = false - @State var copiedData: String = "" diff --git a/litewallet/TransactionsViewController.swift b/litewallet/TransactionsViewController.swift index dd5a141c3..b19d65fab 100644 --- a/litewallet/TransactionsViewController.swift +++ b/litewallet/TransactionsViewController.swift @@ -15,12 +15,9 @@ class TransactionsViewController: UIViewController, UITableViewDelegate, UITable var store: Store? var walletManager: WalletManager? - var selectedIndexes = [IndexPath: NSNumber]() var shouldBeSyncing: Bool = false var syncingHeaderView: SyncProgressHeaderView? - var shouldShowPrompt = true - private var transactions: [Transaction] = [] private var allTransactions: [Transaction] = [] { didSet { diff --git a/litewallet/UnstoppableDomainView.swift b/litewallet/UnstoppableDomainView.swift index cf5491f9f..80623f36c 100644 --- a/litewallet/UnstoppableDomainView.swift +++ b/litewallet/UnstoppableDomainView.swift @@ -7,18 +7,9 @@ struct UnstoppableDomainView: View { @ObservedObject var viewModel: UnstoppableDomainViewModel - @State - private var didReceiveLTCfromUD: Bool = false - - @State - private var shouldDisableLookupButton: Bool = true - @State private var didStartEditing: Bool = false - @State - private var shouldStartScroll: Bool = false - init(viewModel: UnstoppableDomainViewModel) { self.viewModel = viewModel } diff --git a/litewallet/UnstoppableDomainViewModel.swift b/litewallet/UnstoppableDomainViewModel.swift index e41f4c341..b9389234f 100644 --- a/litewallet/UnstoppableDomainViewModel.swift +++ b/litewallet/UnstoppableDomainViewModel.swift @@ -55,20 +55,6 @@ class UnstoppableDomainViewModel: ObservableObject { } } - func resolveDomain() { - isDomainResolving = true - - // Added timing peroformance probes to see what the average time is - let timestamp: String = dateFormatter?.string(from: Date()) ?? "" - - LWAnalytics.logEventWithParameters(itemName: - CustomEvent._20201121_SIL, - properties: - ["start_time": timestamp]) - - resolveUDAddress(domainName: searchString) - } - private func resolveUDAddress(domainName: String) { // This group is created to allow the threads to complete. // Otherwise, we may never get in the callback relative to UDR v4.0.0 diff --git a/litewallet/ViewControllers/Import/StartImportViewController.swift b/litewallet/ViewControllers/Import/StartImportViewController.swift index b9eb28a37..8ff5f5d9e 100644 --- a/litewallet/ViewControllers/Import/StartImportViewController.swift +++ b/litewallet/ViewControllers/Import/StartImportViewController.swift @@ -1,9 +1,7 @@ import BRCore import UIKit -private let mainURL = "https://insight.litecore.io/api/addrs/utxo" -private let fallbackURL = "https://insight.litecore.io/api/addrs/utxo" -private let testnetURL = "https://testnet.litecore.io/api/addrs/utxo" +private let mainURL = "https://litecoinspace.org/graphs/mempool" class StartImportViewController: UIViewController { init(walletManager: WalletManager, store: Store) { @@ -158,7 +156,7 @@ class StartImportViewController: UIViewController { return } - let urlString = E.isTestnet ? testnetURL : mainURL + let urlString = mainURL let request = NSMutableURLRequest(url: URL(string: urlString)!, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 20.0) diff --git a/litewallet/Views/SearchHeaderView.swift b/litewallet/Views/SearchHeaderView.swift index f0eecd854..b96931b24 100644 --- a/litewallet/Views/SearchHeaderView.swift +++ b/litewallet/Views/SearchHeaderView.swift @@ -100,9 +100,6 @@ class SearchHeaderView: UIView { } } - private let sentFilter: TransactionFilter = { $0.direction == .sent } - private let receivedFilter: TransactionFilter = { $0.direction == .received } - override func layoutSubviews() { guard !hasSetup else { return } setup() diff --git a/litewallet/Views/ShadowButton.swift b/litewallet/Views/ShadowButton.swift index 8b3468e1d..8efce3176 100644 --- a/litewallet/Views/ShadowButton.swift +++ b/litewallet/Views/ShadowButton.swift @@ -50,7 +50,6 @@ class ShadowButton: UIControl { private let container = UIView() private let shadowView = UIView() private let label = UILabel() - private let shadowYOffset: CGFloat = 4.0 private let cornerRadius: CGFloat = 4.0 private var imageView: UIImageView?