From 282622fa1d3bf5720adc321ecd1699bddbb3e90d Mon Sep 17 00:00:00 2001 From: Andrew Podkovyrin Date: Tue, 31 Aug 2021 14:05:03 +0300 Subject: [PATCH 1/2] Update DashSync --- DashSyncCurrentCommit | 2 +- Podfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DashSyncCurrentCommit b/DashSyncCurrentCommit index a23053640..9adcaa75a 100644 --- a/DashSyncCurrentCommit +++ b/DashSyncCurrentCommit @@ -1 +1 @@ -08f34489b64061aa549735dd79a19bfb266f5e31 +11837d26130f55c25f763109878920920b039b34 diff --git a/Podfile.lock b/Podfile.lock index 4fbc32c63..7dec177cb 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -511,7 +511,7 @@ SPEC CHECKSUMS: CocoaImageHashing: 8656031d0899abe6c1c415827de43e9798189c53 CocoaLumberjack: 78b0c238666f4f58db069738ec176f4519557516 DAPI-GRPC: e12b93e8f631c379d2bdec74dcbac24e29405712 - DashSync: 39690bbdef9d730fcc96770d26a70e754fd90e2b + DashSync: 5215b6c3bbc2376b1d7af6ca58256d0785315466 DSDynamicOptions: 347cc5d2c4e080eb3de6a86719ad3d861b82adfc DWAlertController: 5f4cd8adf90336331c054857f709f5f8d4b16a5b gRPC: 74bc37f1a952fd2d22e0fc38694970cee800341f From 3bc5f8e8dd6c2e40fa142970127638a5cbd8a901 Mon Sep 17 00:00:00 2001 From: Andrew Podkovyrin Date: Tue, 31 Aug 2021 16:43:50 +0300 Subject: [PATCH 2/2] Multi account support in the wallet --- DashWallet/Sources/Models/DWEnvironment.m | 12 ++- DashWallet/Sources/Models/DWGlobalOptions.h | 2 + DashWallet/Sources/Models/DWGlobalOptions.m | 3 + .../Sources/UI/Home/Models/DWHomeModel.m | 6 +- .../UI/Menu/Settings/DWSettingsMenuModel.h | 2 + .../UI/Menu/Settings/DWSettingsMenuModel.m | 13 +++ .../Settings/DWSettingsMenuViewController.m | 102 ++++++++++++++++++ DashWallet/bg.lproj/Localizable.strings | 15 +++ DashWallet/cs.lproj/Localizable.strings | 15 +++ DashWallet/de.lproj/Localizable.strings | 15 +++ DashWallet/el.lproj/Localizable.strings | 15 +++ DashWallet/en.lproj/Localizable.strings | 15 +++ DashWallet/es.lproj/Localizable.strings | 15 +++ DashWallet/fr.lproj/Localizable.strings | 15 +++ DashWallet/id.lproj/Localizable.strings | 15 +++ DashWallet/it.lproj/Localizable.strings | 15 +++ DashWallet/ja.lproj/Localizable.strings | 15 +++ DashWallet/ko.lproj/Localizable.strings | 15 +++ DashWallet/nl.lproj/Localizable.strings | 15 +++ DashWallet/pl.lproj/Localizable.strings | 15 +++ DashWallet/pt.lproj/Localizable.strings | 15 +++ DashWallet/ru.lproj/Localizable.strings | 15 +++ DashWallet/sk.lproj/Localizable.strings | 15 +++ DashWallet/sq.lproj/Localizable.strings | 15 +++ DashWallet/sv.lproj/Localizable.strings | 15 +++ DashWallet/th.lproj/Localizable.strings | 15 +++ DashWallet/tr.lproj/Localizable.strings | 15 +++ DashWallet/vi.lproj/Localizable.strings | 15 +++ DashWallet/zh-Hans.lproj/Localizable.strings | 15 +++ .../zh-Hant-TW.lproj/Localizable.strings | 15 +++ 30 files changed, 482 insertions(+), 3 deletions(-) diff --git a/DashWallet/Sources/Models/DWEnvironment.m b/DashWallet/Sources/Models/DWEnvironment.m index 7ffc90c0b..8268295f6 100644 --- a/DashWallet/Sources/Models/DWEnvironment.m +++ b/DashWallet/Sources/Models/DWEnvironment.m @@ -17,6 +17,8 @@ #import "DWEnvironment.h" +#import "DWGlobalOptions.h" + #define CURRENT_CHAIN_TYPE_KEY @"CURRENT_CHAIN_TYPE_KEY" NSNotificationName const DWCurrentNetworkDidChangeNotification = @"DWCurrentNetworkDidChangeNotification"; @@ -88,7 +90,10 @@ - (DSWallet *)currentWallet { } - (DSAccount *)currentAccount { - return [[self.currentWallet accounts] firstObject]; + NSDictionary *accounts = self.currentWallet.orderedAccounts; + NSInteger accountIndex = [DWGlobalOptions sharedInstance].currentAccountIndex; + DSAccount *account = accounts[@(accountIndex)]; + return account; } - (NSArray *)allWallets { @@ -187,7 +192,10 @@ - (void)switchToNetwork:(DSChainType)chainType withIdentifier:(NSString *)identi protocolVersion:70216 minProtocolVersion:70216 sporkAddress:@"yQuAu9YAMt4yEiXBeDp3q5bKpo7jsC2eEj" - sporkPrivateKey:@"cVk6u16fT1Pwd9MugowSt7VmNzN8ozE4wJjfJGC97Hf43oxRMjar"]; + sporkPrivateKey:@"cVk6u16fT1Pwd9MugowSt7VmNzN8ozE4wJjfJGC97Hf43oxRMjar" + instantSendLockQuorumType:DSLLMQType_5_60 + chainLockQuorumType:DSLLMQType_5_60 + platformQuorumType:DSLLMQType_5_60]; [destinationChain setDevnetNetworkName:@"Evonet"]; } break; diff --git a/DashWallet/Sources/Models/DWGlobalOptions.h b/DashWallet/Sources/Models/DWGlobalOptions.h index 69be0ee4e..cbecf319f 100644 --- a/DashWallet/Sources/Models/DWGlobalOptions.h +++ b/DashWallet/Sources/Models/DWGlobalOptions.h @@ -52,6 +52,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign, getter=isResyncingWallet) BOOL resyncingWallet; +@property (nonatomic, assign) NSInteger currentAccountIndex; + // Non-dynamic - (BOOL)lockScreenDisabled; diff --git a/DashWallet/Sources/Models/DWGlobalOptions.m b/DashWallet/Sources/Models/DWGlobalOptions.m index 77e0699d0..f041ebcf7 100644 --- a/DashWallet/Sources/Models/DWGlobalOptions.m +++ b/DashWallet/Sources/Models/DWGlobalOptions.m @@ -42,6 +42,7 @@ @implementation DWGlobalOptions @dynamic dashpayRegistrationCompleted; @dynamic mostRecentViewedNotificationDate; @dynamic resyncingWallet; +@dynamic currentAccountIndex; #pragma mark - Init @@ -51,6 +52,7 @@ - (instancetype)init { DW_KEYPATH(self, localNotificationsEnabled) : @YES, DW_KEYPATH(self, autoLockAppInterval) : @60, // 1 min DW_KEYPATH(self, shouldDisplayOnboarding) : @YES, + DW_KEYPATH(self, currentAccountIndex) : @0, }; self = [super initWithUserDefaults:nil defaults:defaults]; @@ -119,6 +121,7 @@ - (void)restoreToDefaults { self.dashpayRegistrationCompleted = NO; self.mostRecentViewedNotificationDate = nil; self.resyncingWallet = NO; + self.currentAccountIndex = 0; } @end diff --git a/DashWallet/Sources/UI/Home/Models/DWHomeModel.m b/DashWallet/Sources/UI/Home/Models/DWHomeModel.m index 4129e708e..b5131699d 100644 --- a/DashWallet/Sources/UI/Home/Models/DWHomeModel.m +++ b/DashWallet/Sources/UI/Home/Models/DWHomeModel.m @@ -293,6 +293,9 @@ - (void)forceStartSyncingActivity { DWSyncModel *syncModel = (DWSyncModel *)self.syncModel; NSAssert([syncModel isKindOfClass:DWSyncModel.class], @"Internal inconsistency"); [syncModel forceStartSyncingActivity]; + + [self updateBalance]; + [self reloadTxDataSource]; } - (void)walletDidWipe { @@ -467,7 +470,8 @@ - (void)reloadTxDataSource { return [(NSNumber *)obj1 compare:obj2]; } }]; - NSArray *transactions = [wallet.allTransactions sortedArrayUsingDescriptors:@[ sortDescriptor ]]; + DSAccount *account = [DWEnvironment sharedInstance].currentAccount; + NSArray *transactions = [account.allTransactions sortedArrayUsingDescriptors:@[ sortDescriptor ]]; BOOL shouldAnimate = YES; DSTransaction *prevTransaction = self.dataSource.items.firstObject; diff --git a/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.h b/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.h index c880304ce..210e11ab8 100644 --- a/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.h +++ b/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.h @@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN @property (readonly, copy, nonatomic) NSString *networkName; @property (readonly, copy, nonatomic) NSString *localCurrencyCode; +@property (assign, nonatomic) NSInteger accountIndex; + @property (assign, nonatomic) BOOL notificationsEnabled; + (void)switchToMainnetWithCompletion:(void (^)(BOOL success))completion; diff --git a/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.m b/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.m index cbda1c775..e2ed72bb2 100644 --- a/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.m +++ b/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuModel.m @@ -32,6 +32,19 @@ - (NSString *)localCurrencyCode { return [DSPriceManager sharedInstance].localCurrencyCode; } +- (NSInteger)accountIndex { + return [DWGlobalOptions sharedInstance].currentAccountIndex; +} + +- (void)setAccountIndex:(NSInteger)accountIndex { + BOOL hasChanged = [DWGlobalOptions sharedInstance].currentAccountIndex != accountIndex; + [DWGlobalOptions sharedInstance].currentAccountIndex = accountIndex; + if (hasChanged) { + [[NSNotificationCenter defaultCenter] postNotificationName:DWCurrentNetworkDidChangeNotification + object:nil]; + } +} + - (BOOL)notificationsEnabled { return [DWGlobalOptions sharedInstance].localNotificationsEnabled; } diff --git a/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuViewController.m b/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuViewController.m index b1426b924..d75bb0fe9 100644 --- a/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuViewController.m +++ b/DashWallet/Sources/UI/Menu/Settings/DWSettingsMenuViewController.m @@ -20,6 +20,7 @@ #import #import "DWAboutViewController.h" +#import "DWEnvironment.h" #import "DWFormTableViewController.h" #import "DWLocalCurrencyViewController.h" #import "DWSettingsMenuModel.h" @@ -33,6 +34,7 @@ @interface DWSettingsMenuViewController ()