Skip to content

Commit

Permalink
restore wallet; forgot password; ui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisDemyanko committed Apr 9, 2019
1 parent a3a83e6 commit 60094e6
Show file tree
Hide file tree
Showing 109 changed files with 4,381 additions and 428 deletions.
214 changes: 197 additions & 17 deletions BeamWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

32 changes: 25 additions & 7 deletions BeamWallet/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//
// AppDelegate.swift
// BeamWallet
// AppDelegate.swift
// BeamWallet
//
// 2/28/19.
// Copyright 2018 Beam Development
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,6 +24,9 @@ import Crashlytics
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var securityScreen = AutoSecurityScreen()
var lockScreen = LockScreen()

var window: UIWindow?
var backgroundTask: UIBackgroundTaskIdentifier = .invalid
var completionHandler: ((UIBackgroundFetchResult) -> Void)?
Expand All @@ -47,7 +49,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {


UIApplication.shared.setMinimumBackgroundFetchInterval (UIApplication.backgroundFetchIntervalMinimum)

UIApplication.shared.isIdleTimerDisabled = true

Crashlytics().debugMode = true
Fabric.with([Crashlytics.self()])
Expand All @@ -70,6 +75,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self.window!.rootViewController = rootController
self.window!.makeKeyAndVisible()

UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = UIColor.main.marineTwo

return true
}
Expand All @@ -78,9 +84,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func applicationDidEnterBackground(_ application: UIApplication) {

if AppModel.sharedManager().isRestoreFlow {
registerBackgroundTask()
}
}

func applicationWillEnterForeground(_ application: UIApplication) {
if AppModel.sharedManager().isRestoreFlow {
endBackgroundTask()
}
}

func applicationDidBecomeActive(_ application: UIApplication) {
Expand All @@ -104,22 +117,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

if let password = KeychainManager.getPassword() {
if(!AppModel.sharedManager().isRestoreFlow) {
// if let password = KeychainManager.getPassword() {
self.completionHandler = completionHandler

self.registerBackgroundTask()

if(AppModel.sharedManager().isLoggedin) {
AppModel.sharedManager().refreshAllInfo()
}
else{
AppModel.sharedManager().openWallet(password)
}
// else{
// AppModel.sharedManager().openWallet(password)
// }

DispatchQueue.main.asyncAfter(deadline: .now() + 26) {
self.endBackgroundTask()
self.completionHandler?(.newData)
}
// }
}
else{
completionHandler(.noData)
}
}
}
Expand Down
34 changes: 31 additions & 3 deletions BeamWallet/BeamSDK/AppModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#import "BMAddress.h"
#import "BMTransaction.h"
#import "BMUTXO.h"
#import "BMContact.h"
#import "BMPaymentProof.h"
#import "Settings.h"

@protocol WalletModelDelegate <NSObject>
@optional
Expand All @@ -37,6 +40,9 @@
-(void)onSendMoneyVerified;
-(void)onCantSendToExpired;
-(void)onReceivedUTXOs:(NSArray<BMUTXO*>*_Nonnull)utxos;
-(void)onContactsChange:(NSArray<BMContact*>*_Nonnull)contacts;
-(void)onReceivePaymentProof:(BMPaymentProof*_Nonnull)proof;
-(void)onLocalNodeStarted;
@end

@interface AppModel : NSObject
Expand All @@ -48,50 +54,72 @@
@property (nonatomic,assign) BOOL isUpdating;
@property (nonatomic,assign) BOOL isConnecting;
@property (nonatomic,assign) BOOL isLoggedin;
@property (nonatomic,assign) BOOL isLocalNodeStarted;
@property (nonatomic,assign) BOOL isRestoreFlow;
@property (nonatomic,assign) BOOL isForgotPasswordFlow;

@property (nonatomic,strong) BMWalletStatus* _Nullable walletStatus;
@property (nonatomic,strong) BMAddress* _Nullable walletAddress;
@property (nonatomic,strong) NSMutableArray<BMTransaction*>*_Nullable transactions;
@property (nonatomic,strong) NSMutableArray<BMUTXO*>*_Nullable utxos;
@property (nonatomic,strong) NSMutableArray<BMAddress*>*_Nullable walletAddresses;
@property (nonatomic,strong) NSMutableArray<BMContact*>*_Nonnull contacts;

+(AppModel*_Nonnull)sharedManager;

// delegates
-(void)addDelegate:(id<WalletModelDelegate>_Nullable) delegate;
-(void)removeDelegate:(id<WalletModelDelegate>_Nullable) delegate;

// create, open
-(BOOL)canRestoreWallet;
-(BOOL)isWalletAlreadyAdded;
-(BOOL)createWallet:(NSString*_Nonnull)phrase pass:(NSString*_Nonnull)pass;
-(BOOL)openWallet:(NSString*_Nonnull)pass;
-(BOOL)canOpenWallet:(NSString*_Nonnull)pass;
-(void)resetWallet;
-(void)startForgotPassword;
-(void)stopForgotPassword;
-(void)cancelForgotPassword;
-(BOOL)isValidPassword:(NSString*_Nonnull)pass;
-(void)changePassword:(NSString*_Nonnull)pass;

//-(void)refreshWallet;
// updates
-(void)getWalletStatus;
-(void)getNetworkStatus;
-(void)refreshAllInfo;

// addresses
-(void)generateNewWalletAddress;
-(void)setExpires:(int)hours toAddress:(NSString*_Nonnull)address ;
-(void)setWalletComment:(NSString*_Nonnull)comment toAddress:(NSString*_Nonnull)address ;
-(NSMutableArray<BMTransaction*>*_Nonnull)getTransactionsFromAddress:(BMAddress*_Nonnull)address;
-(NSMutableArray<BMAddress*>*_Nonnull)getWalletAddresses;
-(void)editAddress:(BMAddress*_Nonnull)address;

-(void)deleteAddress:(NSString*_Nullable)address;
-(BOOL)isValidAddress:(NSString*_Nullable)address;
-(BOOL)isExpiredAddress:(NSString*_Nullable)address;
-(void)deleteAddress:(NSString*_Nullable)address;

// send
-(NSString*_Nullable)canSend:(double)amount fee:(double)fee to:(NSString*_Nullable)to;
-(void)send:(double)amount fee:(double)fee to:(NSString*_Nonnull)to comment:(NSString*_Nonnull)comment;

// logs
-(NSString*_Nonnull)getZipLogs ;

// transactions
-(BMTransaction*_Nullable)validatePaymentProof:(NSString*_Nullable)code;
-(void)getPaymentProof:(BMTransaction*_Nonnull)transaction;
-(void)deleteTransaction:(BMTransaction*_Nonnull)transaction;
-(void)cancelTransaction:(BMTransaction*_Nonnull)transaction;
-(void)resumeTransaction:(BMTransaction*_Nonnull)transaction;
-(NSMutableArray<BMUTXO*>*_Nonnull)getUTXOSFromTransaction:(BMTransaction*_Nonnull)transaction;

// utxo
-(void)getUTXO;
-(NSMutableArray<BMTransaction*>*_Nonnull)getTransactionsFromUTXO:(BMUTXO*_Nonnull)utox;

//contacts
-(BMContact*_Nullable)getContactFromId:(NSString*_Nonnull)idValue;

@end
Loading

0 comments on commit 60094e6

Please sign in to comment.