Make private properties private, reorganize properties order

pull/787/head
Hwee-Boon Yar 6 years ago
parent 7681224891
commit 6f7c9ca9db
  1. 8
      AlphaWallet.xcodeproj/project.pbxproj
  2. 2
      AlphaWallet/AlphaWalletHelp/ViewControllers/HelpContentsViewController.swift
  3. 7
      AlphaWallet/AlphaWalletHelp/Views/ContactUsBannerView.swift
  4. 6
      AlphaWallet/AlphaWalletHelp/Views/HelpViewCell.swift
  5. 4
      AlphaWallet/AssetDefinition/Views/AssetDefinitionsOverridesViewCell.swift
  6. 9
      AlphaWallet/AssetDefinition/XMLHandler.swift
  7. 50
      AlphaWallet/Browser/Coordinators/BrowserCoordinator.swift
  8. 4
      AlphaWallet/Browser/Storage/HistoryStore.swift
  9. 4
      AlphaWallet/Browser/Types/BrowserURLParser.swift
  10. 9
      AlphaWallet/Browser/ViewControllers/BookmarkViewController.swift
  11. 31
      AlphaWallet/Browser/ViewControllers/BrowserViewController.swift
  12. 7
      AlphaWallet/Browser/ViewControllers/HistoryViewController.swift
  13. 7
      AlphaWallet/Browser/ViewControllers/MasterBrowserViewController.swift
  14. 2
      AlphaWallet/Browser/ViewModel/BookmarkViewModel.swift
  15. 2
      AlphaWallet/Browser/ViewModel/BookmarksViewModel.swift
  16. 2
      AlphaWallet/Browser/ViewModel/HistoriesViewModel.swift
  17. 2
      AlphaWallet/Browser/ViewModel/HistoryViewModel.swift
  18. 9
      AlphaWallet/Browser/Views/BrowserErrorView.swift
  19. 14
      AlphaWallet/Browser/Views/BrowserNavigationBar.swift
  20. 11
      AlphaWallet/Core/Coordinators/CheckDeviceCoordinator.swift
  21. 2
      AlphaWallet/Core/Helpers/ScriptMessageProxy.swift
  22. 4
      AlphaWallet/Core/Initializers/MigrationInitializer.swift
  23. 2
      AlphaWallet/Core/Initializers/SkipBackupFilesInitializer.swift
  24. 8
      AlphaWallet/Core/ViewModels/GasViewModel.swift
  25. 3
      AlphaWallet/Core/ViewModels/InCoordinatorViewModel.swift
  26. 4
      AlphaWallet/Deposit/Coordinators/DepositCoordinator.swift
  27. 9
      AlphaWallet/EtherClient/CoinMarket/Types/CoinTicker.swift
  28. 7
      AlphaWallet/EtherClient/EtherKeystore.swift
  29. 2
      AlphaWallet/EtherClient/TransactionSigning.swift
  30. 4
      AlphaWallet/Export/Coordinators/BackupCoordinator.swift
  31. 3
      AlphaWallet/Export/Coordinators/PromptBackupCoordinator.swift
  32. 4
      AlphaWallet/Export/ViewControllers/BackUpViewController.swift
  33. 2
      AlphaWallet/Export/ViewModels/BackupViewModel.swift
  34. 26
      AlphaWallet/Lock/Views/LockView.swift
  35. 8
      AlphaWallet/Lock/Views/PasscodeCharacterView.swift
  36. 4
      AlphaWallet/Market/MarketQueueHandler.swift
  37. 30
      AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift
  38. 13
      AlphaWallet/Market/ViewControllers/StatusViewController.swift
  39. 2
      AlphaWallet/Market/ViewModels/ImportMagicTokenCardRowViewModel.swift
  40. 8
      AlphaWallet/Market/ViewModels/StatusViewControllerViewModel.swift
  41. 2
      AlphaWallet/MarketPlace/ViewControllers/MarketplaceViewController.swift
  42. 12
      AlphaWallet/Protection/Coordinators/ProtectionCoordinator.swift
  43. 6
      AlphaWallet/Protection/Coordinators/SplashCoordinator.swift
  44. 1
      AlphaWallet/Protection/ViewControllers/SplashViewController.swift
  45. 1
      AlphaWallet/Protection/Views/SplashView.swift
  46. 1
      AlphaWallet/Redeem/Helpers/RedeemEventListener.swift
  47. 1
      AlphaWallet/Redeem/Helpers/SignatureHelper.swift
  48. 1
      AlphaWallet/Redeem/Rest/EventsRest.swift
  49. 16
      AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift
  50. 12
      AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift
  51. 16
      AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift
  52. 5
      AlphaWallet/Redeem/ViewModels/RedeemTokenCardQuantitySelectionViewModel.swift
  53. 5
      AlphaWallet/Redeem/ViewModels/RedeemTokenCardViewModel.swift
  54. 4
      AlphaWallet/Redeem/ViewModels/TokenCardRedemptionViewModel.swift
  55. 1
      AlphaWallet/Rest/RestClient.swift
  56. 48
      AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift
  57. 23
      AlphaWallet/Sell/ViewControllers/GenerateSellMagicLinkViewController.swift
  58. 10
      AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift
  59. 44
      AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift
  60. 5
      AlphaWallet/Sell/ViewModels/EnterSellTokensCardPriceQuantityViewControllerViewModel.swift
  61. 6
      AlphaWallet/Sell/ViewModels/GenerateSellMagicLinkViewControllerViewModel.swift
  62. 4
      AlphaWallet/Sell/ViewModels/GenerateTransferMagicLinkViewControllerViewModel.swift
  63. 5
      AlphaWallet/Sell/ViewModels/SellTokensCardViewModel.swift
  64. 6
      AlphaWallet/Sell/ViewModels/SetSellTokensCardExpiryDateViewControllerViewModel.swift
  65. 3
      AlphaWallet/Sell/Views/DateEntryField.swift
  66. 3
      AlphaWallet/Sell/Views/TimeEntryField.swift
  67. 11
      AlphaWallet/Settings/Coordinators/AddCustomNetworkCoordinator.swift
  68. 6
      AlphaWallet/Settings/Coordinators/HelpUsCoordinator.swift
  69. 3
      AlphaWallet/Settings/Coordinators/LocalesCoordinator.swift
  70. 3
      AlphaWallet/Settings/Coordinators/ServersCoordinator.swift
  71. 8
      AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift
  72. 1
      AlphaWallet/Settings/Types/Config.swift
  73. 3
      AlphaWallet/Settings/Types/ConfigExplorer.swift
  74. 7
      AlphaWallet/Settings/ViewControllers/AddCustomNetworkViewController.swift
  75. 11
      AlphaWallet/Settings/ViewControllers/LocalesViewController.swift
  76. 3
      AlphaWallet/Settings/ViewControllers/PreferencesController.swift
  77. 11
      AlphaWallet/Settings/ViewControllers/ServersViewController.swift
  78. 12
      AlphaWallet/Settings/ViewControllers/SettingsViewController.swift
  79. 1
      AlphaWallet/Settings/ViewControllers/WellDoneViewController.swift
  80. 1
      AlphaWallet/Settings/ViewModels/AddCustomNetworkViewModel.swift
  81. 1
      AlphaWallet/Settings/ViewModels/HelpUsViewModel.swift
  82. 4
      AlphaWallet/Settings/ViewModels/LocaleViewModel.swift
  83. 4
      AlphaWallet/Settings/ViewModels/ServerViewModel.swift
  84. 3
      AlphaWallet/Settings/ViewModels/ServersViewModel.swift
  85. 18
      AlphaWallet/Settings/ViewModels/SettingsViewModel.swift
  86. 2
      AlphaWallet/Settings/Views/AlphaWalletSettingsSwitchRow.swift
  87. 3
      AlphaWallet/Settings/Views/AlphaWalletSettingsTextRow.swift
  88. 6
      AlphaWallet/Settings/Views/LocaleViewCell.swift
  89. 6
      AlphaWallet/Settings/Views/ServerViewCell.swift
  90. 4
      AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift
  91. 1
      AlphaWallet/Tokens/Coordinators/GetBalanceCoordinator.swift
  92. 1
      AlphaWallet/Tokens/Coordinators/GetDecimalsCoordinator.swift
  93. 1
      AlphaWallet/Tokens/Coordinators/GetNameCoordinator.swift
  94. 1
      AlphaWallet/Tokens/Coordinators/GetSymbolCoordinator.swift
  95. 14
      AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift
  96. 3
      AlphaWallet/Tokens/Helpers/TokenAdaptor.swift
  97. 4
      AlphaWallet/Tokens/Types/Token.swift
  98. 1
      AlphaWallet/Tokens/Types/TokenBalance.swift
  99. 22
      AlphaWallet/Tokens/Types/TokenHolder.swift
  100. 7
      AlphaWallet/Tokens/Types/TokenObject.swift
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1899,7 +1899,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
29E6E06F1FEA12910079265A /* TransactionConfigurator.swift */, 29E6E06F1FEA12910079265A /* TransactionConfigurator.swift */,
5E7C7A5A98CE71365B6E80FF /* Views */,
); );
path = Controllers; path = Controllers;
sourceTree = "<group>"; sourceTree = "<group>";
@ -2630,13 +2629,6 @@
path = ViewModels; path = ViewModels;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
5E7C7A5A98CE71365B6E80FF /* Views */ = {
isa = PBXGroup;
children = (
);
path = Views;
sourceTree = "<group>";
};
5E7C7A968681D718C8A32B47 /* Commands */ = { 5E7C7A968681D718C8A32B47 /* Commands */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (

@ -3,7 +3,7 @@
import UIKit import UIKit
class HelpContentsViewController: StaticHTMLViewController { class HelpContentsViewController: StaticHTMLViewController {
let banner = ContactUsBannerView() private let banner = ContactUsBannerView()
override init(delegate: StaticHTMLViewControllerDelegate?) { override init(delegate: StaticHTMLViewControllerDelegate?) {
super.init(delegate: delegate) super.init(delegate: delegate)

@ -8,10 +8,11 @@ protocol ContactUsBannerViewDelegate: class {
} }
class ContactUsBannerView: UIView { class ContactUsBannerView: UIView {
private let button = UIButton(type: .system)
private let imageView = UIImageView()
private let label = UILabel()
weak var delegate: ContactUsBannerViewDelegate? weak var delegate: ContactUsBannerViewDelegate?
let button = UIButton(type: .system)
let imageView = UIImageView()
let label = UILabel()
let bannerHeight = CGFloat(60) let bannerHeight = CGFloat(60)
override init(frame: CGRect) { override init(frame: CGRect) {

@ -5,9 +5,9 @@ import UIKit
class HelpViewCell: UITableViewCell { class HelpViewCell: UITableViewCell {
static let identifier = "HelpViewCell" static let identifier = "HelpViewCell"
let background = UIView() private let background = UIView()
let titleLabel = UILabel() private let titleLabel = UILabel()
let iconImageView = UIImageView() private let iconImageView = UIImageView()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)

@ -5,8 +5,8 @@ import UIKit
class AssetDefinitionsOverridesViewCell: UITableViewCell { class AssetDefinitionsOverridesViewCell: UITableViewCell {
static let identifier = "AssetDefinitionsOverridesViewCell" static let identifier = "AssetDefinitionsOverridesViewCell"
let background = UIView() private let background = UIView()
let titleLabel = UILabel() private let titleLabel = UILabel()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)

@ -24,11 +24,10 @@ enum TitlecaseOrNot {
private class PrivateXMLHandler { private class PrivateXMLHandler {
private let xml: XML.Accessor private let xml: XML.Accessor
let contractAddress: String private let contractAddress: String
lazy var contract = xml["token"]["contract"].getElement(attributeName: "type", attributeValue: "holding", fallbackToFirst: true) private lazy var contract = xml["token"]["contract"].getElement(attributeName: "type", attributeValue: "holding", fallbackToFirst: true)
lazy var fields = extractFields() private lazy var fields = extractFields()
private let isOfficial: Bool private let isOfficial: Bool
let hasAssetDefinition: Bool
private let signatureNamespace: String private let signatureNamespace: String
private var signatureNamespacePrefix: String { private var signatureNamespacePrefix: String {
if signatureNamespace.isEmpty { if signatureNamespace.isEmpty {
@ -38,6 +37,8 @@ private class PrivateXMLHandler {
} }
} }
let hasAssetDefinition: Bool
init(contract: String) { init(contract: String) {
contractAddress = contract.add0x.lowercased() contractAddress = contract.add0x.lowercased()
let assetDefinitionStore = AssetDefinitionStore() let assetDefinitionStore = AssetDefinitionStore()

@ -13,35 +13,22 @@ protocol BrowserCoordinatorDelegate: class {
} }
final class BrowserCoordinator: NSObject, Coordinator { final class BrowserCoordinator: NSObject, Coordinator {
var coordinators: [Coordinator] = [] private let session: WalletSession
let session: WalletSession private let keystore: Keystore
let keystore: Keystore
let navigationController: NavigationController
lazy var bookmarksViewController: BookmarkViewController = { private lazy var bookmarksViewController: BookmarkViewController = {
let controller = BookmarkViewController(bookmarksStore: bookmarksStore) let controller = BookmarkViewController(bookmarksStore: bookmarksStore)
controller.delegate = self controller.delegate = self
return controller return controller
}() }()
lazy var historyViewController: HistoryViewController = { private lazy var historyViewController: HistoryViewController = {
let controller = HistoryViewController(store: historyStore) let controller = HistoryViewController(store: historyStore)
controller.delegate = self controller.delegate = self
return controller return controller
}() }()
lazy var rootViewController: MasterBrowserViewController = { private lazy var browserViewController: BrowserViewController = {
let controller = MasterBrowserViewController(
bookmarksViewController: bookmarksViewController,
historyViewController: historyViewController,
browserViewController: browserViewController,
type: .browser
)
controller.delegate = self
return controller
}()
lazy var browserViewController: BrowserViewController = {
let controller = BrowserViewController(account: session.account, config: session.config, server: server) let controller = BrowserViewController(account: session.account, config: session.config, server: server)
controller.delegate = self controller.delegate = self
controller.webView.uiDelegate = self controller.webView.uiDelegate = self
@ -54,26 +41,39 @@ final class BrowserCoordinator: NSObject, Coordinator {
private lazy var historyStore: HistoryStore = { private lazy var historyStore: HistoryStore = {
return HistoryStore(realm: sharedRealm) return HistoryStore(realm: sharedRealm)
}() }()
lazy var preferences: PreferencesController = { private lazy var preferences: PreferencesController = {
return PreferencesController() return PreferencesController()
}() }()
var urlParser: BrowserURLParser { private var urlParser: BrowserURLParser {
let engine = SearchEngine(rawValue: preferences.get(for: .browserSearchEngine)) ?? .default let engine = SearchEngine(rawValue: preferences.get(for: .browserSearchEngine)) ?? .default
return BrowserURLParser(engine: engine) return BrowserURLParser(engine: engine)
} }
var server: RPCServer { private var server: RPCServer {
return session.config.server return session.config.server
} }
private var enableToolbar: Bool = true {
weak var delegate: BrowserCoordinatorDelegate?
var enableToolbar: Bool = true {
didSet { didSet {
navigationController.isToolbarHidden = !enableToolbar navigationController.isToolbarHidden = !enableToolbar
} }
} }
var coordinators: [Coordinator] = []
let navigationController: NavigationController
lazy var rootViewController: MasterBrowserViewController = {
let controller = MasterBrowserViewController(
bookmarksViewController: bookmarksViewController,
historyViewController: historyViewController,
browserViewController: browserViewController,
type: .browser
)
controller.delegate = self
return controller
}()
weak var delegate: BrowserCoordinatorDelegate?
init( init(
session: WalletSession, session: WalletSession,
keystore: Keystore, keystore: Keystore,

@ -4,13 +4,13 @@ import Foundation
import RealmSwift import RealmSwift
final class HistoryStore { final class HistoryStore {
private let realm: Realm
var histories: Results<History> { var histories: Results<History> {
return realm.objects(History.self) return realm.objects(History.self)
.sorted(byKeyPath: "createdAt", ascending: false) .sorted(byKeyPath: "createdAt", ascending: false)
} }
let realm: Realm
init(realm: Realm) { init(realm: Realm) {
self.realm = realm self.realm = realm
} }

@ -3,8 +3,8 @@
import Foundation import Foundation
final class BrowserURLParser { final class BrowserURLParser {
let urlRegEx = try! NSRegularExpression(pattern: "^(http(s)?://)?[a-z0-9-_]+(\\.[a-z0-9-_]+)+(/)?", options: .caseInsensitive) private let urlRegEx = try! NSRegularExpression(pattern: "^(http(s)?://)?[a-z0-9-_]+(\\.[a-z0-9-_]+)+(/)?", options: .caseInsensitive)
let validSchemes = ["http", "https"] private let validSchemes = ["http", "https"]
let engine: SearchEngine let engine: SearchEngine
init( init(

@ -9,19 +9,16 @@ protocol BookmarkViewControllerDelegate: class {
} }
final class BookmarkViewController: UIViewController { final class BookmarkViewController: UIViewController {
private let tableView = UITableView(frame: .zero, style: .plain)
let tableView = UITableView(frame: .zero, style: .plain) private let bookmarksStore: BookmarksStore
weak var delegate: BookmarkViewControllerDelegate? weak var delegate: BookmarkViewControllerDelegate?
private let bookmarksStore: BookmarksStore
lazy var viewModel: BookmarksViewModel = { lazy var viewModel: BookmarksViewModel = {
return BookmarksViewModel(bookmarksStore: bookmarksStore) return BookmarksViewModel(bookmarksStore: bookmarksStore)
}() }()
init( init(bookmarksStore: BookmarksStore) {
bookmarksStore: BookmarksStore
) {
self.bookmarksStore = bookmarksStore self.bookmarksStore = bookmarksStore
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)

@ -22,10 +22,9 @@ protocol BrowserViewControllerDelegate: class {
} }
final class BrowserViewController: UIViewController { final class BrowserViewController: UIViewController {
private var myContext = 0 private var myContext = 0
let account: Wallet private let account: Wallet
let sessionConfig: Config private let sessionConfig: Config
private struct Keys { private struct Keys {
static let estimatedProgress = "estimatedProgress" static let estimatedProgress = "estimatedProgress"
@ -38,6 +37,19 @@ final class BrowserViewController: UIViewController {
return Keys.ClientName + "/" + (Bundle.main.versionNumber ?? "") return Keys.ClientName + "/" + (Bundle.main.versionNumber ?? "")
}() }()
private lazy var errorView: BrowserErrorView = {
let errorView = BrowserErrorView()
errorView.translatesAutoresizingMaskIntoConstraints = false
errorView.delegate = self
return errorView
}()
private var browserNavBar: BrowserNavigationBar? {
return navigationController?.navigationBar as? BrowserNavigationBar
}
weak var delegate: BrowserViewControllerDelegate?
lazy var webView: WKWebView = { lazy var webView: WKWebView = {
let webView = WKWebView( let webView = WKWebView(
frame: .zero, frame: .zero,
@ -52,19 +64,6 @@ final class BrowserViewController: UIViewController {
return webView return webView
}() }()
lazy var errorView: BrowserErrorView = {
let errorView = BrowserErrorView()
errorView.translatesAutoresizingMaskIntoConstraints = false
errorView.delegate = self
return errorView
}()
weak var delegate: BrowserViewControllerDelegate?
private var browserNavBar: BrowserNavigationBar? {
return navigationController?.navigationBar as? BrowserNavigationBar
}
lazy var progressView: UIProgressView = { lazy var progressView: UIProgressView = {
let progressView = UIProgressView(progressViewStyle: .default) let progressView = UIProgressView(progressViewStyle: .default)
progressView.translatesAutoresizingMaskIntoConstraints = false progressView.translatesAutoresizingMaskIntoConstraints = false

@ -8,10 +8,9 @@ protocol HistoryViewControllerDelegate: class {
} }
final class HistoryViewController: UIViewController { final class HistoryViewController: UIViewController {
private let store: HistoryStore
let store: HistoryStore private let tableView = UITableView(frame: .zero, style: .plain)
let tableView = UITableView(frame: .zero, style: .plain) private lazy var viewModel: HistoriesViewModel = {
lazy var viewModel: HistoriesViewModel = {
return HistoriesViewModel(store: store) return HistoriesViewModel(store: store)
}() }()

@ -19,7 +19,6 @@ enum BookmarksViewType: Int {
} }
final class MasterBrowserViewController: UIViewController { final class MasterBrowserViewController: UIViewController {
private lazy var segmentController: UISegmentedControl = { private lazy var segmentController: UISegmentedControl = {
let items = [ let items = [
R.string.localizable.new(), R.string.localizable.new(),
@ -41,10 +40,10 @@ final class MasterBrowserViewController: UIViewController {
return button return button
}() }()
weak var delegate: MasterBrowserViewControllerDelegate? private let bookmarksViewController: BookmarkViewController
private let historyViewController: HistoryViewController
let bookmarksViewController: BookmarkViewController weak var delegate: MasterBrowserViewControllerDelegate?
let historyViewController: HistoryViewController
let browserViewController: BrowserViewController let browserViewController: BrowserViewController
init( init(

@ -4,8 +4,8 @@ import Foundation
import UIKit import UIKit
struct BookmarkViewModel: URLViewModel { struct BookmarkViewModel: URLViewModel {
private let bookmark: Bookmark
let bookmark: Bookmark
init( init(
bookmark: Bookmark bookmark: Bookmark
) { ) {

@ -5,7 +5,7 @@ import RealmSwift
struct BookmarksViewModel { struct BookmarksViewModel {
let bookmarksStore: BookmarksStore private let bookmarksStore: BookmarksStore
init( init(
bookmarksStore: BookmarksStore bookmarksStore: BookmarksStore

@ -4,7 +4,7 @@ import Foundation
struct HistoriesViewModel { struct HistoriesViewModel {
let store: HistoryStore private let store: HistoryStore
init( init(
store: HistoryStore store: HistoryStore

@ -5,7 +5,7 @@ import UIKit
struct HistoryViewModel: URLViewModel { struct HistoryViewModel: URLViewModel {
let history: History private let history: History
init( init(
history: History history: History

@ -7,14 +7,11 @@ protocol BrowserErrorViewDelegate: class {
} }
final class BrowserErrorView: UIView { final class BrowserErrorView: UIView {
weak var delegate: BrowserErrorViewDelegate?
private let topMargin: CGFloat = 120 private let topMargin: CGFloat = 120
private let leftMargin: CGFloat = 40 private let leftMargin: CGFloat = 40
private let buttonTopMargin: CGFloat = 6 private let buttonTopMargin: CGFloat = 6
lazy var textLabel: UILabel = { private lazy var textLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.numberOfLines = 0 label.numberOfLines = 0
label.textColor = Colors.gray label.textColor = Colors.gray
@ -23,7 +20,7 @@ final class BrowserErrorView: UIView {
return label return label
}() }()
lazy var reloadButton: Button = { private lazy var reloadButton: Button = {
let button = Button(size: .normal, style: .borderless) let button = Button(size: .normal, style: .borderless)
button.addTarget(self, action: #selector(reloadTapped), for: .touchUpInside) button.addTarget(self, action: #selector(reloadTapped), for: .touchUpInside)
button.setTitle(R.string.localizable.browserReloadButtonTitle(), for: .normal) button.setTitle(R.string.localizable.browserReloadButtonTitle(), for: .normal)
@ -32,6 +29,8 @@ final class BrowserErrorView: UIView {
return button return button
}() }()
weak var delegate: BrowserErrorViewDelegate?
init() { init() {
super.init(frame: CGRect.zero) super.init(frame: CGRect.zero)
finishInit() finishInit()

@ -7,19 +7,19 @@ protocol BrowserNavigationBarDelegate: class {
} }
final class BrowserNavigationBar: UINavigationBar { final class BrowserNavigationBar: UINavigationBar {
private let moreButton = UIButton()
let textField = UITextField() private let homeButton = UIButton()
let moreButton = UIButton()
let closeButton = UIButton()
let homeButton = UIButton()
let backButton = UIButton()
weak var browserDelegate: BrowserNavigationBarDelegate?
private struct Layout { private struct Layout {
static let width: CGFloat = 34 static let width: CGFloat = 34
static let moreButtonWidth: CGFloat = 24 static let moreButtonWidth: CGFloat = 24
} }
let textField = UITextField()
let closeButton = UIButton()
let backButton = UIButton()
weak var browserDelegate: BrowserNavigationBarDelegate?
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)

@ -4,13 +4,10 @@ import Foundation
import UIKit import UIKit
class CheckDeviceCoordinator: Coordinator { class CheckDeviceCoordinator: Coordinator {
var coordinators: [Coordinator] = [] private let navigationController: UINavigationController
private let jailbreakChecker: JailbreakChecker
let navigationController: UINavigationController
let jailbreakChecker: JailbreakChecker
lazy var alertViewController: UIAlertController = { private lazy var alertViewController: UIAlertController = {
let controller = UIAlertController( let controller = UIAlertController(
title: R.string.localizable.appDeviceJailbreakTitle(), title: R.string.localizable.appDeviceJailbreakTitle(),
message: R.string.localizable.appDeviceJailbreakDescription(), message: R.string.localizable.appDeviceJailbreakDescription(),
@ -22,6 +19,8 @@ class CheckDeviceCoordinator: Coordinator {
return controller return controller
}() }()
var coordinators: [Coordinator] = []
init( init(
navigationController: UINavigationController, navigationController: UINavigationController,
jailbreakChecker: JailbreakChecker jailbreakChecker: JailbreakChecker

@ -6,7 +6,7 @@ import WebKit
///Reason for this class: https://stackoverflow.com/questions/26383031/wkwebview-causes-my-view-controller-to-leak ///Reason for this class: https://stackoverflow.com/questions/26383031/wkwebview-causes-my-view-controller-to-leak
final class ScriptMessageProxy: NSObject, WKScriptMessageHandler { final class ScriptMessageProxy: NSObject, WKScriptMessageHandler {
weak var delegate: WKScriptMessageHandler? private weak var delegate: WKScriptMessageHandler?
init(delegate: WKScriptMessageHandler) { init(delegate: WKScriptMessageHandler) {
self.delegate = delegate self.delegate = delegate

@ -5,9 +5,9 @@ import RealmSwift
import TrustKeystore import TrustKeystore
class MigrationInitializer: Initializer { class MigrationInitializer: Initializer {
private let account: Wallet
private let chainID: Int
let account: Wallet
let chainID: Int
lazy var config: Realm.Configuration = { lazy var config: Realm.Configuration = {
return RealmConfiguration.configuration(for: account, chainID: chainID) return RealmConfiguration.configuration(for: account, chainID: chainID)
}() }()

@ -4,7 +4,7 @@ import Foundation
struct SkipBackupFilesInitializer: Initializer { struct SkipBackupFilesInitializer: Initializer {
let urls: [URL] private let urls: [URL]
init(paths: [URL]) { init(paths: [URL]) {
self.urls = paths self.urls = paths

@ -4,10 +4,10 @@ import Foundation
import BigInt import BigInt
struct GasViewModel { struct GasViewModel {
let fee: BigInt private let fee: BigInt
let symbol: String private let symbol: String
let currencyRate: CurrencyRate? private let currencyRate: CurrencyRate?
let formatter: EtherNumberFormatter private let formatter: EtherNumberFormatter
init( init(
fee: BigInt, fee: BigInt,

@ -3,8 +3,7 @@
import Foundation import Foundation
struct InCoordinatorViewModel { struct InCoordinatorViewModel {
private let config: Config
let config: Config
init(config: Config) { init(config: Config) {
self.config = config self.config = config

@ -8,11 +8,11 @@ protocol DepositCoordinatorDelegate: class, CanOpenURL {
} }
class DepositCoordinator: Coordinator { class DepositCoordinator: Coordinator {
private let account: Wallet
private weak var delegate: DepositCoordinatorDelegate?
let navigationController: UINavigationController let navigationController: UINavigationController
let account: Wallet
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
weak var delegate: DepositCoordinatorDelegate?
init( init(
navigationController: UINavigationController, navigationController: UINavigationController,

@ -4,12 +4,13 @@ import Foundation
import RealmSwift import RealmSwift
struct CoinTicker: Codable { struct CoinTicker: Codable {
let id: String private let id: String
let symbol: String private let symbol: String
var price_usd: String private let image: String = ""
let price_usd: String
let percent_change_24h: String let percent_change_24h: String
let contract: String = Constants.nullAddress let contract: String = Constants.nullAddress
let image: String = ""
lazy var rate: CurrencyRate = { lazy var rate: CurrencyRate = {
CurrencyRate( CurrencyRate(

@ -12,17 +12,18 @@ enum EtherKeystoreError: LocalizedError {
} }
open class EtherKeystore: Keystore { open class EtherKeystore: Keystore {
struct Keys { private struct Keys {
static let recentlyUsedAddress: String = "recentlyUsedAddress" static let recentlyUsedAddress: String = "recentlyUsedAddress"
static let watchAddresses = "watchAddresses" static let watchAddresses = "watchAddresses"
} }
private let keychain: KeychainSwift private let keychain: KeychainSwift
private let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] private let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let keyStore: KeyStore private let keyStore: KeyStore
private let defaultKeychainAccess: KeychainSwiftAccessOptions = .accessibleWhenUnlockedThisDeviceOnly private let defaultKeychainAccess: KeychainSwiftAccessOptions = .accessibleWhenUnlockedThisDeviceOnly
private let userDefaults: UserDefaults
let keystoreDirectory: URL let keystoreDirectory: URL
let userDefaults: UserDefaults
public init( public init(
keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix), keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix),

@ -9,7 +9,7 @@ protocol Signer {
} }
struct EIP155Signer: Signer { struct EIP155Signer: Signer {
let chainId: BigInt private let chainId: BigInt
init(chainId: BigInt) { init(chainId: BigInt) {
self.chainId = chainId self.chainId = chainId

@ -12,11 +12,11 @@ protocol BackupCoordinatorDelegate: class {
} }
class BackupCoordinator: Coordinator { class BackupCoordinator: Coordinator {
private let keystore: Keystore
private let account: Account
let navigationController: UINavigationController let navigationController: UINavigationController
weak var delegate: BackupCoordinatorDelegate? weak var delegate: BackupCoordinatorDelegate?
let keystore: Keystore
let account: Account
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
init( init(

@ -9,9 +9,10 @@ protocol PromptBackupCoordinatorDelegate: class {
///We allow user to switch wallets, so it's important to know which wallet we are prompting for. It might not be the current wallet ///We allow user to switch wallets, so it's important to know which wallet we are prompting for. It might not be the current wallet
class PromptBackupCoordinator: Coordinator { class PromptBackupCoordinator: Coordinator {
private var walletAddress: String
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
weak var delegate: PromptBackupCoordinatorDelegate? weak var delegate: PromptBackupCoordinatorDelegate?
var walletAddress: String
init(walletAddress: String) { init(walletAddress: String) {
self.walletAddress = walletAddress self.walletAddress = walletAddress

@ -9,10 +9,10 @@ protocol BackupViewControllerDelegate: class {
} }
class BackupViewController: UIViewController { class BackupViewController: UIViewController {
private let account: Account
private let viewModel = BackupViewModel()
let account: Account
weak var delegate: BackupViewControllerDelegate? weak var delegate: BackupViewControllerDelegate?
let viewModel = BackupViewModel()
init(account: Account) { init(account: Account) {
self.account = account self.account = account

@ -4,7 +4,7 @@ import Foundation
struct BackupViewModel { struct BackupViewModel {
let config: Config private let config: Config
init( init(
config: Config = Config() config: Config = Config()

@ -4,19 +4,12 @@
import UIKit import UIKit
class LockView: UIView { class LockView: UIView {
var characterView = UIStackView() private var characterView = UIStackView()
private var model: LockViewModel
var lockTitle = UILabel() var lockTitle = UILabel()
var model: LockViewModel
var characters: [PasscodeCharacterView]! var characters: [PasscodeCharacterView]!
init(_ model: LockViewModel) {
self.model = model
super.init(frame: CGRect.zero)
self.characters = passcodeCharacters()
configCharacterView()
configLabel()
addUiElements()
applyConstraints()
}
private func configCharacterView() { private func configCharacterView() {
characterView = UIStackView(arrangedSubviews: characters) characterView = UIStackView(arrangedSubviews: characters)
characterView.axis = .horizontal characterView.axis = .horizontal
@ -54,6 +47,17 @@ class LockView: UIView {
} }
return characters return characters
} }
init(_ model: LockViewModel) {
self.model = model
super.init(frame: CGRect.zero)
self.characters = passcodeCharacters()
configCharacterView()
configLabel()
addUiElements()
applyConstraints()
}
func shake() { func shake() {
let keypath = "position" let keypath = "position"
let animation = CABasicAnimation(keyPath: keypath) let animation = CABasicAnimation(keyPath: keypath)

@ -4,12 +4,14 @@
import UIKit import UIKit
class PasscodeCharacterView: UIView { class PasscodeCharacterView: UIView {
var isEmpty = true private var isEmpty = true
private var circle: CAShapeLayer? private var circle: CAShapeLayer?
private var hyphen: CAShapeLayer? private var hyphen: CAShapeLayer?
override func layoutSubviews() { override func layoutSubviews() {
commonInit() commonInit()
} }
private func commonInit() { private func commonInit() {
isEmpty = true isEmpty = true
backgroundColor = UIColor.clear backgroundColor = UIColor.clear
@ -17,10 +19,12 @@ class PasscodeCharacterView: UIView {
drawHyphen() drawHyphen()
redraw() redraw()
} }
private func redraw() { private func redraw() {
circle?.isHidden = isEmpty circle?.isHidden = isEmpty
hyphen?.isHidden = !isEmpty hyphen?.isHidden = !isEmpty
} }
private func drawCircle() { private func drawCircle() {
let borderWidth: CGFloat = 2 let borderWidth: CGFloat = 2
let radius: CGFloat = bounds.width / 2 - borderWidth let radius: CGFloat = bounds.width / 2 - borderWidth
@ -33,6 +37,7 @@ class PasscodeCharacterView: UIView {
layer.addSublayer(circle) layer.addSublayer(circle)
self.circle = circle self.circle = circle
} }
private func drawHyphen() { private func drawHyphen() {
let horizontalMargin: CGFloat = 2 let horizontalMargin: CGFloat = 2
let hyphenHeight: CGFloat = bounds.height / 7 let hyphenHeight: CGFloat = bounds.height / 7
@ -53,6 +58,7 @@ class PasscodeCharacterView: UIView {
layer.addSublayer(hyphen) layer.addSublayer(hyphen)
self.hyphen = hyphen self.hyphen = hyphen
} }
func setEmpty(_ isEmpty: Bool) { func setEmpty(_ isEmpty: Bool) {
if self.isEmpty != isEmpty { if self.isEmpty != isEmpty {
self.isEmpty = isEmpty self.isEmpty = isEmpty

@ -22,8 +22,8 @@ import BigInt
public class MarketQueueHandler { public class MarketQueueHandler {
public let baseURL = "https://482kdh4npg.execute-api.ap-southeast-1.amazonaws.com/dev/" private let baseURL = "https://482kdh4npg.execute-api.ap-southeast-1.amazonaws.com/dev/"
public let contractAddress = "bC9a1026A4BC6F0BA8Bbe486d1D09dA5732B39e4".lowercased() private let contractAddress = "bC9a1026A4BC6F0BA8Bbe486d1D09dA5732B39e4".lowercased()
public func getOrders(callback: @escaping (_ result: Any) -> Void) { public func getOrders(callback: @escaping (_ result: Any) -> Void) {
Alamofire.request(baseURL + "contract/" + contractAddress, method: .get).responseJSON { [weak self] response in Alamofire.request(baseURL + "contract/" + contractAddress, method: .get).responseJSON { [weak self] response in

@ -14,22 +14,24 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS
case notReady case notReady
} }
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tokenCardRowView = TokenCardRowView()
private let statusLabel = UILabel()
private let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
private var costStackView: UIStackView?
private let ethCostLabelLabel = UILabel()
private let ethCostLabel = UILabel()
private let dollarCostLabelLabel = UILabel()
private let dollarCostLabel = PaddedLabel()
private let buttonSeparator = UIView()
private let actionButton = UIButton(type: .system)
private let cancelButton = UIButton(type: .system)
private var viewModel: ImportMagicTokenViewControllerViewModel?
let config: Config let config: Config
weak var delegate: ImportMagicTokenViewControllerDelegate? weak var delegate: ImportMagicTokenViewControllerDelegate?
let roundedBackground = RoundedBackground()
let header = TokensCardViewControllerTitleHeader()
let tokenCardRowView = TokenCardRowView()
let statusLabel = UILabel()
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
var costStackView: UIStackView?
let ethCostLabelLabel = UILabel()
let ethCostLabel = UILabel()
let dollarCostLabelLabel = UILabel()
let dollarCostLabel = PaddedLabel()
let buttonSeparator = UIView()
let actionButton = UIButton(type: .system)
let cancelButton = UIButton(type: .system)
private var viewModel: ImportMagicTokenViewControllerViewModel?
var contract: String? { var contract: String? {
didSet { didSet {
guard url != nil else { return } guard url != nil else { return }

@ -7,13 +7,14 @@ protocol StatusViewControllerDelegate: class {
} }
class StatusViewController: UIViewController { class StatusViewController: UIViewController {
private let background = UIView()
private let imageView = UIImageView()
private let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
private let titleLabel = UILabel()
private let actionButton = UIButton()
private var viewModel: StatusViewControllerViewModel?
weak var delegate: StatusViewControllerDelegate? weak var delegate: StatusViewControllerDelegate?
let background = UIView()
let imageView = UIImageView()
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge)
let titleLabel = UILabel()
let actionButton = UIButton()
var viewModel: StatusViewControllerViewModel?
init() { init() {
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)

@ -3,7 +3,7 @@
import Foundation import Foundation
struct ImportMagicTokenCardRowViewModel: TokenCardRowViewModelProtocol { struct ImportMagicTokenCardRowViewModel: TokenCardRowViewModelProtocol {
var importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel private var importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel
init(importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel) { init(importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel) {
self.importMagicTokenViewControllerViewModel = importMagicTokenViewControllerViewModel self.importMagicTokenViewControllerViewModel = importMagicTokenViewControllerViewModel

@ -8,10 +8,12 @@ struct StatusViewControllerViewModel {
case succeeded case succeeded
case failed case failed
} }
private let inProgressText: String
private let succeededTextText: String
private let failedText: String
var state: State var state: State
let inProgressText: String
let succeededTextText: String
let failedText: String
var contentsBackgroundColor: UIColor { var contentsBackgroundColor: UIColor {
return Colors.appWhite return Colors.appWhite

@ -3,7 +3,7 @@
import UIKit import UIKit
class MarketplaceViewController: UIViewController { class MarketplaceViewController: UIViewController {
let comingSoonLabel = UILabel() private let comingSoonLabel = UILabel()
init() { init() {
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)

@ -4,14 +4,18 @@
import UIKit import UIKit
class ProtectionCoordinator: Coordinator { class ProtectionCoordinator: Coordinator {
var coordinators: [Coordinator] = [] private lazy var splashCoordinator: SplashCoordinator = {
lazy var splashCoordinator: SplashCoordinator = {
return SplashCoordinator(window: protectionWindow) return SplashCoordinator(window: protectionWindow)
}() }()
lazy var lockEnterPasscodeCoordinator: LockEnterPasscodeCoordinator = {
private lazy var lockEnterPasscodeCoordinator: LockEnterPasscodeCoordinator = {
return LockEnterPasscodeCoordinator(model: LockEnterPasscodeViewModel()) return LockEnterPasscodeCoordinator(model: LockEnterPasscodeViewModel())
}() }()
let protectionWindow = UIWindow()
private let protectionWindow = UIWindow()
var coordinators: [Coordinator] = []
init() { init() {
protectionWindow.windowLevel = UIWindowLevelStatusBar + 2.0 protectionWindow.windowLevel = UIWindowLevelStatusBar + 2.0
} }

@ -3,15 +3,19 @@
import UIKit import UIKit
class SplashCoordinator: Coordinator { class SplashCoordinator: Coordinator {
var coordinators: [Coordinator] = []
private let window: UIWindow private let window: UIWindow
var coordinators: [Coordinator] = []
init(window: UIWindow) { init(window: UIWindow) {
self.window = window self.window = window
} }
func start() { func start() {
window.rootViewController = SplashViewController() window.rootViewController = SplashViewController()
window.isHidden = false window.isHidden = false
} }
func stop() { func stop() {
window.isHidden = true window.isHidden = true
} }

@ -5,6 +5,7 @@ import UIKit
class SplashViewController: UIViewController { class SplashViewController: UIViewController {
private var splashView = SplashView() private var splashView = SplashView()
init() { init() {
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
splashView.translatesAutoresizingMaskIntoConstraints = false splashView.translatesAutoresizingMaskIntoConstraints = false

@ -14,6 +14,7 @@ class SplashView: UIView {
logoImageView.centerYAnchor.constraint(equalTo: centerYAnchor), logoImageView.centerYAnchor.constraint(equalTo: centerYAnchor),
]) ])
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }

@ -10,7 +10,6 @@ import Foundation
import TrustKeystore import TrustKeystore
class RedeemEventListener { class RedeemEventListener {
var shouldListen = false var shouldListen = false
func start(for address: Address, func start(for address: Address,

@ -11,7 +11,6 @@ import TrustKeystore
import BigInt import BigInt
class SignatureHelper { class SignatureHelper {
class func signatureAsHex(for message: String, account: Account) -> String? { class func signatureAsHex(for message: String, account: Account) -> String? {
let keystore = try! EtherKeystore() let keystore = try! EtherKeystore()
let signature = keystore.signMessageData(message.data(using: String.Encoding.utf8), for: account) let signature = keystore.signMessageData(message.data(using: String.Encoding.utf8), for: account)

@ -11,7 +11,6 @@ import Result
import TrustKeystore import TrustKeystore
public class EventsRest { public class EventsRest {
func getEvents(for address: Address, func getEvents(for address: Address,
completion: @escaping (Result<[Event], AnyError>) -> Void) { completion: @escaping (Result<[Event], AnyError>) -> Void) {
let endpoint = EndPoints.EventBaseUrl + "/" + address.description.lowercased() let endpoint = EndPoints.EventBaseUrl + "/" + address.description.lowercased()

@ -14,19 +14,19 @@ protocol RedeemTokenCardQuantitySelectionViewControllerDelegate: class, CanOpenU
} }
class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVerifiableStatusViewController { class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVerifiableStatusViewController {
private let token: TokenObject
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let subtitleLabel = UILabel()
private let quantityStepper = NumberStepper()
private let tokenRowView: TokenRowView & UIView
private let nextButton = UIButton(type: .system)
private var viewModel: RedeemTokenCardQuantitySelectionViewModel
let config: Config let config: Config
var contract: String { var contract: String {
return token.contract return token.contract
} }
private let token: TokenObject
let roundedBackground = RoundedBackground()
let header = TokensCardViewControllerTitleHeader()
let subtitleLabel = UILabel()
let quantityStepper = NumberStepper()
let tokenRowView: TokenRowView & UIView
let nextButton = UIButton(type: .system)
var viewModel: RedeemTokenCardQuantitySelectionViewModel
weak var delegate: RedeemTokenCardQuantitySelectionViewControllerDelegate? weak var delegate: RedeemTokenCardQuantitySelectionViewControllerDelegate?
init(config: Config, token: TokenObject, viewModel: RedeemTokenCardQuantitySelectionViewModel) { init(config: Config, token: TokenObject, viewModel: RedeemTokenCardQuantitySelectionViewModel) {

@ -15,17 +15,17 @@ protocol RedeemTokenViewControllerDelegate: class, CanOpenURL {
} }
class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewController { class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewController {
private let token: TokenObject
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private let nextButton = UIButton(type: .system)
private var viewModel: RedeemTokenCardViewModel
let config: Config let config: Config
var contract: String { var contract: String {
return token.contract return token.contract
} }
private let token: TokenObject
let roundedBackground = RoundedBackground()
let header = TokensCardViewControllerTitleHeader()
let tableView = UITableView(frame: .zero, style: .plain)
let nextButton = UIButton(type: .system)
var viewModel: RedeemTokenCardViewModel
weak var delegate: RedeemTokenViewControllerDelegate? weak var delegate: RedeemTokenViewControllerDelegate?
init(config: Config, token: TokenObject, viewModel: RedeemTokenCardViewModel) { init(config: Config, token: TokenObject, viewModel: RedeemTokenCardViewModel) {

@ -12,19 +12,19 @@ protocol TokenCardRedemptionViewControllerDelegate: class, CanOpenURL {
} }
class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatusViewController { class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatusViewController {
private var viewModel: TokenCardRedemptionViewModel
private var titleLabel = UILabel()
private let imageView = UIImageView()
private let tokenRowView: TokenRowView & UIView
private var timer: Timer!
private var session: WalletSession
private let token: TokenObject
private let redeemListener = RedeemEventListener()
let config: Config let config: Config
var contract: String { var contract: String {
return token.contract return token.contract
} }
var viewModel: TokenCardRedemptionViewModel
var titleLabel = UILabel()
let imageView = UIImageView()
let tokenRowView: TokenRowView & UIView
var timer: Timer!
var session: WalletSession
private let token: TokenObject
let redeemListener = RedeemEventListener()
weak var delegate: TokenCardRedemptionViewControllerDelegate? weak var delegate: TokenCardRedemptionViewControllerDelegate?
init(config: Config, session: WalletSession, token: TokenObject, viewModel: TokenCardRedemptionViewModel) { init(config: Config, session: WalletSession, token: TokenObject, viewModel: TokenCardRedemptionViewModel) {

@ -10,9 +10,8 @@ import Foundation
import UIKit import UIKit
struct RedeemTokenCardQuantitySelectionViewModel { struct RedeemTokenCardQuantitySelectionViewModel {
let token: TokenObject
var token: TokenObject let tokenHolder: TokenHolder
var tokenHolder: TokenHolder
var headerTitle: String { var headerTitle: String {
let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName() let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName()

@ -10,9 +10,8 @@ import Foundation
import UIKit import UIKit
struct RedeemTokenCardViewModel { struct RedeemTokenCardViewModel {
let token: TokenObject
var token: TokenObject let tokenHolders: [TokenHolder]
var tokenHolders: [TokenHolder]
init(token: TokenObject) { init(token: TokenObject) {
self.token = token self.token = token

@ -10,8 +10,8 @@ import Foundation
import UIKit import UIKit
struct TokenCardRedemptionViewModel { struct TokenCardRedemptionViewModel {
var token: TokenObject let token: TokenObject
var tokenHolder: TokenHolder let tokenHolder: TokenHolder
var headerTitle: String { var headerTitle: String {
return R.string.localizable.aWalletTokenRedeemShowQRCodeTitle() return R.string.localizable.aWalletTokenRedeemShowQRCodeTitle()

@ -14,7 +14,6 @@ enum RestError: Error {
} }
struct RestClient { struct RestClient {
static func get(endPoint: String, static func get(endPoint: String,
parameters: [String: AnyHashable]? = nil, parameters: [String: AnyHashable]? = nil,
completion: @escaping (_ response: DataResponse<Any>) -> Void) { completion: @escaping (_ response: DataResponse<Any>) -> Void) {

@ -9,29 +9,22 @@ protocol EnterSellTokensCardPriceQuantityViewControllerDelegate: class, CanOpenU
} }
class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVerifiableStatusViewController { class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVerifiableStatusViewController {
private let storage: TokensDataStore
let config: Config private let roundedBackground = RoundedBackground()
var contract: String { private let scrollView = UIScrollView()
return viewModel.token.contract private let header = TokensCardViewControllerTitleHeader()
} private let pricePerTokenLabel = UILabel()
let storage: TokensDataStore private let quantityLabel = UILabel()
let roundedBackground = RoundedBackground() private let quantityStepper = NumberStepper()
let scrollView = UIScrollView() private let ethCostLabelLabel = UILabel()
let header = TokensCardViewControllerTitleHeader() private let ethCostLabel = UILabel()
let pricePerTokenLabel = UILabel() private let dollarCostLabelLabel = UILabel()
let pricePerTokenField = AmountTextField() private let dollarCostLabel = PaddedLabel()
let quantityLabel = UILabel() private let tokenRowView: TokenRowView & UIView
let quantityStepper = NumberStepper() private let nextButton = UIButton(type: .system)
let ethCostLabelLabel = UILabel() private var viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel
let ethCostLabel = UILabel() private let ethPrice: Subscribable<Double>
let dollarCostLabelLabel = UILabel() private var totalEthCost: Ether {
let dollarCostLabel = PaddedLabel()
let tokenRowView: TokenRowView & UIView
let nextButton = UIButton(type: .system)
var viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel
let paymentFlow: PaymentFlow
let ethPrice: Subscribable<Double>
var totalEthCost: Ether {
if let ethCostPerToken = Ether(string: pricePerTokenField.ethCost) { if let ethCostPerToken = Ether(string: pricePerTokenField.ethCost) {
let quantity = Int(quantityStepper.value) let quantity = Int(quantityStepper.value)
return ethCostPerToken * quantity return ethCostPerToken * quantity
@ -40,7 +33,7 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
} }
} }
var totalDollarCost: String { private var totalDollarCost: String {
if let dollarCostPerToken = Double(pricePerTokenField.dollarCost) { if let dollarCostPerToken = Double(pricePerTokenField.dollarCost) {
let quantity = Double(quantityStepper.value) let quantity = Double(quantityStepper.value)
return StringFormatter().currency(with: dollarCostPerToken * quantity, and: "USD") return StringFormatter().currency(with: dollarCostPerToken * quantity, and: "USD")
@ -48,6 +41,13 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer
return "" return ""
} }
} }
let config: Config
var contract: String {
return viewModel.token.contract
}
let pricePerTokenField = AmountTextField()
let paymentFlow: PaymentFlow
weak var delegate: EnterSellTokensCardPriceQuantityViewControllerDelegate? weak var delegate: EnterSellTokensCardPriceQuantityViewControllerDelegate?
init( init(

@ -9,22 +9,23 @@ protocol GenerateSellMagicLinkViewControllerDelegate: class {
} }
class GenerateSellMagicLinkViewController: UIViewController { class GenerateSellMagicLinkViewController: UIViewController {
private let background = UIView()
private let header = TokensCardViewControllerTitleHeader()
private let detailsBackground = UIView()
private let subtitleLabel = UILabel()
private let tokenCountLabel = UILabel()
private let perTokenPriceLabel = UILabel()
private let totalEthLabel = UILabel()
private let descriptionLabel = UILabel()
private let actionButton = UIButton()
private let cancelButton = UIButton()
private var viewModel: GenerateSellMagicLinkViewControllerViewModel?
weak var delegate: GenerateSellMagicLinkViewControllerDelegate? weak var delegate: GenerateSellMagicLinkViewControllerDelegate?
let background = UIView()
let header = TokensCardViewControllerTitleHeader()
let detailsBackground = UIView()
let subtitleLabel = UILabel()
let tokenCountLabel = UILabel()
let perTokenPriceLabel = UILabel()
let totalEthLabel = UILabel()
let descriptionLabel = UILabel()
let actionButton = UIButton()
let cancelButton = UIButton()
let paymentFlow: PaymentFlow let paymentFlow: PaymentFlow
let tokenHolder: TokenHolder let tokenHolder: TokenHolder
let ethCost: Ether let ethCost: Ether
let linkExpiryDate: Date let linkExpiryDate: Date
var viewModel: GenerateSellMagicLinkViewControllerViewModel?
init(paymentFlow: PaymentFlow, tokenHolder: TokenHolder, ethCost: Ether, linkExpiryDate: Date) { init(paymentFlow: PaymentFlow, tokenHolder: TokenHolder, ethCost: Ether, linkExpiryDate: Date) {
self.paymentFlow = paymentFlow self.paymentFlow = paymentFlow

@ -9,16 +9,16 @@ protocol SellTokensCardViewControllerDelegate: class, CanOpenURL {
} }
class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewController { class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewController {
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private let nextButton = UIButton(type: .system)
private var viewModel: SellTokensCardViewModel
let config: Config let config: Config
var contract: String { var contract: String {
return viewModel.token.contract return viewModel.token.contract
} }
let roundedBackground = RoundedBackground()
let header = TokensCardViewControllerTitleHeader()
let tableView = UITableView(frame: .zero, style: .plain)
let nextButton = UIButton(type: .system)
var viewModel: SellTokensCardViewModel
let paymentFlow: PaymentFlow let paymentFlow: PaymentFlow
weak var delegate: SellTokensCardViewControllerDelegate? weak var delegate: SellTokensCardViewControllerDelegate?

@ -8,34 +8,34 @@ protocol SetSellTokensCardExpiryDateViewControllerDelegate: class, CanOpenURL {
} }
class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiableStatusViewController { class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiableStatusViewController {
private let storage: TokensDataStore
private let roundedBackground = RoundedBackground()
private let scrollView = UIScrollView()
private let header = TokensCardViewControllerTitleHeader()
private let linkExpiryDateLabel = UILabel()
private let linkExpiryDateField = DateEntryField()
private let linkExpiryTimeLabel = UILabel()
private let linkExpiryTimeField = TimeEntryField()
private let tokenCountLabel = UILabel()
private let perTokenPriceLabel = UILabel()
private let totalEthLabel = UILabel()
private let descriptionLabel = UILabel()
private let noteTitleLabel = UILabel()
private let noteLabel = UILabel()
private let noteBorderView = UIView()
private let tokenRowView: TokenRowView & UIView
private let nextButton = UIButton(type: .system)
private let datePicker = UIDatePicker()
private let timePicker = UIDatePicker()
private var viewModel: SetSellTokensCardExpiryDateViewControllerViewModel
private let tokenHolder: TokenHolder
private let ethCost: Ether
let config: Config let config: Config
var contract: String { var contract: String {
return viewModel.token.contract return viewModel.token.contract
} }
let storage: TokensDataStore
let roundedBackground = RoundedBackground()
let scrollView = UIScrollView()
let header = TokensCardViewControllerTitleHeader()
let linkExpiryDateLabel = UILabel()
let linkExpiryDateField = DateEntryField()
let linkExpiryTimeLabel = UILabel()
let linkExpiryTimeField = TimeEntryField()
let tokenCountLabel = UILabel()
let perTokenPriceLabel = UILabel()
let totalEthLabel = UILabel()
let descriptionLabel = UILabel()
let noteTitleLabel = UILabel()
let noteLabel = UILabel()
let noteBorderView = UIView()
let tokenRowView: TokenRowView & UIView
let nextButton = UIButton(type: .system)
let datePicker = UIDatePicker()
let timePicker = UIDatePicker()
var viewModel: SetSellTokensCardExpiryDateViewControllerViewModel
let paymentFlow: PaymentFlow let paymentFlow: PaymentFlow
let tokenHolder: TokenHolder
let ethCost: Ether
weak var delegate: SetSellTokensCardExpiryDateViewControllerDelegate? weak var delegate: SetSellTokensCardExpiryDateViewControllerDelegate?
init( init(

@ -4,9 +4,8 @@ import Foundation
import UIKit import UIKit
struct EnterSellTokensCardPriceQuantityViewControllerViewModel { struct EnterSellTokensCardPriceQuantityViewControllerViewModel {
let token: TokenObject
var token: TokenObject let tokenHolder: TokenHolder
var tokenHolder: TokenHolder
var ethCost: Ether = .zero var ethCost: Ether = .zero
var dollarCost: String = "" var dollarCost: String = ""

@ -3,9 +3,9 @@
import UIKit import UIKit
struct GenerateSellMagicLinkViewControllerViewModel { struct GenerateSellMagicLinkViewControllerViewModel {
let tokenHolder: TokenHolder private let tokenHolder: TokenHolder
let ethCost: Ether private let ethCost: Ether
let linkExpiryDate: Date private let linkExpiryDate: Date
var contentsBackgroundColor: UIColor { var contentsBackgroundColor: UIColor {
return Colors.appWhite return Colors.appWhite

@ -3,8 +3,8 @@
import UIKit import UIKit
struct GenerateTransferMagicLinkViewControllerViewModel { struct GenerateTransferMagicLinkViewControllerViewModel {
var tokenHolder: TokenHolder private let tokenHolder: TokenHolder
var linkExpiryDate: Date private let linkExpiryDate: Date
var contentsBackgroundColor: UIColor { var contentsBackgroundColor: UIColor {
return Colors.appWhite return Colors.appWhite

@ -4,9 +4,8 @@ import Foundation
import UIKit import UIKit
struct SellTokensCardViewModel { struct SellTokensCardViewModel {
let token: TokenObject
var token: TokenObject let tokenHolders: [TokenHolder]
var tokenHolders: [TokenHolder]
init(token: TokenObject) { init(token: TokenObject) {
self.token = token self.token = token

@ -4,10 +4,10 @@ import Foundation
import UIKit import UIKit
struct SetSellTokensCardExpiryDateViewControllerViewModel { struct SetSellTokensCardExpiryDateViewControllerViewModel {
private let ethCost: Ether
var token: TokenObject let token: TokenObject
var tokenHolder: TokenHolder let tokenHolder: TokenHolder
var ethCost: Ether = .zero
var headerTitle: String { var headerTitle: String {
return R.string.localizable.aWalletTokenSellEnterLinkExpiryDateTitle() return R.string.localizable.aWalletTokenSellEnterLinkExpiryDateTitle()

@ -7,7 +7,8 @@ protocol DateEntryFieldDelegate: class {
} }
class DateEntryField: UIControl { class DateEntryField: UIControl {
var leftButton = UIButton(type: .custom) private let leftButton = UIButton(type: .custom)
var value = Date() { var value = Date() {
didSet { didSet {
displayDateString() displayDateString()

@ -7,7 +7,8 @@ protocol TimeEntryFieldDelegate: class {
} }
class TimeEntryField: UIControl { class TimeEntryField: UIControl {
var leftButton = UIButton(type: .custom) private let leftButton = UIButton(type: .custom)
var value = Date() { var value = Date() {
didSet { didSet {
displayTimeString() displayTimeString()

@ -9,11 +9,9 @@ protocol AddCustomNetworkCoordinatorDelegate: class {
} }
class AddCustomNetworkCoordinator: Coordinator { class AddCustomNetworkCoordinator: Coordinator {
let navigationController: UINavigationController private let navigationController: UINavigationController
var coordinators: [Coordinator] = []
weak var delegate: AddCustomNetworkCoordinatorDelegate?
lazy var addNetworkItem: UIBarButtonItem = { private lazy var addNetworkItem: UIBarButtonItem = {
return UIBarButtonItem( return UIBarButtonItem(
barButtonSystemItem: .add, barButtonSystemItem: .add,
target: self, target: self,
@ -21,12 +19,15 @@ class AddCustomNetworkCoordinator: Coordinator {
) )
}() }()
lazy var addCustomNetworkController: AddCustomNetworkViewController = { private lazy var addCustomNetworkController: AddCustomNetworkViewController = {
let controller = AddCustomNetworkViewController() let controller = AddCustomNetworkViewController()
controller.navigationItem.rightBarButtonItem = addNetworkItem controller.navigationItem.rightBarButtonItem = addNetworkItem
return controller return controller
}() }()
var coordinators: [Coordinator] = []
weak var delegate: AddCustomNetworkCoordinatorDelegate?
init( init(
navigationController: UINavigationController = NavigationController() navigationController: UINavigationController = NavigationController()
) { ) {

@ -4,12 +4,12 @@ import UIKit
import StoreKit import StoreKit
class HelpUsCoordinator: Coordinator { class HelpUsCoordinator: Coordinator {
private let navigationController: UINavigationController
private let appTracker: AppTracker
private let viewModel = HelpUsViewModel()
let navigationController: UINavigationController
let appTracker: AppTracker
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
private let viewModel = HelpUsViewModel()
init( init(
navigationController: UINavigationController = NavigationController(), navigationController: UINavigationController = NavigationController(),
appTracker: AppTracker = AppTracker() appTracker: AppTracker = AppTracker()

@ -7,8 +7,9 @@ protocol LocalesCoordinatorDelegate: class {
} }
class LocalesCoordinator: Coordinator { class LocalesCoordinator: Coordinator {
private var config: Config
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
var config: Config
lazy var localesViewController: LocalesViewController = { lazy var localesViewController: LocalesViewController = {
let locales: [AppLocale] = [ let locales: [AppLocale] = [

@ -7,8 +7,9 @@ protocol ServersCoordinatorDelegate: class {
} }
class ServersCoordinator: Coordinator { class ServersCoordinator: Coordinator {
private var config: Config
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []
var config: Config
lazy var serversViewController: ServersViewController = { lazy var serversViewController: ServersViewController = {
let servers: [RPCServer] = { let servers: [RPCServer] = {

@ -14,12 +14,12 @@ protocol SettingsCoordinatorDelegate: class, CanOpenURL {
} }
class SettingsCoordinator: Coordinator { class SettingsCoordinator: Coordinator {
private let keystore: Keystore
private let session: WalletSession
private let storage: TransactionsStorage
private let balanceCoordinator: GetBalanceCoordinator
let navigationController: UINavigationController let navigationController: UINavigationController
let keystore: Keystore
let session: WalletSession
let storage: TransactionsStorage
let balanceCoordinator: GetBalanceCoordinator
weak var delegate: SettingsCoordinatorDelegate? weak var delegate: SettingsCoordinatorDelegate?
var coordinators: [Coordinator] = [] var coordinators: [Coordinator] = []

@ -5,7 +5,6 @@ import ObjectiveC
import TrustKeystore import TrustKeystore
struct Config { struct Config {
struct Keys { struct Keys {
static let chainID = "chainID" static let chainID = "chainID"
static let isCryptoPrimaryCurrency = "isCryptoPrimaryCurrency" static let isCryptoPrimaryCurrency = "isCryptoPrimaryCurrency"

@ -3,8 +3,7 @@
import Foundation import Foundation
struct ConfigExplorer { struct ConfigExplorer {
private let server: RPCServer
let server: RPCServer
init( init(
server: RPCServer server: RPCServer

@ -5,8 +5,7 @@ import Eureka
import Result import Result
class AddCustomNetworkViewController: FormViewController { class AddCustomNetworkViewController: FormViewController {
private let viewModel = AddCustomNetworkViewModel()
let viewModel = AddCustomNetworkViewModel()
private struct Values { private struct Values {
static let chainID = "chainID" static let chainID = "chainID"
@ -15,8 +14,6 @@ class AddCustomNetworkViewController: FormViewController {
static let endpoint = "endpoint" static let endpoint = "endpoint"
} }
weak var delegate: NewTokenViewControllerDelegate?
private var chainIDRow: TextFloatLabelRow? { private var chainIDRow: TextFloatLabelRow? {
return form.rowBy(tag: Values.chainID) as? TextFloatLabelRow return form.rowBy(tag: Values.chainID) as? TextFloatLabelRow
} }
@ -30,6 +27,8 @@ class AddCustomNetworkViewController: FormViewController {
return form.rowBy(tag: Values.endpoint) as? TextFloatLabelRow return form.rowBy(tag: Values.endpoint) as? TextFloatLabelRow
} }
weak var delegate: NewTokenViewControllerDelegate?
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()

@ -8,12 +8,13 @@ protocol LocalesViewControllerDelegate: class {
} }
class LocalesViewController: UIViewController { class LocalesViewController: UIViewController {
let headerHeight = CGFloat(70) private let headerHeight = CGFloat(70)
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private var viewModel: LocalesViewModel?
weak var delegate: LocalesViewControllerDelegate? weak var delegate: LocalesViewControllerDelegate?
let roundedBackground = RoundedBackground()
let header = TokensCardViewControllerTitleHeader()
let tableView = UITableView(frame: .zero, style: .plain)
var viewModel: LocalesViewModel?
init() { init() {
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)

@ -3,8 +3,7 @@
import Foundation import Foundation
final class PreferencesController { final class PreferencesController {
private let userDefaults: UserDefaults
let userDefaults: UserDefaults
init( init(
userDefaults: UserDefaults = .standard userDefaults: UserDefaults = .standard

@ -8,12 +8,13 @@ protocol ServersViewControllerDelegate: class {
} }
class ServersViewController: UIViewController { class ServersViewController: UIViewController {
let headerHeight = CGFloat(70) private let headerHeight = CGFloat(70)
private let roundedBackground = RoundedBackground()
private let header = TokensCardViewControllerTitleHeader()
private let tableView = UITableView(frame: .zero, style: .plain)
private var viewModel: ServersViewModel?
weak var delegate: ServersViewControllerDelegate? weak var delegate: ServersViewControllerDelegate?
let roundedBackground = RoundedBackground()
let header = TokensCardViewControllerTitleHeader()
let tableView = UITableView(frame: .zero, style: .plain)
var viewModel: ServersViewModel?
init() { init() {
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)

@ -12,15 +12,17 @@ protocol SettingsViewControllerDelegate: class, CanOpenURL {
} }
class SettingsViewController: FormViewController { class SettingsViewController: FormViewController {
private var lock = Lock() private let lock = Lock()
weak var delegate: SettingsViewControllerDelegate? private var isPasscodeEnabled: Bool {
var isPasscodeEnabled: Bool {
return lock.isPasscodeSet() return lock.isPasscodeSet()
} }
lazy var viewModel: SettingsViewModel = { private lazy var viewModel: SettingsViewModel = {
return SettingsViewModel(isDebug: isDebug) return SettingsViewModel(isDebug: isDebug)
}() }()
let session: WalletSession private let session: WalletSession
weak var delegate: SettingsViewControllerDelegate?
init(session: WalletSession) { init(session: WalletSession) {
self.session = session self.session = session
super.init(style: .plain) super.init(style: .plain)

@ -10,7 +10,6 @@ protocol WellDoneViewControllerDelegate: class {
} }
class WellDoneViewController: UIViewController { class WellDoneViewController: UIViewController {
weak var delegate: WellDoneViewControllerDelegate? weak var delegate: WellDoneViewControllerDelegate?
override func viewDidLoad() { override func viewDidLoad() {

@ -3,7 +3,6 @@
import Foundation import Foundation
struct AddCustomNetworkViewModel { struct AddCustomNetworkViewModel {
var title: String { var title: String {
return R.string.localizable.settingsCustomNetworkNavigationTitle() return R.string.localizable.settingsCustomNetworkNavigationTitle()
} }

@ -3,7 +3,6 @@ import Foundation
import UIKit import UIKit
struct HelpUsViewModel { struct HelpUsViewModel {
var title: String { var title: String {
return R.string.localizable.welldoneNavigationTitle() return R.string.localizable.welldoneNavigationTitle()
} }

@ -4,8 +4,8 @@ import Foundation
import UIKit import UIKit
struct LocaleViewModel { struct LocaleViewModel {
let locale: AppLocale private let locale: AppLocale
let isSelected: Bool private let isSelected: Bool
init(locale: AppLocale, selected: Bool) { init(locale: AppLocale, selected: Bool) {
self.locale = locale self.locale = locale

@ -4,8 +4,8 @@ import Foundation
import UIKit import UIKit
struct ServerViewModel { struct ServerViewModel {
let server: RPCServer private let server: RPCServer
let isSelected: Bool private let isSelected: Bool
init(server: RPCServer, selected: Bool) { init(server: RPCServer, selected: Bool) {
self.server = server self.server = server

@ -4,8 +4,9 @@ import Foundation
import TrustKeystore import TrustKeystore
struct ServersViewModel { struct ServersViewModel {
private let selectedServer: RPCServer
let servers: [RPCServer] let servers: [RPCServer]
let selectedServer: RPCServer
var title: String { var title: String {
return R.string.localizable.settingsNetworkButtonTitle() return R.string.localizable.settingsNetworkButtonTitle()

@ -3,7 +3,6 @@
import Foundation import Foundation
struct SettingsViewModel { struct SettingsViewModel {
private let isDebug: Bool private let isDebug: Bool
init( init(
@ -12,23 +11,6 @@ struct SettingsViewModel {
self.isDebug = isDebug self.isDebug = isDebug
} }
var servers: [RPCServer] {
return [
RPCServer.main,
RPCServer.classic,
RPCServer.poa,
// RPCServer.callisto, TODO: Enable.
RPCServer.kovan,
RPCServer.ropsten,
RPCServer.rinkeby,
RPCServer.sokol,
]
}
var currency: [Currency] {
return Currency.allValues.map { $0 }
}
var passcodeTitle: String { var passcodeTitle: String {
switch BiometryAuthenticationType.current { switch BiometryAuthenticationType.current {
case .faceID, .touchID: case .faceID, .touchID:

@ -17,8 +17,8 @@ open class _AlphaWalletSettingsSwitchRow: Row<AlphaWalletSwitchCell> {
} }
open class AlphaWalletSwitchCell: Cell<Bool>, CellType { open class AlphaWalletSwitchCell: Cell<Bool>, CellType {
private let background = UIView()
let background = UIView()
@IBOutlet public weak var switchControl: UISwitch! @IBOutlet public weak var switchControl: UISwitch!
required public init(style: UITableViewCellStyle, reuseIdentifier: String?) { required public init(style: UITableViewCellStyle, reuseIdentifier: String?) {

@ -16,7 +16,8 @@ open class _TextRow: FieldRow<AlphaWalletSettingsTextCell> {
} }
open class AlphaWalletSettingsTextCell: _FieldCell<String>, CellType { open class AlphaWalletSettingsTextCell: _FieldCell<String>, CellType {
let background = UIView() private let background = UIView()
let mainLabel = UILabel() let mainLabel = UILabel()
let subLabel = UILabel() let subLabel = UILabel()

@ -6,9 +6,9 @@ import UIKit
class LocaleViewCell: UITableViewCell { class LocaleViewCell: UITableViewCell {
static let identifier = "LocaleViewCell" static let identifier = "LocaleViewCell"
let background = UIView() private let background = UIView()
var selectedIcon = UIImageView(image: R.image.ticket_bundle_checked()) private let selectedIcon = UIImageView(image: R.image.ticket_bundle_checked())
var nameLabel = UILabel() private let nameLabel = UILabel()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)

@ -6,9 +6,9 @@ import UIKit
class ServerViewCell: UITableViewCell { class ServerViewCell: UITableViewCell {
static let identifier = "ServerViewCell" static let identifier = "ServerViewCell"
let background = UIView() private let background = UIView()
var selectedIcon = UIImageView(image: R.image.ticket_bundle_checked()) private let selectedIcon = UIImageView(image: R.image.ticket_bundle_checked())
var nameLabel = UILabel() private let nameLabel = UILabel()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) { override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)

@ -16,9 +16,7 @@ import Result
class ClaimOrderCoordinator { class ClaimOrderCoordinator {
private let web3: Web3Swift private let web3: Web3Swift
init( init(web3: Web3Swift) {
web3: Web3Swift
) {
self.web3 = web3 self.web3 = web3
} }

@ -9,7 +9,6 @@ import TrustKeystore
import web3swift import web3swift
class GetBalanceCoordinator { class GetBalanceCoordinator {
private let config: Config private let config: Config
init(config: Config) { init(config: Config) {

@ -6,7 +6,6 @@ import TrustKeystore
import web3swift import web3swift
class GetDecimalsCoordinator { class GetDecimalsCoordinator {
private let config: Config private let config: Config
init(config: Config) { init(config: Config) {

@ -6,7 +6,6 @@ import TrustKeystore
import web3swift import web3swift
class GetNameCoordinator { class GetNameCoordinator {
private let config: Config private let config: Config
init(config: Config) { init(config: Config) {

@ -6,7 +6,6 @@ import TrustKeystore
import web3swift import web3swift
class GetSymbolCoordinator { class GetSymbolCoordinator {
private let config: Config private let config: Config
init(config: Config) { init(config: Config) {

@ -24,15 +24,12 @@ private enum ContractData {
} }
class TokensCoordinator: Coordinator { class TokensCoordinator: Coordinator {
private let session: WalletSession
let navigationController: UINavigationController private let keystore: Keystore
let session: WalletSession private let storage: TokensDataStore
let keystore: Keystore
var coordinators: [Coordinator] = []
let storage: TokensDataStore
private let assetDefinitionStore: AssetDefinitionStore private let assetDefinitionStore: AssetDefinitionStore
lazy var tokensViewController: TokensViewController = { private lazy var tokensViewController: TokensViewController = {
let controller = TokensViewController( let controller = TokensViewController(
session: session, session: session,
account: session.account, account: session.account,
@ -41,6 +38,9 @@ class TokensCoordinator: Coordinator {
controller.delegate = self controller.delegate = self
return controller return controller
}() }()
let navigationController: UINavigationController
var coordinators: [Coordinator] = []
weak var delegate: TokensCoordinatorDelegate? weak var delegate: TokensCoordinatorDelegate?
lazy var rootViewController: TokensViewController = { lazy var rootViewController: TokensViewController = {

@ -11,7 +11,8 @@ import RealmSwift
import BigInt import BigInt
class TokenAdaptor { class TokenAdaptor {
var token: TokenObject private let token: TokenObject
init(token: TokenObject) { init(token: TokenObject) {
self.token = token self.token = token
} }

@ -16,8 +16,8 @@ struct Token {
let id: BigUInt let id: BigUInt
let index: UInt16 let index: UInt16
var name: String let name: String
var status: Status let status: Status
let values: [String: AssetAttributeValue] let values: [String: AssetAttributeValue]
static var empty: Token { static var empty: Token {

@ -5,7 +5,6 @@ import RealmSwift
import BigInt import BigInt
class TokenBalance: Object { class TokenBalance: Object {
@objc dynamic var balance = "0" @objc dynamic var balance = "0"
convenience init(balance: String = "0") { convenience init(balance: String = "0") {

@ -9,14 +9,12 @@
import Foundation import Foundation
class TokenHolder { class TokenHolder {
var tokens: [Token] let tokens: [Token]
var name: String { return tokens[0].name } let contractAddress: String
var values: [String: AssetAttributeValue] { return tokens[0].values } let hasAssetDefinition: Bool
var status: Token.Status { return tokens[0].status }
var isSelected = false var isSelected = false
var areDetailsVisible = false var areDetailsVisible = false
var contractAddress: String
var hasAssetDefinition: Bool
init(tokens: [Token], contractAddress: String, hasAssetDefinition: Bool) { init(tokens: [Token], contractAddress: String, hasAssetDefinition: Bool) {
self.tokens = tokens self.tokens = tokens
@ -31,4 +29,16 @@ class TokenHolder {
var indices: [UInt16] { var indices: [UInt16] {
return tokens.map { $0.index } return tokens.map { $0.index }
} }
var name: String {
return tokens[0].name
}
var values: [String: AssetAttributeValue] {
return tokens[0].values
}
var status: Token.Status {
return tokens[0].status
}
} }

@ -12,11 +12,14 @@ class TokenObject: Object {
@objc dynamic var decimals: Int = 0 @objc dynamic var decimals: Int = 0
@objc dynamic var value: String = "" @objc dynamic var value: String = ""
@objc dynamic var isDisabled: Bool = false @objc dynamic var isDisabled: Bool = false
var balance = List<TokenBalance>() @objc dynamic var rawType: String = TokenType.erc20.rawValue
let balance = List<TokenBalance>()
var nonZeroBalance: [TokenBalance] { var nonZeroBalance: [TokenBalance] {
return Array(balance.filter { isNonZeroBalance($0.balance) }) return Array(balance.filter { isNonZeroBalance($0.balance) })
} }
@objc dynamic var rawType: String = TokenType.erc20.rawValue
var type: TokenType { var type: TokenType {
get { get {
return TokenType(rawValue: rawType)! return TokenType(rawValue: rawType)!

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save