From 594594da917fd1457d97f17c5c3cf253059d0fb4 Mon Sep 17 00:00:00 2001 From: James Sangalli Date: Tue, 14 May 2019 11:15:02 +1000 Subject: [PATCH] cleaned up some compiler warnings --- .../DirectoryContentsWatcher.swift | 2 +- .../Coordinators/DappBrowserCoordinator.swift | 1 - .../DiscoverDappsViewController.swift | 2 +- .../MyDappsViewController.swift | 4 +-- .../Views/DappBrowserNavigationBar.swift | 4 +-- AlphaWallet/Browser/Views/MyDappCell.swift | 1 - .../Initializers/MigrationInitializer.swift | 4 +-- AlphaWallet/EtherClient/Wallet.swift | 2 +- AlphaWallet/Extensions/Date.swift | 12 ++++----- AlphaWallet/InCoordinator.swift | 2 +- .../UniversalLinkCoordinator.swift | 27 +++++++++---------- .../Coordinators/ClaimOrderCoordinator.swift | 2 +- .../GetERC721BalanceCoordinator.swift | 2 +- .../Tokens/Types/TokensDataStore.swift | 1 - AlphaWallet/UI/ButtonsBar.swift | 2 +- AlphaWallet/UI/FloatLabelTextField.swift | 2 +- 16 files changed, 33 insertions(+), 37 deletions(-) diff --git a/AlphaWallet/AssetDefinition/DirectoryContentsWatcher.swift b/AlphaWallet/AssetDefinition/DirectoryContentsWatcher.swift index 340e8c248..7ff468bb6 100644 --- a/AlphaWallet/AssetDefinition/DirectoryContentsWatcher.swift +++ b/AlphaWallet/AssetDefinition/DirectoryContentsWatcher.swift @@ -56,7 +56,7 @@ public protocol DirectoryContentsWatcherProtocol { public extension DirectoryContentsWatcher { // We don't necessary need the structure of a Local class within an enum as the "namespace", but just keeping it to be similar to the original codebase' structure - public final class Local: DirectoryContentsWatcherProtocol { + final class Local: DirectoryContentsWatcherProtocol { private typealias CancelBlock = () -> Void private enum State { diff --git a/AlphaWallet/Browser/Coordinators/DappBrowserCoordinator.swift b/AlphaWallet/Browser/Coordinators/DappBrowserCoordinator.swift index 38b6ba446..7ddadc048 100644 --- a/AlphaWallet/Browser/Coordinators/DappBrowserCoordinator.swift +++ b/AlphaWallet/Browser/Coordinators/DappBrowserCoordinator.swift @@ -558,7 +558,6 @@ extension DappBrowserCoordinator: DiscoverDappsViewControllerDelegate { } } - extension DappBrowserCoordinator: MyDappsViewControllerDelegate { func didTapToEdit(dapp: Bookmark, inViewController viewController: MyDappsViewController) { let vc = EditMyDappViewController() diff --git a/AlphaWallet/Browser/ViewControllers/DiscoverDappsViewController.swift b/AlphaWallet/Browser/ViewControllers/DiscoverDappsViewController.swift index 3f381685c..b17ac0c20 100644 --- a/AlphaWallet/Browser/ViewControllers/DiscoverDappsViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/DiscoverDappsViewController.swift @@ -129,7 +129,7 @@ extension DiscoverDappsViewController: DiscoverDappCellDelegate { } } -fileprivate class SectionHeaderView: UIView { +private class SectionHeaderView: UIView { private let label = UILabel() var title: String { diff --git a/AlphaWallet/Browser/ViewControllers/MyDappsViewController.swift b/AlphaWallet/Browser/ViewControllers/MyDappsViewController.swift index 3aac243d9..408951335 100644 --- a/AlphaWallet/Browser/ViewControllers/MyDappsViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/MyDappsViewController.swift @@ -61,13 +61,13 @@ class MyDappsViewController: UIViewController { } @objc private func keyboardWillShow(notification: NSNotification) { - if let keyboardEndFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue, let keyboardBeginFrame = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { + if let keyboardEndFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue, let _ = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { tableView.contentInset.bottom = keyboardEndFrame.size.height } } @objc private func keyboardWillHide(notification: NSNotification) { - if let keyboardEndFrame = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue, let keyboardBeginFrame = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { + if let _ = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue, let _ = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { tableView.contentInset.bottom = 0 } } diff --git a/AlphaWallet/Browser/Views/DappBrowserNavigationBar.swift b/AlphaWallet/Browser/Views/DappBrowserNavigationBar.swift index 89b44c9f2..5f27459aa 100644 --- a/AlphaWallet/Browser/Views/DappBrowserNavigationBar.swift +++ b/AlphaWallet/Browser/Views/DappBrowserNavigationBar.swift @@ -12,13 +12,13 @@ protocol DappBrowserNavigationBarDelegate: class { func didTapClose(inNavigationBar navigationBar: DappBrowserNavigationBar) } -fileprivate enum State { +private enum State { case editingURLTextField case notEditingURLTextField case browserOnly } -fileprivate struct Layout { +private struct Layout { static let width: CGFloat = 34 static let moreButtonWidth: CGFloat = 24 } diff --git a/AlphaWallet/Browser/Views/MyDappCell.swift b/AlphaWallet/Browser/Views/MyDappCell.swift index bf2e9e4f2..90c4e68b7 100644 --- a/AlphaWallet/Browser/Views/MyDappCell.swift +++ b/AlphaWallet/Browser/Views/MyDappCell.swift @@ -3,7 +3,6 @@ import Foundation import UIKit - class MyDappCell: UITableViewCell { static let identifier = "MyDappCell" diff --git a/AlphaWallet/Core/Initializers/MigrationInitializer.swift b/AlphaWallet/Core/Initializers/MigrationInitializer.swift index 80b151f79..95adb123f 100644 --- a/AlphaWallet/Core/Initializers/MigrationInitializer.swift +++ b/AlphaWallet/Core/Initializers/MigrationInitializer.swift @@ -21,7 +21,7 @@ class MigrationInitializer: Initializer { if oldSchemaVersion < 2 { //Fix bug created during multi-chain implementation. Where TokenObject instances are created from transfer Transaction instances, with the primaryKey as a empty string; so instead of updating an existing TokenObject, a duplicate TokenObject instead was created but with primaryKey empty migration.enumerateObjects(ofType: TokenObject.className()) { oldObject, newObject in - guard let oldObject = oldObject else { return } + guard let _ = oldObject else { return } guard let newObject = newObject else { return } if let primaryKey = newObject["primaryKey"] as? String, primaryKey.isEmpty { migration.delete(newObject) @@ -33,7 +33,7 @@ class MigrationInitializer: Initializer { config.migrationBlock = { migration, oldSchemaVersion in if oldSchemaVersion < 3 { migration.enumerateObjects(ofType: Transaction.className()) { oldObject, newObject in - guard let oldObject = oldObject else { return } + guard let _ = oldObject else { return } guard let newObject = newObject else { return } newObject["isERC20Interaction"] = false } diff --git a/AlphaWallet/EtherClient/Wallet.swift b/AlphaWallet/EtherClient/Wallet.swift index 6871f9285..5bcd35483 100644 --- a/AlphaWallet/EtherClient/Wallet.swift +++ b/AlphaWallet/EtherClient/Wallet.swift @@ -8,7 +8,7 @@ enum WalletType: Equatable { case watch(Address) } -struct Wallet: Equatable { +struct Wallet: Equatable { let type: WalletType var address: Address { diff --git a/AlphaWallet/Extensions/Date.swift b/AlphaWallet/Extensions/Date.swift index b2261ce1d..e52e310ea 100644 --- a/AlphaWallet/Extensions/Date.swift +++ b/AlphaWallet/Extensions/Date.swift @@ -13,7 +13,7 @@ public extension Date { private static var formatsMap: [String: DateFormatter] = [:] private static var formatsMapLocale: String? - public init?(string: String, format: String) { + init?(string: String, format: String) { let date = Date.formatter(with: format).date(from: string) if date != nil { self = date! @@ -22,11 +22,11 @@ public extension Date { return nil } - public func format(_ format: String, withTimeZone timezone: TimeZone? = nil) -> String { + func format(_ format: String, withTimeZone timezone: TimeZone? = nil) -> String { return Date.formatter(with: format, withTimeZone: timezone).string(from: self) } - public static func formatter(with format: String, withTimeZone timeZone: TimeZone? = nil) -> DateFormatter { + static func formatter(with format: String, withTimeZone timeZone: TimeZone? = nil) -> DateFormatter { if Config.getLocale() != formatsMapLocale { formatsMapLocale = Config.getLocale() formatsMap = Dictionary() @@ -49,15 +49,15 @@ public extension Date { return foundFormatter! } - public static var yesterday: Date { + static var yesterday: Date { return Calendar.current.date(byAdding: .day, value: -1, to: Date())! } - public static var tomorrow: Date { + static var tomorrow: Date { return Calendar.current.date(byAdding: .day, value: 1, to: Date())! } - public func formatAsShortDateString(withTimezone timezone: TimeZone? = nil) -> String { + func formatAsShortDateString(withTimezone timezone: TimeZone? = nil) -> String { return format("dd MMM yyyy", withTimeZone: timezone) } } diff --git a/AlphaWallet/InCoordinator.swift b/AlphaWallet/InCoordinator.swift index 3ae1c534f..8b788b971 100644 --- a/AlphaWallet/InCoordinator.swift +++ b/AlphaWallet/InCoordinator.swift @@ -687,7 +687,7 @@ extension InCoordinator: PromptBackupCoordinatorDelegate { } } -extension InCoordinator: DappBrowserCoordinatorDelegate{ +extension InCoordinator: DappBrowserCoordinatorDelegate { func didSentTransaction(transaction: SentTransaction, inCoordinator coordinator: DappBrowserCoordinator) { handlePendingTransaction(transaction: transaction) } diff --git a/AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift b/AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift index 5f53bd226..dce0dbbe7 100644 --- a/AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift +++ b/AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift @@ -166,24 +166,23 @@ class UniversalLinkCoordinator: Coordinator { let parameters: Parameters let query: String switch signedOrder.order.nativeCurrencyDrop { - case true: - parameters = createHTTPParametersForCurrencyLinksToPaymentServer( - signedOrder: signedOrder, - recipient: recipient - ) - query = Constants.currencyDropServer - case false: - parameters = createHTTPParametersForNormalLinksToPaymentServer( - signedOrder: signedOrder, - isForTransfer: true - ) - query = Constants.paymentServer + case true: + parameters = createHTTPParametersForCurrencyLinksToPaymentServer( + signedOrder: signedOrder, + recipient: recipient + ) + query = Constants.currencyDropServer + case false: + parameters = createHTTPParametersForNormalLinksToPaymentServer( + signedOrder: signedOrder, + isForTransfer: true + ) + query = Constants.paymentServer } return (parameters, query) } - func completeOrderHandling(signedOrder: SignedOrder) - { + func completeOrderHandling(signedOrder: SignedOrder) { let requiresPaymaster = requiresPaymasterForCurrencyLinks(signedOrder: signedOrder) if signedOrder.order.price == 0 { self.checkPaymentServerSupportsContract(contractAddress: signedOrder.order.contractAddress) { supported in diff --git a/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift b/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift index 998f19e7c..4d24a0f37 100644 --- a/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift @@ -78,7 +78,7 @@ class ClaimOrderCoordinator { completion: @escaping (Result) -> Void) { do { - let parameters: [Any] = [expiry, tokenIds, BigUInt(v), Data(hex: r), Data(hex: s), Address(string: recipient)] + let parameters: [Any] = [expiry, tokenIds, BigUInt(v), Data(hex: r), Data(hex: s), Address(string: recipient) as Any] let functionEncoder = Function(name: "spawnPassTo", parameters: [ .uint(bits: 256), .dynamicArray(.uint(bits: 256)), diff --git a/AlphaWallet/Tokens/Coordinators/GetERC721BalanceCoordinator.swift b/AlphaWallet/Tokens/Coordinators/GetERC721BalanceCoordinator.swift index 238ca4ad6..a84cbddd2 100644 --- a/AlphaWallet/Tokens/Coordinators/GetERC721BalanceCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/GetERC721BalanceCoordinator.swift @@ -22,7 +22,7 @@ class GetERC721BalanceCoordinator { ) { let function = GetERC721Balance() callSmartContract(withServer: server, contract: contract, functionName: function.name, abiString: function.abi, parameters: [address.eip55String] as [AnyObject]).done { balanceResult in - let balance = self.adapt(balanceResult["0"]) + let balance = self.adapt(balanceResult["0"] as Any) completion(.success(balance)) }.catch { error in completion(.failure(AnyError(Web3Error(description: "Error extracting result from \(contract.eip55String).\(function.name)(): \(error)")))) diff --git a/AlphaWallet/Tokens/Types/TokensDataStore.swift b/AlphaWallet/Tokens/Types/TokensDataStore.swift index 8569ccc9d..2b236a51d 100644 --- a/AlphaWallet/Tokens/Types/TokensDataStore.swift +++ b/AlphaWallet/Tokens/Types/TokensDataStore.swift @@ -260,7 +260,6 @@ class TokensDataStore { } } - func getERC875Balance(for addressString: String, completion: @escaping (ResultResult<[String], AnyError>.t) -> Void) { let address = Address(string: addressString) diff --git a/AlphaWallet/UI/ButtonsBar.swift b/AlphaWallet/UI/ButtonsBar.swift index e95635e30..cd7ed1d62 100644 --- a/AlphaWallet/UI/ButtonsBar.swift +++ b/AlphaWallet/UI/ButtonsBar.swift @@ -54,7 +54,7 @@ class ButtonsBar: UIView { } } -fileprivate struct ButtonsBarViewModel { +private struct ButtonsBarViewModel { var buttonBackgroundColor: UIColor { return Colors.appActionButtonGreen } diff --git a/AlphaWallet/UI/FloatLabelTextField.swift b/AlphaWallet/UI/FloatLabelTextField.swift index 5d16e8550..406138c1c 100644 --- a/AlphaWallet/UI/FloatLabelTextField.swift +++ b/AlphaWallet/UI/FloatLabelTextField.swift @@ -18,7 +18,7 @@ import Eureka } } set { - accessibilityLabel = newValue + self.accessibilityLabel = newValue } }