Fix: SwiftLint warnings

pull/1923/head
Hwee-Boon Yar 4 years ago
parent b0be01fc84
commit f3ef6466b8
  1. 2
      AlphaWallet/Browser/ViewControllers/BrowserViewController.swift
  2. 5
      AlphaWallet/EtherClient/CoinMarket/Types/CoinTicker.swift
  3. 2
      AlphaWallet/InCoordinator.swift
  4. 2
      AlphaWallet/Market/OrderHandler.swift
  5. 32
      AlphaWallet/Settings/ViewControllers/SupportViewController.swift
  6. 2
      AlphaWallet/TokenScriptClient/Models/EventOrigin.swift
  7. 8
      AlphaWallet/TokenScriptClient/Models/EventsDataStore.swift
  8. 2
      AlphaWallet/TokenScriptClient/Models/FunctionOrigin.swift
  9. 9
      AlphaWallet/TokenScriptClient/Models/TokenScriptFilterParser.swift
  10. 2
      AlphaWallet/TokenScriptClient/Models/XMLHandler+XPaths.swift
  11. 4
      AlphaWallet/Tokens/Coordinators/AddHideTokensCoordinator.swift
  12. 3
      AlphaWallet/Tokens/Coordinators/SingleChainTokenCoordinator.swift
  13. 2
      AlphaWallet/Tokens/Models/WalletFilter.swift
  14. 2
      AlphaWallet/Tokens/Types/TokenObject.swift
  15. 2
      AlphaWallet/Tokens/Types/TokensDataStore.swift
  16. 2
      AlphaWallet/Tokens/ViewControllers/AddHideTokensViewController.swift
  17. 4
      AlphaWallet/Tokens/ViewControllers/StaticHTMLViewController.swift
  18. 6
      AlphaWallet/Tokens/ViewControllers/TokenInstanceViewController.swift
  19. 10
      AlphaWallet/Tokens/ViewControllers/TokenViewController.swift
  20. 4
      AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift
  21. 2
      AlphaWallet/Tokens/ViewModels/TokenViewControllerViewModel.swift
  22. 4
      AlphaWallet/Tokens/Views/TokenInstanceWebView.swift
  23. 4
      AlphaWallet/Transfer/ViewControllers/SendViewController.swift
  24. 2
      AlphaWallet/UI/Views/AmountTextField.swift
  25. 1
      AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift
  26. 9
      AlphaWalletTests/TokenScriptClient/FakeEventsDataStore.swift
  27. 3
      AlphaWalletTests/TokenScriptClient/XMLHandlerTest.swift

@ -217,7 +217,7 @@ extension BrowserViewController: WKNavigationDelegate {
handleError(error: error)
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ()) {
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
guard let url = navigationAction.request.url, let scheme = url.scheme else {
return decisionHandler(.allow)
}

@ -4,11 +4,10 @@ import Foundation
import RealmSwift
struct CoinTicker: Codable {
private enum CodingKeys : String, CodingKey {
private enum CodingKeys: String, CodingKey {
case price_usd = "current_price", percent_change_24h = "market_cap_change_percentage_24h", id = "id", symbol = "symbol", image = "image"
}
private let id: String
private let symbol: String
private let image: String = ""

@ -582,7 +582,7 @@ class InCoordinator: NSObject, Coordinator {
print(error)
}
}
}
}.cauterize()
case .failure: break
}
}

@ -143,7 +143,7 @@ public class OrderHandler {
public static func uInt16ArrayToUInt8(arrayOfUInt16: [UInt16]) -> [UInt8] {
var arrayOfUint8 = [UInt8]()
for i in 0..<arrayOfUInt16.count {
var UInt8ArrayPair = arrayOfUInt16[i].bigEndian.data.array
let UInt8ArrayPair = arrayOfUInt16[i].bigEndian.data.array
arrayOfUint8.append(UInt8ArrayPair[0])
arrayOfUint8.append(UInt8ArrayPair[1])
}

@ -21,22 +21,22 @@ class SupportViewController: UIViewController {
tableView.register(SettingTableViewCell.self, forCellReuseIdentifier: SettingTableViewCell.reuseIdentifier)
tableView.separatorStyle = .singleLine
tableView.backgroundColor = GroupedTable.Color.background
return tableView
}()
weak var delegate: SupportViewControllerDelegate?
override func loadView() {
view = tableView
}
init() {
super.init(nibName: nil, bundle: nil)
tableView.dataSource = self
tableView.delegate = self
}
override func viewDidLoad() {
super.viewDidLoad()
@ -52,7 +52,7 @@ class SupportViewController: UIViewController {
}
extension SupportViewController: UITableViewDataSource {
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
@ -64,17 +64,17 @@ extension SupportViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: SettingTableViewCell.reuseIdentifier, for: indexPath) as! SettingTableViewCell
cell.configure(viewModel: viewModel.cellViewModel(indexPath: indexPath))
return cell
}
}
extension SupportViewController: HelpViewControllerDelegate {
}
extension SupportViewController: CanOpenURL {
func didPressViewContractWebPage(forContract contract: AlphaWallet.Address, server: RPCServer, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, server: server, in: viewController)
}
@ -89,7 +89,7 @@ extension SupportViewController: CanOpenURL {
}
extension SupportViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
@ -100,22 +100,22 @@ extension SupportViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch viewModel.rows[indexPath.row] {
case .faq:
let viewController = HelpViewController(delegate: self)
viewController.navigationItem.largeTitleDisplayMode = .never
viewController.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(viewController, animated: true)
case .telegram:
openURL(.telegram)
@ -125,11 +125,11 @@ extension SupportViewController: UITableViewDelegate {
openURL(.reddit)
case .facebook:
openURL(.facebook)
case .blog:
case .blog:
break
}
}
private func openURL(_ provider: URLServiceProvider) {
if let localURL = provider.localURL, UIApplication.shared.canOpenURL(localURL) {
UIApplication.shared.open(localURL, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: .none)
@ -142,6 +142,6 @@ extension SupportViewController: UITableViewDelegate {
// Helper function inserted by Swift 4.2 migrator.
private func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues:
input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)}
input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value) }
)
}

@ -59,7 +59,7 @@ struct EventOrigin {
"type": "event",
"name": eventName,
"anonymous": false,
"inputs": inputs
"inputs": inputs
]
let contents = result.jsonString ?? ""
return "[\(contents)]"

@ -6,8 +6,8 @@ import RealmSwift
protocol EventsDataStoreProtocol {
func add(events: [EventInstance], forTokenContract contract: AlphaWallet.Address)
func deleteEvents(forTokenContract contract: AlphaWallet.Address)
func getMatchingEvents(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String, filterName: String, filterValue: String) -> Array<EventInstance>
func getMatchingEventsSortedByBlockNumber(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String) -> Array<EventInstance>
func getMatchingEvents(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String, filterName: String, filterValue: String) -> [EventInstance]
func getMatchingEventsSortedByBlockNumber(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String) -> [EventInstance]
func subscribe(_ subscribe: @escaping (_ contract: AlphaWallet.Address) -> Void)
}
@ -27,7 +27,7 @@ class EventsDataStore: EventsDataStoreProtocol {
subscribers.forEach { $0(contract) }
}
func getMatchingEvents(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String, filterName: String, filterValue: String) -> Array<EventInstance> {
func getMatchingEvents(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String, filterName: String, filterValue: String) -> [EventInstance] {
Array(realm.objects(EventInstance.self)
.filter("contract = '\(contract.eip55String)'")
.filter("tokenContract = '\(tokenContract.eip55String)'")
@ -37,7 +37,7 @@ class EventsDataStore: EventsDataStoreProtocol {
.filter("filter = '\(filterName)=\(filterValue)'"))
}
func getMatchingEventsSortedByBlockNumber(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String) -> Array<EventInstance> {
func getMatchingEventsSortedByBlockNumber(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String) -> [EventInstance] {
Array(realm.objects(EventInstance.self)
.filter("contract = '\(contract.eip55String)'")
.filter("tokenContract = '\(tokenContract.eip55String)'")

@ -209,7 +209,7 @@ struct FunctionOrigin {
seal.reject(FunctionError.postTransaction)
}
}
}
}.cauterize()
}
}

@ -3,6 +3,7 @@
import Foundation
import BigInt
// swiftlint:disable type_body_length
struct TokenScriptFilterParser {
enum Operator: String {
case equal = "="
@ -11,6 +12,7 @@ struct TokenScriptFilterParser {
case lessThanOrEqual = "<="
case greaterThanOrEqual = ">="
// swiftlint:disable function_body_length
func isTrueFor(attributeValue: AssetInternalValue, value: String) -> Bool {
switch attributeValue {
case .address(let address):
@ -131,6 +133,7 @@ struct TokenScriptFilterParser {
return false
}
}
// swiftlint:enable function_body_length
}
struct Lexer {
@ -334,7 +337,6 @@ struct TokenScriptFilterParser {
private var tokens: [Lexer.Token]
static func valuesWithImplicitValues(_ values: [AttributeId: AssetAttributeSyntaxValue], ownerAddress: AlphaWallet.Address, symbol: String, fungibleBalance: BigInt?) -> [AttributeId: AssetAttributeSyntaxValue] {
var values = values
let todayString = GeneralisedTime().formatAsGeneralisedTime.substring(to: 8)
var implicitValues: [AttributeId: AssetAttributeSyntaxValue] = [
"symbol": .init(syntax: .directoryString, value: .string(symbol)),
@ -454,7 +456,7 @@ struct TokenScriptFilterParser {
guard let op = tokens.removeFirst().binaryOperatorValue.flatMap({ Operator(rawValue: $0) }) else { return false }
guard let value = tokens.removeFirst().valueValue else { return false }
guard let interpolatedValue = interpolate(value: value) else { return nil }
return op.isTrueFor(attributeValue: attributeValue, value:interpolatedValue)
return op.isTrueFor(attributeValue: attributeValue, value: interpolatedValue)
}
//TODO replace the very dumb regex for now. And also recursively interpolates (not good). Should involve parser
@ -502,10 +504,11 @@ struct TokenScriptFilterParser {
func parse(withValues values: [AttributeId: AssetAttributeSyntaxValue], ownerAddress: AlphaWallet.Address, symbol: String, fungibleBalance: BigInt?) -> Bool {
let tokens = Lexer().tokenize(expression: expression)
var values = Parser.valuesWithImplicitValues(values, ownerAddress: ownerAddress, symbol: symbol, fungibleBalance: fungibleBalance)
let values = Parser.valuesWithImplicitValues(values, ownerAddress: ownerAddress, symbol: symbol, fungibleBalance: fungibleBalance)
return Parser(tokens: tokens, values: values).parse()
}
}
// swiftlint:enable type_body_length
fileprivate extension String {
subscript(i: Int) -> String {

@ -104,7 +104,7 @@ extension XMLHandler {
static func getEventDefinition(contractElement: XMLElement, asnModuleElement: XMLElement, xmlContext: XmlContext) -> EventDefinition? {
let addressElements = XMLHandler.getAddressElements(fromContractElement: contractElement, xmlContext: xmlContext)
guard let address = addressElements.first?.text.flatMap({ AlphaWallet.Address(string: $0.trimmed)}) else { return nil }
guard let address = addressElements.first?.text.flatMap({ AlphaWallet.Address(string: $0.trimmed) }) else { return nil }
guard let eventName = asnModuleElement.at_xpath("namedType", namespaces: xmlContext.namespaces)?["name"] else { return nil }
let parameters = asnModuleElement.xpath("namedType/sequence/element", namespaces: xmlContext.namespaces).compactMap { each -> EventParameter? in
guard let name = each["name"], let type = each["type"] else { return nil }

@ -28,7 +28,7 @@ class AddHideTokensCoordinator: Coordinator {
private let tokenCollection: TokenCollection
private let sessions: ServerDictionary<WalletSession>
private let tickers: [RPCServer : [AlphaWallet.Address : CoinTicker]]
private let tickers: [RPCServer: [AlphaWallet.Address: CoinTicker]]
private let filterTokensCoordinator: FilterTokensCoordinator
private let tokens: [TokenObject]
private let assetDefinitionStore: AssetDefinitionStore
@ -50,7 +50,7 @@ class AddHideTokensCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: AddHideTokensCoordinatorDelegate?
init(tokens: [TokenObject], assetDefinitionStore: AssetDefinitionStore, filterTokensCoordinator: FilterTokensCoordinator, tickers: [RPCServer : [AlphaWallet.Address : CoinTicker]], sessions: ServerDictionary<WalletSession>, navigationController: UINavigationController, tokenCollection: TokenCollection, config: Config, singleChainTokenCoordinators: [SingleChainTokenCoordinator]) {
init(tokens: [TokenObject], assetDefinitionStore: AssetDefinitionStore, filterTokensCoordinator: FilterTokensCoordinator, tickers: [RPCServer: [AlphaWallet.Address: CoinTicker]], sessions: ServerDictionary<WalletSession>, navigationController: UINavigationController, tokenCollection: TokenCollection, config: Config, singleChainTokenCoordinators: [SingleChainTokenCoordinator]) {
self.config = config
self.filterTokensCoordinator = filterTokensCoordinator
self.tickers = tickers

@ -24,6 +24,7 @@ protocol SingleChainTokenCoordinatorDelegate: class, CanOpenURL {
func didTap(transaction: Transaction, inViewController viewController: UIViewController, in coordinator: SingleChainTokenCoordinator)
}
// swiftlint:disable type_body_length
class SingleChainTokenCoordinator: Coordinator {
private let keystore: Keystore
private let storage: TokensDataStore
@ -509,8 +510,8 @@ class SingleChainTokenCoordinator: Coordinator {
vc.navigationItem.largeTitleDisplayMode = .never
viewController.navigationController?.pushViewController(vc, animated: true)
}
}
// swiftlint:enable type_body_length
extension SingleChainTokenCoordinator: TokensCardCoordinatorDelegate {
func didCancel(in coordinator: TokensCardCoordinator) {

@ -22,7 +22,7 @@ func == (lhs: WalletFilter, rhs: WalletFilter) -> Bool {
return true
case (.keyword(let keyword1), .keyword(let keyword2)):
return keyword1 == keyword2
case (.keyword, .all), (.keyword, .currencyOnly), (.keyword, .assetsOnly), (.keyword, .collectiblesOnly), (.collectiblesOnly, .all), (.collectiblesOnly, .currencyOnly), (.collectiblesOnly, .assetsOnly), (.collectiblesOnly, .keyword), (.assetsOnly, .all), (.assetsOnly, .currencyOnly), (.assetsOnly, .collectiblesOnly), (.assetsOnly, .keyword), (.currencyOnly, .all), (.currencyOnly, .assetsOnly), (.currencyOnly, .collectiblesOnly), (.currencyOnly, .keyword), (.all, .currencyOnly), (.all, .assetsOnly):
case (.keyword, .all), (.keyword, .currencyOnly), (.keyword, .assetsOnly), (.keyword, .collectiblesOnly), (.collectiblesOnly, .all), (.collectiblesOnly, .currencyOnly), (.collectiblesOnly, .assetsOnly), (.collectiblesOnly, .keyword), (.assetsOnly, .all), (.assetsOnly, .currencyOnly), (.assetsOnly, .collectiblesOnly), (.assetsOnly, .keyword), (.currencyOnly, .all), (.currencyOnly, .assetsOnly), (.currencyOnly, .collectiblesOnly), (.currencyOnly, .keyword), (.all, .currencyOnly), (.all, .assetsOnly):
return false
case (.all, .collectiblesOnly):
return false

@ -60,7 +60,7 @@ class TokenObject: Object {
var contractAddress: AlphaWallet.Address {
get {
return AlphaWallet.Address(uncheckedAgainstNullAddress: contract)!
AlphaWallet.Address(uncheckedAgainstNullAddress: contract)!
}
set {
contract = contractAddress.eip55String

@ -743,7 +743,7 @@ class TokensDataStore {
let tokenIdInt = BigUInt(tokenId.drop0x, radix: 16)
guard let balance = token.balance.first(where: { BigUInt($0.balance.drop0x, radix: 16) == tokenIdInt }) else { return nil }
let json = balance.json
if let data = json.data(using: .utf8), var dictionary = ((try? JSONSerialization.jsonObject(with: data)) as? [String: Any]) {
if let data = json.data(using: .utf8), let dictionary = ((try? JSONSerialization.jsonObject(with: data)) as? [String: Any]) {
return dictionary[attributeId]
} else {
return nil

@ -242,7 +242,7 @@ extension AddHideTokensViewController: UITableViewDataSource {
let title = R.string.localizable.walletsHideTokenTitle()
let hideAction = UIContextualAction(style: .destructive, title: title) { [weak self] _, _, completionHandler in
guard let strongSelf = self else { return }
if let result = strongSelf.viewModel.deleteToken(indexPath: indexPath){
if let result = strongSelf.viewModel.deleteToken(indexPath: indexPath) {
strongSelf.delegate?.didMark(token: result.token, in: strongSelf, isHidden: true)
tableView.performBatchUpdates({
tableView.deleteRows(at: [indexPath], with: .automatic)

@ -64,8 +64,8 @@ class StaticHTMLViewController: UIViewController {
}
extension StaticHTMLViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ()) {
guard let url = navigationAction.request.url, let scheme = url.scheme else {
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
guard let url = navigationAction.request.url, url.scheme != nil else {
return decisionHandler(.allow)
}

@ -22,7 +22,7 @@ class TokenInstanceViewController: UIViewController, TokenVerifiableStatusViewCo
private lazy var tokenRowView: TokenCardRowViewProtocol & UIView = createTokenRowView()
private let separators = (bar: UIView(), line: UIView())
private let buttonsBar = ButtonsBar(configuration: .combined(buttons: 3))
var tokenHolder: TokenHolder {
return viewModel.tokenHolder
}
@ -134,7 +134,7 @@ class TokenInstanceViewController: UIViewController, TokenVerifiableStatusViewCo
if selection.denial == nil {
button.displayButton = false
}
}
}
case .watch:
button.isEnabled = false
}
@ -174,7 +174,7 @@ class TokenInstanceViewController: UIViewController, TokenVerifiableStatusViewCo
case .tokenScript:
if let selection = action.activeExcludingSelection(selectedTokenHolders: [tokenHolder], forWalletAddress: account.address) {
if let denialMessage = selection.denial {
let alertController = UIAlertController.alert(
UIAlertController.alert(
title: nil,
message: denialMessage,
alertButtonTitles: [R.string.localizable.oK()],

@ -121,7 +121,7 @@ class TokenViewController: UIViewController {
let actions = viewModel.actions
buttonsBar.configure(.combined(buttons: viewModel.actions.count))
buttonsBar.viewController = self
for (action, button) in zip(actions, buttonsBar.buttons) {
button.setTitle(action.name, for: .normal)
button.addTarget(self, action: #selector(actionButtonTapped), for: .touchUpInside)
@ -131,7 +131,7 @@ class TokenViewController: UIViewController {
if selection.denial == nil {
button.displayButton = false
}
}
}
case .watch:
button.isEnabled = false
}
@ -196,7 +196,7 @@ class TokenViewController: UIViewController {
case .tokenScript:
if let tokenHolder = generateTokenHolder(), let selection = action.activeExcludingSelection(selectedTokenHolders: [tokenHolder], forWalletAddress: session.account.address, fungibleBalance: viewModel.fungibleBalance) {
if let denialMessage = selection.denial {
let alertController = UIAlertController.alert(
UIAlertController.alert(
title: nil,
message: denialMessage,
alertButtonTitles: [R.string.localizable.oK()],
@ -221,7 +221,7 @@ class TokenViewController: UIViewController {
//TODO id 1 for fungibles. Might come back to bite us?
let hardcodedTokenIdForFungibles = BigUInt(1)
guard let tokenObject = viewModel?.token else {return nil }
guard let tokenObject = viewModel?.token else { return nil }
let xmlHandler = XMLHandler(contract: tokenObject.contractAddress, assetDefinitionStore: assetDefinitionStore)
//TODO Event support, if/when designed for fungibles
let values = xmlHandler.resolveAttributesBypassingCache(withTokenIdOrEvent: .tokenId(tokenId: hardcodedTokenIdForFungibles), server: self.session.server, account: self.session.account)
@ -232,7 +232,7 @@ class TokenViewController: UIViewController {
} else {
for each in subscribablesForAttributeValues {
guard let subscribable = each.subscribableValue else { continue }
let subscriptionKey = subscribable.subscribe { [weak self] value in
subscribable.subscribe { [weak self] value in
guard let strongSelf = self else { return }
guard let viewModel = strongSelf.viewModel else { return }
strongSelf.configure(viewModel: viewModel)

@ -164,7 +164,7 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
if selection.denial == nil {
button.displayButton = false
}
}
}
case .watch:
button.isEnabled = false
}
@ -238,7 +238,7 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
case .tokenScript:
if let selection = action.activeExcludingSelection(selectedTokenHolders: [tokenHolder], forWalletAddress: account.address) {
if let denialMessage = selection.denial {
let alertController = UIAlertController.alert(
UIAlertController.alert(
title: nil,
message: denialMessage,
alertButtonTitles: [R.string.localizable.oK()],

@ -81,7 +81,7 @@ struct TokenViewControllerViewModel {
var fungibleBalance: BigInt? {
switch transferType {
case .nativeCryptocurrency(_, _, amount: let amount):
case .nativeCryptocurrency:
let string: String? = session.balanceViewModel.value?.amountShort
return string.flatMap { EtherNumberFormatter.full.number(from: $0, decimals: session.server.decimals) }
case .ERC20Token(let tokenObject, _, _):

@ -24,7 +24,7 @@ class TokenInstanceWebView: UIView {
static func fromMessage(_ message: WKScriptMessage) -> SetProperties? {
guard message.name == SetProperties.setActionProps else { return nil }
guard var body = message.body as? [String: AnyObject] else { return nil }
guard let body = message.body as? [String: AnyObject] else { return nil }
guard let changedProperties = body["object"] as? SetProperties.Properties else { return nil }
guard let id = body["id"] as? Int else { return nil }
return .action(id: id, changedProperties: changedProperties)
@ -364,7 +364,7 @@ extension TokenInstanceWebView: WKScriptMessageHandler {
}
}
private func handleSetActionProperties(id: Int, changedProperties: SetProperties.Properties) {
private func handleSetActionProperties(id: Int, changedProperties: SetProperties.Properties) {
guard !changedProperties.isEmpty else { return }
let oldProperties = actionProperties

@ -19,6 +19,7 @@ protocol SendViewControllerDelegate: class, CanOpenURL {
func openQRCode(in controller: SendViewController)
}
// swiftlint:disable type_body_length
class SendViewController: UIViewController, CanScanQRCode {
private let roundedBackground = RoundedBackground()
private let scrollView = UIScrollView()
@ -60,6 +61,7 @@ class SendViewController: UIViewController, CanScanQRCode {
let storage: TokensDataStore
// swiftlint:disable function_body_length
init(
session: WalletSession,
storage: TokensDataStore,
@ -187,6 +189,7 @@ class SendViewController: UIViewController, CanScanQRCode {
storage.updatePrices()
getGasPrice()
}
// swiftlint:enable function_body_length
override func viewDidLoad() {
super.viewDidLoad()
@ -439,6 +442,7 @@ class SendViewController: UIViewController, CanScanQRCode {
configure(viewModel: .init(transferType: transferType, session: session, storage: storage), shouldConfigureBalance: shouldConfigureBalance)
}
}
// swiftlint:enable type_body_length
extension SendViewController: AmountTextFieldDelegate {

@ -24,7 +24,7 @@ class AmountTextField: UIControl {
}
}
enum ErrorState : Error {
enum ErrorState: Error {
case error
case none

@ -619,6 +619,7 @@ class ImportWalletViewController: UIViewController, CanScanQRCode {
}
}
// swiftlint:enable type_body_length
extension ImportWalletViewController: UIDocumentPickerDelegate {
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
guard controller.documentPickerMode == UIDocumentPickerMode.import else { return }

@ -3,22 +3,21 @@
import Foundation
@testable import AlphaWallet
class FakeEventsDataStore: EventsDataStoreProtocol {
class FakeEventsDataStore: EventsDataStoreProtocol {
func add(events: [EventInstance], forTokenContract contract: AlphaWallet.Address) {
}
func deleteEvents(forTokenContract contract: AlphaWallet.Address) {
}
func getMatchingEvents(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String, filterName: String, filterValue: String) -> Array<EventInstance> {
func getMatchingEvents(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String, filterName: String, filterValue: String) -> [EventInstance] {
.init()
}
func getMatchingEventsSortedByBlockNumber(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String) -> Array<EventInstance> {
func getMatchingEventsSortedByBlockNumber(forContract contract: AlphaWallet.Address, tokenContract: AlphaWallet.Address, server: RPCServer, eventName: String) -> [EventInstance] {
.init()
}
func subscribe(_ subscribe: @escaping (_ contract: AlphaWallet.Address) -> Void)
{
func subscribe(_ subscribe: @escaping (_ contract: AlphaWallet.Address) -> Void) {
}
}

@ -41,6 +41,7 @@ class XMLHandlerTest: XCTestCase {
// XCTAssertFalse(XMLHandler(contract: address2.eip55String, assetDefinitionStore: store).hasAssetDefinition)
// }
// swiftlint:disable function_body_length
func testExtractingAttributesWithNamespaceInXML() {
// swiftlint:disable line_length
let xml = """
@ -909,6 +910,7 @@ class XMLHandlerTest: XCTestCase {
let values = token.values
XCTAssertEqual(values["locality"]?.stringValue, "Saint Petersburg")
}
// swiftlint:enable function_body_length
func testNoAssetDefinition() {
let store = AssetDefinitionStore(backingStore: AssetDefinitionInMemoryBackingStore())
@ -926,3 +928,4 @@ class XMLHandlerTest: XCTestCase {
XCTAssertEqual("part1/part2/part3".addToXPath(namespacePrefix: "tb1:"), "tb1:part1/tb1:part2/tb1:part3")
}
}
// swiftlint:enable type_body_length

Loading…
Cancel
Save