7070#include < sys/sysctl.h>
7171#import < sys/utsname.h>
7272
73- #import " BeamWallet-Swift.h"
73+ // #import "BeamWallet-Swift.h"
74+ #import " BeamWalletMasterNet-Swift.h"
7475
7576using namespace beam ;
7677using namespace ECC ;
@@ -264,10 +265,12 @@ -(void)loadRules{
264265}
265266
266267+(NSString *_Nonnull)chooseRandomNodeWithoutNodes : (NSArray *)nodes {
267- auto peers = getDefaultPeers () ;
268+ // return @"eu-node02.masternet.beam.mw:8100" ;
268269
270+ auto peers = getDefaultPeers ();
271+
269272 NSMutableArray *array = [NSMutableArray array ];
270-
273+
271274 for (const auto & item : peers) {
272275 BOOL found = NO ;
273276 NSString *address = [NSString stringWithUTF8String: item.c_str ()];
@@ -277,34 +280,19 @@ +(NSString*_Nonnull)chooseRandomNodeWithoutNodes:(NSArray*)nodes {
277280 found = YES ;
278281 }
279282 }
280-
283+
281284 if (!found) {
282285 [array addObject: address];
283286 }
284287 }
285288 }
286-
287-
289+
290+
288291 if (array.count >0 ) {
289292 return array[0 ];
290293 }
291-
292- return @" " ;
293- }
294294
295- +(NSArray *_Nonnull)randomNodes {
296- auto peers = getDefaultPeers ();
297-
298- NSMutableArray *array = [NSMutableArray array ];
299-
300- for (const auto & item : peers) {
301- NSString *address = [NSString stringWithUTF8String: item.c_str ()];
302- if ([address rangeOfString: @" shanghai" ].location == NSNotFound ) {
303- [array addObject: address];
304- }
305- }
306-
307- return array;
295+ return @" " ;
308296}
309297
310298+(NSString *_Nonnull)chooseRandomNode {
@@ -1190,32 +1178,10 @@ -(BOOL)isAddress:(NSString*_Nullable)address {
11901178
11911179
11921180-(BOOL )isExpiredAddress : (NSString *_Nullable)address {
1193- if (address!=nil ) {
1194- if (address.length )
1195- {
1196- WalletID walletID (Zero);
1197- if (walletID.FromHex (address.string ))
1198- {
1199- try {
1200- auto receiverAddr = walletDb->getAddress (walletID);
1201-
1202- if (receiverAddr) {
1203- if (receiverAddr->m_OwnID && receiverAddr->isExpired ())
1204- {
1205- return YES ;
1206- }
1207- }
1208- }
1209- catch (const std::exception& e) {
1210- return NO ;
1211- }
1212- catch (...) {
1213- return NO ;
1214- }
1215- }
1216- }
1181+ BMAddress *addr = [self findAddressByID: address];
1182+ if (addr != nil && addr.isContact == NO && [addr isExpired ]) {
1183+ return YES ;
12171184 }
1218-
12191185 return NO ;
12201186}
12211187
@@ -3106,9 +3072,12 @@ -(void)approveContractInfo:(NSString*_Nonnull)json info:(NSString*_Nonnull)info
31063072
31073073-(void )stopDAO {
31083074 [daoManager stopApp ];
3075+ daoManager = nil ;
31093076}
31103077
31113078-(void )startApp : (UIViewController*_Nonnull)controller app : (BMApp*)app {
3079+ daoManager = [[DAOManager alloc ] initWithWallet: wallet];
3080+
31123081 BOOL isSupported = [daoManager appSupported: app];
31133082
31143083 __weak typeof (self) weakSelf = self;
@@ -3182,22 +3151,24 @@ -(void)loadApps {
31823151 NSArray *jsonResponse = [NSJSONSerialization JSONObjectWithData: data options: 0 error: &jsonError];
31833152
31843153 if (jsonError == nil ) {
3185- [strongSelf->_apps removeAllObjects ];
3186-
3187- for (NSDictionary *dct in jsonResponse) {
3188- BMApp *app = [BMApp new ];
3189- [app setAPIResult: dct];
3190- [app setIsSupported: [strongSelf->daoManager appSupported: app]];
3191- if (app.icon == nil ) {
3192- app.icon = @" " ;
3154+ if (strongSelf->daoManager != nil ) {
3155+ [strongSelf->_apps removeAllObjects ];
3156+
3157+ for (NSDictionary *dct in jsonResponse) {
3158+ BMApp *app = [BMApp new ];
3159+ [app setAPIResult: dct];
3160+ [app setIsSupported: [strongSelf->daoManager appSupported: app]];
3161+ if (app.icon == nil ) {
3162+ app.icon = @" " ;
3163+ }
3164+ [strongSelf->_apps addObject: app];
31933165 }
3194- [strongSelf->_apps addObject: app];
3195- }
3196-
3197- NSArray *delegates = [AppModel sharedManager ].delegates .allObjects ;
3198- for (id <WalletModelDelegate> delegate in delegates) {
3199- if ([delegate respondsToSelector: @selector (onDAPPsLoaded )]) {
3200- [delegate onDAPPsLoaded ];
3166+
3167+ NSArray *delegates = [AppModel sharedManager ].delegates .allObjects ;
3168+ for (id <WalletModelDelegate> delegate in delegates) {
3169+ if ([delegate respondsToSelector: @selector (onDAPPsLoaded )]) {
3170+ [delegate onDAPPsLoaded ];
3171+ }
32013172 }
32023173 }
32033174 }
0 commit comments