Skip to content

Commit

Permalink
Check if service is even set for migration
Browse files Browse the repository at this point in the history
  • Loading branch information
SwenVanZanten committed Nov 9, 2019
1 parent 59c0e4a commit 2b548f8
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ github "xmartlabs/Eureka" ~> 4.3
github "krzyzanowskim/CryptoSwift"
github "vergecurrency/BitcoinKit" ~> 1.2.0
github "Swinject/Swinject" ~> 2.6.0
github "Swinject/SwinjectStoryboard"
github "Swinject/SwinjectStoryboard" "master"
github "google/promises"
8 changes: 4 additions & 4 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
binary "https://icepa.github.io/Tor.framework/Tor.json" "305.8.1"
github "HamzaGhazouani/HGPlaceholders" "0.4.0"
github "JohnEstropia/CoreStore" "6.3.2"
github "JohnEstropia/CoreStore" "7.0.1"
github "SwiftyJSON/SwiftyJSON" "5.0.0"
github "Swinject/Swinject" "2.7.1"
github "Swinject/SwinjectStoryboard" "2.2.0"
github "danielgindi/Charts" "v3.3.0"
github "Swinject/SwinjectStoryboard" "0ca45c83a8aa398c153d8a036c95abb4343cfa0c"
github "danielgindi/Charts" "v3.4.0"
github "evgenyneu/keychain-swift" "11.0.0"
github "gmotzespina/QRCode" "c07e17120ffb34fdfa7ec1f3a85bc1afd39cfdc2"
github "google/promises" "1.2.8"
github "hackiftekhar/IQKeyboardManager" "v6.1.1"
github "krzyzanowskim/CryptoSwift" "1.0.0"
github "krzyzanowskim/CryptoSwift" "1.1.3"
github "vergecurrency/BitcoinKit" "v1.2.1"
github "xmartlabs/Eureka" "4.3.1"
8 changes: 4 additions & 4 deletions VergeiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2470,8 +2470,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CF_BUNDLE_BUILD_VERSION_STRING = 201909300001;
CF_BUNDLE_SHORT_VERSION_STRING = 1.2.1;
CF_BUNDLE_BUILD_VERSION_STRING = 201911060001;
CF_BUNDLE_SHORT_VERSION_STRING = 1.2.2;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -2534,8 +2534,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CF_BUNDLE_BUILD_VERSION_STRING = 201909300001;
CF_BUNDLE_SHORT_VERSION_STRING = 1.2.1;
CF_BUNDLE_BUILD_VERSION_STRING = 201911060001;
CF_BUNDLE_SHORT_VERSION_STRING = 1.2.2;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down
1 change: 1 addition & 0 deletions VergeiOS/Extensions/Notification+Names.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension Notification.Name {
static let didChangeWalletAmount = Notification.Name("didChangeWalletAmount")
static let didChangeReceiveAddress = Notification.Name("didChangeReceiveAddress")

static let didFinishTorStart = Notification.Name("didFinishTorStart")
static let didStartTorThread = Notification.Name("didStartTorThread")
static let didConnectTorController = Notification.Name("didConnectTorController")
static let didEstablishTorConnection = Notification.Name("didEstablishTorConnection")
Expand Down
8 changes: 7 additions & 1 deletion VergeiOS/Http/TorClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class TorClient {
func start(completion: @escaping () -> Void) {
// If already operational don't start a new client.
if isOperational || turnedOff() {
NotificationCenter.default.post(name: .didFinishTorStart, object: self)
print("hierroeroero")
return completion()
}

Expand All @@ -79,7 +81,11 @@ class TorClient {

DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
// Connect Tor controller.
self.connectController(completion: completion)
self.connectController {
NotificationCenter.default.post(name: .didFinishTorStart, object: self)

completion()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion VergeiOS/Providers/CoreStoreServiceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CoreStoreServiceProvider: ServiceProvider {

override func boot() {
do {
CoreStore.defaultStack = DataStack(
CoreStoreDefaults.dataStack = DataStack(
xcodeModelName: "CoreData",
bundle: Bundle.main,
migrationChain: [
Expand Down
6 changes: 2 additions & 4 deletions VergeiOS/Providers/WalletServiceProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ class WalletServiceProvider: ServiceProvider {
self.registerAddressBookRepository()
self.registerSweeperHelper()
self.registerWalletManager()
}

override func boot() {
NotificationCenter.default.addObserver(
self,
selector: #selector(bootServerMigration(notification:)),
name: .didEstablishTorConnection,
name: .didFinishTorStart,
object: nil
)
}
Expand Down Expand Up @@ -141,7 +139,7 @@ class WalletServiceProvider: ServiceProvider {
let applicationRepository = self.container.resolve(ApplicationRepository.self)!

// Check if the deprecated VWS endpoints are in the users memory.
if !Constants.deprecatedBwsEndpoints.contains(applicationRepository.walletServiceUrl) {
if applicationRepository.isWalletServiceUrlSet && !Constants.deprecatedBwsEndpoints.contains(applicationRepository.walletServiceUrl) {
return print("No deprecated VWS endpoints found.")
}

Expand Down
10 changes: 9 additions & 1 deletion VergeiOS/Repositories/ApplicationRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApplicationRepository {

// Is the wallet already setup?
var setup: Bool {
return self.mnemonic?.count == 12 && (self.passphrase?.count ?? 0) > 7
return self.mnemonic?.count == 12 && (self.passphrase?.count ?? 0) > 7 && self.pin != ""
}

// Store the wallet pin in the app key chain.
Expand All @@ -31,6 +31,10 @@ class ApplicationRepository {

var pinCount: Int {
get {
if self.pin.count > 0 {
self.pinCount = self.pin.count
}

userDefaults.register(defaults: ["wallet.pinCount": 6])
return userDefaults.integer(forKey: "wallet.pinCount")
}
Expand Down Expand Up @@ -143,6 +147,10 @@ class ApplicationRepository {
}
}

var isWalletServiceUrlSet: Bool {
return !(keychain.get("wallet.service.url")?.isEmpty ?? true)
}

var walletId: String? {
get {
return keychain.get("wallet.id")
Expand Down
4 changes: 4 additions & 0 deletions VergeiOS/Wallet/WalletClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ extension WalletClient {
}

print(jsonResponse)

if jsonResponse["code"].stringValue == "WALLET_NOT_FOUND" {
return completion(NSError(domain: "Wallet not found", code: 404, userInfo: nil))
}

if jsonResponse["code"].stringValue == "COPAYER_REGISTERED" {
self.openWallet { error in
Expand Down

0 comments on commit 2b548f8

Please sign in to comment.